]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - drivers/usb/musb-new/musb_uboot.c
musb: Update usb-compat to work with struct usb_device without a parent ptr
[karo-tx-uboot.git] / drivers / usb / musb-new / musb_uboot.c
index 6e58ddf02cc34b67b4550b9f752d5a00c2d0615c..a96e8d2b7488bf273d25ecc34225764a6cc604b8 100644 (file)
@@ -1,5 +1,8 @@
 #include <common.h>
 #include <watchdog.h>
+#ifdef CONFIG_ARCH_SUNXI
+#include <asm/arch/usb_phy.h>
+#endif
 #include <asm/errno.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
@@ -94,7 +97,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe,
                      buffer, len, setup, 0);
 
        /* Fix speed for non hub-attached devices */
-       if (!dev->parent)
+       if (!usb_dev_get_parent(dev))
                dev->speed = host_speed;
 
        return submit_urb(&hcd, &urb);
@@ -177,7 +180,7 @@ void *poll_int_queue(struct usb_device *dev, struct int_queue *queue)
        return NULL; /* URB still pending */
 }
 
-void usb_reset_root_port(void)
+int usb_reset_root_port(struct usb_device *dev)
 {
        void *mbase = host->mregs;
        u8 power;
@@ -186,14 +189,27 @@ void usb_reset_root_port(void)
        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
        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
        host->isr(0, host);
        host_speed = (musb_readb(mbase, MUSB_POWER) & MUSB_POWER_HSMODE) ?
                        USB_SPEED_HIGH :
                        (musb_readb(mbase, MUSB_DEVCTL) & MUSB_DEVCTL_FSDEV) ?
                        USB_SPEED_FULL : USB_SPEED_LOW;
        mdelay((host_speed == USB_SPEED_LOW) ? 200 : 50);
+
+       return 0;
 }
 
 int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
@@ -201,13 +217,17 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
        void *mbase;
        /* USB spec says it may take up to 1 second for a device to connect */
        unsigned long timeout = get_timer(0) + 1000;
+       int ret;
 
        if (!host) {
                printf("MUSB host is not registered\n");
                return -ENODEV;
        }
 
-       musb_start(host);
+       ret = musb_start(host);
+       if (ret)
+               return ret;
+
        mbase = host->mregs;
        do {
                if (musb_readb(mbase, MUSB_DEVCTL) & MUSB_DEVCTL_HM)
@@ -216,7 +236,7 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
        if (get_timer(0) >= timeout)
                return -ENODEV;
 
-       usb_reset_root_port();
+       usb_reset_root_port(NULL);
        host->is_active = 1;
        hcd.hcd_priv = host;
 
@@ -238,7 +258,7 @@ int usb_lowlevel_stop(int index)
 #ifdef CONFIG_MUSB_GADGET
 static struct musb *gadget;
 
-int usb_gadget_handle_interrupts(void)
+int usb_gadget_handle_interrupts(int index)
 {
        WATCHDOG_RESET();
        if (!gadget || !gadget->isr)