Skip to contentSkip to conversation

MX31: Disable watchdog during low-power modes

PATCH Superseded Fabio Estevam 5 participants 7 messages Sep 19, 2011 – Sep 21, 2011

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MX31: Disable watchdog during low-power modes

Turn on the watchdog WDZST bit so that watchdog timer does not count during low power modes.

Prior to applying this patch mx31pdk board got watchdog resets because when it booted in the Linux prompt and there was no activity, the system entered into idle mode while watchdog timer was still active.

Fix this by disabling watchdog timer during idle mode.

---
 arch/arm/cpu/arm1136/mx31/timer.c         |    4 ++--
 arch/arm/include/asm/arch-mx31/imx-regs.h |    2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/cpu/arm1136/mx31/timer.c +2 -2
index c05a39d..7197108 100644
@@ -173,8 +173,8 @@ void mxc_hw_watchdog_enable(void)
 #else
 	secs = 64;
 #endif
-	writew(readw(&wdog->wcr) | (secs << WDOG_WT_SHIFT) | WDOG_ENABLE,
-		&wdog->wcr);
+	writew(readw(&wdog->wcr) | (secs << WDOG_WT_SHIFT) | WDOG_ENABLE
+						| WDOG_WDZST, &wdog->wcr);
 }
 
 
arch/arm/include/asm/arch-mx31/imx-regs.h +2 -0
index 2064870..338ba4d 100644
@@ -71,6 +71,8 @@ struct cspi_regs {
 /* Watchdog Timer (WDOG) registers */
 #define WDOG_ENABLE	(1 << 2)
 #define WDOG_WT_SHIFT	8
+#define WDOG_WDZST	1
+
 struct wdog_regs {
 	u16 wcr;	/* Control */
 	u16 wsr;	/* Service */
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 1/1 MX31: Disable watchdog during low-power modes

Quoted 20 lines · Fabio Estevam

Turn on the watchdog WDZST bit so that watchdog timer does not count during low power modes.

Prior to applying this patch mx31pdk board got watchdog resets because when it booted in the Linux prompt and there was no activity, the system entered into idle mode while watchdog timer was still active.

Fix this by disabling watchdog timer during idle mode.

---
 arch/arm/cpu/arm1136/mx31/timer.c         |    4 ++--
 arch/arm/include/asm/arch-mx31/imx-regs.h |    2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm1136/mx31/timer.c index c05a39d..7197108 100644

arch/arm/cpu/arm1136/mx31/timer.c void mxc_hw_watchdog_enable(void) · line 177

Quoted 7 lines
arch/arm/cpu/arm1136/mx31/timer.c +2 -2
@@ -173,8 +173,8 @@ void mxc_hw_watchdog_enable(void)
 #else
 	secs = 64;
 #endif
-	writew(readw(&wdog->wcr) | (secs << WDOG_WT_SHIFT) | WDOG_ENABLE,
-		&wdog->wcr);
+	writew(readw(&wdog->wcr) | (secs << WDOG_WT_SHIFT) | WDOG_ENABLE
+						| WDOG_WDZST, &wdog->wcr);

Maybe
tmp = readw();
tmp |= ...
writel(tmp, ...);

?

arch/arm/include/asm/arch-mx31/imx-regs.h struct cspi_regs { · line 74

Quoted 12 lines
arch/arm/cpu/arm1136/mx31/timer.c +0 -0
 }
 
 
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-mx31/imx-regs.h index 2064870..338ba4d 100644

arch/arm/include/asm/arch-mx31/imx-regs.h +1 -0
@@ -71,6 +71,8 @@ struct cspi_regs {
 /* Watchdog Timer (WDOG) registers */
 #define WDOG_ENABLE	(1 << 2)
 #define WDOG_WT_SHIFT	8
+#define WDOG_WDZST	1

(1 << 0) ?

Quoted 4 lines
arch/arm/include/asm/arch-mx31/imx-regs.h +1 -0
+
 struct wdog_regs {
 	u16 wcr;	/* Control */
 	u16 wsr;	/* Service */
#2 lore raw

PATCH 1/1 MX31: Disable watchdog during low-power modes

Quoted 25 lines · Marek Vasut
Quoted 24 lines · Fabio Estevam

Turn on the watchdog WDZST bit so that watchdog timer does not count during low power modes.

Prior to applying this patch mx31pdk board got watchdog resets because when it booted in the Linux prompt and there was no activity, the system entered into idle mode while watchdog timer was still active.

Fix this by disabling watchdog timer during idle mode.

---
 arch/arm/cpu/arm1136/mx31/timer.c         |    4 ++--
 arch/arm/include/asm/arch-mx31/imx-regs.h |    2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm1136/mx31/timer.c index c05a39d..7197108 100644

arch/arm/cpu/arm1136/mx31/timer.c +0 -1
@@ -173,8 +173,8 @@ void mxc_hw_watchdog_enable(void)
 #else
 	secs = 64;
 #endif
-	writew(readw(&wdog->wcr) | (secs << WDOG_WT_SHIFT) | WDOG_ENABLE,
Quoted 8 lines

arch/arm/cpu/arm1136/mx31/timer.c void mxc_hw_watchdog_enable(void) · line 177

Quoted 3 lines
arch/arm/cpu/arm1136/mx31/timer.c +2 -1
-		&wdog->wcr);
+	writew(readw(&wdog->wcr) | (secs << WDOG_WT_SHIFT) | WDOG_ENABLE
+						| WDOG_WDZST, &wdog->wcr);

Maybe
tmp = readw();
tmp |= ...
writel(tmp, ...);

Well, I do not see a big difference with your proposal - so it is only a question of taste. Calling write with an embedded read as first parameter is used often in u-boot.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#3 lore raw

PATCH 1/1 MX31: Disable watchdog during low-power modes

Quoted 40 lines · Stefano Babic
Quoted 29 lines · Marek Vasut
Quoted 28 lines · Fabio Estevam

Turn on the watchdog WDZST bit so that watchdog timer does not count during low power modes.

Prior to applying this patch mx31pdk board got watchdog resets because when it booted in the Linux prompt and there was no activity, the system entered into idle mode while watchdog timer was still active.

Fix this by disabling watchdog timer during idle mode.

---

 arch/arm/cpu/arm1136/mx31/timer.c         |    4 ++--
 arch/arm/include/asm/arch-mx31/imx-regs.h |    2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/cpu/arm1136/mx31/timer.c index c05a39d..7197108 100644

arch/arm/cpu/arm1136/mx31/timer.c +0 -0
@@ -173,8 +173,8 @@ void mxc_hw_watchdog_enable(void)
 
 #else
 
 	secs = 64;
 
 #endif
 
Quoted 9 lines

arch/arm/cpu/arm1136/mx31/timer.c void mxc_hw_watchdog_enable(void) · line 177

Quoted 4 lines
arch/arm/cpu/arm1136/mx31/timer.c +2 -2
-	writew(readw(&wdog->wcr) | (secs << WDOG_WT_SHIFT) | WDOG_ENABLE,
-		&wdog->wcr);
+	writew(readw(&wdog->wcr) | (secs << WDOG_WT_SHIFT) | WDOG_ENABLE
+						| WDOG_WDZST, &wdog->wcr);

Maybe
tmp = readw();
tmp |= ...
writel(tmp, ...);

Quoted 3 lines

Well, I do not see a big difference with your proposal - so it is only a question of taste. Calling write with an embedded read as first parameter is used often in u-boot.

It's a matter of taste and readability ... but then maybe use clrsetbits()?

Quoted 3 lines

Best regards,
Stefano Babic

reviewer
#4 lore raw

PATCH 1/1 MX31: Disable watchdog during low-power modes

In reply to Stefano Babic

Hi Stefano and Marek,

On Tue, Sep 20, 2011 at 5:48 AM, Stefano Babic <[email protected]> wrote:
...

Quoted 8 lines
Quoted 4 lines

Maybe
tmp = readw();
tmp |= ...
writel(tmp, ...);

Well, I do not see a big difference with your proposal - so it is only a question of taste. Calling write with an embedded read as first parameter is used often in u-boot.

Have we reached an agreement on whether I should change my original patch or if it is fine as is?

If I need to change it, please let me know how you prefer it.

I am fine either way, but really want to stop my MX31PDK to get watchdog resets all the time ;-)

Thanks,

Fabio Estevam

#5 lore raw

PATCH 1/1 MX31: Disable watchdog during low-power modes

Quoted 1 line · Fabio Estevam

Hi Stefano and Marek,

Hi Fabio,

Quoted 8 lines · Stefano Babic

...

Quoted 5 lines
Quoted 4 lines

Maybe
tmp = readw();
tmp |= ...
writel(tmp, ...);

Quoted 6 lines
Quoted 3 lines

Well, I do not see a big difference with your proposal - so it is only a question of taste. Calling write with an embedded read as first parameter is used often in u-boot.

Have we reached an agreement on whether I should change my original patch or if it is fine as is?

IMHO I can push your patch as it is. Your change uses the same style as in the current file, setting only a further bit.

Quoted 5 lines

If I need to change it, please let me know how you prefer it.

I am fine either way, but really want to stop my MX31PDK to get watchdog resets all the time ;-)

I can understand...

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#6 lore raw

PATCH 1/1 MX31: Disable watchdog during low-power modes

In reply to Fabio Estevam

Dear Fabio Estevam,

Quoted 2 lines · In message <CAOMZO5Do_W8FX6Qyihy8_bwu6XPoCZ=VKOdU54GvpF7p=CkJBw@mail.gmail.com>…

If I need to change it, please let me know how you prefer it.

Please use clrsetbits() as Marek suggested.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Documentation is the castor oil of programming.
Managers know it must be good because the programmers hate it so much.