Skip to content

Commit

Permalink
USB: musb: gadget: fix MUSB_TXMAXP and MUSB_RXMAXP configuration
Browse files Browse the repository at this point in the history
Commit 9f445cb[USB: musb: disable
double buffering for older RTL versions] tries to disable double
buffer mode by writing endpoint hw max packet size to TXMAP/RXMAP.

First the approach can break full speed and cause overflow problems.
We should always set those registers with the actual max packet size
from endpoint descriptor.

Second, the problem describe by commit 9f445cb
was caused by musb gadget driver; nothing to do with RTL revision as
originaly suspected.

The real fix to the problem is to always use actual max packet
size from endpoint descriptor to config TXMAP/RXMAP registers.

Cc: Cliff Cai <cliff.cai@analog.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Anand Gadiyar <gadiyar@ti.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: stable@kernel.org
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Ming Lei authored and Felipe Balbi committed Nov 5, 2010
1 parent 120d074 commit 31c9909
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions drivers/usb/musb/musb_gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,13 +926,9 @@ static int musb_gadget_enable(struct usb_ep *ep,
* likewise high bandwidth periodic tx
*/
/* Set TXMAXP with the FIFO size of the endpoint
* to disable double buffering mode. Currently, It seems that double
* buffering has problem if musb RTL revision number < 2.0.
* to disable double buffering mode.
*/
if (musb->hwvers < MUSB_HWVERS_2000)
musb_writew(regs, MUSB_TXMAXP, hw_ep->max_packet_sz_tx);
else
musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11));
musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11));

csr = MUSB_TXCSR_MODE | MUSB_TXCSR_CLRDATATOG;
if (musb_readw(regs, MUSB_TXCSR)
Expand Down Expand Up @@ -968,10 +964,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
/* Set RXMAXP with the FIFO size of the endpoint
* to disable double buffering mode.
*/
if (musb->hwvers < MUSB_HWVERS_2000)
musb_writew(regs, MUSB_RXMAXP, hw_ep->max_packet_sz_rx);
else
musb_writew(regs, MUSB_RXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11));
musb_writew(regs, MUSB_RXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11));

/* force shared fifo to OUT-only mode */
if (hw_ep->is_shared_fifo) {
Expand Down

0 comments on commit 31c9909

Please sign in to comment.