Merge branch 'master' of git://git.denx.de/u-boot-sunxi
[platform/kernel/u-boot.git] / drivers / usb / musb-new / musb_uboot.c
index 9b56e90..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>
 
@@ -15,7 +13,7 @@
 #include "musb_gadget.h"
 #include "musb_uboot.h"
 
-#ifdef CONFIG_MUSB_HOST
+#ifdef CONFIG_USB_MUSB_HOST
 struct int_queue {
        struct usb_host_endpoint hep;
        struct urb urb;
@@ -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;
@@ -368,9 +365,9 @@ struct dm_usb_ops musb_usb_ops = {
        .reset_root_port = musb_reset_root_port,
 };
 #endif /* CONFIG_DM_USB */
-#endif /* CONFIG_MUSB_HOST */
+#endif /* CONFIG_USB_MUSB_HOST */
 
-#ifdef CONFIG_MUSB_GADGET
+#ifdef CONFIG_USB_MUSB_GADGET
 static struct musb *gadget;
 
 int usb_gadget_handle_interrupts(int index)
@@ -420,7 +417,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
                driver->unbind(&gadget->g);
        return 0;
 }
-#endif /* CONFIG_MUSB_GADGET */
+#endif /* CONFIG_USB_MUSB_GADGET */
 
 int musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
                        void *ctl_regs)
@@ -428,12 +425,12 @@ int musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
        struct musb **musbp;
 
        switch (plat->mode) {
-#if defined(CONFIG_MUSB_HOST) && !defined(CONFIG_DM_USB)
+#if defined(CONFIG_USB_MUSB_HOST) && !defined(CONFIG_DM_USB)
        case MUSB_HOST:
                musbp = &musb_host.host;
                break;
 #endif
-#ifdef CONFIG_MUSB_GADGET
+#ifdef CONFIG_USB_MUSB_GADGET
        case MUSB_PERIPHERAL:
                musbp = &gadget;
                break;
@@ -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;
        }