Commit 0a0e9e0c authored by Matthias Fuchs's avatar Matthias Fuchs Committed by Kumar Gala

powerpc: Fix Book-E watchdog timer interval setting

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 correct mask.
Signed-off-by: default avatarMatthias Fuchs <matthias.fuchs@esd-electronics.com>
Acked-by: default avatarTimur Tabi <timur@freescale.com>
Signed-off-by: default avatarKumar Gala <galak@kernel.crashing.org>
parent b41d6fee
...@@ -42,8 +42,10 @@ u32 booke_wdt_period = WDT_PERIOD_DEFAULT; ...@@ -42,8 +42,10 @@ u32 booke_wdt_period = WDT_PERIOD_DEFAULT;
#ifdef CONFIG_FSL_BOOKE #ifdef CONFIG_FSL_BOOKE
#define WDTP(x) ((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15)) #define WDTP(x) ((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15))
#define WDTP_MASK (WDTP(0))
#else #else
#define WDTP(x) (TCR_WP(x)) #define WDTP(x) (TCR_WP(x))
#define WDTP_MASK (TCR_WP_MASK)
#endif #endif
static DEFINE_SPINLOCK(booke_wdt_lock); static DEFINE_SPINLOCK(booke_wdt_lock);
...@@ -65,6 +67,7 @@ static void __booke_wdt_enable(void *data) ...@@ -65,6 +67,7 @@ static void __booke_wdt_enable(void *data)
/* clear status before enabling watchdog */ /* clear status before enabling watchdog */
__booke_wdt_ping(NULL); __booke_wdt_ping(NULL);
val = mfspr(SPRN_TCR); val = mfspr(SPRN_TCR);
val &= ~WDTP_MASK;
val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period)); val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period));
mtspr(SPRN_TCR, val); mtspr(SPRN_TCR, val);
...@@ -114,7 +117,7 @@ static long booke_wdt_ioctl(struct file *file, ...@@ -114,7 +117,7 @@ static long booke_wdt_ioctl(struct file *file,
case WDIOC_SETTIMEOUT: case WDIOC_SETTIMEOUT:
if (get_user(booke_wdt_period, p)) if (get_user(booke_wdt_period, p))
return -EFAULT; return -EFAULT;
mtspr(SPRN_TCR, (mfspr(SPRN_TCR) & ~WDTP(0)) | mtspr(SPRN_TCR, (mfspr(SPRN_TCR) & ~WDTP_MASK) |
WDTP(booke_wdt_period)); WDTP(booke_wdt_period));
return 0; return 0;
case WDIOC_GETTIMEOUT: case WDIOC_GETTIMEOUT:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment