summaryrefslogtreecommitdiff
path: root/drivers/usb/musb/da8xx.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 09:57:08 +0200
committerFelipe Balbi <balbi@ti.com>2010-12-10 10:21:24 +0200
commit0349176120aa3024e96ae4fd7dc0e0181dc55f52 (patch)
treeefdcef1542f835f98a53507f0a8f73f5c9736012 /drivers/usb/musb/da8xx.c
parent3b7029670d39d22f288ece95254e9ba5ceddd6ba (diff)
downloadlwn-0349176120aa3024e96ae4fd7dc0e0181dc55f52.tar.gz
lwn-0349176120aa3024e96ae4fd7dc0e0181dc55f52.zip
usb: musb: move clock handling to glue layer
musb core doesn't need to know about platform specific details. So start moving clock handling to platform glue layer and make musb core agnostic about that. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/da8xx.c')
-rw-r--r--drivers/usb/musb/da8xx.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 45ccac3aad9d..387f4a75706f 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -83,6 +83,7 @@
struct da8xx_glue {
struct device *dev;
struct platform_device *musb;
+ struct clk *clk;
};
/*
@@ -423,8 +424,6 @@ static int da8xx_musb_init(struct musb *musb)
musb->mregs += DA8XX_MENTOR_CORE_OFFSET;
- clk_enable(musb->clock);
-
/* Returns zero if e.g. not clocked */
rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
if (!rev)
@@ -456,7 +455,6 @@ static int da8xx_musb_init(struct musb *musb)
musb->isr = da8xx_musb_interrupt;
return 0;
fail:
- clk_disable(musb->clock);
return -ENODEV;
}
@@ -470,8 +468,6 @@ static int da8xx_musb_exit(struct musb *musb)
otg_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister();
- clk_disable(musb->clock);
-
return 0;
}
@@ -496,6 +492,8 @@ static int __init da8xx_probe(struct platform_device *pdev)
struct platform_device *musb;
struct da8xx_glue *glue;
+ struct clk *clk;
+
int ret = -ENOMEM;
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
@@ -510,12 +508,26 @@ static int __init da8xx_probe(struct platform_device *pdev)
goto err1;
}
+ clk = clk_get(&pdev->dev, "usb20");
+ if (IS_ERR(clk)) {
+ dev_err(&pdev->dev, "failed to get clock\n");
+ ret = PTR_ERR(clk);
+ goto err2;
+ }
+
+ ret = clk_enable(clk);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to enable clock\n");
+ goto err3;
+ }
+
musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = &da8xx_dmamask;
musb->dev.coherent_dma_mask = da8xx_dmamask;
glue->dev = &pdev->dev;
glue->musb = musb;
+ glue->clk = clk;
pdata->platform_ops = &da8xx_ops;
@@ -525,23 +537,29 @@ static int __init da8xx_probe(struct platform_device *pdev)
pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
- goto err2;
+ goto err4;
}
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
- goto err2;
+ goto err4;
}
ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
- goto err2;
+ goto err4;
}
return 0;
+err4:
+ clk_disable(clk);
+
+err3:
+ clk_put(clk);
+
err2:
platform_device_put(musb);
@@ -558,6 +576,8 @@ static int __exit da8xx_remove(struct platform_device *pdev)
platform_device_del(glue->musb);
platform_device_put(glue->musb);
+ clk_disable(glue->clk);
+ clk_put(glue->clk);
kfree(glue);
return 0;