Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5365949rwr; Mon, 24 Apr 2023 03:05:55 -0700 (PDT) X-Google-Smtp-Source: AKy350ZYoPD6Ja1/5xq2aGmt7LSJ/gvho08i7rpMRLj3Dvt4ubR0quDg3SBFyrHH6TniA+XDtX+8 X-Received: by 2002:a17:902:d4c4:b0:1a6:6fe3:df91 with SMTP id o4-20020a170902d4c400b001a66fe3df91mr16749873plg.50.1682330755293; Mon, 24 Apr 2023 03:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682330755; cv=none; d=google.com; s=arc-20160816; b=LwKmHiLartIZU65LAIfX8wMJ+zyqMRgIPZcA/M14HNEyJioLwmUIqbOxe15QU31Q9z nXemaFNXkYM2exHoZ6vYrkW8MVWVrYDpH1QAokfrsxosRZChNY2LEIJSKqcwhjfBbvfS VZClS31ZTabUcjx5N0k9K//JHzanMpZcO6j/uEpYVSVIY4w0hpjVtxL7AhfB72aYad/d dBhtoWl7Ei5zpsMEbr4TGLjGcljQjxouAQarK+j5WAJDnA9Kd6/8GVSlTBLm6vXesXyz v50TNrY74A+dXIr69cV3sASHbKxpdU9wIuoncELnNjNI0tNY41lWdRQknpjh3fEHK/0T TdmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=70tk1h+wgeQTaLaqiB2qLFxkPdeNb1mwGKko+ahe0Pk=; b=xX4/Ur+TS6TKK0rdOv1RC0V5c426ZqxyviZlyHC9qdpiTsB8KrzwzEr7QnBs/u+KbJ UcwH1FpFY4V2pfgnj6mGBUU/gIIEZG79nXAVyttWzCBlvhgLtO0KeJvcrnAHhd42XEDB YZ9KqY+eoIbD3Y4FGbohYx6Q0jPTffsp7cDUsIO/IxeLw61r4kxjZYuQTWqLTdvIkoC0 ZMFKvOQVgj6oIOuv0lKJmo/qV/CjwwdyPl2642fxtd4FZ8SNY0jeA4b+70hIUamJxdLw 4YjRURK1XqIs6NuS5wet9K2IfFpfrYoV88Gd9I549Es+pPVwdIx2PM4QZPwacMZ6DoBJ VeYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@maquefel.me header.s=mail header.b=KmrSjPIN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020a170902cf0c00b001a6a3954e0fsi7342189plg.18.2023.04.24.03.05.27; Mon, 24 Apr 2023 03:05:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@maquefel.me header.s=mail header.b=KmrSjPIN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231665AbjDXJz5 (ORCPT + 99 others); Mon, 24 Apr 2023 05:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbjDXJzr (ORCPT ); Mon, 24 Apr 2023 05:55:47 -0400 X-Greylist: delayed 465 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 24 Apr 2023 02:55:24 PDT Received: from forward502c.mail.yandex.net (forward502c.mail.yandex.net [178.154.239.210]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C320340EE; Mon, 24 Apr 2023 02:55:23 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:261e:0:640:2e3d:0]) by forward502c.mail.yandex.net (Yandex) with ESMTP id 161E15EC77; Mon, 24 Apr 2023 12:35:48 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id JZBb1pbWwKo0-ZrhHlrZZ; Mon, 24 Apr 2023 12:35:47 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maquefel.me; s=mail; t=1682328947; bh=70tk1h+wgeQTaLaqiB2qLFxkPdeNb1mwGKko+ahe0Pk=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=KmrSjPINTOPndFgRIQ/9jPYIMPspzIV+4nqN8RLXqz1aylvrv9zoL74k3w4hDfY5S n15pcFYLcyijQH2T21QEheg3x+KlT69ReXXDWuwe52eRgCR6M+wV7A4W0DKAu8WCSJ EdOGa09/CODJabDPTbjDwGAj6+FDq7gunwru1BmE= Authentication-Results: mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net; dkim=pass header.i=@maquefel.me From: Nikita Shubin Cc: Arnd Bergmann , Linus Walleij , Alexander Sverdlin , Sebastian Reichel , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 13/43] power: reset: Add a driver for the ep93xx reset Date: Mon, 24 Apr 2023 15:34:29 +0300 Message-Id: <20230424123522.18302-14-nikita.shubin@maquefel.me> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230424123522.18302-1-nikita.shubin@maquefel.me> References: <20230424123522.18302-1-nikita.shubin@maquefel.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/power/reset/Kconfig | 10 +++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/ep93xx-restart.c | 65 ++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 drivers/power/reset/ep93xx-restart.c diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index 8c87eeda0fec..2a61afbb047b 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..0dab09d4fd3c --- /dev/null +++ b/drivers/power/reset/ep93xx-restart.c @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: (GPL-2.0) +/* + * Cirrus EP93xx SoC reset driver + * + * Copyright (C) 2021 Nikita Shubin + */ + +#include +#include +#include +#include +#include + +#include + +#define EP93XX_SYSCON_DEVCFG_SWRST BIT(31) + +static int ep93xx_restart_handle(struct notifier_block *this, + unsigned long mode, void *cmd) +{ + /* Issue the reboot */ + ep93xx_devcfg_set_clear(EP93XX_SYSCON_DEVCFG_SWRST, 0x00); + ep93xx_devcfg_set_clear(0x00, EP93XX_SYSCON_DEVCFG_SWRST); + + mdelay(1000); + + pr_emerg("Unable to restart system\n"); + return NOTIFY_DONE; +} + +static int ep93xx_reboot_probe(struct platform_device *pdev) +{ + struct notifier_block *res_han; + struct device *dev = &pdev->dev; + int err; + + res_han = devm_kzalloc(&pdev->dev, sizeof(*res_han), GFP_KERNEL); + if (!res_han) + return -ENOMEM; + + res_han->notifier_call = ep93xx_restart_handle; + res_han->priority = 128; + + err = register_restart_handler(res_han); + if (err) + dev_err(dev, "can't register restart notifier (err=%d)\n", err); + + return err; +} + +static const struct of_device_id ep93xx_reboot_of_match[] = { + { + .compatible = "cirrus,ep9301-reboot", + }, + {} +}; + +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); -- 2.39.2