diff options
author | Magnus Damm <damm@igel.co.jp> | 2008-10-31 07:22:38 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-12-22 04:42:51 -0500 |
commit | 765786e0aead7faf6c333176d22948c6f155fff1 (patch) | |
tree | 02aab6142a8f215a6228512aedd6709730f72ea3 /drivers/usb | |
parent | af5be79a7f8d7067588dc2863d37f7cd22e5f2de (diff) |
sh: sh_mobile usb clock framework support
Add clock framework support to the usb/r8a66597 driver and
adjust the cpu specific code accordingly.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/host/r8a66597-hcd.c | 35 | ||||
-rw-r--r-- | drivers/usb/host/r8a66597.h | 8 |
2 files changed, 40 insertions, 3 deletions
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 2376f24f3c83..d99b9c7098b5 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -114,6 +114,9 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
114 | int i = 0; | 114 | int i = 0; |
115 | 115 | ||
116 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | 116 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) |
117 | #if defined(CONFIG_HAVE_CLK) | ||
118 | clk_enable(r8a66597->clk); | ||
119 | #endif | ||
117 | do { | 120 | do { |
118 | r8a66597_write(r8a66597, SCKE, SYSCFG0); | 121 | r8a66597_write(r8a66597, SCKE, SYSCFG0); |
119 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 122 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
@@ -154,7 +157,11 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597) | |||
154 | { | 157 | { |
155 | r8a66597_bclr(r8a66597, SCKE, SYSCFG0); | 158 | r8a66597_bclr(r8a66597, SCKE, SYSCFG0); |
156 | udelay(1); | 159 | udelay(1); |
157 | #if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | 160 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) |
161 | #if defined(CONFIG_HAVE_CLK) | ||
162 | clk_disable(r8a66597->clk); | ||
163 | #endif | ||
164 | #else | ||
158 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); | 165 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); |
159 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); | 166 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); |
160 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | 167 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); |
@@ -2261,6 +2268,9 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
2261 | del_timer_sync(&r8a66597->rh_timer); | 2268 | del_timer_sync(&r8a66597->rh_timer); |
2262 | usb_remove_hcd(hcd); | 2269 | usb_remove_hcd(hcd); |
2263 | iounmap((void *)r8a66597->reg); | 2270 | iounmap((void *)r8a66597->reg); |
2271 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | ||
2272 | clk_put(r8a66597->clk); | ||
2273 | #endif | ||
2264 | usb_put_hcd(hcd); | 2274 | usb_put_hcd(hcd); |
2265 | return 0; | 2275 | return 0; |
2266 | } | 2276 | } |
@@ -2268,6 +2278,9 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
2268 | #define resource_len(r) (((r)->end - (r)->start) + 1) | 2278 | #define resource_len(r) (((r)->end - (r)->start) + 1) |
2269 | static int __init r8a66597_probe(struct platform_device *pdev) | 2279 | static int __init r8a66597_probe(struct platform_device *pdev) |
2270 | { | 2280 | { |
2281 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | ||
2282 | char clk_name[8]; | ||
2283 | #endif | ||
2271 | struct resource *res = NULL, *ires; | 2284 | struct resource *res = NULL, *ires; |
2272 | int irq = -1; | 2285 | int irq = -1; |
2273 | void __iomem *reg = NULL; | 2286 | void __iomem *reg = NULL; |
@@ -2320,6 +2333,16 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
2320 | memset(r8a66597, 0, sizeof(struct r8a66597)); | 2333 | memset(r8a66597, 0, sizeof(struct r8a66597)); |
2321 | dev_set_drvdata(&pdev->dev, r8a66597); | 2334 | dev_set_drvdata(&pdev->dev, r8a66597); |
2322 | 2335 | ||
2336 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | ||
2337 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); | ||
2338 | r8a66597->clk = clk_get(&pdev->dev, clk_name); | ||
2339 | if (IS_ERR(r8a66597->clk)) { | ||
2340 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | ||
2341 | ret = PTR_ERR(r8a66597->clk); | ||
2342 | goto clean_up2; | ||
2343 | } | ||
2344 | #endif | ||
2345 | |||
2323 | spin_lock_init(&r8a66597->lock); | 2346 | spin_lock_init(&r8a66597->lock); |
2324 | init_timer(&r8a66597->rh_timer); | 2347 | init_timer(&r8a66597->rh_timer); |
2325 | r8a66597->rh_timer.function = r8a66597_timer; | 2348 | r8a66597->rh_timer.function = r8a66597_timer; |
@@ -2365,11 +2388,19 @@ static int __init r8a66597_probe(struct platform_device *pdev) | |||
2365 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); | 2388 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); |
2366 | if (ret != 0) { | 2389 | if (ret != 0) { |
2367 | dev_err(&pdev->dev, "Failed to add hcd\n"); | 2390 | dev_err(&pdev->dev, "Failed to add hcd\n"); |
2368 | goto clean_up; | 2391 | goto clean_up3; |
2369 | } | 2392 | } |
2370 | 2393 | ||
2371 | return 0; | 2394 | return 0; |
2372 | 2395 | ||
2396 | clean_up3: | ||
2397 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | ||
2398 | clk_put(r8a66597->clk); | ||
2399 | #endif | ||
2400 | |||
2401 | clean_up2: | ||
2402 | usb_put_hcd(hcd); | ||
2403 | |||
2373 | clean_up: | 2404 | clean_up: |
2374 | if (reg) | 2405 | if (reg) |
2375 | iounmap(reg); | 2406 | iounmap(reg); |
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h index 84ee01417315..ecacde4d69b0 100644 --- a/drivers/usb/host/r8a66597.h +++ b/drivers/usb/host/r8a66597.h | |||
@@ -26,6 +26,10 @@ | |||
26 | #ifndef __R8A66597_H__ | 26 | #ifndef __R8A66597_H__ |
27 | #define __R8A66597_H__ | 27 | #define __R8A66597_H__ |
28 | 28 | ||
29 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | ||
30 | #include <linux/clk.h> | ||
31 | #endif | ||
32 | |||
29 | #define SYSCFG0 0x00 | 33 | #define SYSCFG0 0x00 |
30 | #define SYSCFG1 0x02 | 34 | #define SYSCFG1 0x02 |
31 | #define SYSSTS0 0x04 | 35 | #define SYSSTS0 0x04 |
@@ -481,7 +485,9 @@ struct r8a66597_root_hub { | |||
481 | struct r8a66597 { | 485 | struct r8a66597 { |
482 | spinlock_t lock; | 486 | spinlock_t lock; |
483 | unsigned long reg; | 487 | unsigned long reg; |
484 | 488 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | |
489 | struct clk *clk; | ||
490 | #endif | ||
485 | struct r8a66597_device device0; | 491 | struct r8a66597_device device0; |
486 | struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB]; | 492 | struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB]; |
487 | struct list_head pipe_queue[R8A66597_MAX_NUM_PIPE]; | 493 | struct list_head pipe_queue[R8A66597_MAX_NUM_PIPE]; |