Commit 1c4bdc01 authored by Bryan Wu's avatar Bryan Wu Committed by Greg Kroah-Hartman

USB: musb: workaround Blackfin FIFO anomalies

Some of these workarounds are already in place, but labeled as affecting
all BF52x parts.  Since we have official anomaly numbers now, use those
defines.  And since writing to the FIFO has a similar hang issue as reading
from the FIFO, implement the workaround there too when necessary.
Signed-off-by: default avatarBryan Wu <cooloney@kernel.org>
Signed-off-by: default avatarCliff Cai <cliff.cai@analog.com>
Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
Cc: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 0ea52ff4
...@@ -29,6 +29,8 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) ...@@ -29,6 +29,8 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
{ {
void __iomem *fifo = hw_ep->fifo; void __iomem *fifo = hw_ep->fifo;
void __iomem *epio = hw_ep->regs; void __iomem *epio = hw_ep->regs;
u8 epnum = hw_ep->epnum;
u16 dma_reg = 0;
prefetch((u8 *)src); prefetch((u8 *)src);
...@@ -39,67 +41,113 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) ...@@ -39,67 +41,113 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
dump_fifo_data(src, len); dump_fifo_data(src, len);
if (unlikely((unsigned long)src & 0x01)) if (!ANOMALY_05000380 && epnum != 0) {
outsw_8((unsigned long)fifo, src, flush_dcache_range((unsigned int)src,
len & 0x01 ? (len >> 1) + 1 : len >> 1); (unsigned int)(src + len));
else
outsw((unsigned long)fifo, src, /* Setup DMA address register */
len & 0x01 ? (len >> 1) + 1 : len >> 1); dma_reg = (u16) ((u32) src & 0xFFFF);
} bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_LOW), dma_reg);
SSYNC();
dma_reg = (u16) (((u32) src >> 16) & 0xFFFF);
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_HIGH), dma_reg);
SSYNC();
/* Setup DMA count register */
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_LOW), len);
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_HIGH), 0);
SSYNC();
/* Enable the DMA */
dma_reg = (epnum << 4) | DMA_ENA | INT_ENA | DIRECTION;
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), dma_reg);
SSYNC();
/* Wait for compelete */
while (!(bfin_read_USB_DMA_INTERRUPT() & (1 << epnum)))
cpu_relax();
/* acknowledge dma interrupt */
bfin_write_USB_DMA_INTERRUPT(1 << epnum);
SSYNC();
/* Reset DMA */
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), 0);
SSYNC();
} else {
SSYNC();
if (unlikely((unsigned long)src & 0x01))
outsw_8((unsigned long)fifo, src,
len & 0x01 ? (len >> 1) + 1 : len >> 1);
else
outsw((unsigned long)fifo, src,
len & 0x01 ? (len >> 1) + 1 : len >> 1);
}
}
/* /*
* Unload an endpoint's FIFO * Unload an endpoint's FIFO
*/ */
void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
{ {
void __iomem *fifo = hw_ep->fifo; void __iomem *fifo = hw_ep->fifo;
#ifdef CONFIG_BF52x
u8 epnum = hw_ep->epnum; u8 epnum = hw_ep->epnum;
u16 dma_reg = 0; u16 dma_reg = 0;
invalidate_dcache_range((unsigned int)dst, if (ANOMALY_05000467 && epnum != 0) {
(unsigned int)(dst + len));
/* Setup DMA address register */ invalidate_dcache_range((unsigned int)dst,
dma_reg = (u16) ((u32) dst & 0xFFFF); (unsigned int)(dst + len));
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_LOW), dma_reg);
SSYNC();
dma_reg = (u16) (((u32) dst >> 16) & 0xFFFF); /* Setup DMA address register */
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_HIGH), dma_reg); dma_reg = (u16) ((u32) dst & 0xFFFF);
SSYNC(); bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_LOW), dma_reg);
SSYNC();
/* Setup DMA count register */ dma_reg = (u16) (((u32) dst >> 16) & 0xFFFF);
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_LOW), len); bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_HIGH), dma_reg);
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_HIGH), 0); SSYNC();
SSYNC();
/* Enable the DMA */ /* Setup DMA count register */
dma_reg = (epnum << 4) | DMA_ENA | INT_ENA; bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_LOW), len);
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), dma_reg); bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_HIGH), 0);
SSYNC(); SSYNC();
/* Wait for compelete */ /* Enable the DMA */
while (!(bfin_read_USB_DMA_INTERRUPT() & (1 << epnum))) dma_reg = (epnum << 4) | DMA_ENA | INT_ENA;
cpu_relax(); bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), dma_reg);
SSYNC();
/* acknowledge dma interrupt */ /* Wait for compelete */
bfin_write_USB_DMA_INTERRUPT(1 << epnum); while (!(bfin_read_USB_DMA_INTERRUPT() & (1 << epnum)))
SSYNC(); cpu_relax();
/* Reset DMA */ /* acknowledge dma interrupt */
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), 0); bfin_write_USB_DMA_INTERRUPT(1 << epnum);
SSYNC(); SSYNC();
#else
if (unlikely((unsigned long)dst & 0x01))
insw_8((unsigned long)fifo, dst,
len & 0x01 ? (len >> 1) + 1 : len >> 1);
else
insw((unsigned long)fifo, dst,
len & 0x01 ? (len >> 1) + 1 : len >> 1);
#endif
/* Reset DMA */
bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), 0);
SSYNC();
} else {
SSYNC();
/* Read the last byte of packet with odd size from address fifo + 4
* to trigger 1 byte access to EP0 FIFO.
*/
if (len == 1)
*dst = (u8)inw((unsigned long)fifo + 4);
else {
if (unlikely((unsigned long)dst & 0x01))
insw_8((unsigned long)fifo, dst, len >> 1);
else
insw((unsigned long)fifo, dst, len >> 1);
if (len & 0x01)
*(dst + len - 1) = (u8)inw((unsigned long)fifo + 4);
}
}
DBG(4, "%cX ep%d fifo %p count %d buf %p\n", DBG(4, "%cX ep%d fifo %p count %d buf %p\n",
'R', hw_ep->epnum, fifo, len, dst); 'R', hw_ep->epnum, fifo, len, dst);
......
...@@ -69,7 +69,6 @@ static void dump_fifo_data(u8 *buf, u16 len) ...@@ -69,7 +69,6 @@ static void dump_fifo_data(u8 *buf, u16 len)
#define dump_fifo_data(buf, len) do {} while (0) #define dump_fifo_data(buf, len) do {} while (0)
#endif #endif
#ifdef CONFIG_BF52x
#define USB_DMA_BASE USB_DMA_INTERRUPT #define USB_DMA_BASE USB_DMA_INTERRUPT
#define USB_DMAx_CTRL 0x04 #define USB_DMAx_CTRL 0x04
...@@ -79,7 +78,6 @@ static void dump_fifo_data(u8 *buf, u16 len) ...@@ -79,7 +78,6 @@ static void dump_fifo_data(u8 *buf, u16 len)
#define USB_DMAx_COUNT_HIGH 0x14 #define USB_DMAx_COUNT_HIGH 0x14
#define USB_DMA_REG(ep, reg) (USB_DMA_BASE + 0x20 * ep + reg) #define USB_DMA_REG(ep, reg) (USB_DMA_BASE + 0x20 * ep + reg)
#endif
/* Almost 1 second */ /* Almost 1 second */
#define TIMER_DELAY (1 * HZ) #define TIMER_DELAY (1 * HZ)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment