Patchwork [U-Boot] i.MX6 based board does not work if watchdog support is enabled

login
register
mail settings
Submitter Anatolij Gustschin
Date Sept. 29, 2013, 4:57 p.m.
Message ID <20130929185737.076b7cdf@crub>
Download mbox | patch
Permalink /patch/278876/
State Superseded
Headers show

Comments

Anatolij Gustschin - Sept. 29, 2013, 4:57 p.m.
Hi,

On Sat, 28 Sep 2013 21:19:19 -0300
Otavio Salvador <otavio@ossystems.com.br> wrote:

> I am trying to add support for watchdog in one board and it is not
> working as expected.
> 
> I did add the:
> 
> #define CONFIG_HW_WATCHDOG
> #define CONFIG_IMX_WATCHDOG
> 
> into the board config file.
> 
> Into the board .c file, I added:
> 
> int board_late_init(void)
> {
> ...
> #ifdef CONFIG_HW_WATCHDOG
>      hw_watchdog_init();
> #endif
> 
> return 0;
> }
> 
> and the hw_watchdog_init is indeed called.
> 
> It starts booting and shows:
> 
> U-Boot 2013.10-rc3-00046-gc1c2434-dirty (Sep 28 2013 - 21:12:53)
> 
> CPU:   Freescale i.MX6Q rev1.2 at 792 MHz
> Reset cause: WDOG
> Board: yyyy
> DRAM:  1 GiB
> MMC:   FSL_SDHC: 0, FSL_SDHC: 1
> In:    serial
> Out:   serial
> Err:   serial
> Net:�
> 
> and it in fact resets.
> 
> I am booting the board from USB loader. May it be an issue?

No, it shouldn't be an issue. Does the attached patch help?

Thanks,

Anatolij
Otavio Salvador - Sept. 29, 2013, 6:08 p.m.
On Sun, Sep 29, 2013 at 1:57 PM, Anatolij Gustschin <agust@denx.de> wrote:
> On Sat, 28 Sep 2013 21:19:19 -0300
> Otavio Salvador <otavio@ossystems.com.br> wrote:
>
>> I am trying to add support for watchdog in one board and it is not
>> working as expected.
>>
>> I did add the:
>>
>> #define CONFIG_HW_WATCHDOG
>> #define CONFIG_IMX_WATCHDOG
>>
>> into the board config file.
>>
>> Into the board .c file, I added:
>>
>> int board_late_init(void)
>> {
>> ...
>> #ifdef CONFIG_HW_WATCHDOG
>>      hw_watchdog_init();
>> #endif
>>
>> return 0;
>> }
>>
>> and the hw_watchdog_init is indeed called.
>>
>> It starts booting and shows:
>>
>> U-Boot 2013.10-rc3-00046-gc1c2434-dirty (Sep 28 2013 - 21:12:53)
>>
>> CPU:   Freescale i.MX6Q rev1.2 at 792 MHz
>> Reset cause: WDOG
>> Board: yyyy
>> DRAM:  1 GiB
>> MMC:   FSL_SDHC: 0, FSL_SDHC: 1
>> In:    serial
>> Out:   serial
>> Err:   serial
>> Net:�
>>
>> and it in fact resets.
>>
>> I am booting the board from USB loader. May it be an issue?
>
> No, it shouldn't be an issue. Does the attached patch help?

It does fix the issue! :-)
Stefano Babic - Sept. 30, 2013, 5:41 a.m.
Hi Antolji,

On 29/09/2013 20:08, Otavio Salvador wrote:

>>>
>>> I am booting the board from USB loader. May it be an issue?
>>
>> No, it shouldn't be an issue. Does the attached patch help?
> 
> It does fix the issue! :-)
> 

Can you resend the patch in the usual way to ML for including into
mainline ?

Thanks,
Stefano
Anatolij Gustschin - Sept. 30, 2013, 10:49 a.m.
Hi Stefano,

On Mon, 30 Sep 2013 07:41:46 +0200
Stefano Babic <sbabic@denx.de> wrote:
... 
> Can you resend the patch in the usual way to ML for including into
> mainline ?

yes, I can resend it.

Thanks,

Anatolij

Patch

From 394344a469ea18234adc8f611925e41bc532e230 Mon Sep 17 00:00:00 2001
From: Anatolij Gustschin <agust@denx.de>
Date: Tue, 16 Apr 2013 11:01:54 +0200
Subject: [PATCH] imx_watchdog: do not soft-reset while watchdog init

Currently the driver clears WCR_SRS bit when enabling
the watchdog and this causes a software reset. Do not
clear WCR_SRS.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 drivers/watchdog/imx_watchdog.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/imx_watchdog.c b/drivers/watchdog/imx_watchdog.c
index 50e602a..d5993b4 100644
--- a/drivers/watchdog/imx_watchdog.c
+++ b/drivers/watchdog/imx_watchdog.c
@@ -19,6 +19,7 @@  struct watchdog_regs {
 #define WCR_WDBG	0x02
 #define WCR_WDE		0x04	/* WDOG enable */
 #define WCR_WDT		0x08
+#define WCR_SRS		0x10
 #define WCR_WDW		0x80
 #define SET_WCR_WT(x)	(x << 8)
 
@@ -45,7 +46,7 @@  void hw_watchdog_init(void)
 #define CONFIG_WATCHDOG_TIMEOUT_MSECS 128000
 #endif
 	timeout = (CONFIG_WATCHDOG_TIMEOUT_MSECS / 500) - 1;
-	writew(WCR_WDZST | WCR_WDBG | WCR_WDE | WCR_WDT |
+	writew(WCR_WDZST | WCR_WDBG | WCR_WDE | WCR_WDT | WCR_SRS |
 		WCR_WDW | SET_WCR_WT(timeout), &wdog->wcr);
 	hw_watchdog_reset();
 }
-- 
1.7.9.5