Skip to content

Commit 85ca88f

Browse files
rogerqgregkh
authored andcommitted
usb: dwc3: core: Fix system suspend on TI AM62 platforms
[ Upstream commit 705e3ce ] 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: stable@vger.kernel.org # v6.9+ Fixes: 6d73572 ("usb: dwc3: core: Prevent phy suspend during init") Link: https://lore.kernel.org/all/1519dbe7-73b6-4afc-bfe3-23f4f75d772f@kernel.org/ Signed-off-by: Roger Quadros <rogerq@kernel.org> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Tested-by: Markus Schneider-Pargmann <msp@baylibre.com> Reviewed-by: Dhruva Gole <d-gole@ti.com> Link: https://lore.kernel.org/r/20241011-am62-lpm-usb-v3-1-562d445625b5@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e0deb60 commit 85ca88f

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎drivers/usb/dwc3/core.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,11 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
21312131
{
21322132
u32 reg;
21332133

2134+
dwc->susphy_state = (dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)) &
2135+
DWC3_GUSB2PHYCFG_SUSPHY) ||
2136+
(dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)) &
2137+
DWC3_GUSB3PIPECTL_SUSPHY);
2138+
21342139
switch (dwc->current_dr_role) {
21352140
case DWC3_GCTL_PRTCAP_DEVICE:
21362141
if (pm_runtime_suspended(dwc->dev))
@@ -2178,6 +2183,15 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
21782183
break;
21792184
}
21802185

2186+
if (!PMSG_IS_AUTO(msg)) {
2187+
/*
2188+
* TI AM62 platform requires SUSPHY to be
2189+
* enabled for system suspend to work.
2190+
*/
2191+
if (!dwc->susphy_state)
2192+
dwc3_enable_susphy(dwc, true);
2193+
}
2194+
21812195
return 0;
21822196
}
21832197

@@ -2240,6 +2254,11 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
22402254
break;
22412255
}
22422256

2257+
if (!PMSG_IS_AUTO(msg)) {
2258+
/* restore SUSPHY state to that before system suspend. */
2259+
dwc3_enable_susphy(dwc, dwc->susphy_state);
2260+
}
2261+
22432262
return 0;
22442263
}
22452264

‎drivers/usb/dwc3/core.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,8 @@ struct dwc3_scratchpad_array {
11181118
* @dis_metastability_quirk: set to disable metastability quirk.
11191119
* @dis_split_quirk: set to disable split boundary.
11201120
* @suspended: set to track suspend event due to U3/L2.
1121+
* @susphy_state: state of DWC3_GUSB2PHYCFG_SUSPHY + DWC3_GUSB3PIPECTL_SUSPHY
1122+
* before PM suspend.
11211123
* @imod_interval: set the interrupt moderation interval in 250ns
11221124
* increments or 0 to disable.
11231125
* @max_cfg_eps: current max number of IN eps used across all USB configs.
@@ -1341,6 +1343,7 @@ struct dwc3 {
13411343
unsigned dis_split_quirk:1;
13421344
unsigned async_callbacks:1;
13431345
unsigned suspended:1;
1346+
unsigned susphy_state:1;
13441347

13451348
u16 imod_interval;
13461349

0 commit comments

Comments
 (0)