aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2015-10-28 13:16:04 -0400
committerTony Lindgren <tony@atomide.com>2015-10-28 13:16:04 -0400
commit8f2279d5d908119a08e906be1c6b69c744d0c379 (patch)
tree9375149660aed82c465c47313082ff98c33df3e1
parent1bd5dfe41b994a6e793363894befef76626965a9 (diff)
usb: musb: omap2430: Fix regression caused by driver core change
Commit ddef08dd00f5 ("Driver core: wakeup the parent device before trying probe") started automatically ensuring the parent device is enabled when the child gets probed. This however caused a regression for MUSB omap2430 interface as the runtime PM for the parent device needs the child initialized to access the MUSB hardware registers. Let's delay the enabling of PM runtime for the parent until the child has been properly initialized as suggested in an earlier patch by Grygorii Strashko <grygorii.strashko@ti.com>. In addition to delaying pm_runtime_enable, we now also need to make sure the parent is enabled during omap2430_musb_init. We also want to propagate an error from omap2430_runtime_resume if struct musb is not initialized. Note that we use pm_runtime_put_noidle here for both the child and parent to prevent an extra runtime_suspend/resume cycle. Let's also add some comments to avoid confusion between the two different devices. Fixes: ddef08dd00f5 ("Driver core: wakeup the parent device before trying probe") Suggested-by: Grygorii Strashko <grygorii.strashko@ti.com> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com> Acked-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--drivers/usb/musb/omap2430.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 70f2b8a2e6cf..1bd9232ff76f 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -391,9 +391,20 @@ static int omap2430_musb_init(struct musb *musb)
391 } 391 }
392 musb->isr = omap2430_musb_interrupt; 392 musb->isr = omap2430_musb_interrupt;
393 393
394 /*
395 * Enable runtime PM for musb parent (this driver). We can't
396 * do it earlier as struct musb is not yet allocated and we
397 * need to touch the musb registers for runtime PM.
398 */
399 pm_runtime_enable(glue->dev);
400 status = pm_runtime_get_sync(glue->dev);
401 if (status < 0)
402 goto err1;
403
394 status = pm_runtime_get_sync(dev); 404 status = pm_runtime_get_sync(dev);
395 if (status < 0) { 405 if (status < 0) {
396 dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status); 406 dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status);
407 pm_runtime_put_sync(glue->dev);
397 goto err1; 408 goto err1;
398 } 409 }
399 410
@@ -426,6 +437,7 @@ static int omap2430_musb_init(struct musb *musb)
426 phy_power_on(musb->phy); 437 phy_power_on(musb->phy);
427 438
428 pm_runtime_put_noidle(musb->controller); 439 pm_runtime_put_noidle(musb->controller);
440 pm_runtime_put_noidle(glue->dev);
429 return 0; 441 return 0;
430 442
431err1: 443err1:
@@ -626,7 +638,11 @@ static int omap2430_probe(struct platform_device *pdev)
626 goto err2; 638 goto err2;
627 } 639 }
628 640
629 pm_runtime_enable(&pdev->dev); 641 /*
642 * Note that we cannot enable PM runtime yet for this
643 * driver as we need struct musb initialized first.
644 * See omap2430_musb_init above.
645 */
630 646
631 ret = platform_device_add(musb); 647 ret = platform_device_add(musb);
632 if (ret) { 648 if (ret) {
@@ -675,11 +691,12 @@ static int omap2430_runtime_resume(struct device *dev)
675 struct omap2430_glue *glue = dev_get_drvdata(dev); 691 struct omap2430_glue *glue = dev_get_drvdata(dev);
676 struct musb *musb = glue_to_musb(glue); 692 struct musb *musb = glue_to_musb(glue);
677 693
678 if (musb) { 694 if (!musb)
679 omap2430_low_level_init(musb); 695 return -EPROBE_DEFER;
680 musb_writel(musb->mregs, OTG_INTERFSEL, 696
681 musb->context.otg_interfsel); 697 omap2430_low_level_init(musb);
682 } 698 musb_writel(musb->mregs, OTG_INTERFSEL,
699 musb->context.otg_interfsel);
683 700
684 return 0; 701 return 0;
685} 702}