USB: musb: AM35x: Workaround for fifo read issue
authorAjay Kumar Gupta <ajay.gupta@ti.com>
Tue, 19 Oct 2010 07:08:13 +0000 (10:08 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 22 Oct 2010 17:22:17 +0000 (10:22 -0700)
AM35x supports only 32bit read operations so we need to have
workaround for 8bit and 16bit read operations.

Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/musb/am35x.c
drivers/usb/musb/musb_core.c

index 53962a0389ebc072946e2d8cd36a08d5bb3a7c8e..b0aabf3a606f39cb06b8c99da654ff420a5651a9 100644 (file)
@@ -492,3 +492,33 @@ void musb_platform_restore_context(struct musb *musb,
        phy_on();
 }
 #endif
+
+/* AM35x supports only 32bit read operation */
+void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
+{
+       void __iomem *fifo = hw_ep->fifo;
+       u32             val;
+       int             i;
+
+       /* Read for 32bit-aligned destination address */
+       if (likely((0x03 & (unsigned long) dst) == 0) && len >= 4) {
+               readsl(fifo, dst, len >> 2);
+               dst += len & ~0x03;
+               len &= 0x03;
+       }
+       /*
+        * Now read the remaining 1 to 3 byte or complete length if
+        * unaligned address.
+        */
+       if (len > 4) {
+               for (i = 0; i < (len >> 2); i++) {
+                       *(u32 *) dst = musb_readl(fifo, 0);
+                       dst += 4;
+               }
+               len &= 0x03;
+       }
+       if (len > 0) {
+               val = musb_readl(fifo, 0);
+               memcpy(dst, &val, len);
+       }
+}
index 7e2c353755d2ce316962e03f45160e3792fa4a70..c9f9024c551525d8704a0d888bb8b1913859d326 100644 (file)
@@ -272,6 +272,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
        }
 }
 
+#if !defined(CONFIG_USB_MUSB_AM35X)
 /*
  * Unload an endpoint's FIFO
  */
@@ -309,6 +310,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
                readsb(fifo, dst, len);
        }
 }
+#endif
 
 #endif /* normal PIO */
 
This page took 0.039418 seconds and 5 git commands to generate.