diff mbox

[V2] powerpc: Fix Book-E watchdog timer interval setting

Message ID 200809231704.56449.matthias.fuchs@esd-electronics.com (mailing list archive)
State Changes Requested, archived
Delegated to: Kumar Gala
Headers show

Commit Message

Matthias Fuchs Sept. 23, 2008, 3:04 p.m. UTC
This patch fixes the setting of the Book-E watchdog timer interval setup
on initialization and by ioctl().

On initialization the period bits have to be masked before setting
a new period.

In WDIOC_SETTIMEOUT ioctl we have to use the currect mask.

Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
---
 drivers/watchdog/booke_wdt.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Comments

Timur Tabi Sept. 23, 2008, 4:31 p.m. UTC | #1
On Tue, Sep 23, 2008 at 10:04 AM, Matthias Fuchs
<matthias.fuchs@esd-electronics.com> wrote:
>  #ifdef CONFIG_FSL_BOOKE
>  #define WDTP(x)                ((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15))
> +#define WDTP_MASK      (WDTP(63))

WDTP(63) is "((((63-63)&0x3)<<30)|(((63-63)&0x3c)<<15))", which is
equal to 0.  Shouldn't WDTP_MASK be equal to "(3 << 30) | (15 << 15)"?
Matthias Fuchs Nov. 3, 2008, 8:56 a.m. UTC | #2
Timur,

I missed you posting. But you are right. My patch is ok for 4xx CPUs and touching 
the CONFIG_FSL_BOOKE path was not my intention.

So for CONFIG_FSL_BOOKE WDTP_MASK should be WDTP(0). There is still a slightly difference
between WDTP(0)="(3 << 30) | (0x3c << 15)" and "(3 << 30) | (15 << 15)". 
Can you check that please and I will resend my patch.

Thanks for pointing that out.

Matthias

On Tuesday 23 September 2008 18:31, Timur Tabi wrote:
> On Tue, Sep 23, 2008 at 10:04 AM, Matthias Fuchs
> <matthias.fuchs@esd-electronics.com> wrote:
> >  #ifdef CONFIG_FSL_BOOKE
> >  #define WDTP(x)                ((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15))
> > +#define WDTP_MASK      (WDTP(63))
> 
> WDTP(63) is "((((63-63)&0x3)<<30)|(((63-63)&0x3c)<<15))", which is
> equal to 0.  Shouldn't WDTP_MASK be equal to "(3 << 30) | (15 << 15)"?
>
Timur Tabi Nov. 3, 2008, 4:28 p.m. UTC | #3
Matthias Fuchs wrote:
> Timur,
> 
> I missed you posting. But you are right. My patch is ok for 4xx CPUs and touching 
> the CONFIG_FSL_BOOKE path was not my intention.
> 
> So for CONFIG_FSL_BOOKE WDTP_MASK should be WDTP(0). There is still a slightly difference
> between WDTP(0)="(3 << 30) | (0x3c << 15)" and "(3 << 30) | (15 << 15)". 
> Can you check that please and I will resend my patch.

Yes, I think WDTP(0) is correct for Book E.
diff mbox

Patch

diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
index c3b78a7..41ba9b8 100644
--- a/drivers/watchdog/booke_wdt.c
+++ b/drivers/watchdog/booke_wdt.c
@@ -42,8 +42,10 @@  u32 booke_wdt_period = WDT_PERIOD_DEFAULT;
 
 #ifdef	CONFIG_FSL_BOOKE
 #define WDTP(x)		((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15))
+#define WDTP_MASK	(WDTP(63))
 #else
 #define WDTP(x)		(TCR_WP(x))
+#define WDTP_MASK	(TCR_WP_MASK)
 #endif
 
 static DEFINE_SPINLOCK(booke_wdt_lock);
@@ -65,6 +67,7 @@  static void __booke_wdt_enable(void *data)
 	/* clear status before enabling watchdog */
 	__booke_wdt_ping(NULL);
 	val = mfspr(SPRN_TCR);
+	val &= ~WDTP_MASK;
 	val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period));
 
 	mtspr(SPRN_TCR, val);
@@ -114,7 +117,7 @@  static long booke_wdt_ioctl(struct file *file,
 	case WDIOC_SETTIMEOUT:
 		if (get_user(booke_wdt_period, p))
 			return -EFAULT;
-		mtspr(SPRN_TCR, (mfspr(SPRN_TCR) & ~WDTP(0)) |
+		mtspr(SPRN_TCR, (mfspr(SPRN_TCR) & ~WDTP_MASK) |
 						WDTP(booke_wdt_period));
 		return 0;
 	case WDIOC_GETTIMEOUT: