summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-device-wdt.c58
-rw-r--r--common/include/asm/arch/ips/wdt.h2
-rw-r--r--common/include/asm/arch/wdt.h16
-rw-r--r--polux/linux-2.6.10/arch/arm/mach-mse500/wdt.c58
4 files changed, 122 insertions, 12 deletions
diff --git a/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-device-wdt.c b/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-device-wdt.c
index 82deef79d3..23f7322610 100644
--- a/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-device-wdt.c
+++ b/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-device-wdt.c
@@ -29,9 +29,33 @@
uint32_t spc300_wdt_user_mode = 0;
EXPORT_SYMBOL(spc300_wdt_user_mode);
-int spc300_wdt_start(uint timeout_s)
+/**
+ * Refresh watchdog timer.
+ *
+ * \param va true if need to use virtual address to access register, false
+ * for physical address.
+ */
+static void spc300_wdt_refresh_(bool va)
+{
+ uint32_t reg = WDT_BF(CR, WDT_CR_VAL);
+ if (va)
+ WDT_CRR_VA = reg;
+ else
+ WDT_CRR_PA = reg;
+}
+
+/**
+ * Start watchdog timer countdown.
+ *
+ * \param timeout_s timeout of the watchdog (in second).
+ * \param va true if need to use virtual address to access register, false
+ * for physical address.
+ * \return 0 if no error, error value otherwise (-EINVAL if timeout_s is too
+ * big).
+ */
+static int spc300_wdt_start_(uint timeout_s, bool va)
{
- uint32_t cnt_value, top;
+ uint32_t cnt_value, top, reg;
//Timeout period = (2^(16+ TOP_reg)) / PCLK
@@ -47,17 +71,34 @@ int spc300_wdt_start(uint timeout_s)
{
if(cnt_value >= (1<<(top+16)))
{
- WDT_TORR_VA = WDT_BFINS(TOP, top, WDT_TORR_VA);
+ if (va)
+ WDT_TORR_VA = WDT_BFINS(TOP, top, WDT_TORR_VA);
+ else
+ WDT_TORR_PA = WDT_BFINS(TOP, top, WDT_TORR_PA);
break;
}
}
}
//Enable WDT with reset pulse = 32pclk and without interrupt management
- WDT_CR_VA = WDT_BF(RPL, 4) | WDT_BF(RMOD, 0) | WDT_BF(EN, 1);
- spc300_wdt_refresh();
+ reg = WDT_BF(RPL, 4) | WDT_BF(RMOD, 0) | WDT_BF(EN, 1);
+ if (va)
+ WDT_CR_VA = reg;
+ else
+ WDT_CR_PA = reg;
+ spc300_wdt_refresh_(va);
return 0;
}
+int spc300_wdt_start(uint timeout_s)
+{
+ return spc300_wdt_start_(timeout_s, true);
+}
+
+int spc300_wdt_start_pa(uint timeout_s)
+{
+ return spc300_wdt_start_(timeout_s, false);
+}
+
void spc300_wdt_switch(int use_umode)
{
if(use_umode)
@@ -68,7 +109,12 @@ void spc300_wdt_switch(int use_umode)
void spc300_wdt_refresh(void)
{
- WDT_CRR_VA = WDT_BF(CR, WDT_CR_VAL);
+ spc300_wdt_refresh_ (true);
+}
+
+void spc300_wdt_refresh_pa(void)
+{
+ spc300_wdt_refresh_ (false);
}
int spc300_wdt_gettimeout(void)
diff --git a/common/include/asm/arch/ips/wdt.h b/common/include/asm/arch/ips/wdt.h
index d4f574bfb0..39680347fb 100644
--- a/common/include/asm/arch/ips/wdt.h
+++ b/common/include/asm/arch/ips/wdt.h
@@ -40,6 +40,8 @@
#define WDT_COMP_TYPE_VA (*((volatile uint32_t *)(IO_ADDRESS(ARM_WDT_BASE) + WDTCOMP_TYPE_Offset)))
#define WDT_CRR_PA (*((volatile uint32_t *)(ARM_WDT_BASE + WDTCounterResetReg_Offset)))
+#define WDT_CR_PA (*((volatile uint32_t *)(ARM_WDT_BASE + WDTControlReg_Offset)))
+#define WDT_TORR_PA (*((volatile uint32_t *)(ARM_WDT_BASE + WDTTimeoutRangeReg_Offset)))
#endif /* __ASSEMBLY__ */
// Bitfields in Control Register
diff --git a/common/include/asm/arch/wdt.h b/common/include/asm/arch/wdt.h
index 76cc399eb1..52ccddffa3 100644
--- a/common/include/asm/arch/wdt.h
+++ b/common/include/asm/arch/wdt.h
@@ -43,6 +43,17 @@ extern uint32_t spc300_wdt_user_mode;
int spc300_wdt_start(uint timeout_s);
/**
+ * Start watchdog timer countdown (using physical address).
+ *
+ * \param timeout_s timeout of the watchdog (in second).
+ * \return 0 if no error, error value otherwise (EINVAL if timeout_s is too
+ * big).
+ *
+ * This function is the same as spc300_wdt_start but using physical address.
+ */
+int spc300_wdt_start_pa(uint timeout_s);
+
+/**
* Switch watchdog between user and kernel mode.
*
* \param use_umode 1 to switch to user mode.
@@ -55,6 +66,11 @@ void spc300_wdt_switch(int use_umode);
void spc300_wdt_refresh(void);
/**
+ * Refresh watchdog timer (using physical address).
+ */
+void spc300_wdt_refresh_pa(void);
+
+/**
* Get the watchdog time interval.
*
* \return time interval.
diff --git a/polux/linux-2.6.10/arch/arm/mach-mse500/wdt.c b/polux/linux-2.6.10/arch/arm/mach-mse500/wdt.c
index d8d70d2841..2e195b5852 100644
--- a/polux/linux-2.6.10/arch/arm/mach-mse500/wdt.c
+++ b/polux/linux-2.6.10/arch/arm/mach-mse500/wdt.c
@@ -29,9 +29,33 @@
uint32_t spc300_wdt_user_mode = 0;
EXPORT_SYMBOL(spc300_wdt_user_mode);
-int spc300_wdt_start(uint timeout_s)
+/**
+ * Refresh watchdog timer.
+ *
+ * \param va true if need to use virtual address to access register, false
+ * for physical address.
+ */
+static void spc300_wdt_refresh_(bool va)
+{
+ uint32_t reg = WDT_BF(CR, WDT_CR_VAL);
+ if (va)
+ WDT_CRR_VA = reg;
+ else
+ WDT_CRR_PA = reg;
+}
+
+/**
+ * Start watchdog timer countdown.
+ *
+ * \param timeout_s timeout of the watchdog (in second).
+ * \param va true if need to use virtual address to access register, false
+ * for physical address.
+ * \return 0 if no error, error value otherwise (-EINVAL if timeout_s is too
+ * big).
+ */
+static int spc300_wdt_start_(uint timeout_s, bool va)
{
- uint32_t cnt_value, top;
+ uint32_t cnt_value, top, reg;
//Timeout period = (2^(16+ TOP_reg)) / PCLK
@@ -47,17 +71,34 @@ int spc300_wdt_start(uint timeout_s)
{
if(cnt_value >= (1<<(top+16)))
{
- WDT_TORR_VA = WDT_BFINS(TOP, top, WDT_TORR_VA);
+ if (va)
+ WDT_TORR_VA = WDT_BFINS(TOP, top, WDT_TORR_VA);
+ else
+ WDT_TORR_PA = WDT_BFINS(TOP, top, WDT_TORR_PA);
break;
}
}
}
//Enable WDT with reset pulse = 32pclk and without interrupt management
- WDT_CR_VA = WDT_BF(RPL, 4) | WDT_BF(RMOD, 0) | WDT_BF(EN, 1);
- spc300_wdt_refresh();
+ reg = WDT_BF(RPL, 4) | WDT_BF(RMOD, 0) | WDT_BF(EN, 1);
+ if (va)
+ WDT_CR_VA = reg;
+ else
+ WDT_CR_PA = reg;
+ spc300_wdt_refresh_(va);
return 0;
}
+int spc300_wdt_start(uint timeout_s)
+{
+ return spc300_wdt_start_(timeout_s, true);
+}
+
+int spc300_wdt_start_pa(uint timeout_s)
+{
+ return spc300_wdt_start_(timeout_s, false);
+}
+
void spc300_wdt_switch(int use_umode)
{
if(use_umode)
@@ -68,7 +109,12 @@ void spc300_wdt_switch(int use_umode)
void spc300_wdt_refresh(void)
{
- WDT_CRR_VA = WDT_BF(CR, WDT_CR_VAL);
+ spc300_wdt_refresh_ (true);
+}
+
+void spc300_wdt_refresh_pa(void)
+{
+ spc300_wdt_refresh_ (false);
}
EXPORT_SYMBOL(spc300_wdt_refresh);