]> git.sur5r.net Git - u-boot/commitdiff
usb: musb: only write CLRDATATOG when appropriate
authorBryan Wu <bryan.wu@analog.com>
Mon, 9 Aug 2010 18:58:24 +0000 (14:58 -0400)
committerRemy Bohmer <linux@bohmer.net>
Wed, 13 Oct 2010 10:08:43 +0000 (12:08 +0200)
This is a change similar to what is already in the Linux driver.  We
should only program the CLRDATATOG bit when the current mode indicates
that it is needed.

Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Signed-off-by: Cliff Cai <cliff.cai@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
drivers/usb/musb/musb_hcd.c

index af989aa78d27175ba22a04958d909e752c51fb57..f38b279096c31fbfaf5abb161526ffa82eca19c1 100644 (file)
@@ -144,19 +144,28 @@ static void write_toggle(struct usb_device *dev, u8 ep, u8 dir_out)
        u16 csr;
 
        if (dir_out) {
-               if (!toggle)
-                       writew(MUSB_TXCSR_CLRDATATOG, &musbr->txcsr);
-               else {
-                       csr = readw(&musbr->txcsr);
+               csr = readw(&musbr->txcsr);
+               if (!toggle) {
+                       if (csr & MUSB_TXCSR_MODE)
+                               csr = MUSB_TXCSR_CLRDATATOG;
+                       else
+                               csr = 0;
+                       writew(csr, &musbr->txcsr);
+               } else {
                        csr |= MUSB_TXCSR_H_WR_DATATOGGLE;
                        writew(csr, &musbr->txcsr);
                        csr |= (toggle << MUSB_TXCSR_H_DATATOGGLE_SHIFT);
                        writew(csr, &musbr->txcsr);
                }
        } else {
-               if (!toggle)
-                       writew(MUSB_RXCSR_CLRDATATOG, &musbr->rxcsr);
-               else {
+               if (!toggle) {
+                       csr = readw(&musbr->txcsr);
+                       if (csr & MUSB_TXCSR_MODE)
+                               csr = MUSB_RXCSR_CLRDATATOG;
+                       else
+                               csr = 0;
+                       writew(csr, &musbr->rxcsr);
+               } else {
                        csr = readw(&musbr->rxcsr);
                        csr |= MUSB_RXCSR_H_WR_DATATOGGLE;
                        writew(csr, &musbr->rxcsr);