Skip to content

Commit

Permalink
usb: musb: Improve PM runtime and phy handling for 2430 glue layer
Browse files Browse the repository at this point in the history
This simplifies things and allows idling both MUSB and PHY
when nothing is configured. Let's just return early from PM
runtime if musb is not yet initialized.

Let's also warn if PHY is not configured.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Tony Lindgren authored and Greg Kroah-Hartman committed Jun 1, 2016
1 parent 21f77be commit a83e17d
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions drivers/usb/musb/omap2430.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ static int omap2430_musb_init(struct musb *musb)
return PTR_ERR(musb->phy);
}
musb->isr = omap2430_musb_interrupt;
phy_init(musb->phy);

/*
* Enable runtime PM for musb parent (this driver). We can't
Expand Down Expand Up @@ -471,8 +472,6 @@ static int omap2430_musb_init(struct musb *musb)
if (glue->status != MUSB_UNKNOWN)
omap_musb_set_mailbox(glue);

phy_init(musb->phy);
phy_power_on(musb->phy);
pm_runtime_put(glue->dev);
return 0;

Expand All @@ -489,6 +488,9 @@ static void omap2430_musb_enable(struct musb *musb)
struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev);
struct omap_musb_board_data *data = pdata->board_data;

if (!WARN_ON(!musb->phy))
phy_power_on(musb->phy);

omap2430_set_power(musb, true, glue->cable_connected);

switch (glue->status) {
Expand Down Expand Up @@ -526,6 +528,9 @@ static void omap2430_musb_disable(struct musb *musb)
struct device *dev = musb->controller;
struct omap2430_glue *glue = dev_get_drvdata(dev->parent);

if (!WARN_ON(!musb->phy))
phy_power_off(musb->phy);

if (glue->status != MUSB_UNKNOWN)
omap_control_usb_set_mode(glue->control_otghs,
USB_MODE_DISCONNECT);
Expand All @@ -535,11 +540,14 @@ static void omap2430_musb_disable(struct musb *musb)

static int omap2430_musb_exit(struct musb *musb)
{
del_timer_sync(&musb_idle_timer);
struct device *dev = musb->controller;
struct omap2430_glue *glue = dev_get_drvdata(dev->parent);

del_timer_sync(&musb_idle_timer);
omap2430_low_level_exit(musb);
phy_power_off(musb->phy);
phy_exit(musb->phy);
musb->phy = NULL;
cancel_work_sync(&glue->omap_musb_mailbox_work);

return 0;
}
Expand Down Expand Up @@ -707,7 +715,6 @@ static int omap2430_remove(struct platform_device *pdev)
struct musb *musb = glue_to_musb(glue);

pm_runtime_get_sync(glue->dev);
cancel_work_sync(&glue->omap_musb_mailbox_work);
platform_device_unregister(glue->musb);
omap2430_set_power(musb, false, false);
pm_runtime_put_sync(glue->dev);
Expand All @@ -723,12 +730,13 @@ static int omap2430_runtime_suspend(struct device *dev)
struct omap2430_glue *glue = dev_get_drvdata(dev);
struct musb *musb = glue_to_musb(glue);

if (musb) {
musb->context.otg_interfsel = musb_readl(musb->mregs,
OTG_INTERFSEL);
if (!musb)
return 0;

omap2430_low_level_exit(musb);
}
musb->context.otg_interfsel = musb_readl(musb->mregs,
OTG_INTERFSEL);

omap2430_low_level_exit(musb);

return 0;
}
Expand All @@ -739,7 +747,7 @@ static int omap2430_runtime_resume(struct device *dev)
struct musb *musb = glue_to_musb(glue);

if (!musb)
return -EPROBE_DEFER;
return 0;

omap2430_low_level_init(musb);
musb_writel(musb->mregs, OTG_INTERFSEL,
Expand Down

0 comments on commit a83e17d

Please sign in to comment.