diff mbox

[V2,2/6] arm_smp_twd: mpcore_wdt: Fix watchdog counter loading

Message ID 1309892440-3260-3-git-send-email-vkuzmichev@mvista.com (mailing list archive)
State New, archived
Headers show

Commit Message

vkuzmichev@mvista.com July 5, 2011, 7 p.m. UTC
Although the commit "98af057092f8f0dabe63c5df08adc2bbfbddb1d2
 ARM: 6126/1: ARM mpcore_wdt: fix build failure and other fixes"
resolved long standing mpcore_wdt driver build problems, it
introduced an error in the relationship between the MPcore watchdog
timer clock rate and mpcore_margin, "MPcore timer margin in seconds",
such that watchdog timeouts are now arbitrary rather than the number
of seconds specified by mpcore_margin.

This change restores mpcore_wdt_keepalive() to its equivalent
implementation prior to commit 98af057 such that watchdog timeouts now
occur as specified by mpcore_margin.

The variable 'mpcore_timer_rate' which caused that build failure was
replaced by 'twd_timer_rate'. Adding exported function to obtain
'twd_timer_rate' value in mpcore_wdt driver.

A build error will not occur because MPCORE_WATCHDOG needed to build
'mpcore_wdt' depends on HAVE_ARM_TWD needed to build 'smp_twd'.

Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
---
 drivers/clocksource/arm_smp_twd.c |   13 +++++++++++++
 drivers/watchdog/mpcore_wdt.c     |    6 +++---
 2 files changed, 16 insertions(+), 3 deletions(-)

Comments

Arnd Bergmann July 6, 2011, 12:05 p.m. UTC | #1
On Tuesday 05 July 2011, Vitaly Kuzmichev wrote:
> +/* Needed by mpcore_wdt */
> +unsigned long twd_timer_get_rate(void)
> +{
> +       unsigned long rate;
> +
> +       if (!IS_ERR_OR_NULL(twd_clk))
> +               rate = clk_get_rate(twd_clk);
> +       else
> +               rate = twd_timer_rate;
> +       return rate;
> +}
> +EXPORT_SYMBOL(twd_timer_get_rate);

I would generally prefer to make new exported symbols EXPORT_SYMBOL_GPL
instead of EXPORT_SYMBOL.

	Arnd
diff mbox

Patch

diff --git a/drivers/clocksource/arm_smp_twd.c b/drivers/clocksource/arm_smp_twd.c
index 6acbdac..32f78ff 100644
--- a/drivers/clocksource/arm_smp_twd.c
+++ b/drivers/clocksource/arm_smp_twd.c
@@ -241,6 +241,19 @@  static void __cpuinit twd_setup(void *data)
 					0xf, 0xffffffff);
 }
 
+/* Needed by mpcore_wdt */
+unsigned long twd_timer_get_rate(void)
+{
+	unsigned long rate;
+
+	if (!IS_ERR_OR_NULL(twd_clk))
+		rate = clk_get_rate(twd_clk);
+	else
+		rate = twd_timer_rate;
+	return rate;
+}
+EXPORT_SYMBOL(twd_timer_get_rate);
+
 static void __cpuinit twd_teardown(void *data)
 {
 	struct clock_event_device *clk = data;
diff --git a/drivers/watchdog/mpcore_wdt.c b/drivers/watchdog/mpcore_wdt.c
index f638206..7a3d6b2 100644
--- a/drivers/watchdog/mpcore_wdt.c
+++ b/drivers/watchdog/mpcore_wdt.c
@@ -33,6 +33,8 @@ 
 #include <linux/slab.h>
 #include <linux/io.h>
 
+unsigned long twd_timer_get_rate(void);
+
 #define TWD_WDOG_LOAD			0x20
 #define TWD_WDOG_COUNTER		0x24
 #define TWD_WDOG_CONTROL		0x28
@@ -104,9 +106,7 @@  static void mpcore_wdt_keepalive(struct mpcore_wdt *wdt)
 
 	spin_lock(&wdt_lock);
 	/* Assume prescale is set to 256 */
-	count =  __raw_readl(wdt->base + TWD_WDOG_COUNTER);
-	count = (0xFFFFFFFFU - count) * (HZ / 5);
-	count = (count / 256) * mpcore_margin;
+	count = (twd_timer_get_rate() / 256) * mpcore_margin;
 
 	/* Reload the counter */
 	writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);