From patchwork Fri Sep 15 08:10:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Shubin via B4 Relay X-Patchwork-Id: 140225 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp888425vqi; Fri, 15 Sep 2023 01:23:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3ejTHi6DYAjLJ0c/71khKJMfCHdKqBVp8RTofpQc8ordsnEETL3/+yaH1bHJTKX9aT1Bb X-Received: by 2002:aca:130c:0:b0:3a0:38c2:2654 with SMTP id e12-20020aca130c000000b003a038c22654mr784314oii.58.1694766209632; Fri, 15 Sep 2023 01:23:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694766209; cv=none; d=google.com; s=arc-20160816; b=UeV67Gum4dj2kASU8egi23NaqZYbNytN5ovp/Qqdf2O+QxukEzc/eeq/iXnASrdkxr RGsVHC054HzvX/CuhacJKxi6P+G7ViJPc7i2qNa4Xn+u5GalZHF2lkmxFFZSKq1zVEUX qn3PH7+F3zhi5kng/QNZlW2hdjd1hqBfwiFZaZ7ceeDG3YL6GW1k/nTVVEx/ALaCYjne qvi1cVWGQoG1bwT1Zqt75n/ZiNOEDVHDTCU49WPmmzLKJp5xAt12u2N6J7rVgxQloLWl T6xkprC4BndOk2LzrER1FfyQtqhvz4c4aosBtNJnJSr9xyFEXEV722YNiDMiDufJZyyK ViIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=AtB271zpNLHx72ZohQJR6ZbA4bjmETwlXaa6dJN7DhQ=; fh=/kw+TuarY8Ld21esNj6ls3bmOGjpzuFrq8S1iOsIl6g=; b=iYCeWloHyqLkMtb+oOCgXKTisueIycytLBdc0zTqrhRYIwOSEXi7ItadM44tRYTOLF jgI9GOf9f1icgT7bcDjaV5bKQzzdePO+mqhPeaFIBOrlj/hC945snshZ0EIttHqPOFUV Ih7bVmlv3Lov+6XUQEYq5E7wppNTHPUSawvbMBPceis8fBVts38Nl3OU9VURz96IEVhI f2S1SRDoCG++psAvmEPsmofPD78LFNKV5AtafenuOU/X92/Sa1evYglmybXnXfAGAxYI HgqLEoFtwnfhm9ZO7L0TcHpodBw1sGUKngTEuCFbqMLDsuAE4yDjjYxzE+fhXlDW5uqu f50A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ryKp9X5S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id z11-20020a6552cb000000b0056a670ebd6fsi2807026pgp.669.2023.09.15.01.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 01:23:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ryKp9X5S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2F9D885C6464; Fri, 15 Sep 2023 01:12:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232955AbjIOIMc (ORCPT + 32 others); Fri, 15 Sep 2023 04:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232874AbjIOIMQ (ORCPT ); Fri, 15 Sep 2023 04:12:16 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F26B2710; Fri, 15 Sep 2023 01:12:10 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPS id 84035C43142; Fri, 15 Sep 2023 08:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694765528; bh=K1YlojQUwHVfz3jXgeY8tQ+lVYD/z+pvlMhS9gIfTKU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ryKp9X5Si17D/iCiaKaMWYtQs/ozudwz7m9PTugDajpBsU+5FjK+vtgUMh09lJqMK 5tPyKwQ6KtO0oJLoSBn5wXpJbyFLFTlA/LP0xMuVzUmkYoTWg0s5933xLlUjNEXZhM fm7mS/l0Ik4sN0kWMcDxm4g8keVmXuO5NZfWmfpoiTQAnZl29+4NfKfO7WjXjLytQ1 e0uQXa4qS4a1RcfWuw1NXLdnE9ZtQDuV6wfnIFo/Cg78BjOr0bVTGXTQQ9f/cnXYEH DOLNJGGOk8uz9OrbSNvESScVQRzmLBVFtdHsfFjh9nOSOBxQbsMh9Me6w3Yc+bKmvV US34by7A/tFhA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73ABEEE643D; Fri, 15 Sep 2023 08:12:08 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Fri, 15 Sep 2023 11:10:50 +0300 Subject: [PATCH v4 08/42] power: reset: Add a driver for the ep93xx reset MIME-Version: 1.0 Message-Id: <20230915-ep93xx-v4-8-a1d779dcec10@maquefel.me> References: <20230915-ep93xx-v4-0-a1d779dcec10@maquefel.me> In-Reply-To: <20230915-ep93xx-v4-0-a1d779dcec10@maquefel.me> To: Sebastian Reichel Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Arnd Bergmann , Alexander Sverdlin X-Mailer: b4 0.13-dev-e3e53 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694765525; l=4419; i=nikita.shubin@maquefel.me; s=20230718; h=from:subject:message-id; bh=ue19S7x0buqeac3S+9Rq3Mq9gtPiw4CWJl2XJVARssk=; =?utf-8?q?b=3DQJUbM+uVMMUI?= =?utf-8?q?DyTOR2gHpk1dTPaI19Z9JgWjVkfgVTwuDp8zFwUglkPCvmNdTvzZW+UcRfUfEDn6?= 8/9/rx6rDDPJpd0DRjoWl0RoDqkgnNP+sHmmVds2+qYRwhV7HYXc X-Developer-Key: i=nikita.shubin@maquefel.me; a=ed25519; pk=vqf5YIUJ7BJv3EJFaNNxWZgGuMgDH6rwufTLflwU9ac= X-Endpoint-Received: by B4 Relay for nikita.shubin@maquefel.me/20230718 with auth_id=65 X-Original-From: Nikita Shubin Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 15 Sep 2023 01:12:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777091173118913919 X-GMAIL-MSGID: 1777091173118913919 From: Nikita Shubin Implement the reset behaviour of the various EP93xx SoCS in drivers/power/reset. It used to be located in arch/arm/mach-ep93xx. Signed-off-by: Nikita Shubin Acked-by: Sebastian Reichel --- drivers/power/reset/Kconfig | 10 +++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/ep93xx-restart.c | 85 ++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index fff07b2bd77b..9c2aa9218841 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -75,6 +75,16 @@ config POWER_RESET_BRCMSTB Say Y here if you have a Broadcom STB board and you wish to have restart support. +config POWER_RESET_EP93XX + bool "Cirrus EP93XX reset driver" if COMPILE_TEST + depends on MFD_SYSCON + default ARCH_EP93XX + help + This driver provides restart support for Cirrus EP93XX SoC. + + Say Y here if you have a Cirrus EP93XX SoC and you wish + to have restart support. + config POWER_RESET_GEMINI_POWEROFF bool "Cortina Gemini power-off driver" depends on ARCH_GEMINI || COMPILE_TEST diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index d763e6735ee3..61f4e11619b2 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_POWER_RESET_ATC260X) += atc260x-poweroff.o obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o obj-$(CONFIG_POWER_RESET_BRCMKONA) += brcm-kona-reset.o obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o +obj-$(CONFIG_POWER_RESET_EP93XX) += ep93xx-restart.o obj-$(CONFIG_POWER_RESET_GEMINI_POWEROFF) += gemini-poweroff.o obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o diff --git a/drivers/power/reset/ep93xx-restart.c b/drivers/power/reset/ep93xx-restart.c new file mode 100644 index 000000000000..4da456d45d29 --- /dev/null +++ b/drivers/power/reset/ep93xx-restart.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Cirrus EP93xx SoC reset driver + * + * Copyright (C) 2021 Nikita Shubin + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#define EP93XX_SYSCON_DEVCFG 0x80 +#define EP93XX_SYSCON_DEVCFG_SWRST BIT(31) + +struct ep93xx_restart { + struct regmap *map; + struct notifier_block restart_handler; +}; + +static int ep93xx_restart_handle(struct notifier_block *this, + unsigned long mode, void *cmd) +{ + struct ep93xx_restart *priv = + container_of(this, struct ep93xx_restart, restart_handler); + + /* Issue the reboot */ + ep93xx_regmap_update_bits(priv->map, EP93XX_SYSCON_DEVCFG, + EP93XX_SYSCON_DEVCFG_SWRST, EP93XX_SYSCON_DEVCFG_SWRST); + ep93xx_regmap_update_bits(priv->map, EP93XX_SYSCON_DEVCFG, + EP93XX_SYSCON_DEVCFG_SWRST, 0); + + return NOTIFY_DONE; +} + +static int ep93xx_reboot_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct ep93xx_restart *priv; + struct device_node *parent; + int err; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + parent = of_get_parent(dev->of_node); + if (!parent) + return dev_err_probe(dev, -EINVAL, "no syscon parent for reboot node\n"); + + priv->map = syscon_node_to_regmap(parent); + of_node_put(parent); + if (IS_ERR(priv->map)) + return dev_err_probe(dev, -EINVAL, "no syscon regmap\n"); + + priv->restart_handler.notifier_call = ep93xx_restart_handle; + priv->restart_handler.priority = 128; + + err = register_restart_handler(&priv->restart_handler); + if (err) + return dev_err_probe(dev, err, "can't register restart notifier\n"); + + return 0; +} + +static const struct of_device_id ep93xx_reboot_of_match[] = { + { + .compatible = "cirrus,ep9301-reboot", + }, + { /* sentinel */ } +}; + +static struct platform_driver ep93xx_reboot_driver = { + .probe = ep93xx_reboot_probe, + .driver = { + .name = "ep9301-reboot", + .of_match_table = ep93xx_reboot_of_match, + }, +}; +builtin_platform_driver(ep93xx_reboot_driver);