diff options
author | Tom Rini <trini@konsulko.com> | 2015-08-08 20:20:17 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2015-08-08 20:20:17 -0400 |
commit | 15f8876b1dd95dd6bcee686ada36369871bbcdc9 (patch) | |
tree | 8695ca6182a99fea5a4f79ab67e9ec5b015069ac /drivers/usb/musb-new/sunxi.c | |
parent | bd48c0617b5c7212e5bf22169e716da878842da4 (diff) | |
parent | 39920c81ce4431b7ea08f5e80feb5ec8b156864e (diff) |
Merge branch 'master' of http://git.denx.de/u-boot-sunxi
Diffstat (limited to 'drivers/usb/musb-new/sunxi.c')
-rw-r--r-- | drivers/usb/musb-new/sunxi.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index 16a264a9dd..a146c0861f 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -196,8 +196,6 @@ static bool enabled = false; static int sunxi_musb_enable(struct musb *musb) { - int ret; - pr_debug("%s():\n", __func__); musb_ep_select(musb->mregs, 0); @@ -210,17 +208,26 @@ static int sunxi_musb_enable(struct musb *musb) musb_writeb(musb->mregs, USBC_REG_o_VEND0, 0); if (is_host_enabled(musb)) { - ret = sunxi_usb_phy_vbus_detect(0); - if (ret == 1) { - printf("A charger is plugged into the OTG: "); - return -ENODEV; + int id = sunxi_usb_phy_id_detect(0); + + if (id == 1 && sunxi_usb_phy_power_is_on(0)) + sunxi_usb_phy_power_off(0); + + if (!sunxi_usb_phy_power_is_on(0)) { + int vbus = sunxi_usb_phy_vbus_detect(0); + if (vbus == 1) { + printf("A charger is plugged into the OTG: "); + return -ENODEV; + } } - ret = sunxi_usb_phy_id_detect(0); - if (ret == 1) { + + if (id == 1) { printf("No host cable detected: "); return -ENODEV; } - sunxi_usb_phy_power_on(0); /* port power on */ + + if (!sunxi_usb_phy_power_is_on(0)) + sunxi_usb_phy_power_on(0); } USBC_ForceVbusValidToHigh(musb->mregs); @@ -236,9 +243,6 @@ static void sunxi_musb_disable(struct musb *musb) if (!enabled) return; - if (is_host_enabled(musb)) - sunxi_usb_phy_power_off(0); /* port power off */ - USBC_ForceVbusValidToLow(musb->mregs); mdelay(200); /* Wait for the current session to timeout */ |