From patchwork Mon Apr 24 12:34:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Shubin X-Patchwork-Id: 86948 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2633655vqo; Mon, 24 Apr 2023 03:14:32 -0700 (PDT) X-Google-Smtp-Source: AKy350besD8R8SUWXacseUnHv9WJa/oEQ7L5jG1taxdzI5WEWUhakKZ9YoEgnw7apCIB1Jk6F+dL X-Received: by 2002:a17:902:d10b:b0:1a6:4016:8974 with SMTP id w11-20020a170902d10b00b001a640168974mr12679977plw.31.1682331272150; Mon, 24 Apr 2023 03:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682331272; cv=none; d=google.com; s=arc-20160816; b=pHRpOftPDoutUOg2v7Gbuvdwnlaw5FP5cnB4n25j4v57WAmBNegGa925cU+HIsqIBx L4vSV+5FIJi1BXBq38UQLfztVhPV43HgzbJBX2glGZZhPcJ8xkbor5HQaPfpol1rvp2V GR9NApP0Uou3h4mTWVHkOCVGzsC+qeU2MqDQdcEG+NXG2Ea5hMbv+uMrv6qCfhhie6/C oSl9d2wIKY/DYevlE1EETGxfybA/m2tqorwZxYegskB7K2My4ZajnXfbb8ELzpdV1Yc8 FLrqPaGaGjVe2NWOuTb7qkSKkdhUdFrgqZ5PbNZ5mZyaaqAKEQnLzOlO/djAjoUZ7it+ JqWQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q1-20020a170902dac100b001a92694cbd6si11747720plx.600.2023.04.24.03.14.19; Mon, 24 Apr 2023 03:14:32 -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 S231668AbjDXJz6 (ORCPT + 99 others); Mon, 24 Apr 2023 05:55:58 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764052195689909681?= X-GMAIL-MSGID: =?utf-8?q?1764052195689909681?= 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 | 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);