diff options
author | Tom Rini <trini@konsulko.com> | 2024-06-16 09:10:13 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-06-16 09:10:13 -0600 |
commit | e242cd95130b64cf91692da41363ac59b25fc08d (patch) | |
tree | b3b167faa221aff7adf419741acbc0c1e39833a6 /drivers | |
parent | d8c213c9c7f827a9de0096bb4e5247c9a07bb248 (diff) | |
parent | 85c476759a42dfedb2d66e9734f8c05b7cfb62d5 (diff) | |
download | u-boot-e242cd95130b64cf91692da41363ac59b25fc08d.zip u-boot-e242cd95130b64cf91692da41363ac59b25fc08d.tar.gz u-boot-e242cd95130b64cf91692da41363ac59b25fc08d.tar.bz2 |
Merge branch 'next' of https://source.denx.de/u-boot/custodians/u-boot-watchdog into next
- misc cyclic infrastructure improvements (Rasmus)
- watchdog_reset cleanup (Rasmus)
CI: https://dev.azure.com/sr0718/u-boot/_build/results?buildId=369&view=results
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/serial/ns16550.c | 8 | ||||
-rw-r--r-- | drivers/watchdog/wdt-uclass.c | 57 |
2 files changed, 26 insertions, 39 deletions
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 4963385..42b6971 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -291,9 +291,9 @@ void ns16550_putc(struct ns16550 *com_port, char c) serial_out(c, &com_port->thr); /* - * Call watchdog_reset() upon newline. This is done here in putc + * Call schedule() upon newline. This is done here in putc * since the environment code uses a single puts() to print the complete - * environment upon "printenv". So we can't put this watchdog call + * environment upon "printenv". So we can't put this schedule call * in puts(). */ if (c == '\n') @@ -390,9 +390,9 @@ static int ns16550_serial_putc(struct udevice *dev, const char ch) serial_out(ch, &com_port->thr); /* - * Call watchdog_reset() upon newline. This is done here in putc + * Call schedule() upon newline. This is done here in putc * since the environment code uses a single puts() to print the complete - * environment upon "printenv". So we can't put this watchdog call + * environment upon "printenv". So we can't put this schedule call * in puts(). */ if (ch == '\n') diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c index c88312e..10be334 100644 --- a/drivers/watchdog/wdt-uclass.c +++ b/drivers/watchdog/wdt-uclass.c @@ -17,17 +17,20 @@ #include <asm/global_data.h> #include <dm/device-internal.h> #include <dm/lists.h> +#include <linux/kernel.h> DECLARE_GLOBAL_DATA_PTR; #define WATCHDOG_TIMEOUT_SECS (CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000) struct wdt_priv { + /* The udevice owning this wdt_priv. */ + struct udevice *dev; /* Timeout, in seconds, to configure this device to. */ u32 timeout; /* * Time, in milliseconds, between calling the device's ->reset() - * method from watchdog_reset(). + * method from schedule(). */ ulong reset_period; /* @@ -40,18 +43,17 @@ struct wdt_priv { /* autostart */ bool autostart; - struct cyclic_info *cyclic; + struct cyclic_info cyclic; }; -static void wdt_cyclic(void *ctx) +static void wdt_cyclic(struct cyclic_info *c) { - struct udevice *dev = ctx; - struct wdt_priv *priv; + struct wdt_priv *priv = container_of(c, struct wdt_priv, cyclic); + struct udevice *dev = priv->dev; if (!device_active(dev)) return; - priv = dev_get_uclass_priv(dev); if (!priv->running) return; @@ -121,24 +123,20 @@ int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags) struct wdt_priv *priv = dev_get_uclass_priv(dev); char str[16]; - priv->running = true; - memset(str, 0, 16); if (IS_ENABLED(CONFIG_WATCHDOG)) { + if (priv->running) + cyclic_unregister(&priv->cyclic); + /* Register the watchdog driver as a cyclic function */ - priv->cyclic = cyclic_register(wdt_cyclic, - priv->reset_period * 1000, - dev->name, dev); - if (!priv->cyclic) { - printf("cyclic_register for %s failed\n", - dev->name); - return -ENODEV; - } else { - snprintf(str, 16, "every %ldms", - priv->reset_period); - } + cyclic_register(&priv->cyclic, wdt_cyclic, + priv->reset_period * 1000, + dev->name); + + snprintf(str, 16, "every %ldms", priv->reset_period); } + priv->running = true; printf("WDT: Started %s with%s servicing %s (%ds timeout)\n", dev->name, IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", str, (u32)lldiv(timeout_ms, 1000)); @@ -159,6 +157,9 @@ int wdt_stop(struct udevice *dev) if (ret == 0) { struct wdt_priv *priv = dev_get_uclass_priv(dev); + if (IS_ENABLED(CONFIG_WATCHDOG) && priv->running) + cyclic_unregister(&priv->cyclic); + priv->running = false; } @@ -221,21 +222,6 @@ int wdt_expire_now(struct udevice *dev, ulong flags) return ret; } -#if defined(CONFIG_WATCHDOG) -/* - * Called by macro WATCHDOG_RESET. This function be called *very* early, - * so we need to make sure, that the watchdog driver is ready before using - * it in this function. - */ -void watchdog_reset(void) -{ - /* - * Empty function for now. The actual WDT handling is now done in - * the cyclic function instead. - */ -} -#endif - static int wdt_pre_probe(struct udevice *dev) { u32 timeout = WATCHDOG_TIMEOUT_SECS; @@ -257,12 +243,13 @@ static int wdt_pre_probe(struct udevice *dev) autostart = true; } priv = dev_get_uclass_priv(dev); + priv->dev = dev; priv->timeout = timeout; priv->reset_period = reset_period; priv->autostart = autostart; /* * Pretend this device was last reset "long" ago so the first - * watchdog_reset will actually call its ->reset method. + * schedule() will actually call its ->reset method. */ priv->next_reset = get_timer(0); |