Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp238874rwd; Wed, 31 May 2023 22:39:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5T/WmSnr924OjYofLu84YEAsKFuRHh/OCWikNcU6vyNmldgTJeBMTuJSqY1E2css4GiAhr X-Received: by 2002:aca:de44:0:b0:398:1849:ea55 with SMTP id v65-20020acade44000000b003981849ea55mr5703457oig.50.1685597953352; Wed, 31 May 2023 22:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685597953; cv=none; d=google.com; s=arc-20160816; b=DTTYSmRVPn1AaxhExZUTcuQuFNLRvJrF6V63wiKrQz043gqwZFWYdN5EKgw3Gzs55S ObY6U0fryphtfPDuGoeKiE2rAXKJc9lQLmZaat7/wdpUD2LmK+MzgfXreJL+tsCblw0u uMFBtoalPzLnNxc5zzoTLkK5Ce6KFFwh/G1ILE00zqt5Zm4wM2pzyqUEfbnKNOMwwovG wdDqvy/qhsIOan/ZuKcENNwiMQ4uXt3/ULTQUQcLNO7c4QFbuzi7NNTbnLafHf5W4+EU nm0P87TYwWLWneBTSNIagjzUrV55CZE2qIs5glbUT6lq0C2rr5pjugAgI4bZQzNNiyGx hMmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RJv1enniNURToHuLUERjxyUqTf6LjwxVg1LD+JWPLmA=; b=CUi/CwlYwUjLPJy/OOUfxJxjN/ja7HcCNxtWnFPj8Z3T6VC9ZorSjoNiiD1HvU8BtM zwwbDENVXlJD6t+3JeAzBet4JH1rZ084Ub4RGu1l4pUihjbc+AH7hoGygyVLgmvMES5i Tl+IR4CBwhwPzHcn2wPKVJc08pmAjyj7NoVtVcIdp2J9LKbmqnKX36kXTNBSTRJnNjze 2FldChW/Y0rJAbxyxSSpt7tACv85jBhEExBT1oKqWW7sggvwzlMHN5JfRmYzb5ancw4C dFbZKsiv0v4ptqtXxxoD6zjDng4zYEPBPnw9ia39eUHTENJgbFzzKW5MBEzXqD3MuLe6 ndyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maquefel.me header.s=mail header.b=MVDnefRD; 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 d22-20020a170902b71600b001ac6d4cc269si2085102pls.396.2023.05.31.22.39.00; Wed, 31 May 2023 22:39:13 -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=pass header.i=@maquefel.me header.s=mail header.b=MVDnefRD; 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 S231434AbjFAFif (ORCPT + 99 others); Thu, 1 Jun 2023 01:38:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231408AbjFAFiN (ORCPT ); Thu, 1 Jun 2023 01:38:13 -0400 Received: from forward103b.mail.yandex.net (forward103b.mail.yandex.net [178.154.239.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A72A19D; Wed, 31 May 2023 22:37:17 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-45.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-45.sas.yp-c.yandex.net [IPv6:2a02:6b8:c14:c83:0:640:84f9:0]) by forward103b.mail.yandex.net (Yandex) with ESMTP id 7B13660064; Thu, 1 Jun 2023 08:37:13 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-45.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id OaGNfZvWv8c0-bTdTQYrz; Thu, 01 Jun 2023 08:37:13 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maquefel.me; s=mail; t=1685597833; bh=RJv1enniNURToHuLUERjxyUqTf6LjwxVg1LD+JWPLmA=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=MVDnefRDt1lyXlfumLMMFOHp2cWmDIMGCBXR3hDxQlR6guXnuyb7pMZ6HqAVlsH8F AWZDG6eYzf0T1M2YTVtYoyXGYFPpWbKttRKXkr9pQwhtJT2nzlHHu1ZoqyaOi7tdPn bI6w0fP3B45FnW6riDtFHfA/qreqG3ZCfplp/xWc= Authentication-Results: mail-nwsmtp-smtp-production-main-45.sas.yp-c.yandex.net; dkim=pass header.i=@maquefel.me From: Nikita Shubin To: Alexander Sverdlin , Arnd Bergmann , Linus Walleij , Sebastian Reichel Cc: Nikita Shubin , Michael Peters , Kris Bahnsen , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v1 14/43] power: reset: Add a driver for the ep93xx reset Date: Thu, 1 Jun 2023 08:34:05 +0300 Message-Id: <20230601053546.9574-15-nikita.shubin@maquefel.me> X-Mailer: git-send-email 2.37.4 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 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 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); -- 2.37.4