Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1152157rbb; Sun, 25 Feb 2024 23:32:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU4SfLK4dhz4UKnYzhLU0g8uNStlJOeXw0A6r30F4gzN/Gz4Rx6B8jA1G0LBgATuJqZ50RQSA3Wj0FCNd11LvxGjL8Z8okKaZ6fFScBRw== X-Google-Smtp-Source: AGHT+IGChhtoE84zQ1miwyn1m/w+oHD8OTK931GBPF9lsDS5EFLoi0Q68PKdeQFZdJb5XFxb+M5p X-Received: by 2002:a05:6402:1a30:b0:565:bc3d:d9dd with SMTP id be16-20020a0564021a3000b00565bc3dd9ddmr2543440edb.38.1708932765212; Sun, 25 Feb 2024 23:32:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708932765; cv=pass; d=google.com; s=arc-20160816; b=OOxSn3XTFA55q6s36MnTqWpV+ZHRTWYyTFoOP/zrBaVGTEl1aKs8DqfPLWrdQOCcN5 NBd0+pGpj0QiNsAQ+EGbHRkQ90nvjAPxvshrQ8yAM3knAVhQI63QxbWZsMLAfButRxUf Olza7mX5ohV0Gvw3XyQ6eI/80JDbl749uJmzmDJ7uLQQjkAKV/pjWNqUfDhJ0xMLITW8 pE/sQfZ1xGipLKa0WngGpZVkOdge0IXFjh3KEJoQpUgwtVxAe/h1cu7x0m7BHBw80X1P CzJyPHj8pgRNTGKwOOTf8L/RCuP9+DdcbwsgyQ8slbZaCdiS+2v9guyY1LOVBYRPQCci gBGA== 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=N9iOx0e60+SNLV6WGIDhjre9sBvC39J1vNn0iSI+mQKrOQ085INeMgzFmk0fiqdZG2 s3oSpGv3dBojk7e4l6wG00OOoZ2PmzKrUh28lmRbtH2/PDRUNRqM27yP1st4ZtY2br7+ W3MSBySXzGFqCNBxfPAO3A1mY27a0Wa4PxCCPY/jpU5qJ4IeDaOhSOS7B5G4crtztt4/ iw+euWy79DbH2XKzuHuWp+gbXoh0ACjzrnhXjsGN0u2R4gFfwvJkDv4RaeaWvJd9tkOF C2sE0CRm8hDg7ykQqx26DVYe0Nkfju7BNrHGKvp8gyRohCqmVkoO+1f38eB/428/TC2a 6Usg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JsGslZ9K; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80638-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t4-20020a05640203c400b0056578ed894csi1902768edw.641.2024.02.25.23.32.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 23:32:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JsGslZ9K; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80638-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80638-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 am.mirrors.kernel.org (Postfix) with ESMTPS id CA7991F21154 for ; Mon, 26 Feb 2024 07:32:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 89EDD1CD2D; Mon, 26 Feb 2024 07:31:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JsGslZ9K" 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 603A51BF50; Mon, 26 Feb 2024 07:31:22 +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=1708932682; cv=none; b=LiLHUk+Ei4qk7BDuZaEZ+hzgrREIrLN/cKGVnoSazNhcNOpy89k9ebSuRhwbHfPnnwCCyBymzBN/zaF6AF7///WGOKUjftAThhCPOZrOuolodCKR/Fbf7R55pyibq+cD1xFQMFAs8pki40fefKoOpXi1LcSD1pofJ5s7C9Wx0Pk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708932682; c=relaxed/simple; bh=TYixwRJ/HLIf39is6KOuK1f7P0/ZpeuMCtRoeFDjtsw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TN5HJjkT90Ldki8OiDg8bkldvoLRI3Zpff4KuIUGYEwpXl84SbMtCCzg5emLzO6+wpt06n4fKP70H6prbsqJFNbo+GezvwbkuZNaV5714hCdv1/iQ2gh66hCb6iQiKKUs+XY1Y+ISyA8N9/oou2Hqr3VvAjtpKyO0hxOUlkMYYA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JsGslZ9K; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id E72C2C41679; Mon, 26 Feb 2024 07:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708932681; bh=TYixwRJ/HLIf39is6KOuK1f7P0/ZpeuMCtRoeFDjtsw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=JsGslZ9KLtiyyCW94IzHxMy8vZqyWx7CKC8zKoHOHg1q8oGixHtpLaCrnLC4gvdAW Zm+QiaeHW2vkR2mkQu7OY1YO2+n/HNY390RND5R+k5hQXuyqHfUfMCeXBO6Yn2ry99 YgC7Nda2+P4C3ajhpJ6r2a6ZkyNbhmrL+CXtZlcYXqKHD/e5g7/CioyoXh7eLrZdNc DRkPJCCeFLVSUu1rpbOH1ITwwTrH26ET2RPcFxcudnzvdITPEiY6dCrWXYi/bHvnCT VCoa8kOTo3v10lEbKfgnbNv+Ba4Z2QAyz8jqzIY3+qU2bVHVPkSdaUycnys0g4XxaG vsM2bkOlRENIQ== 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 D7CE8C54E49; Mon, 26 Feb 2024 07:31:21 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Mon, 26 Feb 2024 10:30:01 +0300 Subject: [PATCH v8 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: <20240226-ep93xx-v8-5-3136dca7238f@maquefel.me> References: <20240226-ep93xx-v8-0-3136dca7238f@maquefel.me> In-Reply-To: <20240226-ep93xx-v8-0-3136dca7238f@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=1708932678; l=4433; i=nikita.shubin@maquefel.me; s=20230718; h=from:subject:message-id; bh=KjqqsnfXxGMwFFM/StkMK0mGDkJJNduKtVKAsKoiuVY=; =?utf-8?q?b=3D3drhl5EXDiGL?= =?utf-8?q?DTo/4kW6UjThL9XgCB1A+tmm5lWyZZEZDU5EX5a1FEXqet4OON7zfEIYc1HKxTN2?= c9LME5WHAIfb8AEngpWFSwPrZcDNizBDnmKkimNOnAVu/JcuVFDw 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: 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