usb: dwc3-msm: Add support for snps SSPHY suspend in system suspend

Currently the platforms using SNPS SSPHY do not suspend it so as
to receive SS wakeup events via pwr_event_irq. But certain
telematics platforms do not need SS wakeup in system suspend
scenario.
USB wakeup from PM suspend/hibernation is not a requirement for
automotive/telematics platforms. Use enable_wakeup parameter in
dwc3_msm_suspend call to allow SSPHY suspend to happen and also
to keep the IRQs enabled/disabled.

Change-Id: I691585e15539490e63a345fe2b3aacf182352399
Signed-off-by: Ajay Agarwal <ajaya@codeaurora.org>
Signed-off-by: Harsh Agarwal <harshq@codeaurora.org>
This commit is contained in:
Ajay Agarwal 2020-11-27 14:19:17 +05:30 • committed by Gerrit - the friendly Code Review server
commit b595281eb8

View file

@ -2851,7 +2851,8 @@ static int dwc3_msm_update_bus_bw(struct dwc3_msm *mdwc, enum bus_vote bv)
return ret;
}
static int dwc3_msm_suspend(struct dwc3_msm *mdwc, bool force_power_collapse)
static int dwc3_msm_suspend(struct dwc3_msm *mdwc, bool force_power_collapse,
bool enable_wakeup)
{
int ret;
struct dwc3 *dwc = platform_get_drvdata(mdwc->dwc3);
@ -2944,7 +2945,8 @@ static int dwc3_msm_suspend(struct dwc3_msm *mdwc, bool force_power_collapse)
((mdwc->hs_phy->flags & (PHY_HSFS_MODE | PHY_LS_MODE)) &&
!dwc3_msm_is_superspeed(mdwc)));
can_suspend_ssphy = dwc->maximum_speed >= USB_SPEED_SUPER &&
(!mdwc->use_pwr_event_for_wakeup || no_active_ss);
(!mdwc->use_pwr_event_for_wakeup || no_active_ss ||
!enable_wakeup);
/* Suspend SS PHY */
if (can_suspend_ssphy) {
if (mdwc->in_host_mode) {
@ -3015,7 +3017,7 @@ static int dwc3_msm_suspend(struct dwc3_msm *mdwc, bool force_power_collapse)
* using HS_PHY_IRQ or SS_PHY_IRQ. Hence enable wakeup only in
* case of host bus suspend and device bus suspend.
*/
if (!(mdwc->lpm_flags & MDWC3_POWER_COLLAPSE)) {
if (!(mdwc->lpm_flags & MDWC3_POWER_COLLAPSE) && enable_wakeup) {
if (mdwc->use_pdc_interrupts) {
enable_usb_pdc_interrupt(mdwc, true);
} else {
@ -5313,7 +5315,8 @@ static int dwc3_msm_pm_suspend(struct device *dev)
return 0;
}
ret = dwc3_msm_suspend(mdwc, false);
/* Wakeup not required for automotive/telematics platform host mode */
ret = dwc3_msm_suspend(mdwc, false, false);
if (!ret)
atomic_set(&mdwc->pm_suspended, 1);
@ -5385,8 +5388,9 @@ static int dwc3_msm_pm_freeze(struct device *dev)
/*
* Power collapse the core. Hence call dwc3_msm_suspend with
* 'force_power_collapse' set to 'true'.
* Wakeup not required for automotive/telematics platform host mode.
*/
ret = dwc3_msm_suspend(mdwc, true);
ret = dwc3_msm_suspend(mdwc, true, false);
if (!ret)
atomic_set(&mdwc->pm_suspended, 1);
@ -5449,7 +5453,7 @@ static int dwc3_msm_runtime_suspend(struct device *dev)
dev_dbg(dev, "DWC3-msm runtime suspend\n");
dbg_event(0xFF, "RT Sus", 0);
return dwc3_msm_suspend(mdwc, false);
return dwc3_msm_suspend(mdwc, false, true);
}
static int dwc3_msm_runtime_resume(struct device *dev)