Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3196803lqp; Tue, 26 Mar 2024 02:23:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVhp1b7At9pjRfcXGpkjeQ0sRbGtGvccS3d4iIQCqh1ebN0KgXGgIxiyy5D0AscBHPcQ/v0YO/gJDaN9YISw0XLF5tDZQy3LASvuqwakA== X-Google-Smtp-Source: AGHT+IHCOdJiIpGYzI7AGHGa0ldZz8BiSWAsMt+6StN4mfiy2YBcinY16h0mXlvhOyomfRMf+6Cq X-Received: by 2002:a67:f989:0:b0:472:eca1:46c with SMTP id b9-20020a67f989000000b00472eca1046cmr476237vsq.30.1711444990233; Tue, 26 Mar 2024 02:23:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711444990; cv=pass; d=google.com; s=arc-20160816; b=gZHsHUcdMF4NACDneXOfRy486BqsZU6tFaMCf/gF+Twh6I4SUljpNQyJbhce9VM+di wskTvsJKVvsGm3obfS7y84C6xTWrnZ+7mXzzUwBHwIM11gYK0CvgXCs3FkYu4JeUYGZ1 riotO6Sg1/FmhFgO6PWaqH4RIOryv8GxP3GxEuAkE8acdPqLo8qfxG4y0LGm7uCgiJcg VLabLFG+dTwfvokf07Vm2TnRwx+xftsU8POTVxCTmsFsGo2ohJqscBOZQKmnL+tz4ISa aGDtBRRZ3Y6hCUwFJHpdnzjgTdJYMJDZBCKvGoNqFEc0nkZkl8zFQbU0SS18V9Sed04W Ef9A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=aUVb/hdHPPvUEoPXZoMytdU6Q9cL7YhUpc5Ho5OhDko=; fh=P8yGLrXRuAnKChgaH1QWhXRa/RsjRa4wP7kTOc4BgXg=; b=MzbwJrGeW34glXRwXH0YKMKuT3X6ogJmqBUW/GoLR9umBWbmjMLI6gey6oHCYMSkHf AsiX+8nmHKPrX7nbkFD9XMAw2xoOEsMvnW4JnqkpSOmvzMsqckCGyaUb3SrsqV1P3p32 SB4fac1GacyeMpQBR76R7AhBbFug3gMOz20k1VvW2nYmDSretwwKgBH77KuFeiBpsod/ fPqWa6MCRmfE6XxQl8HaU/zHbcYqZSwrMss9vBNobNPAU0seWAnZyO+dZYTDBDGgNJuk AUELitIQD3SoSZ5bkiNW7zzR0kQEFgAKSmGvAxf6UBZ9UfoVeCmThuoGXrhFmFo6stFx R32g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q4LTXpVK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-118639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k8-20020ae9f108000000b0078a54c289e0si4164308qkg.167.2024.03.26.02.23.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 02:23:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q4LTXpVK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-118639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DCD291C385CD for ; Tue, 26 Mar 2024 09:23:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1059F745DC; Tue, 26 Mar 2024 09:20:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q4LTXpVK" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B33545A0E1; Tue, 26 Mar 2024 09:20:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711444841; cv=none; b=aUrJm6dHbI77cf64KLxi0bDbttXI7u/2rffTJE9Ny5+ktWN83ivHoVft+GD65D3vOWhvWMkWhpJxXRYqJkola7mJm/XXHQ2ZOglVLRQYBlBNgdOkJKwbtm6FJLkBVn75BX4t/QVpv//6WWUPdhMgQ79Gbp3RkYjTqHnLyzMZNv0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711444841; c=relaxed/simple; bh=TYixwRJ/HLIf39is6KOuK1f7P0/ZpeuMCtRoeFDjtsw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hWVrvEd3OnX3iTT/aXtIkB1FKHAAGFHcrFmBZn64sqIro1S7/LQz0NnXn+Tp/GM9huVT0qtVQ1jjg1/7vdqeD55j+XTbM0h4LXVNiyQ5EtIWOsPIUJas713070/u3JbHuSc8fZujUWCUHzXlQZNRBZnh67kQGDFsdri4pnpbrZE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q4LTXpVK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 2E4F7C43601; Tue, 26 Mar 2024 09:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711444841; bh=TYixwRJ/HLIf39is6KOuK1f7P0/ZpeuMCtRoeFDjtsw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=q4LTXpVKiPg6j5++lO7pXpUf0e2RJHC91qq4lbh6vy8VXTbVyn2Ui6eCHZypfkw6w QfY8wbgPJ8Tn2308ZwvYw11IW8WqNEGTXkGsOfymwBPFf/JvFWqOFP4RK95QwmqpfW zRK1+V8SeKnVtu/CuuIlJfTAzYLNNOPdsdv8v/vvOysErqBIKAURN1cqDrQgJ08feV VCd2X0kK6u865ANLLAle6967cP259DWNQiGB6mwcBCiG5MeW8028i+2gJD3HpU0fP9 rycoO1uP12VkllrFSfykHspNMuMDvmpYwwdN046qXLt/nOQS5A5ngbS++AHnbf89C9 xs36gSmGHnecw== 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 119F5C6FD1F; Tue, 26 Mar 2024 09:20:41 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Tue, 26 Mar 2024 12:18:32 +0300 Subject: [PATCH v9 05/38] power: reset: Add a driver for the ep93xx reset Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240326-ep93xx-v9-5-156e2ae5dfc8@maquefel.me> References: <20240326-ep93xx-v9-0-156e2ae5dfc8@maquefel.me> In-Reply-To: <20240326-ep93xx-v9-0-156e2ae5dfc8@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=1711444837; l=4433; i=nikita.shubin@maquefel.me; s=20230718; h=from:subject:message-id; bh=KjqqsnfXxGMwFFM/StkMK0mGDkJJNduKtVKAsKoiuVY=; b=rYJobRzHqQE5DGP3ynEMYV24vj7PzH0tGEBq3R9N8sg/440vBBshFiAoOARny15Khl2ugN/Me2VI VhDv+a1cALrxUiZAyRYiDttwbdHxuaoy3HbZl3wv0bMYuCPdritO 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: nikita.shubin@maquefel.me 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 | 84 ++++++++++++++++++++++++++++++++++++ 3 files changed, 95 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..57cfb8620faf --- /dev/null +++ b/drivers/power/reset/ep93xx-restart.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Cirrus EP93xx SoC reset driver + * + * Copyright (C) 2021 Nikita Shubin + */ + +#include +#include +#include +#include +#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); -- 2.41.0