Skip to content

Commit

Permalink
usb: musb: Add missing PM suspend and resume functions for 2430 glue
Browse files Browse the repository at this point in the history
Looks like we are missing suspend and resume functions for pm_ops that
are needed to idle the hardware for system suspend for 2430 glue layer.

We can rely on the driver internal PM runtime state, and call driver
functions to idle the hardware on suspend if needed. There is no need
to add a dependency to PM runtime for system suspend here.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20210518074449.17070-1-tony@atomide.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Tony Lindgren authored and Greg Kroah-Hartman committed May 21, 2021
1 parent c5c7489 commit 62d472d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions drivers/usb/musb/omap2430.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ struct omap2430_glue {
enum musb_vbus_id_status status;
struct work_struct omap_musb_mailbox_work;
struct device *control_otghs;
unsigned int is_runtime_suspended:1;
unsigned int needs_resume:1;
};
#define glue_to_musb(g) platform_get_drvdata(g->musb)

Expand Down Expand Up @@ -459,6 +461,8 @@ static int omap2430_runtime_suspend(struct device *dev)
phy_power_off(musb->phy);
phy_exit(musb->phy);

glue->is_runtime_suspended = 1;

return 0;
}

Expand All @@ -480,12 +484,40 @@ static int omap2430_runtime_resume(struct device *dev)
/* Wait for musb to get oriented. Otherwise we can get babble */
usleep_range(200000, 250000);

glue->is_runtime_suspended = 0;

return 0;
}

static int omap2430_suspend(struct device *dev)
{
struct omap2430_glue *glue = dev_get_drvdata(dev);

if (glue->is_runtime_suspended)
return 0;

glue->needs_resume = 1;

return omap2430_runtime_suspend(dev);
}

static int omap2430_resume(struct device *dev)
{
struct omap2430_glue *glue = dev_get_drvdata(dev);

if (!glue->needs_resume)
return 0;

glue->needs_resume = 0;

return omap2430_runtime_resume(dev);
}

static const struct dev_pm_ops omap2430_pm_ops = {
.runtime_suspend = omap2430_runtime_suspend,
.runtime_resume = omap2430_runtime_resume,
.suspend = omap2430_suspend,
.resume = omap2430_resume,
};

#define DEV_PM_OPS (&omap2430_pm_ops)
Expand Down

0 comments on commit 62d472d

Please sign in to comment.