diff options
-rw-r--r-- | drivers/usb/phy/phy-mxs-usb.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index fcadbd2d65a8..eb746051eda4 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c | |||
@@ -40,6 +40,7 @@ | |||
40 | 40 | ||
41 | #define BM_USBPHY_CTRL_SFTRST BIT(31) | 41 | #define BM_USBPHY_CTRL_SFTRST BIT(31) |
42 | #define BM_USBPHY_CTRL_CLKGATE BIT(30) | 42 | #define BM_USBPHY_CTRL_CLKGATE BIT(30) |
43 | #define BM_USBPHY_CTRL_OTG_ID_VALUE BIT(27) | ||
43 | #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS BIT(26) | 44 | #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS BIT(26) |
44 | #define BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATE BIT(25) | 45 | #define BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATE BIT(25) |
45 | #define BM_USBPHY_CTRL_ENVBUSCHG_WKUP BIT(23) | 46 | #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) | |||
255 | usleep_range(500, 1000); | 256 | usleep_range(500, 1000); |
256 | } | 257 | } |
257 | 258 | ||
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 | |||
258 | static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on) | 271 | static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on) |
259 | { | 272 | { |
260 | bool vbus_is_on = false; | 273 | bool vbus_is_on = false; |
@@ -269,7 +282,7 @@ static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on) | |||
269 | 282 | ||
270 | vbus_is_on = mxs_phy_get_vbus_status(mxs_phy); | 283 | vbus_is_on = mxs_phy_get_vbus_status(mxs_phy); |
271 | 284 | ||
272 | if (on && !vbus_is_on) | 285 | if (on && !vbus_is_on && !mxs_phy_is_otg_host(mxs_phy)) |
273 | __mxs_phy_disconnect_line(mxs_phy, true); | 286 | __mxs_phy_disconnect_line(mxs_phy, true); |
274 | else | 287 | else |
275 | __mxs_phy_disconnect_line(mxs_phy, false); | 288 | __mxs_phy_disconnect_line(mxs_phy, false); |