From patchwork Tue Dec 12 08:20:23 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: 177144 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7581648vqy; Tue, 12 Dec 2023 00:23:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNjSgnTrFwhZveVsyixCUkGZxBbeyHW+sTbs7BkGPaR+XsvAnVmqR6JMTMkTnJ0A0Dgrwr X-Received: by 2002:a05:6358:99a0:b0:170:b266:6bc9 with SMTP id j32-20020a05635899a000b00170b2666bc9mr5522181rwb.0.1702369393400; Tue, 12 Dec 2023 00:23:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702369393; cv=none; d=google.com; s=arc-20160816; b=SniFYQsbce1x6u1j0qyl60zsG9DUO+f9kpDsauIqFAHmnkJApWWSs1U5z31qzkWkVd NjI0iw32j783k6RBPcJ9ZAKChf+eYGv+qKIQ0ZMBLS9M118f1Yk6C76DhqnAmo7HLR2A 4GOxB12bJNyI3NrWKGB8jX/ly9bhY4FVR/MvOioSIDvQlnD06R2G4FAK6hI6/etaOUjT +noT4w9XBySJsJGOZ1Tl2u+6GeE4+ldJVqwSn4J7uMhWj6JIES2zbczbuoCpWv6Nj7Ga IMG2U972dR6QzFsT+kqk7NEY01Zjt4cjnq1Y/L6BJUY2dll2d1+ISqjS0IRI1RdAwwhH Yr2w== 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=TohCVTs2R3BQaFb4zqHXKbfkXPQHd1Cxh3/t9fdatxI=; fh=P8yGLrXRuAnKChgaH1QWhXRa/RsjRa4wP7kTOc4BgXg=; b=Pe6nZh/pGxuQVrULBFmxx+3RVQU5CqU4Xos70/oFsL0+OrhGK0nQ0/JSeIS95pLkjG 1prHduwEsljxCmcZVo8DME33PtFnu+I4OPEPzJBkNPtWCEHgCHPeGD5JFaH12L1Cw2IT Aq6IjmlpESlS+sCRYCZKgzdE22MN0HbawwcEmruUSChSEP2umwDIeSS9+/qS8GdPFwCQ xVI6izsOKQhxqhVwA0X8RCfgZ7zYWD3p0ACnojxA72NY5euEzPDNskyKJEq9z34bmxW5 S99WdwVHw4zH45rnlUUfqrviT+u2z1lvlAimBht1b6Ik3yoPk6lAho+FaZ7U7sW5LtJD tBJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Cq61huRf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id o14-20020a63e34e000000b005c1b30b1b65si7525777pgj.648.2023.12.12.00.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:23:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Cq61huRf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 1204F80A0DC7; Tue, 12 Dec 2023 00:23:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346063AbjLLIWD (ORCPT + 99 others); Tue, 12 Dec 2023 03:22:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346002AbjLLIV7 (ORCPT ); Tue, 12 Dec 2023 03:21:59 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 161C6DB for ; Tue, 12 Dec 2023 00:22:06 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPS id D3962C433B8; Tue, 12 Dec 2023 08:22:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702369324; bh=nhbnpoftpIrxDJQZ3vgKcyXcXESwZFe3xYGr1Sax3RM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Cq61huRfjxL6DAux6fgXemwfKSsro+YGXtLw5ZMowXDf2WgENqG5eAOdt7Vdje4qr BlfbicT9zL91wSQZqxrL0Kz/w7yyNX0ySJThVOJ3Y+cyBwHREgQ0jfHjkk1GaNFz2p KIFn/ND7XqBiXfbJFdvL/iTyNLzviw1ClIK9B/ERxiQW0ne0Hxd99xIb9P451dzQke dg1sW3cSLjxjD0zmtbwebuUoIJpgpsl/eGFfIp4jJOEFVR73Sl8WZ5UhB+o90/MvrD xTWJK8NN+Nu5u8Dmq2M2WswG/wbDKdjkiR/K0gz4P5SOHgBUYEdhfIs/Of1lmmUOg3 Ln3YON63EgTxg== 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 C2F1CC4167B; Tue, 12 Dec 2023 08:22:04 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Tue, 12 Dec 2023 11:20:23 +0300 Subject: [PATCH v6 06/40] power: reset: Add a driver for the ep93xx reset MIME-Version: 1.0 Message-Id: <20231212-ep93xx-v6-6-c307b8ac9aa8@maquefel.me> References: <20231212-ep93xx-v6-0-c307b8ac9aa8@maquefel.me> In-Reply-To: <20231212-ep93xx-v6-0-c307b8ac9aa8@maquefel.me> To: Sebastian Reichel Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Arnd Bergmann X-Mailer: b4 0.13-dev-e3e53 X-Developer-Signature: v=1; a=ed25519-sha256; t=1702369322; l=4318; i=nikita.shubin@maquefel.me; s=20230718; h=from:subject:message-id; bh=NXpqXmqowszymNUyE0q7/VwTUV5jg2WJAr8usHDU2Os=; =?utf-8?q?b=3DnnpJyAohgWQZ?= =?utf-8?q?z7sl5lGFOvGf+vzavoVyZ9VEm58wqp+MipNQ5W67W6lrON1vIbwYTo3RQI+SCBeU?= mkP5Dn0dAulg+wS7XknwpkA4SjwFkg43ZvgePXTvMeHBnKhKb3Uv 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=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Tue, 12 Dec 2023 00:23:03 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785063688922510492 X-GMAIL-MSGID: 1785063688922510492 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 | 80 ++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index fece990af4a7..389d5a193e5d 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 a95d1bd275d1..10782d32e1da 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..3b051694459d --- /dev/null +++ b/drivers/power/reset/ep93xx-restart.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Cirrus EP93xx SoC reset driver + * + * Copyright (C) 2021 Nikita Shubin + */ + +#include +#include +#include +#include +#include +#include + +#include + +#define EP93XX_SYSCON_DEVCFG 0x80 +#define EP93XX_SYSCON_DEVCFG_SWRST BIT(31) + +struct ep93xx_restart { + struct ep93xx_regmap_adev *aux_dev; + 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); + struct ep93xx_regmap_adev *aux = priv->aux_dev; + + /* Issue the reboot */ + aux->update_bits(aux->map, aux->lock, EP93XX_SYSCON_DEVCFG, + EP93XX_SYSCON_DEVCFG_SWRST, EP93XX_SYSCON_DEVCFG_SWRST); + aux->update_bits(aux->map, aux->lock, EP93XX_SYSCON_DEVCFG, + EP93XX_SYSCON_DEVCFG_SWRST, 0); + + return NOTIFY_DONE; +} + +static int ep93xx_reboot_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + struct ep93xx_regmap_adev *rdev = to_ep93xx_regmap_adev(adev); + struct device *dev = &adev->dev; + struct ep93xx_restart *priv; + int err; + + if (!rdev->update_bits) + return -ENODEV; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->aux_dev = rdev; + + 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 auxiliary_device_id ep93xx_reboot_ids[] = { + { + .name = "soc_ep93xx.reset-ep93xx", + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(auxiliary, ep93xx_reboot_ids); + +static struct auxiliary_driver ep93xx_reboot_driver = { + .probe = ep93xx_reboot_probe, + .id_table = ep93xx_reboot_ids, +}; +module_auxiliary_driver(ep93xx_reboot_driver);