Skip to content

Commit 5eda42a

Browse files
Xu Yanggregkh
authored andcommitted
usb: phy: mxs: fix getting wrong state with mxs_phy_is_otg_host()
The function mxs_phy_is_otg_host() will return true if OTG_ID_VALUE is 0 at USBPHY_CTRL register. However, OTG_ID_VALUE will not reflect the real state if the ID pin is float, such as Host-only or Type-C cases. The value of OTG_ID_VALUE is always 1 which means device mode. This patch will fix the issue by judging the current mode based on last_event. The controller will update last_event in time. Fixes: 7b09e67 ("usb: phy: mxs: refine mxs_phy_disconnect_line") Signed-off-by: Xu Yang <[email protected]> Acked-by: Peter Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b7a6261 commit 5eda42a

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,14 +388,8 @@ static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect)
388388

389389
static bool mxs_phy_is_otg_host(struct mxs_phy *mxs_phy)
390390
{
391-
void __iomem *base = mxs_phy->phy.io_priv;
392-
u32 phyctrl = readl(base + HW_USBPHY_CTRL);
393-
394-
if (IS_ENABLED(CONFIG_USB_OTG) &&
395-
!(phyctrl & BM_USBPHY_CTRL_OTG_ID_VALUE))
396-
return true;
397-
398-
return false;
391+
return IS_ENABLED(CONFIG_USB_OTG) &&
392+
mxs_phy->phy.last_event == USB_EVENT_ID;
399393
}
400394

401395
static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)

0 commit comments

Comments
 (0)