Skip to content

Commit 843bb1d

Browse files
Ajay Kumar Guptagregkh
authored andcommitted
USB: musb: AM35x: Workaround for fifo read issue
AM35x supports only 32bit read operations so we need to have workaround for 8bit and 16bit read operations. Signed-off-by: Ajay Kumar Gupta <[email protected]> Signed-off-by: Felipe Balbi <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent eb83092 commit 843bb1d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

drivers/usb/musb/am35x.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,3 +492,33 @@ void musb_platform_restore_context(struct musb *musb,
492492
phy_on();
493493
}
494494
#endif
495+
496+
/* AM35x supports only 32bit read operation */
497+
void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
498+
{
499+
void __iomem *fifo = hw_ep->fifo;
500+
u32 val;
501+
int i;
502+
503+
/* Read for 32bit-aligned destination address */
504+
if (likely((0x03 & (unsigned long) dst) == 0) && len >= 4) {
505+
readsl(fifo, dst, len >> 2);
506+
dst += len & ~0x03;
507+
len &= 0x03;
508+
}
509+
/*
510+
* Now read the remaining 1 to 3 byte or complete length if
511+
* unaligned address.
512+
*/
513+
if (len > 4) {
514+
for (i = 0; i < (len >> 2); i++) {
515+
*(u32 *) dst = musb_readl(fifo, 0);
516+
dst += 4;
517+
}
518+
len &= 0x03;
519+
}
520+
if (len > 0) {
521+
val = musb_readl(fifo, 0);
522+
memcpy(dst, &val, len);
523+
}
524+
}

drivers/usb/musb/musb_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
272272
}
273273
}
274274

275+
#if !defined(CONFIG_USB_MUSB_AM35X)
275276
/*
276277
* Unload an endpoint's FIFO
277278
*/
@@ -309,6 +310,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
309310
readsb(fifo, dst, len);
310311
}
311312
}
313+
#endif
312314

313315
#endif /* normal PIO */
314316

0 commit comments

Comments
 (0)