From patchwork Fri Mar 5 21:36:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1448266 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=W3taVWIi; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dsh0y0pWZz9sW1 for ; Sat, 6 Mar 2021 08:37:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7F5EA826A5; Fri, 5 Mar 2021 22:37:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="W3taVWIi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0B8A182652; Fri, 5 Mar 2021 22:37:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 63CE480598 for ; Fri, 5 Mar 2021 22:37:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id D6E31650A5; Fri, 5 Mar 2021 21:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614980242; bh=gz/c/OChrl95swv0P9T38DQ3ZK0WAgIvyd2062qfMsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W3taVWIisEOCxts8TFRzJnQaz30+Lb2cvqH4Tw7gdADhViw9I/coLvLVyujAowPXS +vmmBdNMYVE8Hp7dpt1nt/ZRHDq+I2FDgJDR+65FivU9txwH4dM4R/KcgLOEQRCk+F ckql/tGkeIJAN7yR/uYLmS2U9jF/ERNKRtcCbf8ivqzKW49JSZHwdOIiYnUtS35byb PrafGSPCoIorO0tYIFU0G8eW+nvV/csLZgwplRBNt3C24EzUJwbRvhezCABPVsCDwS OhEyOmG8LHP5mySAo9WUBPiHIJyn5kq0WSsC5fGzp6F9ITCqFQRrbO9Ui0vyGVA+1t yh/IVme8MawjA== Received: by pali.im (Postfix) id 36D3B105A; Fri, 5 Mar 2021 22:37:20 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Stefan Roese , Simon Glass , Maxim Sloyko , Konstantin Porotchkin Cc: u-boot@lists.denx.de, =?utf-8?q?Marek_Beh=C3=BAn?= , Andre Heider , Luka Kovacic Subject: [PATCH 3/4] watchdog: Allow to use CONFIG_WDT without starting watchdog Date: Fri, 5 Mar 2021 22:36:58 +0100 Message-Id: <20210305213659.31025-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210305213659.31025-1-pali@kernel.org> References: <20210305213659.31025-1-pali@kernel.org> MIME-Version: 1.0 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.102.4 at phobos.denx.de X-Virus-Status: Clean In some cases it is useful to compile support for U-Boot command 'wdt' without starting HW watchdog in early U-Boot phase. For example when user want to start watchdog only on demand by some boot script. This change adds a new compile option WATCHDOG_AUTOSTART to control whether U-Boot should automatically start watchdog during init phase or not. This option is enabled by default as it was was default behavior prior introducing this new change. When compiling U-Boot users can decide to turn this option off. Signed-off-by: Pali Rohár --- drivers/watchdog/Kconfig | 13 +++++++++++++ drivers/watchdog/wdt-uclass.c | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 602ccbe41c00..aa76a8f2d239 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -9,6 +9,19 @@ config WATCHDOG this option if you want to service enabled watchdog by U-Boot. Disable this option if you want U-Boot to start watchdog but never service it. +config WATCHDOG_AUTOSTART + bool "Automatically start watchdog timer" + depends on WDT + default y + help + Automatically start watchdog timer and start servicing it during + init phase. Enabled by default. Disable this option if you want + to compile U-Boot with CONFIG_WDT support but do not want to + activate watchdog, like when CONFIG_WDT option is disabled. You + would be able to start watchdog manually by 'wdt' command. Useful + when you want to have support for 'wdt' command but do not want + to have watchdog enabled by default. + config WATCHDOG_TIMEOUT_MSECS int "Watchdog timeout in msec" default 128000 if ARCH_MX25 || ARCH_MX31 || ARCH_MX5 || ARCH_MX6 diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c index 7500b3ed90e3..00a408bf5cc5 100644 --- a/drivers/watchdog/wdt-uclass.c +++ b/drivers/watchdog/wdt-uclass.c @@ -27,7 +27,9 @@ static ulong reset_period = 1000; int initr_watchdog(void) { u32 timeout = WATCHDOG_TIMEOUT_SECS; +#ifdef CONFIG_WATCHDOG_AUTOSTART int ret; +#endif /* * Init watchdog: This will call the probe function of the @@ -51,6 +53,10 @@ int initr_watchdog(void) 4 * reset_period) / 4; } +#ifndef CONFIG_WATCHDOG_AUTOSTART + printf("WDT: Not starting\n"); + return 0; +#else ret = wdt_start(gd->watchdog_dev, timeout * 1000, 0); if (ret != 0) { printf("WDT: Failed to start\n"); @@ -61,6 +67,7 @@ int initr_watchdog(void) IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout); return 0; +#endif } int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)