aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/davinci.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/davinci.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/davinci.c')
-rw-r--r--drivers/usb/musb/davinci.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 831a04dd5a53..de67480d4f19 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -56,6 +56,7 @@
56struct davinci_glue { 56struct davinci_glue {
57 struct device *dev; 57 struct device *dev;
58 struct platform_device *musb; 58 struct platform_device *musb;
59 struct clk *clk;
59}; 60};
60 61
61/* REVISIT (PM) we should be able to keep the PHY in low power mode most 62/* REVISIT (PM) we should be able to keep the PHY in low power mode most
@@ -395,8 +396,6 @@ static int davinci_musb_init(struct musb *musb)
395 396
396 musb->mregs += DAVINCI_BASE_OFFSET; 397 musb->mregs += DAVINCI_BASE_OFFSET;
397 398
398 clk_enable(musb->clock);
399
400 /* returns zero if e.g. not clocked */ 399 /* returns zero if e.g. not clocked */
401 revision = musb_readl(tibase, DAVINCI_USB_VERSION_REG); 400 revision = musb_readl(tibase, DAVINCI_USB_VERSION_REG);
402 if (revision == 0) 401 if (revision == 0)
@@ -451,8 +450,6 @@ static int davinci_musb_init(struct musb *musb)
451 return 0; 450 return 0;
452 451
453fail: 452fail:
454 clk_disable(musb->clock);
455
456 otg_put_transceiver(musb->xceiv); 453 otg_put_transceiver(musb->xceiv);
457 usb_nop_xceiv_unregister(); 454 usb_nop_xceiv_unregister();
458 return -ENODEV; 455 return -ENODEV;
@@ -502,8 +499,6 @@ static int davinci_musb_exit(struct musb *musb)
502 499
503 phy_off(); 500 phy_off();
504 501
505 clk_disable(musb->clock);
506
507 otg_put_transceiver(musb->xceiv); 502 otg_put_transceiver(musb->xceiv);
508 usb_nop_xceiv_unregister(); 503 usb_nop_xceiv_unregister();
509 504
@@ -529,6 +524,7 @@ static int __init davinci_probe(struct platform_device *pdev)
529 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 524 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
530 struct platform_device *musb; 525 struct platform_device *musb;
531 struct davinci_glue *glue; 526 struct davinci_glue *glue;
527 struct clk *clk;
532 528
533 int ret = -ENOMEM; 529 int ret = -ENOMEM;
534 530
@@ -544,12 +540,26 @@ static int __init davinci_probe(struct platform_device *pdev)
544 goto err1; 540 goto err1;
545 } 541 }
546 542
543 clk = clk_get(&pdev->dev, "usb");
544 if (IS_ERR(clk)) {
545 dev_err(&pdev->dev, "failed to get clock\n");
546 ret = PTR_ERR(clk);
547 goto err2;
548 }
549
550 ret = clk_enable(clk);
551 if (ret) {
552 dev_err(&pdev->dev, "failed to enable clock\n");
553 goto err3;
554 }
555
547 musb->dev.parent = &pdev->dev; 556 musb->dev.parent = &pdev->dev;
548 musb->dev.dma_mask = &davinci_dmamask; 557 musb->dev.dma_mask = &davinci_dmamask;
549 musb->dev.coherent_dma_mask = davinci_dmamask; 558 musb->dev.coherent_dma_mask = davinci_dmamask;
550 559
551 glue->dev = &pdev->dev; 560 glue->dev = &pdev->dev;
552 glue->musb = musb; 561 glue->musb = musb;
562 glue->clk = clk;
553 563
554 pdata->platform_ops = &davinci_ops; 564 pdata->platform_ops = &davinci_ops;
555 565
@@ -559,23 +569,29 @@ static int __init davinci_probe(struct platform_device *pdev)
559 pdev->num_resources); 569 pdev->num_resources);
560 if (ret) { 570 if (ret) {
561 dev_err(&pdev->dev, "failed to add resources\n"); 571 dev_err(&pdev->dev, "failed to add resources\n");
562 goto err2; 572 goto err4;
563 } 573 }
564 574
565 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 575 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
566 if (ret) { 576 if (ret) {
567 dev_err(&pdev->dev, "failed to add platform_data\n"); 577 dev_err(&pdev->dev, "failed to add platform_data\n");
568 goto err2; 578 goto err4;
569 } 579 }
570 580
571 ret = platform_device_add(musb); 581 ret = platform_device_add(musb);
572 if (ret) { 582 if (ret) {
573 dev_err(&pdev->dev, "failed to register musb device\n"); 583 dev_err(&pdev->dev, "failed to register musb device\n");
574 goto err2; 584 goto err4;
575 } 585 }
576 586
577 return 0; 587 return 0;
578 588
589err4:
590 clk_disable(clk);
591
592err3:
593 clk_put(clk);
594
579err2: 595err2:
580 platform_device_put(musb); 596 platform_device_put(musb);
581 597
@@ -592,6 +608,8 @@ static int __exit davinci_remove(struct platform_device *pdev)
592 608
593 platform_device_del(glue->musb); 609 platform_device_del(glue->musb);
594 platform_device_put(glue->musb); 610 platform_device_put(glue->musb);
611 clk_disable(glue->clk);
612 clk_put(glue->clk);
595 kfree(glue); 613 kfree(glue);
596 614
597 return 0; 615 return 0;