Skip to content

Commit

Permalink
usb: musb: support ISO high bandwidth for gadget mode
Browse files Browse the repository at this point in the history
This patch has been tested OK on beagle B5 board and
use usbtest #15 and #16 as testcase.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Reviewed-by: Sergei Shtylyov <sshtylyov@mvista.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>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Ming Lei authored and Greg Kroah-Hartman committed Oct 22, 2010
1 parent 3ee076d commit f11d893
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
49 changes: 37 additions & 12 deletions drivers/usb/musb/musb_gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,15 @@ static void txstate(struct musb *musb, struct musb_request *req)
csr |= (MUSB_TXCSR_DMAENAB |
MUSB_TXCSR_MODE);
/* against programming guide */
} else
csr |= (MUSB_TXCSR_AUTOSET
| MUSB_TXCSR_DMAENAB
} else {
csr |= (MUSB_TXCSR_DMAENAB
| MUSB_TXCSR_DMAMODE
| MUSB_TXCSR_MODE);

if (!musb_ep->hb_mult)
csr |= MUSB_TXCSR_AUTOSET;
}
csr &= ~MUSB_TXCSR_P_UNDERRUN;

musb_writew(epio, MUSB_TXCSR, csr);
}
}
Expand Down Expand Up @@ -643,7 +645,8 @@ static void rxstate(struct musb *musb, struct musb_request *req)
*/

csr |= MUSB_RXCSR_DMAENAB;
csr |= MUSB_RXCSR_AUTOCLEAR;
if (!musb_ep->hb_mult)
csr |= MUSB_RXCSR_AUTOCLEAR;
#ifdef USE_MODE1
/* csr |= MUSB_RXCSR_DMAMODE; */

Expand Down Expand Up @@ -875,9 +878,25 @@ static int musb_gadget_enable(struct usb_ep *ep,

/* REVISIT this rules out high bandwidth periodic transfers */
tmp = le16_to_cpu(desc->wMaxPacketSize);
if (tmp & ~0x07ff)
goto fail;
musb_ep->packet_sz = tmp;
if (tmp & ~0x07ff) {
int ok;

if (usb_endpoint_dir_in(desc))
ok = musb->hb_iso_tx;
else
ok = musb->hb_iso_rx;

if (!ok) {
DBG(4, "%s: not support ISO high bandwidth\n", __func__);
goto fail;
}
musb_ep->hb_mult = (tmp >> 11) & 3;
} else {
musb_ep->hb_mult = 0;
}

musb_ep->packet_sz = tmp & 0x7ff;
tmp = musb_ep->packet_sz * (musb_ep->hb_mult + 1);

/* enable the interrupts for the endpoint, set the endpoint
* packet size (or fail), set the mode, clear the fifo
Expand All @@ -890,8 +909,11 @@ static int musb_gadget_enable(struct usb_ep *ep,
musb_ep->is_in = 1;
if (!musb_ep->is_in)
goto fail;
if (tmp > hw_ep->max_packet_sz_tx)

if (tmp > hw_ep->max_packet_sz_tx) {
DBG(4, "%s: packet size beyond hw fifo size\n", __func__);
goto fail;
}

int_txe |= (1 << epnum);
musb_writew(mbase, MUSB_INTRTXE, int_txe);
Expand All @@ -906,7 +928,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
if (musb->hwvers < MUSB_HWVERS_2000)
musb_writew(regs, MUSB_TXMAXP, hw_ep->max_packet_sz_tx);
else
musb_writew(regs, MUSB_TXMAXP, tmp);
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 All @@ -927,8 +949,11 @@ static int musb_gadget_enable(struct usb_ep *ep,
musb_ep->is_in = 0;
if (musb_ep->is_in)
goto fail;
if (tmp > hw_ep->max_packet_sz_rx)

if (tmp > hw_ep->max_packet_sz_rx) {
DBG(4, "%s: packet size beyond hw fifo size\n", __func__);
goto fail;
}

int_rxe |= (1 << epnum);
musb_writew(mbase, MUSB_INTRRXE, int_rxe);
Expand All @@ -942,7 +967,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
if (musb->hwvers < MUSB_HWVERS_2000)
musb_writew(regs, MUSB_RXMAXP, hw_ep->max_packet_sz_rx);
else
musb_writew(regs, MUSB_RXMAXP, tmp);
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
2 changes: 2 additions & 0 deletions drivers/usb/musb/musb_gadget.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ struct musb_ep {

/* true if lock must be dropped but req_list may not be advanced */
u8 busy;

u8 hb_mult;
};

static inline struct musb_ep *to_musb_ep(struct usb_ep *ep)
Expand Down

0 comments on commit f11d893

Please sign in to comment.