Hi,
On Thu, Nov 18, 2010 at 06:18:17PM +0800, Bob Liu wrote:
--- a/musb_gadget.c
+++ b/musb_gadget.c
@@ -919,7 +919,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
* to disable double buffering mode. Currently, It
seems that double
* buffering has problem if musb RTL revision number < 2.0.
*/
- if (musb->hwvers < MUSB_HWVERS_2000)
+ if (musb->hwvers < MUSB_HWVERS_2000 && musb->config->gpio_vrsel)
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));
@@ -958,7 +958,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)
+ if (musb->hwvers < MUSB_HWVERS_2000 && musb->config->gpio_vrsel)
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));
no, this is not acceptable. Also, you don't have the newest code on your
tree.
Anyways, try the patch below:
============= cut here ==================================================
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index fcb5206..dba1f63 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -397,6 +397,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
musb->xceiv->set_power = bfin_set_power;
musb->isr = blackfin_interrupt;
+ musb->double_buffer_not_ok = true;
return 0;
}
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index febaabc..05cf5ef 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -443,6 +443,19 @@ struct musb {
unsigned test_mode:1;
unsigned softconnect:1;
+ /*
+ * FIXME: Remove this flag.
+ *
+ * This is only added to allow Blackfin to work
+ * with current driver. For some unknown reason
+ * Blackfin doesn't work with double buffering
+ * and that's enabled by default.
+ *
+ * We added this flag to forcefully disable double
+ * buffering until we get it working.
+ */
+ unsigned double_buffer_not_ok:1 __deprecated;
+
u8 address;
u8 test_mode_nr;
u16 ackpend; /* ep0 */
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 363cfad..e354dfd 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -984,10 +984,18 @@ static int musb_gadget_enable(struct usb_ep *ep,
/* REVISIT if can_bulk_split(), use by updating "tmp";
* likewise high bandwidth periodic tx
*/
- /* Set TXMAXP with the FIFO size of the endpoint
- * to disable double buffering mode.
+
+ /*
+ * At least blackfin doesn't like Double Buffering
+ * which is enabled by default. So check if we can
+ * support double buffering and MaxPacket register
+ * accordingly.
*/
- musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11));
+ if (musb->double_buffer_not_ok)
+ musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz);
+ else
+ 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)
@@ -1020,10 +1028,18 @@ static int musb_gadget_enable(struct usb_ep *ep,
/* REVISIT if can_bulk_combine() use by updating "tmp"
* likewise high bandwidth periodic rx
*/
- /* Set RXMAXP with the FIFO size of the endpoint
- * to disable double buffering mode.
+
+ /*
+ * At least blackfin doesn't like Double Buffering
+ * which is enabled by default. So check if we can
+ * support double buffering and MaxPacket register
+ * accordingly.
*/
- musb_writew(regs, MUSB_RXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11));
+ if (musb->double_buffer_not_ok)
+ musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz);
+ else
+ musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz
+ | (musb_ep->hb_mult << 11));
/* force shared fifo to OUT-only mode */
if (hw_ep->is_shared_fifo) {
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 4d5bcb4..1e7baad 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -606,10 +606,11 @@ musb_rx_reinit(struct musb *musb, struct musb_qh *qh, struct musb_hw_ep *ep)
musb_writeb(ep->regs, MUSB_RXTYPE, qh->type_reg);
musb_writeb(ep->regs, MUSB_RXINTERVAL, qh->intv_reg);
/* NOTE: bulk combining rewrites high bits of maxpacket */
- /* Set RXMAXP with the FIFO size of the endpoint
+ /*
+ * Set RXMAXP with the FIFO size of the endpoint
* to disable double buffer mode.
*/
- if (musb->hwvers < MUSB_HWVERS_2000)
+ if (musb->double_buffer_not_ok)
musb_writew(ep->regs, MUSB_RXMAXP, ep->max_packet_sz_rx);
else
musb_writew(ep->regs, MUSB_RXMAXP,
@@ -784,14 +785,14 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
/* protocol/endpoint/interval/NAKlimit */
if (epnum) {
musb_writeb(epio, MUSB_TXTYPE, qh->type_reg);
- if (can_bulk_split(musb, qh->type))
+ if (musb->double_buffer_not_ok)
musb_writew(epio, MUSB_TXMAXP,
- packet_sz
- | ((hw_ep->max_packet_sz_tx /
- packet_sz) - 1) << 11);
+ hw_ep->max_packet_sz_tx);
else
musb_writew(epio, MUSB_TXMAXP,
- packet_sz);
+ qh->maxpacket |
+ ((qh->hb_mult - 1) << 11));
+
musb_writeb(epio, MUSB_TXINTERVAL, qh->intv_reg);
} else {
musb_writeb(epio, MUSB_NAKLIMIT0, qh->intv_reg);
ps: I'm marking that flag as deprecated and that *will* be removed on
2.6.40 merge window. Please get double buffering working on your
platform by that time. Let me know if you need help to get that done.
With a board and documentation I could find some time to help you handle
that.
--
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html