Commit 765786e0 authored by Magnus Damm's avatar Magnus Damm Committed by Paul Mundt

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: default avatarMagnus Damm <damm@igel.co.jp>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent af5be79a
...@@ -185,7 +185,6 @@ static int __init sh7366_devices_setup(void) ...@@ -185,7 +185,6 @@ static int __init sh7366_devices_setup(void)
clk_always_enable("mstp023"); /* INTC3 */ clk_always_enable("mstp023"); /* INTC3 */
clk_always_enable("mstp022"); /* INTC */ clk_always_enable("mstp022"); /* INTC */
clk_always_enable("mstp020"); /* SuperHyway */ clk_always_enable("mstp020"); /* SuperHyway */
clk_always_enable("mstp211"); /* USB */
clk_always_enable("mstp207"); /* VEU-2 */ clk_always_enable("mstp207"); /* VEU-2 */
clk_always_enable("mstp202"); /* VEU-1 */ clk_always_enable("mstp202"); /* VEU-1 */
clk_always_enable("mstp201"); /* VPU */ clk_always_enable("mstp201"); /* VPU */
......
...@@ -240,7 +240,6 @@ static int __init sh7723_devices_setup(void) ...@@ -240,7 +240,6 @@ static int __init sh7723_devices_setup(void)
clk_always_enable("mstp020"); /* SuperHyway */ clk_always_enable("mstp020"); /* SuperHyway */
clk_always_enable("mstp000"); /* MERAM */ clk_always_enable("mstp000"); /* MERAM */
clk_always_enable("mstp108"); /* RTC */ clk_always_enable("mstp108"); /* RTC */
clk_always_enable("mstp211"); /* USB */
clk_always_enable("mstp206"); /* VEU2H1 */ clk_always_enable("mstp206"); /* VEU2H1 */
clk_always_enable("mstp202"); /* VEU2H0 */ clk_always_enable("mstp202"); /* VEU2H0 */
clk_always_enable("mstp201"); /* VPU */ clk_always_enable("mstp201"); /* VPU */
......
...@@ -114,6 +114,9 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) ...@@ -114,6 +114,9 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)
int i = 0; int i = 0;
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
#if defined(CONFIG_HAVE_CLK)
clk_enable(r8a66597->clk);
#endif
do { do {
r8a66597_write(r8a66597, SCKE, SYSCFG0); r8a66597_write(r8a66597, SCKE, SYSCFG0);
tmp = r8a66597_read(r8a66597, SYSCFG0); tmp = r8a66597_read(r8a66597, SYSCFG0);
...@@ -154,7 +157,11 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597) ...@@ -154,7 +157,11 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597)
{ {
r8a66597_bclr(r8a66597, SCKE, SYSCFG0); r8a66597_bclr(r8a66597, SCKE, SYSCFG0);
udelay(1); udelay(1);
#if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
#if defined(CONFIG_HAVE_CLK)
clk_disable(r8a66597->clk);
#endif
#else
r8a66597_bclr(r8a66597, PLLC, SYSCFG0); r8a66597_bclr(r8a66597, PLLC, SYSCFG0);
r8a66597_bclr(r8a66597, XCKE, SYSCFG0); r8a66597_bclr(r8a66597, XCKE, SYSCFG0);
r8a66597_bclr(r8a66597, USBE, SYSCFG0); r8a66597_bclr(r8a66597, USBE, SYSCFG0);
...@@ -2261,6 +2268,9 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) ...@@ -2261,6 +2268,9 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev)
del_timer_sync(&r8a66597->rh_timer); del_timer_sync(&r8a66597->rh_timer);
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
iounmap((void *)r8a66597->reg); iounmap((void *)r8a66597->reg);
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK)
clk_put(r8a66597->clk);
#endif
usb_put_hcd(hcd); usb_put_hcd(hcd);
return 0; return 0;
} }
...@@ -2268,6 +2278,9 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) ...@@ -2268,6 +2278,9 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev)
#define resource_len(r) (((r)->end - (r)->start) + 1) #define resource_len(r) (((r)->end - (r)->start) + 1)
static int __init r8a66597_probe(struct platform_device *pdev) static int __init r8a66597_probe(struct platform_device *pdev)
{ {
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK)
char clk_name[8];
#endif
struct resource *res = NULL, *ires; struct resource *res = NULL, *ires;
int irq = -1; int irq = -1;
void __iomem *reg = NULL; void __iomem *reg = NULL;
...@@ -2320,6 +2333,16 @@ static int __init r8a66597_probe(struct platform_device *pdev) ...@@ -2320,6 +2333,16 @@ static int __init r8a66597_probe(struct platform_device *pdev)
memset(r8a66597, 0, sizeof(struct r8a66597)); memset(r8a66597, 0, sizeof(struct r8a66597));
dev_set_drvdata(&pdev->dev, r8a66597); dev_set_drvdata(&pdev->dev, r8a66597);
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK)
snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id);
r8a66597->clk = clk_get(&pdev->dev, clk_name);
if (IS_ERR(r8a66597->clk)) {
dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name);
ret = PTR_ERR(r8a66597->clk);
goto clean_up2;
}
#endif
spin_lock_init(&r8a66597->lock); spin_lock_init(&r8a66597->lock);
init_timer(&r8a66597->rh_timer); init_timer(&r8a66597->rh_timer);
r8a66597->rh_timer.function = r8a66597_timer; r8a66597->rh_timer.function = r8a66597_timer;
...@@ -2365,11 +2388,19 @@ static int __init r8a66597_probe(struct platform_device *pdev) ...@@ -2365,11 +2388,19 @@ static int __init r8a66597_probe(struct platform_device *pdev)
ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger);
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Failed to add hcd\n"); dev_err(&pdev->dev, "Failed to add hcd\n");
goto clean_up; goto clean_up3;
} }
return 0; return 0;
clean_up3:
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK)
clk_put(r8a66597->clk);
#endif
clean_up2:
usb_put_hcd(hcd);
clean_up: clean_up:
if (reg) if (reg)
iounmap(reg); iounmap(reg);
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
#ifndef __R8A66597_H__ #ifndef __R8A66597_H__
#define __R8A66597_H__ #define __R8A66597_H__
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK)
#include <linux/clk.h>
#endif
#define SYSCFG0 0x00 #define SYSCFG0 0x00
#define SYSCFG1 0x02 #define SYSCFG1 0x02
#define SYSSTS0 0x04 #define SYSSTS0 0x04
...@@ -481,7 +485,9 @@ struct r8a66597_root_hub { ...@@ -481,7 +485,9 @@ struct r8a66597_root_hub {
struct r8a66597 { struct r8a66597 {
spinlock_t lock; spinlock_t lock;
unsigned long reg; unsigned long reg;
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK)
struct clk *clk;
#endif
struct r8a66597_device device0; struct r8a66597_device device0;
struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB]; struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB];
struct list_head pipe_queue[R8A66597_MAX_NUM_PIPE]; struct list_head pipe_queue[R8A66597_MAX_NUM_PIPE];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment