aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
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
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')
-rw-r--r--drivers/usb/musb/am35x.c91
-rw-r--r--drivers/usb/musb/da8xx.c36
-rw-r--r--drivers/usb/musb/davinci.c36
-rw-r--r--drivers/usb/musb/musb_core.c39
-rw-r--r--drivers/usb/musb/musb_core.h2
-rw-r--r--drivers/usb/musb/omap2430.c46
-rw-r--r--drivers/usb/musb/tusb6010.c15
7 files changed, 140 insertions, 125 deletions
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index e372c87f37e..e4e571bf9ba 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -85,6 +85,8 @@
85struct am35x_glue { 85struct am35x_glue {
86 struct device *dev; 86 struct device *dev;
87 struct platform_device *musb; 87 struct platform_device *musb;
88 struct clk *phy_clk;
89 struct clk *clk;
88}; 90};
89 91
90static inline void phy_on(void) 92static inline void phy_on(void)
@@ -402,34 +404,18 @@ static int am35x_musb_init(struct musb *musb)
402{ 404{
403 void __iomem *reg_base = musb->ctrl_base; 405 void __iomem *reg_base = musb->ctrl_base;
404 u32 rev, lvl_intr, sw_reset; 406 u32 rev, lvl_intr, sw_reset;
405 int status;
406 407
407 musb->mregs += USB_MENTOR_CORE_OFFSET; 408 musb->mregs += USB_MENTOR_CORE_OFFSET;
408 409
409 clk_enable(musb->clock);
410 DBG(2, "musb->clock=%lud\n", clk_get_rate(musb->clock));
411
412 musb->phy_clock = clk_get(musb->controller, "fck");
413 if (IS_ERR(musb->phy_clock)) {
414 status = PTR_ERR(musb->phy_clock);
415 goto exit0;
416 }
417 clk_enable(musb->phy_clock);
418 DBG(2, "musb->phy_clock=%lud\n", clk_get_rate(musb->phy_clock));
419
420 /* Returns zero if e.g. not clocked */ 410 /* Returns zero if e.g. not clocked */
421 rev = musb_readl(reg_base, USB_REVISION_REG); 411 rev = musb_readl(reg_base, USB_REVISION_REG);
422 if (!rev) { 412 if (!rev)
423 status = -ENODEV; 413 return -ENODEV;
424 goto exit1;
425 }
426 414
427 usb_nop_xceiv_register(); 415 usb_nop_xceiv_register();
428 musb->xceiv = otg_get_transceiver(); 416 musb->xceiv = otg_get_transceiver();
429 if (!musb->xceiv) { 417 if (!musb->xceiv)
430 status = -ENODEV; 418 return -ENODEV;
431 goto exit1;
432 }
433 419
434 if (is_host_enabled(musb)) 420 if (is_host_enabled(musb))
435 setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); 421 setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);
@@ -459,13 +445,8 @@ static int am35x_musb_init(struct musb *musb)
459 lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); 445 lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
460 lvl_intr |= AM35XX_USBOTGSS_INT_CLR; 446 lvl_intr |= AM35XX_USBOTGSS_INT_CLR;
461 omap_ctrl_writel(lvl_intr, AM35XX_CONTROL_LVL_INTR_CLEAR); 447 omap_ctrl_writel(lvl_intr, AM35XX_CONTROL_LVL_INTR_CLEAR);
448
462 return 0; 449 return 0;
463exit1:
464 clk_disable(musb->phy_clock);
465 clk_put(musb->phy_clock);
466exit0:
467 clk_disable(musb->clock);
468 return status;
469} 450}
470 451
471static int am35x_musb_exit(struct musb *musb) 452static int am35x_musb_exit(struct musb *musb)
@@ -478,11 +459,6 @@ static int am35x_musb_exit(struct musb *musb)
478 otg_put_transceiver(musb->xceiv); 459 otg_put_transceiver(musb->xceiv);
479 usb_nop_xceiv_unregister(); 460 usb_nop_xceiv_unregister();
480 461
481 clk_disable(musb->clock);
482
483 clk_disable(musb->phy_clock);
484 clk_put(musb->phy_clock);
485
486 return 0; 462 return 0;
487} 463}
488 464
@@ -551,6 +527,9 @@ static int __init am35x_probe(struct platform_device *pdev)
551 struct platform_device *musb; 527 struct platform_device *musb;
552 struct am35x_glue *glue; 528 struct am35x_glue *glue;
553 529
530 struct clk *phy_clk;
531 struct clk *clk;
532
554 int ret = -ENOMEM; 533 int ret = -ENOMEM;
555 534
556 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 535 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
@@ -565,12 +544,40 @@ static int __init am35x_probe(struct platform_device *pdev)
565 goto err1; 544 goto err1;
566 } 545 }
567 546
547 phy_clk = clk_get(&pdev->dev, "fck");
548 if (IS_ERR(phy_clk)) {
549 dev_err(&pdev->dev, "failed to get PHY clock\n");
550 ret = PTR_ERR(phy_clk);
551 goto err2;
552 }
553
554 clk = clk_get(&pdev->dev, "ick");
555 if (IS_ERR(clk)) {
556 dev_err(&pdev->dev, "failed to get clock\n");
557 ret = PTR_ERR(clk);
558 goto err3;
559 }
560
561 ret = clk_enable(phy_clk);
562 if (ret) {
563 dev_err(&pdev->dev, "failed to enable PHY clock\n");
564 goto err4;
565 }
566
567 ret = clk_enable(clk);
568 if (ret) {
569 dev_err(&pdev->dev, "failed to enable clock\n");
570 goto err5;
571 }
572
568 musb->dev.parent = &pdev->dev; 573 musb->dev.parent = &pdev->dev;
569 musb->dev.dma_mask = &am35x_dmamask; 574 musb->dev.dma_mask = &am35x_dmamask;
570 musb->dev.coherent_dma_mask = am35x_dmamask; 575 musb->dev.coherent_dma_mask = am35x_dmamask;
571 576
572 glue->dev = &pdev->dev; 577 glue->dev = &pdev->dev;
573 glue->musb = musb; 578 glue->musb = musb;
579 glue->phy_clk = phy_clk;
580 glue->clk = clk;
574 581
575 pdata->platform_ops = &am35x_ops; 582 pdata->platform_ops = &am35x_ops;
576 583
@@ -580,23 +587,35 @@ static int __init am35x_probe(struct platform_device *pdev)
580 pdev->num_resources); 587 pdev->num_resources);
581 if (ret) { 588 if (ret) {
582 dev_err(&pdev->dev, "failed to add resources\n"); 589 dev_err(&pdev->dev, "failed to add resources\n");
583 goto err2; 590 goto err6;
584 } 591 }
585 592
586 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 593 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
587 if (ret) { 594 if (ret) {
588 dev_err(&pdev->dev, "failed to add platform_data\n"); 595 dev_err(&pdev->dev, "failed to add platform_data\n");
589 goto err2; 596 goto err6;
590 } 597 }
591 598
592 ret = platform_device_add(musb); 599 ret = platform_device_add(musb);
593 if (ret) { 600 if (ret) {
594 dev_err(&pdev->dev, "failed to register musb device\n"); 601 dev_err(&pdev->dev, "failed to register musb device\n");
595 goto err2; 602 goto err6;
596 } 603 }
597 604
598 return 0; 605 return 0;
599 606
607err6:
608 clk_disable(clk);
609
610err5:
611 clk_disable(phy_clk);
612
613err4:
614 clk_put(clk);
615
616err3:
617 clk_put(phy_clk);
618
600err2: 619err2:
601 platform_device_put(musb); 620 platform_device_put(musb);
602 621
@@ -613,6 +632,10 @@ static int __exit am35x_remove(struct platform_device *pdev)
613 632
614 platform_device_del(glue->musb); 633 platform_device_del(glue->musb);
615 platform_device_put(glue->musb); 634 platform_device_put(glue->musb);
635 clk_disable(glue->clk);
636 clk_disable(glue->phy_clk);
637 clk_put(glue->clk);
638 clk_put(glue->phy_clk);
616 kfree(glue); 639 kfree(glue);
617 640
618 return 0; 641 return 0;
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 45ccac3aad9..387f4a75706 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;
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 831a04dd5a5..de67480d4f1 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;
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index dcc77ef6cff..6078eece74c 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1048,8 +1048,6 @@ static void musb_shutdown(struct platform_device *pdev)
1048 spin_lock_irqsave(&musb->lock, flags); 1048 spin_lock_irqsave(&musb->lock, flags);
1049 musb_platform_disable(musb); 1049 musb_platform_disable(musb);
1050 musb_generic_disable(musb); 1050 musb_generic_disable(musb);
1051 if (musb->clock)
1052 clk_put(musb->clock);
1053 spin_unlock_irqrestore(&musb->lock, flags); 1051 spin_unlock_irqrestore(&musb->lock, flags);
1054 1052
1055 /* FIXME power down */ 1053 /* FIXME power down */
@@ -1994,29 +1992,13 @@ bad_config:
1994 spin_lock_init(&musb->lock); 1992 spin_lock_init(&musb->lock);
1995 musb->board_mode = plat->mode; 1993 musb->board_mode = plat->mode;
1996 musb->board_set_power = plat->set_power; 1994 musb->board_set_power = plat->set_power;
1997 musb->set_clock = plat->set_clock;
1998 musb->min_power = plat->min_power; 1995 musb->min_power = plat->min_power;
1999 musb->ops = plat->platform_ops; 1996 musb->ops = plat->platform_ops;
2000 1997
2001 /* Clock usage is chip-specific ... functional clock (DaVinci,
2002 * OMAP2430), or PHY ref (some TUSB6010 boards). All this core
2003 * code does is make sure a clock handle is available; platform
2004 * code manages it during start/stop and suspend/resume.
2005 */
2006 if (plat->clock) {
2007 musb->clock = clk_get(dev, plat->clock);
2008 if (IS_ERR(musb->clock)) {
2009 status = PTR_ERR(musb->clock);
2010 musb->clock = NULL;
2011 goto fail1;
2012 }
2013 }
2014
2015 /* The musb_platform_init() call: 1998 /* The musb_platform_init() call:
2016 * - adjusts musb->mregs and musb->isr if needed, 1999 * - adjusts musb->mregs and musb->isr if needed,
2017 * - may initialize an integrated tranceiver 2000 * - may initialize an integrated tranceiver
2018 * - initializes musb->xceiv, usually by otg_get_transceiver() 2001 * - initializes musb->xceiv, usually by otg_get_transceiver()
2019 * - activates clocks.
2020 * - stops powering VBUS 2002 * - stops powering VBUS
2021 * - assigns musb->board_set_vbus if host mode is enabled 2003 * - assigns musb->board_set_vbus if host mode is enabled
2022 * 2004 *
@@ -2028,7 +2010,7 @@ bad_config:
2028 musb->isr = generic_interrupt; 2010 musb->isr = generic_interrupt;
2029 status = musb_platform_init(musb); 2011 status = musb_platform_init(musb);
2030 if (status < 0) 2012 if (status < 0)
2031 goto fail2; 2013 goto fail1;
2032 2014
2033 if (!musb->isr) { 2015 if (!musb->isr) {
2034 status = -ENODEV; 2016 status = -ENODEV;
@@ -2178,10 +2160,6 @@ fail3:
2178 device_init_wakeup(dev, 0); 2160 device_init_wakeup(dev, 0);
2179 musb_platform_exit(musb); 2161 musb_platform_exit(musb);
2180 2162
2181fail2:
2182 if (musb->clock)
2183 clk_put(musb->clock);
2184
2185fail1: 2163fail1:
2186 dev_err(musb->controller, 2164 dev_err(musb->controller,
2187 "musb_init_controller failed with status %d\n", status); 2165 "musb_init_controller failed with status %d\n", status);
@@ -2410,9 +2388,6 @@ static int musb_suspend(struct device *dev)
2410 unsigned long flags; 2388 unsigned long flags;
2411 struct musb *musb = dev_to_musb(&pdev->dev); 2389 struct musb *musb = dev_to_musb(&pdev->dev);
2412 2390
2413 if (!musb->clock)
2414 return 0;
2415
2416 spin_lock_irqsave(&musb->lock, flags); 2391 spin_lock_irqsave(&musb->lock, flags);
2417 2392
2418 if (is_peripheral_active(musb)) { 2393 if (is_peripheral_active(musb)) {
@@ -2427,10 +2402,6 @@ static int musb_suspend(struct device *dev)
2427 2402
2428 musb_save_context(musb); 2403 musb_save_context(musb);
2429 2404
2430 if (musb->set_clock)
2431 musb->set_clock(musb->clock, 0);
2432 else
2433 clk_disable(musb->clock);
2434 spin_unlock_irqrestore(&musb->lock, flags); 2405 spin_unlock_irqrestore(&musb->lock, flags);
2435 return 0; 2406 return 0;
2436} 2407}
@@ -2440,14 +2411,6 @@ static int musb_resume_noirq(struct device *dev)
2440 struct platform_device *pdev = to_platform_device(dev); 2411 struct platform_device *pdev = to_platform_device(dev);
2441 struct musb *musb = dev_to_musb(&pdev->dev); 2412 struct musb *musb = dev_to_musb(&pdev->dev);
2442 2413
2443 if (!musb->clock)
2444 return 0;
2445
2446 if (musb->set_clock)
2447 musb->set_clock(musb->clock, 1);
2448 else
2449 clk_enable(musb->clock);
2450
2451 musb_restore_context(musb); 2414 musb_restore_context(musb);
2452 2415
2453 /* for static cmos like DaVinci, register values were preserved 2416 /* for static cmos like DaVinci, register values were preserved
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index fac1eab3c59..6c8e9630fb1 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -384,8 +384,6 @@ struct musb_context_registers {
384struct musb { 384struct musb {
385 /* device lock */ 385 /* device lock */
386 spinlock_t lock; 386 spinlock_t lock;
387 struct clk *clock;
388 struct clk *phy_clock;
389 387
390 const struct musb_platform_ops *ops; 388 const struct musb_platform_ops *ops;
391 struct musb_context_registers context; 389 struct musb_context_registers context;
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 2eea1703e63..fa3154b0304 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;
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index d6b832641c5..2ba3b070ed0 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -281,17 +281,6 @@ static int tusb_draw_power(struct otg_transceiver *x, unsigned mA)
281 void __iomem *tbase = musb->ctrl_base; 281 void __iomem *tbase = musb->ctrl_base;
282 u32 reg; 282 u32 reg;
283 283
284 /*
285 * Keep clock active when enabled. Note that this is not tied to
286 * drawing VBUS, as with OTG mA can be less than musb->min_power.
287 */
288 if (musb->set_clock) {
289 if (mA)
290 musb->set_clock(musb->clock, 1);
291 else
292 musb->set_clock(musb->clock, 0);
293 }
294
295 /* tps65030 seems to consume max 100mA, with maybe 60mA available 284 /* tps65030 seems to consume max 100mA, with maybe 60mA available
296 * (measured on one board) for things other than tps and tusb. 285 * (measured on one board) for things other than tps and tusb.
297 * 286 *
@@ -537,8 +526,6 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
537 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 526 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
538 527
539 if (is_on) { 528 if (is_on) {
540 if (musb->set_clock)
541 musb->set_clock(musb->clock, 1);
542 timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE); 529 timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
543 musb->xceiv->default_a = 1; 530 musb->xceiv->default_a = 1;
544 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; 531 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
@@ -577,8 +564,6 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
577 564
578 devctl &= ~MUSB_DEVCTL_SESSION; 565 devctl &= ~MUSB_DEVCTL_SESSION;
579 conf &= ~TUSB_DEV_CONF_USB_HOST_MODE; 566 conf &= ~TUSB_DEV_CONF_USB_HOST_MODE;
580 if (musb->set_clock)
581 musb->set_clock(musb->clock, 0);
582 } 567 }
583 prcm &= ~(TUSB_PRCM_MNGMT_15_SW_EN | TUSB_PRCM_MNGMT_33_SW_EN); 568 prcm &= ~(TUSB_PRCM_MNGMT_15_SW_EN | TUSB_PRCM_MNGMT_33_SW_EN);
584 569