Merge branch 'master' of git://git.denx.de/u-boot-sunxi
[platform/kernel/u-boot.git] / drivers / usb / musb-new / musb_uboot.c
index 10f6b5d..2b04fbd 100644 (file)
@@ -1,9 +1,7 @@
 #include <common.h>
+#include <console.h>
 #include <watchdog.h>
-#ifdef CONFIG_ARCH_SUNXI
-#include <asm/arch/usb_phy.h>
-#endif
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
 
@@ -192,19 +190,16 @@ static int _musb_reset_root_port(struct musb_host_data *host,
        power &= 0xf0;
        musb_writeb(mbase, MUSB_POWER, MUSB_POWER_RESET | power);
        mdelay(50);
-#ifdef CONFIG_ARCH_SUNXI
-       /*
-        * sunxi phy has a bug and it will wrongly detect high speed squelch
-        * when clearing reset on low-speed devices, temporary disable
-        * squelch detection to work around this.
-        */
-       sunxi_usb_phy_enable_squelch_detect(0, 0);
-#endif
+
+       if (host->host->ops->pre_root_reset_end)
+               host->host->ops->pre_root_reset_end(host->host);
+
        power = musb_readb(mbase, MUSB_POWER);
        musb_writeb(mbase, MUSB_POWER, ~MUSB_POWER_RESET & power);
-#ifdef CONFIG_ARCH_SUNXI
-       sunxi_usb_phy_enable_squelch_detect(0, 1);
-#endif
+
+       if (host->host->ops->post_root_reset_end)
+               host->host->ops->post_root_reset_end(host->host);
+
        host->host->isr(0, host->host);
        host->host_speed = (musb_readb(mbase, MUSB_POWER) & MUSB_POWER_HSMODE) ?
                        USB_SPEED_HIGH :
@@ -236,8 +231,10 @@ int musb_lowlevel_init(struct musb_host_data *host)
                if (musb_readb(mbase, MUSB_DEVCTL) & MUSB_DEVCTL_HM)
                        break;
        } while (get_timer(0) < timeout);
-       if (get_timer(0) >= timeout)
+       if (get_timer(0) >= timeout) {
+               musb_stop(host->host);
                return -ENODEV;
+       }
 
        _musb_reset_root_port(host, NULL);
        host->host->is_active = 1;
@@ -443,7 +440,7 @@ int musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
        }
 
        *musbp = musb_init_controller(plat, (struct device *)bdata, ctl_regs);
-       if (!musbp) {
+       if (!*musbp) {
                printf("Failed to init the controller\n");
                return -EIO;
        }