aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/omap2430.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 02:57:08 -0500
committerFelipe Balbi <balbi@ti.com>2010-12-10 03:21:24 -0500
commit0349176120aa3024e96ae4fd7dc0e0181dc55f52 (patch)
treeefdcef1542f835f98a53507f0a8f73f5c9736012 /drivers/usb/musb/omap2430.c
parent3b7029670d39d22f288ece95254e9ba5ceddd6ba (diff)
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/omap2430.c')
-rw-r--r--drivers/usb/musb/omap2430.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 2eea1703e630..fa3154b03044 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -40,6 +40,7 @@
40struct omap2430_glue { 40struct omap2430_glue {
41 struct device *dev; 41 struct device *dev;
42 struct platform_device *musb; 42 struct platform_device *musb;
43 struct clk *clk;
43}; 44};
44 45
45static struct timer_list musb_idle_timer; 46static struct timer_list musb_idle_timer;
@@ -277,9 +278,6 @@ static int omap2430_musb_suspend(struct musb *musb)
277{ 278{
278 u32 l; 279 u32 l;
279 280
280 if (!musb->clock)
281 return 0;
282
283 /* in any role */ 281 /* in any role */
284 l = musb_readl(musb->mregs, OTG_FORCESTDBY); 282 l = musb_readl(musb->mregs, OTG_FORCESTDBY);
285 l |= ENABLEFORCE; /* enable MSTANDBY */ 283 l |= ENABLEFORCE; /* enable MSTANDBY */
@@ -291,11 +289,6 @@ static int omap2430_musb_suspend(struct musb *musb)
291 289
292 otg_set_suspend(musb->xceiv, 1); 290 otg_set_suspend(musb->xceiv, 1);
293 291
294 if (musb->set_clock)
295 musb->set_clock(musb->clock, 0);
296 else
297 clk_disable(musb->clock);
298
299 return 0; 292 return 0;
300} 293}
301 294
@@ -303,16 +296,8 @@ static int omap2430_musb_resume(struct musb *musb)
303{ 296{
304 u32 l; 297 u32 l;
305 298
306 if (!musb->clock)
307 return 0;
308
309 otg_set_suspend(musb->xceiv, 0); 299 otg_set_suspend(musb->xceiv, 0);
310 300
311 if (musb->set_clock)
312 musb->set_clock(musb->clock, 1);
313 else
314 clk_enable(musb->clock);
315
316 l = musb_readl(musb->mregs, OTG_SYSCONFIG); 301 l = musb_readl(musb->mregs, OTG_SYSCONFIG);
317 l &= ~ENABLEWAKEUP; /* disable wakeup */ 302 l &= ~ENABLEWAKEUP; /* disable wakeup */
318 musb_writel(musb->mregs, OTG_SYSCONFIG, l); 303 musb_writel(musb->mregs, OTG_SYSCONFIG, l);
@@ -356,6 +341,7 @@ static int __init omap2430_probe(struct platform_device *pdev)
356 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 341 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
357 struct platform_device *musb; 342 struct platform_device *musb;
358 struct omap2430_glue *glue; 343 struct omap2430_glue *glue;
344 struct clk *clk;
359 345
360 int ret = -ENOMEM; 346 int ret = -ENOMEM;
361 347
@@ -371,12 +357,26 @@ static int __init omap2430_probe(struct platform_device *pdev)
371 goto err1; 357 goto err1;
372 } 358 }
373 359
360 clk = clk_get(&pdev->dev, "ick");
361 if (IS_ERR(clk)) {
362 dev_err(&pdev->dev, "failed to get clock\n");
363 ret = PTR_ERR(clk);
364 goto err2;
365 }
366
367 ret = clk_enable(clk);
368 if (ret) {
369 dev_err(&pdev->dev, "failed to enable clock\n");
370 goto err3;
371 }
372
374 musb->dev.parent = &pdev->dev; 373 musb->dev.parent = &pdev->dev;
375 musb->dev.dma_mask = &omap2430_dmamask; 374 musb->dev.dma_mask = &omap2430_dmamask;
376 musb->dev.coherent_dma_mask = omap2430_dmamask; 375 musb->dev.coherent_dma_mask = omap2430_dmamask;
377 376
378 glue->dev = &pdev->dev; 377 glue->dev = &pdev->dev;
379 glue->musb = musb; 378 glue->musb = musb;
379 glue->clk = clk;
380 380
381 pdata->platform_ops = &omap2430_ops; 381 pdata->platform_ops = &omap2430_ops;
382 382
@@ -386,23 +386,29 @@ static int __init omap2430_probe(struct platform_device *pdev)
386 pdev->num_resources); 386 pdev->num_resources);
387 if (ret) { 387 if (ret) {
388 dev_err(&pdev->dev, "failed to add resources\n"); 388 dev_err(&pdev->dev, "failed to add resources\n");
389 goto err2; 389 goto err4;
390 } 390 }
391 391
392 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 392 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
393 if (ret) { 393 if (ret) {
394 dev_err(&pdev->dev, "failed to add platform_data\n"); 394 dev_err(&pdev->dev, "failed to add platform_data\n");
395 goto err2; 395 goto err4;
396 } 396 }
397 397
398 ret = platform_device_add(musb); 398 ret = platform_device_add(musb);
399 if (ret) { 399 if (ret) {
400 dev_err(&pdev->dev, "failed to register musb device\n"); 400 dev_err(&pdev->dev, "failed to register musb device\n");
401 goto err2; 401 goto err4;
402 } 402 }
403 403
404 return 0; 404 return 0;
405 405
406err4:
407 clk_disable(clk);
408
409err3:
410 clk_put(clk);
411
406err2: 412err2:
407 platform_device_put(musb); 413 platform_device_put(musb);
408 414
@@ -419,6 +425,8 @@ static int __exit omap2430_remove(struct platform_device *pdev)
419 425
420 platform_device_del(glue->musb); 426 platform_device_del(glue->musb);
421 platform_device_put(glue->musb); 427 platform_device_put(glue->musb);
428 clk_disable(glue->clk);
429 clk_put(glue->clk);
422 kfree(glue); 430 kfree(glue);
423 431
424 return 0; 432 return 0;