]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/usb/musb-new/sunxi.c
sunxi: musb: Move vbus check to sunxi_musb_enable
[karo-tx-uboot.git] / drivers / usb / musb-new / sunxi.c
index 052e0657d03d22261f9951a13c9295cc119c395b..ee018c7e6e76751248962430f54bf8bec59b8d80 100644 (file)
@@ -199,22 +199,31 @@ static irqreturn_t sunxi_musb_interrupt(int irq, void *__hci)
 /* musb_core does not call enable / disable in a balanced manner <sigh> */
 static bool enabled = false;
 
-static void sunxi_musb_enable(struct musb *musb)
+static int sunxi_musb_enable(struct musb *musb)
 {
+       int ret;
+
        pr_debug("%s():\n", __func__);
 
        if (enabled)
-               return;
+               return 0;
 
        /* select PIO mode */
        musb_writeb(musb->mregs, USBC_REG_o_VEND0, 0);
 
-       if (is_host_enabled(musb))
+       if (is_host_enabled(musb)) {
+               ret = sunxi_usb_phy_vbus_detect(0);
+               if (ret) {
+                       printf("A charger is plugged into the OTG: ");
+                       return -ENODEV;
+               }
                sunxi_usb_phy_power_on(0); /* port power on */
+       }
 
        USBC_ForceVbusValidToHigh(musb->mregs);
 
        enabled = true;
+       return 0;
 }
 
 static void sunxi_musb_disable(struct musb *musb)
@@ -236,18 +245,9 @@ static void sunxi_musb_disable(struct musb *musb)
 static int sunxi_musb_init(struct musb *musb)
 {
        struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
-       int err;
 
        pr_debug("%s():\n", __func__);
 
-       if (is_host_enabled(musb)) {
-               err = sunxi_usb_phy_vbus_detect(0);
-               if (err) {
-                       eprintf("Error: A charger is plugged into the OTG\n");
-                       return -EIO;
-               }
-       }
-
        musb->isr = sunxi_musb_interrupt;
 
        setbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_USB0);