diff options
author | Florian Fainelli <florian@openwrt.org> | 2010-01-27 03:10:06 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2010-02-27 06:53:16 -0500 |
commit | 780019ddf02f214ad61e641b57b8ac30c837e2a7 (patch) | |
tree | 2d0a01efc4d508057bcfaa7b3df5b3e490c249ed /drivers/watchdog/ar7_wdt.c | |
parent | 5f3c909881d5deebb9a3ddc836a15937e76daefc (diff) |
MIPS: AR7: Implement clock API
This patch makes the ar7 clock code implement the Linux clk API. Drivers
using the various clocks available in the SoC are updated accordingly.
Signed-off-by: Florian Fainelli <florian@openwrt.org>
Acked-by: Wim Van Sebroeck <wim@iguana.be>
To: linux-mips@linux-mips.org
Cc: Wim Van Sebroeck <wim@iguana.be>
Cc: netdev@vger.kernel.org
Cc: David Miller <davem@davemloft.net>
Patchwork: http://patchwork.linux-mips.org/patch/881/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'drivers/watchdog/ar7_wdt.c')
-rw-r--r-- | drivers/watchdog/ar7_wdt.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/watchdog/ar7_wdt.c b/drivers/watchdog/ar7_wdt.c index 2e94b71b20d9..2bb95cd308c1 100644 --- a/drivers/watchdog/ar7_wdt.c +++ b/drivers/watchdog/ar7_wdt.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/ioport.h> | 34 | #include <linux/ioport.h> |
35 | #include <linux/io.h> | 35 | #include <linux/io.h> |
36 | #include <linux/uaccess.h> | 36 | #include <linux/uaccess.h> |
37 | #include <linux/clk.h> | ||
37 | 38 | ||
38 | #include <asm/addrspace.h> | 39 | #include <asm/addrspace.h> |
39 | #include <asm/mach-ar7/ar7.h> | 40 | #include <asm/mach-ar7/ar7.h> |
@@ -80,6 +81,8 @@ static struct resource *ar7_regs_wdt; | |||
80 | /* Pointer to the remapped WDT IO space */ | 81 | /* Pointer to the remapped WDT IO space */ |
81 | static struct ar7_wdt *ar7_wdt; | 82 | static struct ar7_wdt *ar7_wdt; |
82 | 83 | ||
84 | static struct clk *vbus_clk; | ||
85 | |||
83 | static void ar7_wdt_kick(u32 value) | 86 | static void ar7_wdt_kick(u32 value) |
84 | { | 87 | { |
85 | WRITE_REG(ar7_wdt->kick_lock, 0x5555); | 88 | WRITE_REG(ar7_wdt->kick_lock, 0x5555); |
@@ -138,17 +141,19 @@ static void ar7_wdt_disable(u32 value) | |||
138 | static void ar7_wdt_update_margin(int new_margin) | 141 | static void ar7_wdt_update_margin(int new_margin) |
139 | { | 142 | { |
140 | u32 change; | 143 | u32 change; |
144 | u32 vbus_rate; | ||
141 | 145 | ||
142 | change = new_margin * (ar7_vbus_freq() / prescale_value); | 146 | vbus_rate = clk_get_rate(vbus_clk); |
147 | change = new_margin * (vbus_rate / prescale_value); | ||
143 | if (change < 1) | 148 | if (change < 1) |
144 | change = 1; | 149 | change = 1; |
145 | if (change > 0xffff) | 150 | if (change > 0xffff) |
146 | change = 0xffff; | 151 | change = 0xffff; |
147 | ar7_wdt_change(change); | 152 | ar7_wdt_change(change); |
148 | margin = change * prescale_value / ar7_vbus_freq(); | 153 | margin = change * prescale_value / vbus_rate; |
149 | printk(KERN_INFO DRVNAME | 154 | printk(KERN_INFO DRVNAME |
150 | ": timer margin %d seconds (prescale %d, change %d, freq %d)\n", | 155 | ": timer margin %d seconds (prescale %d, change %d, freq %d)\n", |
151 | margin, prescale_value, change, ar7_vbus_freq()); | 156 | margin, prescale_value, change, vbus_rate); |
152 | } | 157 | } |
153 | 158 | ||
154 | static void ar7_wdt_enable_wdt(void) | 159 | static void ar7_wdt_enable_wdt(void) |
@@ -298,6 +303,13 @@ static int __devinit ar7_wdt_probe(struct platform_device *pdev) | |||
298 | goto out_mem_region; | 303 | goto out_mem_region; |
299 | } | 304 | } |
300 | 305 | ||
306 | vbus_clk = clk_get(NULL, "vbus"); | ||
307 | if (IS_ERR(vbus_clk)) { | ||
308 | printk(KERN_ERR DRVNAME ": could not get vbus clock\n"); | ||
309 | rc = PTR_ERR(vbus_clk); | ||
310 | goto out_mem_region; | ||
311 | } | ||
312 | |||
301 | ar7_wdt_disable_wdt(); | 313 | ar7_wdt_disable_wdt(); |
302 | ar7_wdt_prescale(prescale_value); | 314 | ar7_wdt_prescale(prescale_value); |
303 | ar7_wdt_update_margin(margin); | 315 | ar7_wdt_update_margin(margin); |