Skip to contentSkip to conversation

musb/tusb6010 fixes for host mode

PATCH In review Tony Lindgren 2 participants 16 messages May 3, 2007 – May 4, 2007 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): musb-2007-05-03-164131

#1 lore raw

cover musb/tusb6010 fixes for host mode

Hi all,

Here are some USB patches that make tusb6010 host mode work finally reliably on at least N800. Now all testusb cases pass with N800 running as a host.

Some of the patches should also help other musb devices.

I'd like to push them to linux-omap tree, so please test and comment.

Regards,

Tony

#2 lore raw

PATCH 1/1 MUSB_HDRC: Allow selecting OTG, peripheral or host mode via sysfs

This can be used on systems that don't use ID pin, or have mini-B connector.

For example, to force N800 into host mode with non-standard mini-B to mini-B cable connected to a powered hub:

Note that connected mini-A cable cannot be forced to peripheral mode as the ID pin is grounded by the cable. Also note that any VBUS load above the 100mA will cause the host mode to fail.

---
 drivers/usb/musb/musbdefs.h |    2 +
 drivers/usb/musb/plat_uds.c |   21 ++++++++++-
 drivers/usb/musb/tusb6010.c |   82 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 1 deletions(-)
drivers/usb/musb/musbdefs.h +2 -0
index f4be080..f641297 100644
@@ -506,9 +506,11 @@ extern void musb_platform_disable(struct musb *musb);
 #ifdef CONFIG_USB_TUSB6010
 extern void musb_platform_try_idle(struct musb *musb);
 extern int musb_platform_get_vbus_status(struct musb *musb);
+extern void musb_platform_set_mode(struct musb *musb, u8 musb_mode);
 #else
 #define musb_platform_try_idle(x)		do {} while (0)
 #define musb_platform_get_vbus_status(x)	0
+#define musb_platform_set_mode(x, y)		do {} while (0)
 #endif
 
 extern int __init musb_platform_init(struct musb *musb);
drivers/usb/musb/plat_uds.c +20 -1
index d208db8..14fbeba 100644
@@ -1511,7 +1511,26 @@ musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
 
 	return ret;
 }
-static DEVICE_ATTR(mode, S_IRUGO, musb_mode_show, NULL);
+
+static ssize_t
+musb_mode_store(struct device *dev, struct device_attribute *attr,
+		const char *buf, size_t n)
+{
+	struct musb	*musb = dev_to_musb(dev);
+	unsigned long	flags;
+
+	spin_lock_irqsave(&musb->Lock, flags);
+	if (!strncmp(buf, "host", 4))
+		musb_platform_set_mode(musb, MUSB_HOST);
+	if (!strncmp(buf, "peripheral", 10))
+		musb_platform_set_mode(musb, MUSB_PERIPHERAL);
+	if (!strncmp(buf, "otg", 3))
+		musb_platform_set_mode(musb, MUSB_OTG);
+	spin_unlock_irqrestore(&musb->Lock, flags);
+
+	return n;
+}
+static DEVICE_ATTR(mode, 0644, musb_mode_show, musb_mode_store);
 
 static ssize_t
 musb_cable_show(struct device *dev, struct device_attribute *attr, char *buf)
drivers/usb/musb/tusb6010.c +82 -0

88 lines not on this page · raw message

Signature · 1 line
1.4.4.2
#3 lore raw

PATCH 1/1 musb_hdrc: Enable host DMA for tusb6010

This patch allows host to try to use DMA on tusb6010.

Please note that until tusb6010 DMA size limitations are fixed, DMA happens with host side rarely.

---
 drivers/usb/musb/musb_host.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/usb/musb/musb_host.c +3 -3
index ef473e9..440df48 100644
@@ -236,7 +236,7 @@ start:
 
 		if (!pEnd->tx_channel)
 			musb_h_tx_start(pEnd);
-		else if (is_cppi_enabled())
+		else if (is_cppi_enabled() || tusb_dma_omap())
 			cppi_host_txdma_start(pEnd);
 	}
 }
