From 7f3d53c8bf3b851837dc2f5dd85e0c6a0d0116a1 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Wed, 2 Oct 2024 21:23:23 +0200 Subject: [PATCH 01/16] watchdog: gpio_wdt: add support for stoppable devices Back when I added this driver in commit 2ac8490412c9, I wrote The corresponding linux driver apparently has support for some watchdog circuits which can be disabled by tri-stating the gpio, but I have never actually encountered such a chip in the wild; That has changed now; I have a board with just such a watchdog on my desk currently. Add support for that. - For a hw_algo="toggle" device, the gpio is requested as output if the always-running flag is set, otherwise as input. - The ->start() method is updated to change the direction to output when required (i.e. it is not always-running). - The ->stop() method is implemented, but of course reports failure if always-running. As I still haven't met any hw_algo="level" devices, I'm not entirely sure how they fit in, but I'm borrowing logic from the corresponding linux driver: - In ->probe(), such devices always request the gpio as GPIOD_IS_OUT. - In ->stop(), the linux driver has an "eternal ping" comment and sets the gpio to (logic) high. Stefan: Added necessary changes in test/dm/wdt.c to fix CI build breakage, as suggested by Rasmus. Signed-off-by: Rasmus Villemoes Reviewed-by: Stefan Roese --- drivers/watchdog/gpio_wdt.c | 27 ++++++++++++++++++++++++--- test/dm/wdt.c | 4 ++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c index 2920c2c751f..e889861e917 100644 --- a/drivers/watchdog/gpio_wdt.c +++ b/drivers/watchdog/gpio_wdt.c @@ -45,14 +45,32 @@ static int gpio_wdt_start(struct udevice *dev, u64 timeout, ulong flags) if (priv->always_running) return 0; - return -ENOSYS; + dm_gpio_set_dir_flags(&priv->gpio, GPIOD_IS_OUT); + gpio_wdt_reset(dev); + + return 0; +} + +static int gpio_wdt_stop(struct udevice *dev) +{ + struct gpio_wdt_priv *priv = dev_get_priv(dev); + + if (priv->always_running) + return -EOPNOTSUPP; + + if (priv->hw_algo == HW_ALGO_TOGGLE) + dm_gpio_set_dir_flags(&priv->gpio, GPIOD_IS_IN); + else + dm_gpio_set_value(&priv->gpio, 1); + + return 0; } static int dm_probe(struct udevice *dev) { struct gpio_wdt_priv *priv = dev_get_priv(dev); - int ret; const char *algo = dev_read_string(dev, "hw_algo"); + int ret, flags; if (!algo) return -EINVAL; @@ -64,7 +82,9 @@ static int dm_probe(struct udevice *dev) return -EINVAL; priv->always_running = dev_read_bool(dev, "always-running"); - ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT); + flags = priv->always_running || priv->hw_algo == HW_ALGO_LEVEL ? + GPIOD_IS_OUT : GPIOD_IS_IN; + ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, flags); if (ret < 0) { dev_err(dev, "Request for wdt gpio failed: %d\n", ret); return ret; @@ -78,6 +98,7 @@ static int dm_probe(struct udevice *dev) static const struct wdt_ops gpio_wdt_ops = { .start = gpio_wdt_start, + .stop = gpio_wdt_stop, .reset = gpio_wdt_reset, }; diff --git a/test/dm/wdt.c b/test/dm/wdt.c index 541bcba1b53..710414881fa 100644 --- a/test/dm/wdt.c +++ b/test/dm/wdt.c @@ -71,7 +71,7 @@ static int dm_test_wdt_gpio_toggle(struct unit_test_state *uts) ut_assertok(wdt_reset(wdt)); ut_asserteq(val, sandbox_gpio_get_value(gpio, offset)); - ut_asserteq(-ENOSYS, wdt_stop(wdt)); + ut_asserteq(-EOPNOTSUPP, wdt_stop(wdt)); return 0; } @@ -103,7 +103,7 @@ static int dm_test_wdt_gpio_level(struct unit_test_state *uts) ut_assertok(wdt_reset(wdt)); ut_asserteq(val, sandbox_gpio_get_value(gpio, offset)); - ut_asserteq(-ENOSYS, wdt_stop(wdt)); + ut_asserteq(-EOPNOTSUPP, wdt_stop(wdt)); return 0; } From f9318b067f43aa1618036db8d77d34086d62dc06 Mon Sep 17 00:00:00 2001 From: Bastien Curutchet Date: Thu, 3 Oct 2024 10:42:55 +0200 Subject: [PATCH 02/16] drivers: watchdog: Add DaVinci's watchdog support Add support for the DaVinci's watchdog timer Signed-off-by: Bastien Curutchet Reviewed-by: Stefan Roese --- drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/davinci_wdt.c | 131 +++++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 drivers/watchdog/davinci_wdt.c diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 90bc5653ee3..b6f7e4ee08a 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -175,6 +175,13 @@ config WDT_DA9063 help Enable support for the watchdog timer in Dialog DA9063. +config WDT_DAVINCI + bool "DaVinci watchdog timer support" + depends on WDT + help + Select this to enable the watchdog timer for DaVinci SoCs such as the + OMAP-L138. + config WDT_GPIO bool "External gpio watchdog support" depends on WDT diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 51be6ab9abe..cef98975d07 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -30,6 +30,7 @@ obj-$(CONFIG_WDT_CORTINA) += cortina_wdt.o obj-$(CONFIG_WDT_ORION) += orion_wdt.o obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o obj-$(CONFIG_WDT_DA9063) += da9063-wdt.o +obj-$(CONFIG_WDT_DAVINCI) += davinci_wdt.o obj-$(CONFIG_WDT_FTWDT010) += ftwdt010_wdt.o obj-$(CONFIG_WDT_GPIO) += gpio_wdt.o obj-$(CONFIG_WDT_MAX6370) += max6370_wdt.o diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c new file mode 100644 index 00000000000..fa8d7842e94 --- /dev/null +++ b/drivers/watchdog/davinci_wdt.c @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * DaVinci Watchdog driver + * + */ + +#include +#include +#include +#include + +/* Control Register */ +#define DAVINCI_WDT_ID 0x00 +#define DAVINCI_WDT_TIM12 0x10 +#define DAVINCI_WDT_TIM34 0x14 +#define DAVINCI_WDT_PRD12 0x18 +#define DAVINCI_WDT_PRD34 0x1C +#define DAVINCI_WDT_TCR 0x20 +#define DAVINCI_WDT_TGCR 0x24 +#define DAVINCI_WDT_WDTCR 0x28 + +#define DAVINCI_TCR_CONT_EN BIT(7) + +#define DAVINCI_TGCR_PLUSEN BIT(4) +#define DAVINCI_TGCR_WDT_MODE BIT(3) +#define DAVINCI_TGCR_TIM34RS BIT(1) +#define DAVINCI_TGCR_TIM12RS BIT(0) + +#define DAVINCI_WDTCR_INVALID_KEY (0x5555 << 16) +#define DAVINCI_WDTCR_WDKEY0 (0xA5C6 << 16) +#define DAVINCI_WDTCR_WDKEY1 (0xDA7E << 16) +#define DAVINCI_WDTCR_WDFLAG BIT(15) +#define DAVINCI_WDTCR_WDEN BIT(14) + +#define DEFAULT_THRESHOLD 0xA03200000 + +struct davinci_wdt_priv { + void __iomem *base; + struct clk *ref_clk; +}; + +static int davinci_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags) +{ + struct davinci_wdt_priv *priv = dev_get_priv(dev); + ulong rate = clk_get_rate(priv->ref_clk); + u64 threshold; + + if (!rate) + threshold = DEFAULT_THRESHOLD; + else + threshold = rate * timeout_ms / 1000; + + /* Reset control registers */ + writel(0, priv->base + DAVINCI_WDT_TCR); + writel(0, priv->base + DAVINCI_WDT_TGCR); + + /* Enable watchdog mode and timers */ + writel(DAVINCI_TGCR_WDT_MODE | DAVINCI_TGCR_TIM12RS | DAVINCI_TGCR_TIM34RS, + priv->base + DAVINCI_WDT_TGCR); + + /* Reset counters */ + writel(0, priv->base + DAVINCI_WDT_TIM12); + writel(0, priv->base + DAVINCI_WDT_TIM34); + + /* Set timeout threshold */ + writel(threshold & 0xFFFFFFFF, priv->base + DAVINCI_WDT_PRD12); + writel(threshold >> 32, priv->base + DAVINCI_WDT_PRD34); + + /* Enable counter */ + writel(DAVINCI_TCR_CONT_EN, priv->base + DAVINCI_WDT_TCR); + + /* Go to watchdog's active state */ + writel(DAVINCI_WDTCR_WDEN | DAVINCI_WDTCR_WDKEY0, priv->base + DAVINCI_WDT_WDTCR); + writel(DAVINCI_WDTCR_WDEN | DAVINCI_WDTCR_WDKEY1, priv->base + DAVINCI_WDT_WDTCR); + + return 0; +} + +static int davinci_wdt_expire_now(struct udevice *dev, ulong flags) +{ + struct davinci_wdt_priv *priv = dev_get_priv(dev); + + writel(DAVINCI_WDTCR_INVALID_KEY, priv->base + DAVINCI_WDT_WDTCR); + + return 0; +} + +static int davinci_wdt_restart(struct udevice *dev) +{ + struct davinci_wdt_priv *priv = dev_get_priv(dev); + + writel(DAVINCI_WDTCR_WDEN | DAVINCI_WDTCR_WDKEY0, priv->base + DAVINCI_WDT_WDTCR); + writel(DAVINCI_WDTCR_WDEN | DAVINCI_WDTCR_WDKEY1, priv->base + DAVINCI_WDT_WDTCR); + + return 0; +} + +static int davinci_wdt_probe(struct udevice *dev) +{ + struct davinci_wdt_priv *priv = dev_get_priv(dev); + + priv->base = dev_remap_addr_index(dev, 0); + if (!priv->base) + return -EFAULT; + + priv->ref_clk = devm_clk_get(dev, "ref"); + if (IS_ERR(priv->ref_clk)) + return PTR_ERR(priv->ref_clk); + + return 0; +} + +static const struct wdt_ops davinci_wdt_ops = { + .start = davinci_wdt_start, + .reset = davinci_wdt_restart, + .expire_now = davinci_wdt_expire_now, +}; + +static const struct udevice_id davinci_wdt_ids[] = { + {.compatible = "ti,davinci-wdt"}, + {} +}; + +U_BOOT_DRIVER(davinci_wdt) = { + .name = "davinci_wdt", + .id = UCLASS_WDT, + .probe = davinci_wdt_probe, + .of_match = davinci_wdt_ids, + .ops = &davinci_wdt_ops, + .priv_auto = sizeof(struct davinci_wdt_priv), +}; From 625094536716631915e6e8b8e4d16d4b25a1645d Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:50 +0200 Subject: [PATCH 03/16] doc: cyclic: remove reference to WATCHDOG_RESET WATCHDOG_RESET is no more. Replace the reference by schedule(). While here, rearrange the sentence a bit so that "cyclic_run()" becomes the object and "the main function responsible for calling all registered cyclic functions" a parenthetical rather than the other way around, which at least to me makes it more readable. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- doc/develop/cyclic.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/develop/cyclic.rst b/doc/develop/cyclic.rst index 893c269099a..6f1da6f0d9b 100644 --- a/doc/develop/cyclic.rst +++ b/doc/develop/cyclic.rst @@ -49,8 +49,8 @@ executed all 10ms. How is this cyclic functionality integrated / executed? -------------------------------------------------------- -The cyclic infrastructure integrates the main function responsible for -calling all registered cyclic functions cyclic_run() into the common -WATCHDOG_RESET macro. This guarantees that cyclic_run() is executed -very often, which is necessary for the cyclic functions to get scheduled -and executed at their configured periods. +The cyclic infrastructure integrates cyclic_run(), the main function +responsible for calling all registered cyclic functions, into the +common schedule() function. This guarantees that cyclic_run() is +executed very often, which is necessary for the cyclic functions to +get scheduled and executed at their configured periods. From 4457e5c61d825a2673547e4cd60570a77fbcc3cd Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:51 +0200 Subject: [PATCH 04/16] cyclic: introduce u-boot/schedule.h I noticed an "unnecessary" include of in global_data.h, in the sense that nothing in cyclic.h is needed in order to define 'struct global_data'. Well, it's not unnecessary, as it implicitly ensures that everybody gets a declaration of schedule(), and schedule() is (obviously) called all over the tree. Almost none of those places directly include , but for historical reasons, many do include (most schedule() instances are replacements of WATCHDOG_RESET()). However, very few TUs actually need the declarations of the cyclic_register() and struct cyclic_info, and they also don't really need anything from the watchdog.h header. So introduce a new header which just contains a declaration of schedule(), which can then be included from all the places that do call schedule(). I removed the direct reference to cyclic_run(), because we shouldn't have two public functions for doing roughly the same without being very explicit about when one should call one or the other. Testing of later patches that explicitly include when schedule() is used revealed a problem with host tool build on win32, which apparently picked up a host . To avoid that problem, put the new header in include/u-boot/ and hence make the include statements say . Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- common/cyclic.c | 1 + include/cyclic.h | 12 +----------- include/u-boot/schedule.h | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 include/u-boot/schedule.h diff --git a/common/cyclic.c b/common/cyclic.c index ec38fad6775..38d815bec35 100644 --- a/common/cyclic.c +++ b/common/cyclic.c @@ -15,6 +15,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; diff --git a/include/cyclic.h b/include/cyclic.h index cd95b691d48..e8de616dcd5 100644 --- a/include/cyclic.h +++ b/include/cyclic.h @@ -13,6 +13,7 @@ #include #include +#include // to be removed later /** * struct cyclic_info - Information about cyclic execution function @@ -94,13 +95,6 @@ struct hlist_head *cyclic_get_list(void); */ void cyclic_run(void); -/** - * schedule() - Schedule all potentially waiting tasks - * - * Basically a wrapper for cyclic_run(), pontentially enhanced by some - * other parts, that need to get handled periodically. - */ -void schedule(void); #else static inline void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func, @@ -116,10 +110,6 @@ static inline void cyclic_run(void) { } -static inline void schedule(void) -{ -} - static inline int cyclic_unregister_all(void) { return 0; diff --git a/include/u-boot/schedule.h b/include/u-boot/schedule.h new file mode 100644 index 00000000000..4fd34c41229 --- /dev/null +++ b/include/u-boot/schedule.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _U_BOOT_SCHEDULE_H +#define _U_BOOT_SCHEDULE_H + +#if CONFIG_IS_ENABLED(CYCLIC) +/** + * schedule() - Schedule all potentially waiting tasks + * + * Run all pending tasks registered via the cyclic framework, and + * potentially perform other actions that need to be done + * periodically. + */ +void schedule(void); + +#else + +static inline void schedule(void) +{ +} + +#endif + +#endif From 9e628922283834edaec342f335eb9726ab53570e Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:52 +0200 Subject: [PATCH 05/16] led: include cyclic.h in led_sw_blink.c This makes use of the cyclic API but relies on implicitly getting the appropriate declarations through some nested include. Include the cyclic.h header directly. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- drivers/led/led_sw_blink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/led/led_sw_blink.c b/drivers/led/led_sw_blink.c index 06a43db340c..ee1546d02d4 100644 --- a/drivers/led/led_sw_blink.c +++ b/drivers/led/led_sw_blink.c @@ -5,6 +5,7 @@ * Author: Mikhail Kshevetskiy */ +#include #include #include #include From b279aa505de7e22762e00c7f360da7b84fa8ab59 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:53 +0200 Subject: [PATCH 06/16] m68k: asm/ptrace.h: include linux/types.h Modifying a generic header like watchdog.h, removing not directly used asm/ptrace.h header relies on whoever includes it to already have included something that defines the type ulong. Make the asm/ptrace.h header self-contained by including the proper header. Signed-off-by: Rasmus Villemoes Reviewed-by: Tom Rini Reviewed-by: Stefan Roese --- arch/m68k/include/asm/ptrace.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/m68k/include/asm/ptrace.h b/arch/m68k/include/asm/ptrace.h index d419824806c..5decf73a1d1 100644 --- a/arch/m68k/include/asm/ptrace.h +++ b/arch/m68k/include/asm/ptrace.h @@ -9,6 +9,8 @@ */ #ifndef __ASSEMBLY__ +#include + struct pt_regs { ulong d0; ulong d1; From 92957de3621ecc77f2bd1883a8fc33b8e598d964 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:54 +0200 Subject: [PATCH 07/16] fs/cramfs: use schedule instead of cyclic_run as callback Prior to commit 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()") we had /* Currently only needed for fs/cramfs/uncompress.c */ static inline void watchdog_reset_func(void) { WATCHDOG_RESET(); } and .outcb was set to that watchdog_reset_func(). Said commit changed that .outcb to cyclic_run instead of schedule, which would otherwise match all the other WATCHDOG_RESET replacements done. As the HW_WATCHDOG case is not handled by cyclic_run, this seems to be an oversight. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- fs/cramfs/uncompress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/cramfs/uncompress.c b/fs/cramfs/uncompress.c index 2141edf22e4..97af8cb2b4f 100644 --- a/fs/cramfs/uncompress.c +++ b/fs/cramfs/uncompress.c @@ -21,9 +21,9 @@ */ #include -#include #include #include +#include #include static z_stream stream; @@ -63,7 +63,7 @@ int cramfs_uncompress_init (void) stream.avail_in = 0; #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) - stream.outcb = (cb_func)cyclic_run; + stream.outcb = (cb_func)schedule; #else stream.outcb = Z_NULL; #endif /* CONFIG_HW_WATCHDOG */ From e3bc477e8038195b54bf50e7915b111e9c357cf0 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:55 +0200 Subject: [PATCH 08/16] test: dm: wdt: replace cyclic_run() by schedule() This is the last place outside of cyclic.c that references cyclic_run() directly. Replace by schedule(), so that cyclic_run() can be made private. This also better matches what I believe commit 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()") intended to do. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- test/dm/wdt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/dm/wdt.c b/test/dm/wdt.c index 710414881fa..bef29591d5a 100644 --- a/test/dm/wdt.c +++ b/test/dm/wdt.c @@ -3,7 +3,6 @@ * Copyright 2017 Google, Inc */ -#include #include #include #include @@ -14,6 +13,7 @@ #include #include #include +#include #include /* Test that watchdog driver functions are called */ @@ -131,7 +131,7 @@ static int dm_test_wdt_watchdog_reset(struct unit_test_state *uts) /* Neither device should be "started", so watchdog_reset() should be a no-op. */ reset_count = state->wdt.reset_count; val = sandbox_gpio_get_value(gpio, offset); - cyclic_run(); + schedule(); ut_asserteq(reset_count, state->wdt.reset_count); ut_asserteq(val, sandbox_gpio_get_value(gpio, offset)); @@ -141,19 +141,19 @@ static int dm_test_wdt_watchdog_reset(struct unit_test_state *uts) /* Make sure both devices have just been pinged. */ timer_test_add_offset(100); - cyclic_run(); + schedule(); reset_count = state->wdt.reset_count; val = sandbox_gpio_get_value(gpio, offset); /* The gpio watchdog should be pinged, the sandbox one not. */ timer_test_add_offset(30); - cyclic_run(); + schedule(); ut_asserteq(reset_count, state->wdt.reset_count); ut_asserteq(!val, sandbox_gpio_get_value(gpio, offset)); /* After another ~30ms, both devices should get pinged. */ timer_test_add_offset(30); - cyclic_run(); + schedule(); ut_asserteq(reset_count + 1, state->wdt.reset_count); ut_asserteq(val, sandbox_gpio_get_value(gpio, offset)); From 307449de9058657eef544043013e8655468b3032 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:56 +0200 Subject: [PATCH 09/16] cyclic: make cyclic_run static The only caller left is schedule(); everybody outside cyclic.c now calls or references schedule(). Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- common/cyclic.c | 2 +- include/cyclic.h | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/common/cyclic.c b/common/cyclic.c index 38d815bec35..196797fd61e 100644 --- a/common/cyclic.c +++ b/common/cyclic.c @@ -45,7 +45,7 @@ void cyclic_unregister(struct cyclic_info *cyclic) hlist_del(&cyclic->list); } -void cyclic_run(void) +static void cyclic_run(void) { struct cyclic_info *cyclic; struct hlist_node *tmp; diff --git a/include/cyclic.h b/include/cyclic.h index e8de616dcd5..c6c463d68e9 100644 --- a/include/cyclic.h +++ b/include/cyclic.h @@ -87,14 +87,6 @@ int cyclic_unregister_all(void); */ struct hlist_head *cyclic_get_list(void); -/** - * cyclic_run() - Interate over all registered cyclic functions - * - * Interate over all registered cyclic functions and if the it's function - * needs to be executed, then call into these registered functions. - */ -void cyclic_run(void); - #else static inline void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func, @@ -106,10 +98,6 @@ static inline void cyclic_unregister(struct cyclic_info *cyclic) { } -static inline void cyclic_run(void) -{ -} - static inline int cyclic_unregister_all(void) { return 0; From bd665754894ffe4ea01e43f4fc5d3ef4cba1689d Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:57 +0200 Subject: [PATCH 10/16] watchdog.h: change include of cyclic.h to u-boot/schedule.h Nobody relies on getting the cyclic API declared by including the watchdog.h header, but for historical reasons, many TUs include watchdog.h to get a declaration of schedule(). Now that we have a dedicated header for just that, include that header instead of cyclic.h. Eventually, all TUs that call schedule() should themselves include u-boot/schedule.h, but this is a step towards getting rid of unnecessary include statements in cyclic.h and global_data.h. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- include/watchdog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/watchdog.h b/include/watchdog.h index d1956fafca1..0149b44d077 100644 --- a/include/watchdog.h +++ b/include/watchdog.h @@ -10,7 +10,7 @@ #ifndef _WATCHDOG_H_ #define _WATCHDOG_H_ -#include +#include // to be removed later /* * Reset the watchdog timer, always returns 0 From ed8a807df87eae2f3c1a41f9b2d4b3e0191648db Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:58 +0200 Subject: [PATCH 11/16] lib/sha*: include u-boot/schedule.h instead of cyclic.h These library routines obviously do not make use of the cyclic_register() etc. API, but do need to call schedule(). Include the proper header. Eventually, their ifdef logic should be updated to avoid talking about CONFIG_WATCHDOG. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- lib/sha1.c | 2 +- lib/sha256.c | 2 +- lib/sha512.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sha1.c b/lib/sha1.c index 81412283b49..a9d6497c4ce 100644 --- a/lib/sha1.c +++ b/lib/sha1.c @@ -17,7 +17,7 @@ #endif #ifndef USE_HOSTCC -#include +#include #endif /* USE_HOSTCC */ #include #include diff --git a/lib/sha256.c b/lib/sha256.c index 665ba6f152e..329802fd827 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -6,7 +6,7 @@ */ #ifndef USE_HOSTCC -#include +#include #endif /* USE_HOSTCC */ #include #include diff --git a/lib/sha512.c b/lib/sha512.c index ffe2c5cd964..ea555ff33eb 100644 --- a/lib/sha512.c +++ b/lib/sha512.c @@ -11,7 +11,7 @@ */ #ifndef USE_HOSTCC -#include +#include #endif /* USE_HOSTCC */ #include #include From 4da44fa6467da0372e42be4c7c84e863d9d44258 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:27:59 +0200 Subject: [PATCH 12/16] i2c: rzg2l: include u-boot/schedule.h This TU currently relies on getting a declaration of schedule() through some nested include. Include the proper header directly. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- drivers/i2c/rz_riic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/rz_riic.c b/drivers/i2c/rz_riic.c index 5f3f8d1b24b..f292c824362 100644 --- a/drivers/i2c/rz_riic.c +++ b/drivers/i2c/rz_riic.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #define RIIC_ICCR1 0x00 From 02e352f0da0cad06c6db69d928308362a6835a9f Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:28:00 +0200 Subject: [PATCH 13/16] ddr: altera: include u-boot/schedule.h These TUs currently rely on getting a declaration of schedule() through some nested include. Include the proper header directly. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- drivers/ddr/altera/sdram_n5x.c | 1 + drivers/ddr/altera/sdram_soc64.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/ddr/altera/sdram_n5x.c b/drivers/ddr/altera/sdram_n5x.c index db09986f64b..d1fc93b6bdd 100644 --- a/drivers/ddr/altera/sdram_n5x.c +++ b/drivers/ddr/altera/sdram_n5x.c @@ -22,6 +22,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/ddr/altera/sdram_soc64.c b/drivers/ddr/altera/sdram_soc64.c index 9e57c2ecfa4..10a8e64af3d 100644 --- a/drivers/ddr/altera/sdram_soc64.c +++ b/drivers/ddr/altera/sdram_soc64.c @@ -24,6 +24,7 @@ #include #include #include +#include #define PGTABLE_OFF 0x4000 From a21aed059761d67066d71a09b2dfb9387fdcfcbd Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:28:01 +0200 Subject: [PATCH 14/16] boot: cedit: include u-boot/schedule.h This TU currently relies on getting a declaration of schedule() through some nested include. Include the proper header directly. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- boot/cedit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/boot/cedit.c b/boot/cedit.c index d12892fbc4a..d69290c172e 100644 --- a/boot/cedit.c +++ b/boot/cedit.c @@ -20,6 +20,7 @@ #include #include #include "scene_internal.h" +#include enum { CMOS_MAX_BITS = 2048, From 6459964d738fe74f2cec7bca7caa1de444bc9d54 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 3 Oct 2024 23:28:02 +0200 Subject: [PATCH 15/16] global_data.h: remove unnecesary include of cyclic.h Nothing in cyclic.h is needed to define struct global_data, so do not include that header. If any .c file relies on getting cyclic.h through asm/global_data.h, it needs to include it itself. Signed-off-by: Rasmus Villemoes Reviewed-by: Tom Rini Reviewed-by: Stefan Roese --- include/asm-generic/global_data.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 644a0d77873..b84cc5bbecd 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -21,7 +21,6 @@ #ifndef __ASSEMBLY__ #include -#include #include #include #include From ed3410ee6049a7683718e8255575ad55ee1bdefd Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Mon, 7 Oct 2024 19:47:16 +0200 Subject: [PATCH 16/16] watchdog: introduce separate SPL symbol for WDT_GPIO Currently, enabling WDT_GPIO on a board which uses SPL, but does not have SPL_WDT, SPL_DM_GPIO or SPL_OF_CONTROL enabled, breaks the build. Make it possible to use the WDT_GPIO driver on such boards by introducing a separate symbol controlling whether the driver is built for SPL. Make it default to WDT_GPIO such that boards that already have it enabled and all the SPL prerequisites satisfied will continue to have it in SPL. Signed-off-by: Rasmus Villemoes Reviewed-by: Tom Rini Reviewed-by: Stefan Roese --- drivers/watchdog/Kconfig | 9 +++++++++ drivers/watchdog/Makefile | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index b6f7e4ee08a..0e45f0a0922 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -191,6 +191,15 @@ config WDT_GPIO doc/device-tree-bindings/watchdog/gpio-wdt.txt for information on how to describe the watchdog in device tree. +config SPL_WDT_GPIO + bool "External gpio watchdog support in SPL" + depends on SPL_WDT + depends on SPL_DM_GPIO + depends on SPL_OF_REAL + default WDT_GPIO + help + Support for external watchdog fed by toggling a gpio in SPL. + config WDT_MAX6370 bool "MAX6370 watchdog timer support" depends on WDT diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index cef98975d07..0b107c008f7 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -32,7 +32,7 @@ obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o obj-$(CONFIG_WDT_DA9063) += da9063-wdt.o obj-$(CONFIG_WDT_DAVINCI) += davinci_wdt.o obj-$(CONFIG_WDT_FTWDT010) += ftwdt010_wdt.o -obj-$(CONFIG_WDT_GPIO) += gpio_wdt.o +obj-$(CONFIG_$(SPL_TPL_)WDT_GPIO) += gpio_wdt.o obj-$(CONFIG_WDT_MAX6370) += max6370_wdt.o obj-$(CONFIG_WDT_MCF) += mcf_wdt.o obj-$(CONFIG_WDT_MESON_GXBB) += meson_gxbb_wdt.o