All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] watchdog: mpcore_wdt Add reload value setting for CNS3xxx hardware
@ 2011-07-05 12:05 Tommy Lin
  2011-07-05 14:05 ` Anton Vorontsov
  0 siblings, 1 reply; 9+ messages in thread
From: Tommy Lin @ 2011-07-05 12:05 UTC (permalink / raw)
  To: Wim Van Sebroeck, linux-watchdog, Anton Vorontsov
  Cc: linux-kernel, mac.lin, Tommy Lin

Original MPcore watchdog setting about load register (offset 0x20) is different
from CNS3xxx data sheet. The CNS3xxx data sheet says watchdog has following
features:
1. The Watchdog Counter Register (offset 0x24) is a down counter.
2. The timer interval is calculated using following equation:
   (PRESCALER_value+1) X (Load_value+1) X 2 / CPU CLK_frequency
Thus the watchdog load register control in CNS3xxx way is add to MPcore watchdog
source. The original control method is also kept if the CPU architecture is not
CNS3xxx.

Signed-off-by: Tommy Lin <tommy.lin@caviumnetworks.com>
---
 drivers/watchdog/mpcore_wdt.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/watchdog/mpcore_wdt.c b/drivers/watchdog/mpcore_wdt.c
index 2b4af22..816e0c5 100644
--- a/drivers/watchdog/mpcore_wdt.c
+++ b/drivers/watchdog/mpcore_wdt.c
@@ -42,6 +42,9 @@ struct mpcore_wdt {
 	int		irq;
 	unsigned int	perturb;
 	char		expect_close;
+#ifdef CONFIG_ARCH_CNS3XXX
+	unsigned long	reload_unit; /* ticks per second */
+#endif
 };
 
 static struct platform_device *mpcore_wdt_dev;
@@ -98,10 +101,14 @@ static void mpcore_wdt_keepalive(struct mpcore_wdt *wdt)
 	unsigned long count;
 
 	spin_lock(&wdt_lock);
+#ifdef CONFIG_ARCH_CNS3XXX
+	count = wdt->reload_unit * mpcore_margin;
+#else
 	/* Assume prescale is set to 256 */
 	count =  __raw_readl(wdt->base + TWD_WDOG_COUNTER);
 	count = (0xFFFFFFFFU - count) * (HZ / 5);
 	count = (count / 256) * mpcore_margin;
+#endif
 
 	/* Reload the counter */
 	writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);
@@ -375,6 +382,11 @@ static int __devinit mpcore_wdt_probe(struct platform_device *dev)
 		goto err_irq;
 	}
 
+#ifdef CONFIG_ARCH_CNS3XXX
+	/* Assume prescale is set to 256 */
+	wdt->reload_unit = cns3xxx_cpu_clock() * 1000000 / 256 / 2;
+#endif
+
 	mpcore_wdt_stop(wdt);
 	platform_set_drvdata(dev, wdt);
 	mpcore_wdt_dev = dev;
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-07-08  7:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-05 12:05 [PATCH 2/2] watchdog: mpcore_wdt Add reload value setting for CNS3xxx hardware Tommy Lin
2011-07-05 14:05 ` Anton Vorontsov
2011-07-06 10:05   ` Tommy Lin
2011-07-06 11:16     ` Anton Vorontsov
2011-07-06 11:28       ` Anton Vorontsov
2011-07-06 11:46         ` Anton Vorontsov
2011-07-06 14:54           ` Lin, Tommy
2011-07-06 19:34             ` Anton Vorontsov
2011-07-08  7:28               ` Tommy Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.