@@ -806,7 +806,7 @@ static void musb_ep_program(struct musb *pThis, u8 bEnd,
 #endif
 
 		/* candidate for DMA */
-		if (is_cppi_enabled() && pDmaChannel) {
+		if ((is_cppi_enabled() || tusb_dma_omap()) && pDmaChannel) {
 
 			/* program endpoint CSRs first, then setup DMA.
 			 * assume CPPI setup succeeds.
@@ -897,7 +897,7 @@ static void musb_ep_program(struct musb *pThis, u8 bEnd,
 
 		/* kick things off */
 
-		if (is_cppi_enabled()) {
+		if ((is_cppi_enabled() || tusb_dma_omap()) && pDmaChannel) {
 			/* candidate for DMA */
 			if (pDmaChannel) {
 				pDmaChannel->dwActualLength = 0L;
Signature · 1 line
1.4.4.2
#4 lore raw

PATCH 1/1 musb_hdrc: Allow tusb dma to transfer various data sizes

With this patch tusb can transfer sizes that are not multiples of 32 bytes.

---
 drivers/usb/musb/tusb6010_omap.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)
drivers/usb/musb/tusb6010_omap.c +19 -8
index 07f9efe..8e864d6 100644
@@ -171,7 +171,22 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
 	remaining = TUSB_EP_CONFIG_XFR_SIZE(remaining);
 	channel->dwActualLength = chdat->transfer_len - remaining;
 
-	DBG(2, "remaining %lu/%u\n", remaining, chdat->transfer_len);
+	DBG(2, "DMA remaining %lu/%u\n", remaining, chdat->transfer_len);
+
+	/* Transfer remaining 1 - 31 bytes if DMA worked */
+	if (remaining == 0) {
+		u32	pio;
+		u8	*buf;
+
+		pio = chdat->len - channel->dwActualLength;
+		buf = phys_to_virt((u32)chdat->dma_addr)
+				+ chdat->transfer_len;
+		if (chdat->tx)
+			musb_write_fifo(hw_ep, pio, buf);
+		else
+			musb_read_fifo(hw_ep, pio, buf);
+		channel->dwActualLength += pio;
+	}
 
 	if (!dmareq_works())
 		tusb_omap_free_shared_dmareq(chdat);
@@ -224,14 +239,10 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
 	s8				dmareq;
 	s8				sync_dev;
 
-	if (unlikely(dma_addr & 0x1))
-		return FALSE;
-	if (len < 32)
-		return FALSE;
-	if ((len % 32 != 0))
+	if (unlikely(dma_addr & 0x1) || len < 32)
 		return FALSE;
-	else
-		chdat->transfer_len = len;
+
+	chdat->transfer_len = len & ~0x1f;
 
 	if (len < packet_sz)
 		chdat->transfer_packet_sz = chdat->transfer_len;
Signature · 1 line
1.4.4.2
#5 lore raw

PATCH 1/1 musb_hdrc: Transfer remaining bytes with PIO

DMA callback can manually transfer remaining 1 - 31 bytes after DMA transfer using PIO. This allows transferring a wider range of sizes with DMA.

---
 drivers/usb/musb/tusb6010_omap.c |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)
drivers/usb/musb/tusb6010_omap.c +15 -11
index 8e864d6..1d9d80f 100644
@@ -146,7 +146,7 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
 	struct musb_hw_ep	*hw_ep = chdat->hw_ep;
 	void __iomem		*ep_conf = hw_ep->conf;
 	void __iomem		*musb_base = musb->pRegs;
-	unsigned long		remaining, flags;
+	unsigned long		remaining, flags, pio;
 	int			ch;
 
 	spin_lock_irqsave(&musb->Lock, flags);
@@ -170,21 +170,25 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
 
 	remaining = TUSB_EP_CONFIG_XFR_SIZE(remaining);
 	channel->dwActualLength = chdat->transfer_len - remaining;
+	pio = chdat->len - channel->dwActualLength;
 
 	DBG(2, "DMA remaining %lu/%u\n", remaining, chdat->transfer_len);
 
-	/* Transfer remaining 1 - 31 bytes if DMA worked */
-	if (remaining == 0) {
-		u32	pio;
+	/* Transfer remaining 1 - 31 bytes */
+	if (pio > 0 && pio < 32) {
 		u8	*buf;
 
-		pio = chdat->len - channel->dwActualLength;
-		buf = phys_to_virt((u32)chdat->dma_addr)
-				+ chdat->transfer_len;
-		if (chdat->tx)
+		DBG(2, "Using PIO for remaining %i bytes\n", pio);
+		buf = phys_to_virt((u32)chdat->dma_addr) + chdat->transfer_len;
+		if (chdat->tx) {
+			consistent_sync(phys_to_virt((u32)chdat->dma_addr),
+					chdat->transfer_len, DMA_TO_DEVICE);
 			musb_write_fifo(hw_ep, pio, buf);
-		else
+		} else {
 			musb_read_fifo(hw_ep, pio, buf);
+			consistent_sync(phys_to_virt((u32)chdat->dma_addr),
+					chdat->transfer_len, DMA_FROM_DEVICE);
+		}
 		channel->dwActualLength += pio;
 	}
 
@@ -201,7 +205,7 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
 	if (!chdat->tx)
 		musb_dma_completion(musb, chdat->epnum, chdat->tx);
 
-	/* We musb terminate short tx transfers manually by setting TXPKTRDY.
+	/* We must terminate short tx transfers manually by setting TXPKTRDY.
 	 * REVISIT: This same problem may occur with other MUSB dma as well.
 	 * Easy to test with g_ether by pinging the MUSB board with ping -s54.
 	 */
@@ -239,7 +243,7 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
 	s8				dmareq;
 	s8				sync_dev;
 
-	if (unlikely(dma_addr & 0x1) || len < 32)
+	if (unlikely(dma_addr & 0x1) || (len < 32) || (len > packet_sz))
 		return FALSE;
 
 	chdat->transfer_len = len & ~0x1f;
Signature · 1 line
1.4.4.2
#6 lore raw

PATCH 1/1 musb_hdrc: DMA RX workaround for tusb6010

Async RX DMA on tusb6010 will eventually corrupt the XFR_SIZE register. This patch blocks DMA transfers for async RX DMA.

---
 drivers/usb/musb/tusb6010_omap.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
drivers/usb/musb/tusb6010_omap.c +16 -0
index 1d9d80f..1ca6a3a 100644
@@ -169,6 +169,13 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
 		remaining = musb_readl(ep_conf, TUSB_EP_RX_OFFSET);
 
 	remaining = TUSB_EP_CONFIG_XFR_SIZE(remaining);
+
+	/* HW issue #10: XFR_SIZE may get corrupt on async DMA */
+	if (unlikely(remaining > chdat->transfer_len)) {
+		WARN("Corrupt XFR_SIZE with async DMA: %lu\n", remaining);
+		remaining = 0;
+	}
+
 	channel->dwActualLength = chdat->transfer_len - remaining;
 	pio = chdat->len - channel->dwActualLength;
 
@@ -246,6 +253,15 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
 	if (unlikely(dma_addr & 0x1) || (len < 32) || (len > packet_sz))
 		return FALSE;
 
+	/*
+	 * HW issue #10: Async dma will eventually corrupt the XFR_SIZE
+	 * register which will cause missed DMA interrupt. We could try to
+	 * use a timer for the callback, but it is unsafe as the XFR_SIZE
+	 * register is corrupt, and we won't know if the DMA worked.
+	 */
+	if (dma_addr & 0x2)
+		return FALSE;
+
 	chdat->transfer_len = len & ~0x1f;
 
 	if (len < packet_sz)
Signature · 1 line
1.4.4.2
#7 lore raw

PATCH 1/1 musb_hdrc: Stop host session on BABBLE

Babble is a non-recoverable error condition and we need to fix whatever causes it. Stop the session on BABBLE to make debugging the cause of BABBLE possible.

---
 drivers/usb/musb/plat_uds.c |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)
drivers/usb/musb/plat_uds.c +7 -12
index 14fbeba..86dd6b2 100644
@@ -534,19 +534,14 @@ static irqreturn_t musb_stage0_irq(struct musb * pThis, u8 bIntrUSB,
 	 */
 	if (bIntrUSB & MGC_M_INTR_RESET) {
 		if (devctl & MGC_M_DEVCTL_HM) {
-			DBG(1, "BABBLE\n");
-
-			/* REVISIT it's unclear how to handle this.  Mentor's
-			 * code stopped the whole USB host, which is clearly
-			 * very wrong.  Docs say (15.1) that babble ends the
-			 * current sesssion, so shutdown _with restart_ would
-			 * be appropriate ... except that seems to be wrong,
-			 * at least some lowspeed enumerations trigger the
-			 * babbles without aborting the session!
-			 *
-			 * (A "babble" IRQ seems quite pointless...)
+			/*
+			 * BABBLE is an error condition, so the solution is
+			 * to avoid babble in the first place and fix whatever
+			 * causes BABBLE. When BABBLE happens we can only stop
+			 * the session.
 			 */
-
+			ERR("Stopping host session because of babble\n");
+			musb_writeb(pBase, MGC_O_HDRC_DEVCTL, 0);
 		} else {
 			DBG(1, "BUS RESET\n");
 
Signature · 1 line
1.4.4.2
#8 lore raw

PATCH 1/1 musb_hdrc: Avoid host babble by checking tx fifo

Running a tusb6010 system in host mode would fail with testusb -a -t12 -c1 most of the time with BABBLE errors.

Turns out this was caused by incorrect handling of TX FIFONOTEMPTY, where the code did not wait for it to clear.

This patch introduces musb_h_tx_flush_fifo(), and makes musb_host.c to use it.

---
 drivers/usb/musb/musb_host.c |   58 +++++++++++++++++++++++++++--------------
 1 files changed, 38 insertions(+), 20 deletions(-)
drivers/usb/musb/musb_host.c +38 -20
index 440df48..82ece3b 100644
@@ -108,6 +108,29 @@ static void musb_ep_program(struct musb *pThis, u8 bEnd,
 			u8 * pBuffer, u32 dwLength);
 
 /*
+ * Clear TX fifo. Needed to avoid BABBLE errors.
+ */
+static inline void musb_h_tx_flush_fifo(struct musb_hw_ep *ep)
+{
+	void __iomem	*epio = ep->regs;
+	u16		csr;
+	int		retries = 1000;
+
+	csr = musb_readw(epio, MGC_O_HDRC_TXCSR);
+	while (csr & MGC_M_TXCSR_FIFONOTEMPTY) {
+		DBG(5, "Host TX FIFONOTEMPTY csr: %02x\n", csr);
+		csr |= MGC_M_TXCSR_FLUSHFIFO;
+		musb_writew(epio, MGC_O_HDRC_TXCSR, csr);
+		csr = musb_readw(epio, MGC_O_HDRC_TXCSR);
+		if (retries-- < 1) {
+			ERR("Could not flush host TX fifo: csr: %04x\n", csr);
+			return;
+		}
+		mdelay(1);
+	}
+}
+
+/*
  * Start transmit. Caller is responsible for locking shared resources.
  * pThis must be locked.
  */
@@ -570,14 +593,9 @@ musb_rx_reinit(struct musb *musb, struct musb_qh *qh, struct musb_hw_ep *ep)
 	if (ep->bIsSharedFifo) {
 		csr = musb_readw(ep->regs, MGC_O_HDRC_TXCSR);
 		if (csr & MGC_M_TXCSR_MODE) {
-			if (csr & MGC_M_TXCSR_FIFONOTEMPTY) {
-				/* this shouldn't happen; irq?? */
-				ERR("shared fifo not empty?\n");
-				musb_writew(ep->regs, MGC_O_HDRC_TXCSR,
-						MGC_M_TXCSR_FLUSHFIFO);
-				musb_writew(ep->regs, MGC_O_HDRC_TXCSR,
-						MGC_M_TXCSR_FRCDATATOG);
-			}
+			musb_h_tx_flush_fifo(ep);
+			musb_writew(ep->regs, MGC_O_HDRC_TXCSR,
+					MGC_M_TXCSR_FRCDATATOG);
 		}
 		/* clear mode (and everything else) to enable Rx */
 		musb_writew(ep->regs, MGC_O_HDRC_TXCSR, 0);
@@ -683,14 +701,12 @@ static void musb_ep_program(struct musb *pThis, u8 bEnd,
 			/* ASSERT:  TXCSR_DMAENAB was already cleared */
 
 			/* flush all old state, set default */
-			if (csr & MGC_M_TXCSR_FIFONOTEMPTY)
-				csr |= MGC_M_TXCSR_FLUSHFIFO;
+			musb_h_tx_flush_fifo(pEnd);
 			csr &= ~(MGC_M_TXCSR_H_NAKTIMEOUT
 					| MGC_M_TXCSR_DMAMODE
 					| MGC_M_TXCSR_FRCDATATOG
 					| MGC_M_TXCSR_H_RXSTALL
 					| MGC_M_TXCSR_H_ERROR
-					| MGC_M_TXCSR_FIFONOTEMPTY
 					| MGC_M_TXCSR_TXPKTRDY
 					);
 			csr |= MGC_M_TXCSR_MODE;
@@ -1229,11 +1245,8 @@ void musb_host_tx(struct musb *pThis, u8 bEnd)
 		/* do the proper sequence to abort the transfer in the
 		 * usb core; the dma engine should already be stopped.
 		 */
-// SCRUB (TX)
-		if (wTxCsrVal & MGC_M_TXCSR_FIFONOTEMPTY)
-			wTxCsrVal |= MGC_M_TXCSR_FLUSHFIFO;
-		wTxCsrVal &= ~(MGC_M_TXCSR_FIFONOTEMPTY
-				| MGC_M_TXCSR_AUTOSET
+		musb_h_tx_flush_fifo(pEnd);
+		wTxCsrVal &= ~(MGC_M_TXCSR_AUTOSET
 				| MGC_M_TXCSR_DMAENAB
 				| MGC_M_TXCSR_H_ERROR
 				| MGC_M_TXCSR_H_RXSTALL
@@ -1949,16 +1962,13 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh, int is_in)
 		 * clearing that status is platform-specific...
 		 */
 	} else {
-// SCRUB (TX)
+		musb_h_tx_flush_fifo(ep);
 		csr = musb_readw(epio, MGC_O_HDRC_TXCSR);
-		if (csr & MGC_M_TXCSR_FIFONOTEMPTY)
-			csr |= MGC_M_TXCSR_FLUSHFIFO;
 		csr &= ~( MGC_M_TXCSR_AUTOSET
 			| MGC_M_TXCSR_DMAENAB
 			| MGC_M_TXCSR_H_RXSTALL
 			| MGC_M_TXCSR_H_NAKTIMEOUT
 			| MGC_M_TXCSR_H_ERROR
-			| MGC_M_TXCSR_FIFONOTEMPTY
 			);
 		musb_writew(epio, MGC_O_HDRC_TXCSR, csr);
 		/* REVISIT may need to clear FLUSHFIFO ... */
@@ -2002,6 +2012,14 @@ static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
 		}
 	}
 	spin_unlock(&urb->lock);
+
+	/* already completed */
+	if (!qh) {
+		status = 0;
+		goto done;
+	}
+
+	/* still queued but not found on the list */
 	if (status)
 		goto done;
 
Signature · 1 line
1.4.4.2
#9 lore raw

PATCH 1/1 musb_hdrc: Clean-up TUSB fifo access

I found one more patch in addition to these seven patches that has been pending a while but never got pushed because of the remaining flakeyness. Seems to work just fine.

Tony

Quoted 1 line

From be9d415b172e8c3fb375058ef3a35aca95192233 Mon Sep 17 00:00:00 2001

From: Tony Lindgren <[email protected]>
Date: Thu, 3 May 2007 18:31:35 +0000
Subject: [PATCH] musb_hdrc: Clean-up TUSB fifo access

This patch cleans-up TUSB fifo access and uses readsl/writesl() when possible. It also has hooks for some further optimization, notably synchronous burst access using PIO.

---
 drivers/usb/musb/musbdefs.h |    2 +
 drivers/usb/musb/plat_uds.c |    3 +
 drivers/usb/musb/tusb6010.c |  170 ++++++++++++++++++++++++++-----------------
 3 files changed, 108 insertions(+), 67 deletions(-)
drivers/usb/musb/musbdefs.h +2 -0
index f641297..a64e2ed 100644
@@ -296,6 +296,7 @@ struct musb_hw_ep {
 	/* TUSB has "asynchronous" and "synchronous" dma modes */
 	dma_addr_t		fifo_async;
 	dma_addr_t		fifo_sync;
+	void __iomem		*fifo_sync_va;
 #endif
 
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
@@ -381,6 +382,7 @@ struct musb {
 #ifdef CONFIG_USB_TUSB6010
 	dma_addr_t		async;
 	dma_addr_t		sync;
+	void __iomem		*sync_va;
 #endif
 
 	/* passed down from chip/board specific irq handlers */
drivers/usb/musb/plat_uds.c +3 -0
index 86dd6b2..856075f 100644
@@ -1269,6 +1269,9 @@ static int __init musb_core_init(u16 wType, struct musb *pThis)
 #ifdef CONFIG_USB_TUSB6010
 		hw_ep->fifo_async = pThis->async + 0x400 + MUSB_FIFO_OFFSET(i);
 		hw_ep->fifo_sync = pThis->sync + 0x400 + MUSB_FIFO_OFFSET(i);
+		hw_ep->fifo_sync_va =
+			pThis->sync_va + 0x400 + MUSB_FIFO_OFFSET(i);
+
 		if (i == 0)
 			hw_ep->conf = pBase - 0x400 + TUSB_EP0_CONF;
 		else
drivers/usb/musb/tusb6010.c +103 -67

231 lines not on this page · raw message

Signature · 1 line
1.4.4.2
#10 lore raw

Re: [PATCH] musb_hdrc: Enable host DMA for tusb6010

In reply to Tony Lindgren
Quoted 1 line · Tony Lindgren

This patch allows host to try to use DMA on tusb6010.

Here's an updated version of this to fix the compile problem Kevin pointed out on non-tusb systems.

Tony

Quoted 1 line

From cac0b797100c284366305471b8d12ca7daa73861 Mon Sep 17 00:00:00 2001

From: Tony Lindgren <[email protected]>
Date: Tue, 6 Feb 2007 15:41:54 -0800
Subject: [PATCH] musb_hdrc: Enable host DMA for tusb6010

This patch allows host to try to use DMA on tusb6010.

Please note that until tusb6010 DMA size limitations are fixed, DMA happens with host side rarely.

---
 drivers/usb/musb/musb_host.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/usb/musb/musb_host.c +3 -3
@@ -236,7 +236,7 @@ start:
 
 		if (!pEnd->tx_channel)
 			musb_h_tx_start(pEnd);
-		else if (is_cppi_enabled())
+		else if (is_cppi_enabled() || tusb_dma_omap())
 			cppi_host_txdma_start(pEnd);
 	}
 }
@@ -806,7 +806,7 @@ static void musb_ep_program(struct musb 
 #endif
 
 		/* candidate for DMA */
-		if (is_cppi_enabled() && pDmaChannel) {
+		if ((is_cppi_enabled() || tusb_dma_omap()) && pDmaChannel) {
 
 			/* program endpoint CSRs first, then setup DMA.
 			 * assume CPPI setup succeeds.
@@ -897,7 +897,7 @@ static void musb_ep_program(struct musb 
 
 		/* kick things off */
 
-		if (is_cppi_enabled()) {
+		if ((is_cppi_enabled() || tusb_dma_omap()) && pDmaChannel) {
 			/* candidate for DMA */
 			if (pDmaChannel) {
 				pDmaChannel->dwActualLength = 0L;
drivers/usb/musb/dma.h +5 -0
@@ -73,6 +73,11 @@ struct musb_hw_ep;
 #define	is_cppi_enabled()	0
 #endif
 
+#ifdef CONFIG_USB_TUSB_OMAP_DMA
+#define tusb_dma_omap()			1
+#else
+#define tusb_dma_omap()			0
+#endif
 
 /*
  * DMA channel status ... updated by the dma controller driver whenever that
#11 lore raw
In reply to Tony Lindgren
Quoted 3 lines · Tony Lindgren

Here are some USB patches that make tusb6010 host mode work finally reliably on at least N800. Now all testusb cases pass with N800 running as a host.

Tony,

There are some uses of tusb_dma_omap() that are not defined when compiling for !tusb platforms. The hack below gets it to compile on 2430, but is probably not "the right thing."

Also, with your fixes, it's still not working on 2430. Looks like I have some more digging to do.

Kevin

drivers/usb/musb/musbdefs.h +4 -0
Index: dev/drivers/usb/musb/musbdefs.h
===================================================================
@@ -518,6 +518,10 @@ extern void musb_platform_set_mode(struc
 extern int __init musb_platform_init(struct musb *musb);
 extern int musb_platform_exit(struct musb *musb);
 
+#ifndef tusb_dma_omap
+#define tusb_dma_omap() 0
+#endif
+
 /*-------------------------- ProcFS definitions ---------------------*/
 
 struct proc_dir_entry;
#12 lore raw
Quoted 11 lines · Kevin Hilman
Quoted 3 lines · Tony Lindgren

Here are some USB patches that make tusb6010 host mode work finally reliably on at least N800. Now all testusb cases pass with N800 running as a host.

Tony,

There are some uses of tusb_dma_omap() that are not defined when compiling for !tusb platforms. The hack below gets it to compile on 2430, but is probably not "the right thing."

Thanks, looks like I missed that. That's how it should be :) I'll push it today.

Quoted 2 lines

Also, with your fixes, it's still not working on 2430. Looks like I have some more digging to do.

Is the peripheral working OK?

Tony

#13 lore raw
Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Kevin Hilman
Quoted 3 lines · Tony Lindgren

Here are some USB patches that make tusb6010 host mode work finally reliably on at least N800. Now all testusb cases pass with N800 running as a host.

Quoted 8 lines
Quoted 5 lines

Tony,

There are some uses of tusb_dma_omap() that are not defined when compiling for !tusb platforms. The hack below gets it to compile on 2430, but is probably not "the right thing."

Thanks, looks like I missed that. That's how it should be :) I'll push it today.

Actually, I'll just move the #define tusb_dma_omap() to dma.h there.

Tony

#14 lore raw
In reply to Tony Lindgren
Quoted 7 lines · Tony Lindgren
Quoted 2 lines · Kevin Hilman

Also, with your fixes, it's still not working on 2430. Looks like I have some more digging to do.

Is the peripheral working OK?

Yes.

#15 lore raw
Quoted 10 lines · Kevin Hilman
Quoted 7 lines · Tony Lindgren
Quoted 2 lines · Kevin Hilman

Also, with your fixes, it's still not working on 2430. Looks like I have some more digging to do.

Is the peripheral working OK?

Yes.

And that's the musb peripheral, not the built in omap_udc, right? Assuming it has both...

Tony

#16 lore raw
In reply to Tony Lindgren
Quoted 10 lines · Tony Lindgren

Hi all,

Here are some USB patches that make tusb6010 host mode work finally reliably on at least N800. Now all testusb cases pass with N800 running as a host.

Some of the patches should also help other musb devices.

I'd like to push them to linux-omap tree, so please test and comment.

Pushed these.

Tony