Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2312BC433F5 for ; Thu, 4 Nov 2021 07:48:17 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F6F361183 for ; Thu, 4 Nov 2021 07:48:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8F6F361183 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D146083660; Thu, 4 Nov 2021 08:48:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1636012095; bh=fC/nHg+FpDw7fOMa3ThDXDpPwWmWdQWdWtbkIFfTQWg=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SIlAQ6PWj+xxH+WdqUiQU3IVLKlozs9u4ZLdnkBqGvxBQZ0VkUzgscB1YO0ub+96p Y0WveTKgeKiU7+Qx3bLRPUN0LDERGT2rmSFPk2TwPqYg1E2My2PWqaSs0Sc/3X6ukk q2ZLGbBbU6+xDxwyoa5IQ5nFSvshChviykPHS41hS1GmtgBNQQXaKDtziV15Q3LBdL uHdGZrphGYJfL8vwQRTXEeQqwMn0D9blJe0PirKEg3lbluVkqhvgU1TeRf1K0FrYsH oGbWJtIGtM0rvuomnbJ2VCi8Fp1SfA4jMqibg+92SApTMlip8SUh9VRLk5O+iSZa8L pm4eVoAjisTXw== Received: by phobos.denx.de (Postfix, from userid 109) id ECF0083661; Thu, 4 Nov 2021 08:48:13 +0100 (CET) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [IPv6:2001:67c:2050:1::465:107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 58272835DE for ; Thu, 4 Nov 2021 08:48:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp202.mailbox.org (unknown [91.198.250.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4HlG2x6x2VzQjf3; Thu, 4 Nov 2021 08:48:09 +0100 (CET) Subject: Re: [PATCH v3 4/6] watchdog: Automatically register device with sysreset To: Samuel Holland , u-boot@lists.denx.de, Jagan Teki , Andre Przywara Cc: Bin Meng , Heinrich Schuchardt , Sean Anderson , Simon Glass References: <20211104035516.28268-1-samuel@sholland.org> <20211104035516.28268-5-samuel@sholland.org> From: Stefan Roese Message-ID: Date: Thu, 4 Nov 2021 08:48:04 +0100 MIME-Version: 1.0 In-Reply-To: <20211104035516.28268-5-samuel@sholland.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7B5BF131C X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 04.11.21 04:55, Samuel Holland wrote: > Add an option to automatically register watchdog devices with the > wdt_reboot driver for use with sysreset. This allows sysreset to be a > drop-in replacement for platform-specific watchdog reset code, without > needing any device tree changes. > > Signed-off-by: Samuel Holland Reviewed-by: Stefan Roese Thanks, Stefan > --- > > Changes in v3: > - Move condition to wdt-uclass.c to fix build errors. > - Include watchdog name in error message. > > Changes in v2: > - Rebase on top of 492ee6b8d0e7 (now handle all watchdogs). > > drivers/sysreset/Kconfig | 7 +++++++ > drivers/sysreset/sysreset_watchdog.c | 24 ++++++++++++++++++++++++ > drivers/watchdog/wdt-uclass.c | 8 ++++++++ > include/sysreset.h | 10 ++++++++++ > 4 files changed, 49 insertions(+) > > diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig > index de75c9cccc..f6d60038b8 100644 > --- a/drivers/sysreset/Kconfig > +++ b/drivers/sysreset/Kconfig > @@ -131,6 +131,13 @@ config SYSRESET_WATCHDOG > help > Reboot support for generic watchdog reset. > > +config SYSRESET_WATCHDOG_AUTO > + bool "Automatically register first watchdog with sysreset" > + depends on SYSRESET_WATCHDOG > + help > + If enabled, the first watchdog (as selected by the watchdog uclass) > + will automatically be registered with the watchdog reboot driver. > + > config SYSRESET_RESETCTL > bool "Enable support for reset controller reboot driver" > select DM_RESET > diff --git a/drivers/sysreset/sysreset_watchdog.c b/drivers/sysreset/sysreset_watchdog.c > index b723f5647c..35efcac59d 100644 > --- a/drivers/sysreset/sysreset_watchdog.c > +++ b/drivers/sysreset/sysreset_watchdog.c > @@ -5,7 +5,9 @@ > > #include > #include > +#include > #include > +#include > #include > #include > > @@ -57,3 +59,25 @@ U_BOOT_DRIVER(wdt_reboot) = { > .plat_auto = sizeof(struct wdt_reboot_plat), > .ops = &wdt_reboot_ops, > }; > + > +#if IS_ENABLED(CONFIG_SYSRESET_WATCHDOG_AUTO) > +int sysreset_register_wdt(struct udevice *dev) > +{ > + struct wdt_reboot_plat *plat = malloc(sizeof(*plat)); > + int ret; > + > + if (!plat) > + return -ENOMEM; > + > + plat->wdt = dev; > + > + ret = device_bind(dev, DM_DRIVER_GET(wdt_reboot), > + dev->name, plat, ofnode_null(), NULL); > + if (ret) { > + free(plat); > + return ret; > + } > + > + return 0; > +} > +#endif > diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c > index 7570710c4d..6d0f473867 100644 > --- a/drivers/watchdog/wdt-uclass.c > +++ b/drivers/watchdog/wdt-uclass.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -44,6 +45,13 @@ static void init_watchdog_dev(struct udevice *dev) > > priv = dev_get_uclass_priv(dev); > > + if (IS_ENABLED(CONFIG_SYSRESET_WATCHDOG_AUTO)) { > + ret = sysreset_register_wdt(dev); > + if (ret) > + printf("WDT: Failed to register %s for sysreset\n", > + dev->name); > + } > + > if (!IS_ENABLED(CONFIG_WATCHDOG_AUTOSTART)) { > printf("WDT: Not starting %s\n", dev->name); > return; > diff --git a/include/sysreset.h b/include/sysreset.h > index 9d4ed87cea..ff20abdeed 100644 > --- a/include/sysreset.h > +++ b/include/sysreset.h > @@ -133,4 +133,14 @@ void sysreset_walk_halt(enum sysreset_t type); > */ > void reset_cpu(void); > > +/** > + * sysreset_register_wdt() - register a watchdog for use with sysreset > + * > + * This registers the given watchdog timer to be used to reset the system. > + * > + * @dev: WDT device > + * @return: 0 if OK, -errno if error > + */ > +int sysreset_register_wdt(struct udevice *dev); > + > #endif > Viele Grüße, Stefan -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de