From 9fd868f440c3d722199a14200b2a64a0a5e70221 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 10 Feb 2009 20:30:37 -0800 Subject: [PATCH] [WATCHDOG] davinci: use clock framework for timer frequency Remove use of CLOCK_TICK_RATE in favor of using clock framework for getting timer frequency. Signed-off-by: Kevin Hilman Signed-off-by: Russell King Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/davinci_wdt.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c index 83e22e7ea4a2..9d7520fa9e9c 100644 --- a/drivers/watchdog/davinci_wdt.c +++ b/drivers/watchdog/davinci_wdt.c @@ -25,6 +25,7 @@ #include #include #include +#include #define MODULE_NAME "DAVINCI-WDT: " @@ -69,6 +70,7 @@ static unsigned long wdt_status; static struct resource *wdt_mem; static void __iomem *wdt_base; +struct clk *wdt_clk; static void wdt_service(void) { @@ -86,6 +88,9 @@ static void wdt_enable(void) { u32 tgcr; u32 timer_margin; + unsigned long wdt_freq; + + wdt_freq = clk_get_rate(wdt_clk); spin_lock(&io_lock); @@ -99,9 +104,9 @@ static void wdt_enable(void) iowrite32(0, wdt_base + TIM12); iowrite32(0, wdt_base + TIM34); /* set timeout period */ - timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) & 0xffffffff); + timer_margin = (((u64)heartbeat * wdt_freq) & 0xffffffff); iowrite32(timer_margin, wdt_base + PRD12); - timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) >> 32); + timer_margin = (((u64)heartbeat * wdt_freq) >> 32); iowrite32(timer_margin, wdt_base + PRD34); /* enable run continuously */ iowrite32(ENAMODE12_PERIODIC, wdt_base + TCR); @@ -199,6 +204,12 @@ static int __devinit davinci_wdt_probe(struct platform_device *pdev) struct resource *res; struct device *dev = &pdev->dev; + wdt_clk = clk_get(dev, NULL); + if (WARN_ON(IS_ERR(wdt_clk))) + return PTR_ERR(wdt_clk); + + clk_enable(wdt_clk); + if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) heartbeat = DEFAULT_HEARTBEAT; @@ -245,6 +256,10 @@ static int __devexit davinci_wdt_remove(struct platform_device *pdev) kfree(wdt_mem); wdt_mem = NULL; } + + clk_disable(wdt_clk); + clk_put(wdt_clk); + return 0; } -- 2.30.2