aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/da8xx.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/da8xx.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/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 @@
83struct da8xx_glue { 83struct da8xx_glue {
84 struct device *dev; 84 struct device *dev;
85 struct platform_device *musb; 85 struct platform_device *musb;
86 struct clk *clk;
86}; 87};
87 88
88/* 89/*
@@ -423,8 +424,6 @@ static int da8xx_musb_init(struct musb *musb)
423 424
424 musb->mregs += DA8XX_MENTOR_CORE_OFFSET; 425 musb->mregs += DA8XX_MENTOR_CORE_OFFSET;
425 426
426 clk_enable(musb->clock);
427
428 /* Returns zero if e.g. not clocked */ 427 /* Returns zero if e.g. not clocked */
429 rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG); 428 rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
430 if (!rev) 429 if (!rev)
@@ -456,7 +455,6 @@ static int da8xx_musb_init(struct musb *musb)
456 musb->isr = da8xx_musb_interrupt; 455 musb->isr = da8xx_musb_interrupt;
457 return 0; 456 return 0;
458fail: 457fail:
459 clk_disable(musb->clock);
460 return -ENODEV; 458 return -ENODEV;
461} 459}
462 460
@@ -470,8 +468,6 @@ static int da8xx_musb_exit(struct musb *musb)
470 otg_put_transceiver(musb->xceiv); 468 otg_put_transceiver(musb->xceiv);
471 usb_nop_xceiv_unregister(); 469 usb_nop_xceiv_unregister();
472 470
473 clk_disable(musb->clock);
474
475 return 0; 471 return 0;
476} 472}
477 473
@@ -496,6 +492,8 @@ static int __init da8xx_probe(struct platform_device *pdev)
496 struct platform_device *musb; 492 struct platform_device *musb;
497 struct da8xx_glue *glue; 493 struct da8xx_glue *glue;
498 494
495 struct clk *clk;
496
499 int ret = -ENOMEM; 497 int ret = -ENOMEM;
500 498
501 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 499 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
@@ -510,12 +508,26 @@ static int __init da8xx_probe(struct platform_device *pdev)
510 goto err1; 508 goto err1;
511 } 509 }
512 510
511 clk = clk_get(&pdev->dev, "usb20");
512 if (IS_ERR(clk)) {
513 dev_err(&pdev->dev, "failed to get clock\n");
514 ret = PTR_ERR(clk);
515 goto err2;
516 }
517
518 ret = clk_enable(clk);
519 if (ret) {
520 dev_err(&pdev->dev, "failed to enable clock\n");
521 goto err3;
522 }
523
513 musb->dev.parent = &pdev->dev; 524 musb->dev.parent = &pdev->dev;
514 musb->dev.dma_mask = &da8xx_dmamask; 525 musb->dev.dma_mask = &da8xx_dmamask;
515 musb->dev.coherent_dma_mask = da8xx_dmamask; 526 musb->dev.coherent_dma_mask = da8xx_dmamask;
516 527
517 glue->dev = &pdev->dev; 528 glue->dev = &pdev->dev;
518 glue->musb = musb; 529 glue->musb = musb;
530 glue->clk = clk;
519 531
520 pdata->platform_ops = &da8xx_ops; 532 pdata->platform_ops = &da8xx_ops;
521 533
@@ -525,23 +537,29 @@ static int __init da8xx_probe(struct platform_device *pdev)
525 pdev->num_resources); 537 pdev->num_resources);
526 if (ret) { 538 if (ret) {
527 dev_err(&pdev->dev, "failed to add resources\n"); 539 dev_err(&pdev->dev, "failed to add resources\n");
528 goto err2; 540 goto err4;
529 } 541 }
530 542
531 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 543 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
532 if (ret) { 544 if (ret) {
533 dev_err(&pdev->dev, "failed to add platform_data\n"); 545 dev_err(&pdev->dev, "failed to add platform_data\n");
534 goto err2; 546 goto err4;
535 } 547 }
536 548
537 ret = platform_device_add(musb); 549 ret = platform_device_add(musb);
538 if (ret) { 550 if (ret) {
539 dev_err(&pdev->dev, "failed to register musb device\n"); 551 dev_err(&pdev->dev, "failed to register musb device\n");
540 goto err2; 552 goto err4;
541 } 553 }
542 554
543 return 0; 555 return 0;
544 556
557err4:
558 clk_disable(clk);
559
560err3:
561 clk_put(clk);
562
545err2: 563err2:
546 platform_device_put(musb); 564 platform_device_put(musb);
547 565
@@ -558,6 +576,8 @@ static int __exit da8xx_remove(struct platform_device *pdev)
558 576
559 platform_device_del(glue->musb); 577 platform_device_del(glue->musb);
560 platform_device_put(glue->musb); 578 platform_device_put(glue->musb);
579 clk_disable(glue->clk);
580 clk_put(glue->clk);
561 kfree(glue); 581 kfree(glue);
562 582
563 return 0; 583 return 0;