diff options
Diffstat (limited to 'drivers/usb/musb/davinci.c')
-rw-r--r-- | drivers/usb/musb/davinci.c | 36 |
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 @@ | |||
56 | struct davinci_glue { | 56 | struct 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 | ||
453 | fail: | 452 | fail: |
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 | ||
589 | err4: | ||
590 | clk_disable(clk); | ||
591 | |||
592 | err3: | ||
593 | clk_put(clk); | ||
594 | |||
579 | err2: | 595 | err2: |
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; |