Skip to content

Commit 705e3ce

Browse files
rogerqgregkh
authored andcommitted
usb: dwc3: core: Fix system suspend on TI AM62 platforms
Since commit 6d73572 ("usb: dwc3: core: Prevent phy suspend during init"), system suspend is broken on AM62 TI platforms. Before that commit, both DWC3_GUSB3PIPECTL_SUSPHY and DWC3_GUSB2PHYCFG_SUSPHY bits (hence forth called 2 SUSPHY bits) were being set during core initialization and even during core re-initialization after a system suspend/resume. These bits are required to be set for system suspend/resume to work correctly on AM62 platforms. Since that commit, the 2 SUSPHY bits are not set for DEVICE/OTG mode if gadget driver is not loaded and started. For Host mode, the 2 SUSPHY bits are set before the first system suspend but get cleared at system resume during core re-init and are never set again. This patch resovles these two issues by ensuring the 2 SUSPHY bits are set before system suspend and restored to the original state during system resume. Cc: [email protected] # v6.9+ Fixes: 6d73572 ("usb: dwc3: core: Prevent phy suspend during init") Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Roger Quadros <[email protected]> Acked-by: Thinh Nguyen <[email protected]> Tested-by: Markus Schneider-Pargmann <[email protected]> Reviewed-by: Dhruva Gole <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7d38113 commit 705e3ce

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

drivers/usb/dwc3/core.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,6 +2342,11 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
23422342
u32 reg;
23432343
int i;
23442344

2345+
dwc->susphy_state = (dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)) &
2346+
DWC3_GUSB2PHYCFG_SUSPHY) ||
2347+
(dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)) &
2348+
DWC3_GUSB3PIPECTL_SUSPHY);
2349+
23452350
switch (dwc->current_dr_role) {
23462351
case DWC3_GCTL_PRTCAP_DEVICE:
23472352
if (pm_runtime_suspended(dwc->dev))
@@ -2393,6 +2398,15 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
23932398
break;
23942399
}
23952400

2401+
if (!PMSG_IS_AUTO(msg)) {
2402+
/*
2403+
* TI AM62 platform requires SUSPHY to be
2404+
* enabled for system suspend to work.
2405+
*/
2406+
if (!dwc->susphy_state)
2407+
dwc3_enable_susphy(dwc, true);
2408+
}
2409+
23962410
return 0;
23972411
}
23982412

@@ -2460,6 +2474,11 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
24602474
break;
24612475
}
24622476

2477+
if (!PMSG_IS_AUTO(msg)) {
2478+
/* restore SUSPHY state to that before system suspend. */
2479+
dwc3_enable_susphy(dwc, dwc->susphy_state);
2480+
}
2481+
24632482
return 0;
24642483
}
24652484

drivers/usb/dwc3/core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,8 @@ struct dwc3_scratchpad_array {
11501150
* @sys_wakeup: set if the device may do system wakeup.
11511151
* @wakeup_configured: set if the device is configured for remote wakeup.
11521152
* @suspended: set to track suspend event due to U3/L2.
1153+
* @susphy_state: state of DWC3_GUSB2PHYCFG_SUSPHY + DWC3_GUSB3PIPECTL_SUSPHY
1154+
* before PM suspend.
11531155
* @imod_interval: set the interrupt moderation interval in 250ns
11541156
* increments or 0 to disable.
11551157
* @max_cfg_eps: current max number of IN eps used across all USB configs.
@@ -1382,6 +1384,7 @@ struct dwc3 {
13821384
unsigned sys_wakeup:1;
13831385
unsigned wakeup_configured:1;
13841386
unsigned suspended:1;
1387+
unsigned susphy_state:1;
13851388

13861389
u16 imod_interval;
13871390

0 commit comments

Comments
 (0)