watchdog: imx2_wdt: handle enabled watchdog properly
Subsystems (2)
PATCH 1/1 watchdog: imx2_wdt: handle enabled watchdog properly
If the watchdog is already enabled (e.g. started by the boot loader), we need to handle this case properly and start reloading the watchdog time-out counter as frequently as needed.
--- drivers/watchdog/imx2_wdt.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/watchdog/imx2_wdt.c +24 -0
@@ -54,6 +54,7 @@#define IMX2_WDT_DEFAULT_TIME 60/* in seconds */ #define WDOG_SEC_TO_COUNT (s) ((s * 2 - 1) << 8) +#define WDOG_COUNT_TO_SEC (c) ((((c) >> 8) + 1) / 2)#define IMX2_WDT_STATUS_OPEN 0#define IMX2_WDT_STATUS_STARTED 1
@@ -120,6 +121,27 @@ static void imx2_wdt_timer_ping(unsigned long arg)mod_timer (&imx2_wdt.timer, jiffies + imx2_wdt.timeout *HZ /2 ); } +static inline void imx2_wdt_ping_if_active (void ) +{ +u16 val =__raw_readw (imx2_wdt.base +IMX2_WDT_WCR ); + +if (val &IMX2_WDT_WCR_WDE ) { +/* Must enable the clock, wdog service doesn't work otherwise */ +clk_prepare_enable (imx2_wdt.clk); + +set_bit (IMX2_WDT_STATUS_STARTED , &imx2_wdt.status); + imx2_wdt.timeout =WDOG_COUNT_TO_SEC (val); +if (imx2_wdt.timeout <2 ) { + imx2_wdt.timeout =2 ; +/* Set new watchdog time-out value */ + val &= ~IMX2_WDT_WCR_WT ; + val |=WDOG_SEC_TO_COUNT (imx2_wdt.timeout); +__raw_writew (val, imx2_wdt.base +IMX2_WDT_WCR ); + } +imx2_wdt_timer_ping (0 ); + } +} +static void imx2_wdt_start (void ) {if (!test_and_set_bit (IMX2_WDT_STATUS_STARTED , &imx2_wdt.status)) {
@@ -283,6 +305,8 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)if (ret) goto fail; +imx2_wdt_ping_if_active (); +dev_info (&pdev->dev,"IMX2+ Watchdog Timer enabled. timeout=%ds (nowayout=%d)\n" , imx2_wdt.timeout, nowayout);
Signature · 1 line
1.7.9.5
PATCH 1/1 watchdog: imx2_wdt: handle enabled watchdog properly
Quoted 7 lines · Anatolij Gustschin
If the watchdog is already enabled (e.g. started by the boot loader), we need to handle this case properly and start reloading the watchdog time-out counter as frequently as needed.
Signed-off-by Anatolij Gustschin <[email protected]>Cc Wolfram Sang <[email protected]>Cc Wim Van Sebroeck <[email protected]>
Uh, this driver has not been converted to use the watchdog framework yet? I'd suggest this should be the first step.
@Wim: Does the watchdog core already handle the case that the wdt might have been started by the bootloader?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140404/e7bcaf92/attachment.sig>
Guenter Roeck
maintainerPATCH 1/1 watchdog: imx2_wdt: handle enabled watchdog properly
Quoted 5 lines · Wolfram Sang
Quoted 4 lines · Anatolij Gustschin
If the watchdog is already enabled (e.g. started by the boot loader), we need to handle this case properly and start reloading the watchdog time-out counter as frequently as needed.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Anatolij Gustschin <[email protected]>Cc Wolfram Sang <[email protected]>Cc Wim Van Sebroeck <[email protected]>Uh, this driver has not been converted to use the watchdog framework yet? I'd suggest this should be the first step.
Yes, that would make sense at this time, especially given the amount of work going into it. There is also a separate patch set pending, converting the driver to use regmap [1]; I am copying the author. Maybe one of the people working with the driver would be willing to do the conversion.
Guenter
Hi Wolfram,
Quoted 9 lines · Anatolij Gustschin
Quoted 7 lines
If the watchdog is already enabled (e.g. started by the boot loader), we need to handle this case properly and start reloading the watchdog time-out counter as frequently as needed.
Signed-off-by Anatolij Gustschin <[email protected]>Cc Wolfram Sang <[email protected]>Cc Wim Van Sebroeck <[email protected]>
Quoted 5 lines
Uh, this driver has not been converted to use the watchdog framework yet? I'd suggest this should be the first step.
@Wim: Does the watchdog core already handle the case that the wdt might have been started by the bootloader?
There is nothing for that in the core. And I think that it makes no sense to put this in the core. It's something you have to take care of during init/probe and that is driver specific. See also this message: http://www.spinics.net/lists/linux-watchdog/msg04066.html .
Kind regards,
Wim.
Hi Wolfram,
Quoted 9 lines · Anatolij Gustschin
Quoted 7 lines
If the watchdog is already enabled (e.g. started by the boot loader), we need to handle this case properly and start reloading the watchdog time-out counter as frequently as needed.
Signed-off-by Anatolij Gustschin <[email protected]>Cc Wolfram Sang <[email protected]>Cc Wim Van Sebroeck <[email protected]>
Quoted 5 lines
Uh, this driver has not been converted to use the watchdog framework yet? I'd suggest this should be the first step.
@Wim: Does the watchdog core already handle the case that the wdt might have been started by the bootloader?
No, not yet.
Kind regards,
Wim.