Message ID | 20211122013256.3050966-1-linus.walleij@linaro.org |
---|---|
State | New |
Headers | show |
Series | watchdog: ixp4xx: Implement restart | expand |
On 11/21/21 5:32 PM, Linus Walleij wrote: > Implement watchdog restart in the IXP4xx watchdog timer. > > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > drivers/watchdog/ixp4xx_wdt.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/watchdog/ixp4xx_wdt.c b/drivers/watchdog/ixp4xx_wdt.c > index 31b03fa71341..7b188591f6d4 100644 > --- a/drivers/watchdog/ixp4xx_wdt.c > +++ b/drivers/watchdog/ixp4xx_wdt.c > @@ -18,6 +18,7 @@ > #include <linux/bits.h> > #include <linux/platform_device.h> > #include <linux/clk.h> > +#include <linux/delay.h> > #include <linux/soc/ixp4xx/cpu.h> > > struct ixp4xx_wdt { > @@ -84,10 +85,25 @@ static int ixp4xx_wdt_set_timeout(struct watchdog_device *wdd, > return 0; > } > > +static int ixp4xx_wdt_restart(struct watchdog_device *wdd, > + unsigned long action, void *data) > +{ > + struct ixp4xx_wdt *iwdt = to_ixp4xx_wdt(wdd); > + > + __raw_writel(IXP4XX_WDT_KEY, iwdt->base + IXP4XX_OSWK_OFFSET); > + __raw_writel(0, iwdt->base + IXP4XX_OSWT_OFFSET); > + __raw_writel(IXP4XX_WDT_COUNT_ENABLE | IXP4XX_WDT_RESET_ENABLE, > + iwdt->base + IXP4XX_OSWE_OFFSET); > + msleep(1000); > + A restart handler should not sleep, and it doesn't make sense either since it is called from machine_restart() and nothing else is supposed to happen at this point. Also, are you sure that this is going to take 1 second ? That seems excessive. Thanks, Guenter > + return 0; > +} > + > static const struct watchdog_ops ixp4xx_wdt_ops = { > .start = ixp4xx_wdt_start, > .stop = ixp4xx_wdt_stop, > .set_timeout = ixp4xx_wdt_set_timeout, > + .restart = ixp4xx_wdt_restart, > .owner = THIS_MODULE, > }; > >
diff --git a/drivers/watchdog/ixp4xx_wdt.c b/drivers/watchdog/ixp4xx_wdt.c index 31b03fa71341..7b188591f6d4 100644 --- a/drivers/watchdog/ixp4xx_wdt.c +++ b/drivers/watchdog/ixp4xx_wdt.c @@ -18,6 +18,7 @@ #include <linux/bits.h> #include <linux/platform_device.h> #include <linux/clk.h> +#include <linux/delay.h> #include <linux/soc/ixp4xx/cpu.h> struct ixp4xx_wdt { @@ -84,10 +85,25 @@ static int ixp4xx_wdt_set_timeout(struct watchdog_device *wdd, return 0; } +static int ixp4xx_wdt_restart(struct watchdog_device *wdd, + unsigned long action, void *data) +{ + struct ixp4xx_wdt *iwdt = to_ixp4xx_wdt(wdd); + + __raw_writel(IXP4XX_WDT_KEY, iwdt->base + IXP4XX_OSWK_OFFSET); + __raw_writel(0, iwdt->base + IXP4XX_OSWT_OFFSET); + __raw_writel(IXP4XX_WDT_COUNT_ENABLE | IXP4XX_WDT_RESET_ENABLE, + iwdt->base + IXP4XX_OSWE_OFFSET); + msleep(1000); + + return 0; +} + static const struct watchdog_ops ixp4xx_wdt_ops = { .start = ixp4xx_wdt_start, .stop = ixp4xx_wdt_stop, .set_timeout = ixp4xx_wdt_set_timeout, + .restart = ixp4xx_wdt_restart, .owner = THIS_MODULE, };
Implement watchdog restart in the IXP4xx watchdog timer. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- drivers/watchdog/ixp4xx_wdt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)