[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / psp / 0011-usb-musb-host-Flush-txfifo-only-if-TxPktRdy-bit-set.patch
1 From e5fad55642b91e45ed640c546dd10bd454b6e4df Mon Sep 17 00:00:00 2001
2 From: Ajay Kumar Gupta <ajay.gupta@ti.com>
3 Date: Thu, 24 May 2012 15:42:53 +0530
4 Subject: [PATCH 11/18] usb: musb: host: Flush txfifo only if TxPktRdy bit set
6 This is needed as per mentor core documents.
8 Signed-off-by: Ravi B <ravibabu@ti.com>
9 ---
10 drivers/usb/musb/musb_host.c | 23 ++++++++++++-----------
11 1 files changed, 12 insertions(+), 11 deletions(-)
13 diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
14 index c3629bd..7545a65 100644
15 --- a/drivers/usb/musb/musb_host.c
16 +++ b/drivers/usb/musb/musb_host.c
17 @@ -133,25 +133,26 @@ static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep)
18 struct musb *musb = ep->musb;
19 void __iomem *epio = ep->regs;
20 u16 csr;
21 - u16 lastcsr = 0;
22 int retries = 1000;
24 csr = musb_readw(epio, MUSB_TXCSR);
25 - while (csr & MUSB_TXCSR_FIFONOTEMPTY) {
26 - if (csr != lastcsr)
27 - dev_dbg(musb->controller, "Host TX FIFONOTEMPTY csr: %02x\n", csr);
28 - lastcsr = csr;
29 - csr = MUSB_TXCSR_FLUSHFIFO;
30 + while (csr & MUSB_TXCSR_TXPKTRDY) {
31 + if (!(csr & MUSB_TXCSR_FIFONOTEMPTY))
32 + return;
33 + else
34 + dev_dbg(musb->controller,
35 + "Host TX FIFONOTEMPTY csr: %02x\n", csr);
36 +
37 + csr |= MUSB_TXCSR_FLUSHFIFO;
38 musb_writew(epio, MUSB_TXCSR, csr);
39 csr = musb_readw(epio, MUSB_TXCSR);
40 - if (!(csr & MUSB_TXCSR_FIFONOTEMPTY))
41 - break;
42 +
43 if (retries-- < 1) {
44 - dev_dbg(musb->controller, "Could not flush host TX%d fifo: csr: %04x\n",
45 - ep->epnum, csr);
46 + dev_dbg(musb->controller,
47 + "Could not flush host TX%d fifo: csr: %04x\n",
48 + ep->epnum, csr);
49 return;
50 }
51 - mdelay(1);
52 }
53 }
55 --
56 1.7.7.6