Commit a83e17d0 authored by Tony Lindgren's avatar Tony Lindgren Committed by Greg Kroah-Hartman

usb: musb: Improve PM runtime and phy handling for 2430 glue layer

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: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarBin Liu <b-liu@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 21f77bee
...@@ -435,6 +435,7 @@ static int omap2430_musb_init(struct musb *musb) ...@@ -435,6 +435,7 @@ static int omap2430_musb_init(struct musb *musb)
return PTR_ERR(musb->phy); return PTR_ERR(musb->phy);
} }
musb->isr = omap2430_musb_interrupt; musb->isr = omap2430_musb_interrupt;
phy_init(musb->phy);
/* /*
* Enable runtime PM for musb parent (this driver). We can't * Enable runtime PM for musb parent (this driver). We can't
...@@ -471,8 +472,6 @@ static int omap2430_musb_init(struct musb *musb) ...@@ -471,8 +472,6 @@ static int omap2430_musb_init(struct musb *musb)
if (glue->status != MUSB_UNKNOWN) if (glue->status != MUSB_UNKNOWN)
omap_musb_set_mailbox(glue); omap_musb_set_mailbox(glue);
phy_init(musb->phy);
phy_power_on(musb->phy);
pm_runtime_put(glue->dev); pm_runtime_put(glue->dev);
return 0; return 0;
...@@ -489,6 +488,9 @@ static void omap2430_musb_enable(struct musb *musb) ...@@ -489,6 +488,9 @@ static void omap2430_musb_enable(struct musb *musb)
struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev); struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev);
struct omap_musb_board_data *data = pdata->board_data; 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); omap2430_set_power(musb, true, glue->cable_connected);
switch (glue->status) { switch (glue->status) {
...@@ -526,6 +528,9 @@ static void omap2430_musb_disable(struct musb *musb) ...@@ -526,6 +528,9 @@ static void omap2430_musb_disable(struct musb *musb)
struct device *dev = musb->controller; struct device *dev = musb->controller;
struct omap2430_glue *glue = dev_get_drvdata(dev->parent); struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
if (!WARN_ON(!musb->phy))
phy_power_off(musb->phy);
if (glue->status != MUSB_UNKNOWN) if (glue->status != MUSB_UNKNOWN)
omap_control_usb_set_mode(glue->control_otghs, omap_control_usb_set_mode(glue->control_otghs,
USB_MODE_DISCONNECT); USB_MODE_DISCONNECT);
...@@ -535,11 +540,14 @@ static void omap2430_musb_disable(struct musb *musb) ...@@ -535,11 +540,14 @@ static void omap2430_musb_disable(struct musb *musb)
static int omap2430_musb_exit(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); omap2430_low_level_exit(musb);
phy_power_off(musb->phy);
phy_exit(musb->phy); phy_exit(musb->phy);
musb->phy = NULL;
cancel_work_sync(&glue->omap_musb_mailbox_work);
return 0; return 0;
} }
...@@ -707,7 +715,6 @@ static int omap2430_remove(struct platform_device *pdev) ...@@ -707,7 +715,6 @@ static int omap2430_remove(struct platform_device *pdev)
struct musb *musb = glue_to_musb(glue); struct musb *musb = glue_to_musb(glue);
pm_runtime_get_sync(glue->dev); pm_runtime_get_sync(glue->dev);
cancel_work_sync(&glue->omap_musb_mailbox_work);
platform_device_unregister(glue->musb); platform_device_unregister(glue->musb);
omap2430_set_power(musb, false, false); omap2430_set_power(musb, false, false);
pm_runtime_put_sync(glue->dev); pm_runtime_put_sync(glue->dev);
...@@ -723,12 +730,13 @@ static int omap2430_runtime_suspend(struct device *dev) ...@@ -723,12 +730,13 @@ static int omap2430_runtime_suspend(struct device *dev)
struct omap2430_glue *glue = dev_get_drvdata(dev); struct omap2430_glue *glue = dev_get_drvdata(dev);
struct musb *musb = glue_to_musb(glue); struct musb *musb = glue_to_musb(glue);
if (musb) { if (!musb)
musb->context.otg_interfsel = musb_readl(musb->mregs, return 0;
OTG_INTERFSEL);
omap2430_low_level_exit(musb); musb->context.otg_interfsel = musb_readl(musb->mregs,
} OTG_INTERFSEL);
omap2430_low_level_exit(musb);
return 0; return 0;
} }
...@@ -739,7 +747,7 @@ static int omap2430_runtime_resume(struct device *dev) ...@@ -739,7 +747,7 @@ static int omap2430_runtime_resume(struct device *dev)
struct musb *musb = glue_to_musb(glue); struct musb *musb = glue_to_musb(glue);
if (!musb) if (!musb)
return -EPROBE_DEFER; return 0;
omap2430_low_level_init(musb); omap2430_low_level_init(musb);
musb_writel(musb->mregs, OTG_INTERFSEL, musb_writel(musb->mregs, OTG_INTERFSEL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment