Skip to content

Commit 7b09e67

Browse files
Li JunFelipe Balbi
authored andcommitted
usb: phy: mxs: refine mxs_phy_disconnect_line
For non-otg mode, we keep the usage of disconnect line between phy analog and digital unchanging; for otg mode, at peripheral role, we keep the usage unchanging too, at host role, the digital part needs to know dp/dm change to respond device's data pulse when it is at low power mode. Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Li Jun <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent dd811ba commit 7b09e67

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/usb/phy/phy-mxs-usb.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#define BM_USBPHY_CTRL_SFTRST BIT(31)
4242
#define BM_USBPHY_CTRL_CLKGATE BIT(30)
43+
#define BM_USBPHY_CTRL_OTG_ID_VALUE BIT(27)
4344
#define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS BIT(26)
4445
#define BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATE BIT(25)
4546
#define BM_USBPHY_CTRL_ENVBUSCHG_WKUP BIT(23)
@@ -255,6 +256,18 @@ static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect)
255256
usleep_range(500, 1000);
256257
}
257258

259+
static bool mxs_phy_is_otg_host(struct mxs_phy *mxs_phy)
260+
{
261+
void __iomem *base = mxs_phy->phy.io_priv;
262+
u32 phyctrl = readl(base + HW_USBPHY_CTRL);
263+
264+
if (IS_ENABLED(CONFIG_USB_OTG) &&
265+
!(phyctrl & BM_USBPHY_CTRL_OTG_ID_VALUE))
266+
return true;
267+
268+
return false;
269+
}
270+
258271
static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
259272
{
260273
bool vbus_is_on = false;
@@ -269,7 +282,7 @@ static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
269282

270283
vbus_is_on = mxs_phy_get_vbus_status(mxs_phy);
271284

272-
if (on && !vbus_is_on)
285+
if (on && !vbus_is_on && !mxs_phy_is_otg_host(mxs_phy))
273286
__mxs_phy_disconnect_line(mxs_phy, true);
274287
else
275288
__mxs_phy_disconnect_line(mxs_phy, false);

0 commit comments

Comments
 (0)