mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 01:24:12 +08:00
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: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
21f77beece
commit
a83e17d0f7
@ -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
|
||||
@ -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;
|
||||
|
||||
@ -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) {
|
||||
@ -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);
|
||||
@ -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;
|
||||
}
|
||||
@ -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);
|
||||
@ -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;
|
||||
}
|
||||
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user