2009-09-16 23:38:46

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 01/11] USB: musb: tweak musb_read_fifo() to avoid unused warnings

Otherwise gcc will whine about epnum/dma_reg being unused when building
for BF54x parts.

Signed-off-by: Mike Frysinger <[email protected]>
Signed-off-by: Bryan Wu <[email protected]>
Signed-off-by: Cliff Cai <[email protected]>
---
drivers/usb/musb/blackfin.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index f2f66eb..80c765e 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -54,13 +54,11 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
{
void __iomem *fifo = hw_ep->fifo;
+
+#ifdef CONFIG_BF52x
u8 epnum = hw_ep->epnum;
u16 dma_reg = 0;

- DBG(4, "%cX ep%d fifo %p count %d buf %p\n",
- 'R', hw_ep->epnum, fifo, len, dst);
-
-#ifdef CONFIG_BF52x
invalidate_dcache_range((unsigned int)dst,
(unsigned int)(dst + len));

@@ -103,6 +101,9 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
len & 0x01 ? (len >> 1) + 1 : len >> 1);
#endif

+ DBG(4, "%cX ep%d fifo %p count %d buf %p\n",
+ 'R', hw_ep->epnum, fifo, len, dst);
+
dump_fifo_data(dst, len);
}

--
1.6.5.rc1


2009-09-16 23:40:46

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 02/11] USB: musb: kill compile warning for Blackfin systems

From: Bryan Wu <[email protected]>

The Blackfin version of musb_read_target_reg_base() returns a u16 when the
common code expects a (void __iomem *), so update the Blackfin function to
return the right value. This fixes the compile warning:

drivers/usb/musb/musb_core.c: In function 'musb_core_init':
drivers/usb/musb/musb_core.c:1448: warning: assignment makes pointer from
integer without a cast

Signed-off-by: Bryan Wu <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
drivers/usb/musb/musb_regs.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h
index fbfd3fd..0154e38 100644
--- a/drivers/usb/musb/musb_regs.h
+++ b/drivers/usb/musb/musb_regs.h
@@ -474,9 +474,9 @@ static inline u16 musb_read_hwvers(void __iomem *mbase)
return 0;
}

-static inline u16 musb_read_target_reg_base(u8 i, void __iomem *mbase)
+static inline void __iomem *musb_read_target_reg_base(u8 i, void __iomem *mbase)
{
- return 0;
+ return NULL;
}

static inline void musb_write_rxfunaddr(void __iomem *ep_target_regs,
--
1.6.5.rc1

2009-09-16 23:40:56

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 03/11] USB: musb: kill some useless comments in Blackfin driver

From: Bryan Wu <[email protected]>

Signed-off-by: Bryan Wu <[email protected]>
Signed-off-by: Cliff Cai <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
drivers/usb/musb/blackfin.c | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 80c765e..bbee5f6 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -263,10 +263,6 @@ int __init musb_platform_init(struct musb *musb)
SSYNC();
}

- /* TODO
- * Set SIC-IVG register
- */
-
/* Configure PLL oscillator register */
bfin_write_USB_PLLOSC_CTRL(0x30a8);
SSYNC();
--
1.6.5.rc1

2009-09-16 23:38:51

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 04/11] USB: musb: update Blackfin processor dependency

From: Sonic Zhang <[email protected]>

Do not allow MUSB driver to be selected on derivatives that don't have the
MUSB controller on them.

Signed-off-by: Sonic Zhang <[email protected]>
Signed-off-by: Bryan Wu <[email protected]>
Signed-off-by: Cliff Cai <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
drivers/usb/musb/Kconfig | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 803adcb..2fb3216 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -10,6 +10,7 @@ comment "Enable Host or Gadget support to see Inventra options"
config USB_MUSB_HDRC
depends on (USB || USB_GADGET) && HAVE_CLK
depends on !SUPERH
+ depends on !BLACKFIN || (BF54x && !BF544) || (BF52x && !BF522 && !BF523)
select NOP_USB_XCEIV if ARCH_DAVINCI
select TWL4030_USB if MACH_OMAP_3430SDP
select NOP_USB_XCEIV if MACH_OMAP3EVM
--
1.6.5.rc1

2009-09-16 23:40:05

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 05/11] USB: musb: add notes for Blackfin anomalies

From: Sonic Zhang <[email protected]>

Add some helpful notes about how the driver works around different
anomalies that exist in the on-chip host controller.

Signed-off-by: Sonic Zhang <[email protected]>
Signed-off-by: Cliff Cai <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
drivers/usb/musb/blackfin.h | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/musb/blackfin.h b/drivers/usb/musb/blackfin.h
index a240c1e..de62962 100644
--- a/drivers/usb/musb/blackfin.h
+++ b/drivers/usb/musb/blackfin.h
@@ -14,6 +14,35 @@
* Blackfin specific definitions
*/

+/* Anomalies notes:
+ *
+ * 05000450 - USB DMA Mode 1 Short Packet Data Corruption:
+ * MUSB driver is designed to transfer buffer of N * maxpacket size
+ * in DMA mode 1 and leave rest data to the next transfer in DMA
+ * mode 0, so we never transmit a short packet in DMA mode 1.
+ *
+ * 05000463 - This anomaly doesn't affect this driver,Since it
+ * never uses L1 or L2 memory as data destination.
+ *
+ * 05000464 - This anomaly doesn't affect this driver,Since it
+ * never uses L1 or L2 memory as data source.
+ *
+ * 05000465 - Actually,the anomaly still can be seen when SCLK
+ * is over 100 MHz,and there is no way to workaround
+ * for bulk endpoints,because the wMaxPackSize of bulk
+ * is less than or equal to 512,while the fifo size of
+ * endpoint 5,6,7 is 1024,the double buffer mode is
+ * enabled automatically when these endpoints are used
+ * for bulk OUT.
+ *
+ * 05000466 - This anomaly doesn't affect this driver,Since it
+ * never mixs concurrent DMA and core accesses to the
+ * TX endpoint FIFOs.
+ *
+ * 05000467 - The workaround for this anomaly will introduce another
+ * anomaly - 05000465.
+ */
+
#undef DUMP_FIFO_DATA
#ifdef DUMP_FIFO_DATA
static void dump_fifo_data(u8 *buf, u16 len)
--
1.6.5.rc1

2009-09-16 23:40:25

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 06/11] USB: musb: add work around for Blackfin anomaly 05000456

From: Sonic Zhang <[email protected]>

Only allow USE_MODE1 when the Blackfin part is not affected by anomaly
05000456 (USB Receive Interrupt Is Not Generated in DMA Mode 1) since we
can't support the mode in that case.

Signed-off-by: Sonic Zhang <[email protected]>
Signed-off-by: Cliff Cai <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
drivers/usb/musb/musb_dma.h | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h
index 0a2c4e3..916065b 100644
--- a/drivers/usb/musb/musb_dma.h
+++ b/drivers/usb/musb/musb_dma.h
@@ -80,6 +80,17 @@ struct musb_hw_ep;
#define tusb_dma_omap() 0
#endif

+/* Anomaly 05000456 - USB Receive Interrupt Is Not Generated in DMA Mode 1
+ * Only allow DMA mode 1 to be used when the USB will actually generate the
+ * interrupts we expect.
+ */
+#ifdef CONFIG_BLACKFIN
+# undef USE_MODE1
+# if !ANOMALY_05000456
+# define USE_MODE1
+# endif
+#endif
+
/*
* DMA channel status ... updated by the dma controller driver whenever that
* status changes, and protected by the overall controller spinlock.
--
1.6.5.rc1

2009-09-16 23:38:56

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 07/11] USB: musb: fix musb_platform_set_mode() definition

From: Bryan Wu <[email protected]>

Update function definition to match latest MUSB framework.

Signed-off-by: Bryan Wu <[email protected]>
Signed-off-by: Cliff Cai <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
drivers/usb/musb/blackfin.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index bbee5f6..db099e2 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -227,8 +227,9 @@ int musb_platform_get_vbus_status(struct musb *musb)
return 0;
}

-void musb_platform_set_mode(struct musb *musb, u8 musb_mode)
+int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
{
+ return -EIO;
}

int __init musb_platform_init(struct musb *musb)
--
1.6.5.rc1

2009-09-16 23:39:51

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 08/11] USB: musb: clear the Blackfin interrupt pending bits early in the ISR

From: Cliff Cai <[email protected]>

If we clear the interrupt pending bits at the end, we sometimes return too
fast and have the same interrupt assert itself. There is no way in a
Blackfin system to force a sync of this state, so the hardware manual
instructs people to clear interrupt flags early in their ISR.

Signed-off-by: Cliff Cai <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
drivers/usb/musb/musbhsdma.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 5e83f96..c767387 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -259,6 +259,11 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
if (!int_hsdma)
goto done;

+#ifdef CONFIG_BLACKFIN
+ /* Clear DMA interrupt flags */
+ musb_writeb(mbase, MUSB_HSDMA_INTR, int_hsdma);
+#endif
+
for (bchannel = 0; bchannel < MUSB_HSDMA_CHANNELS; bchannel++) {
if (int_hsdma & (1 << bchannel)) {
musb_channel = (struct musb_dma_channel *)
@@ -324,11 +329,6 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
}
}

-#ifdef CONFIG_BLACKFIN
- /* Clear DMA interrup flags */
- musb_writeb(mbase, MUSB_HSDMA_INTR, int_hsdma);
-#endif
-
retval = IRQ_HANDLED;
done:
spin_unlock_irqrestore(&musb->lock, flags);
--
1.6.5.rc1

2009-09-16 23:39:00

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 09/11] USB: musb: error out when anomaly 05000380 is applicable

From: Sonic Zhang <[email protected]>

Since we can't work around anomaly 05000380, throw a build error up and
instruct the user to use a different mode.

Signed-off-by: Sonic Zhang <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
drivers/usb/musb/blackfin.h | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/musb/blackfin.h b/drivers/usb/musb/blackfin.h
index de62962..21b7730 100644
--- a/drivers/usb/musb/blackfin.h
+++ b/drivers/usb/musb/blackfin.h
@@ -43,6 +43,16 @@
* anomaly - 05000465.
*/

+/* The Mentor USB DMA engine on BF52x (silicon v0.0 and v0.1) seems to be
+ * unstable in host mode. This may be caused by Anomaly 05000380. After
+ * digging out the root cause, we will change this number accordingly.
+ * So, need to either use silicon v0.2+ or disable DMA mode in MUSB.
+ */
+#if ANOMALY_05000380 && defined(CONFIG_BF52x) && \
+ defined(CONFIG_USB_MUSB_HDRC) && !defined(CONFIG_MUSB_PIO_ONLY)
+# error "Please use PIO mode in MUSB driver on bf52x chip v0.0 and v0.1"
+#endif
+
#undef DUMP_FIFO_DATA
#ifdef DUMP_FIFO_DATA
static void dump_fifo_data(u8 *buf, u16 len)
--
1.6.5.rc1

2009-09-16 23:39:20

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 10/11] USB: musb: Blackfin code needs NOP_USB_XCEIV too

From: Cliff Cai <[email protected]>

Otherwise we get the link failure:
drivers/built-in.o: In function 'musb_platform_init':
drivers/usb/musb/blackfin.c:300: undefined reference to 'usb_nop_xceiv_register'
make: *** [.tmp_vmlinux1] Error 1

Signed-off-by: Cliff Cai <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
drivers/usb/musb/Kconfig | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 2fb3216..06135a1 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -11,9 +11,8 @@ config USB_MUSB_HDRC
depends on (USB || USB_GADGET) && HAVE_CLK
depends on !SUPERH
depends on !BLACKFIN || (BF54x && !BF544) || (BF52x && !BF522 && !BF523)
- select NOP_USB_XCEIV if ARCH_DAVINCI
+ select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN)
select TWL4030_USB if MACH_OMAP_3430SDP
- select NOP_USB_XCEIV if MACH_OMAP3EVM
select USB_OTG_UTILS
tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
help
--
1.6.5.rc1

2009-09-16 23:39:38

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 11/11] USB: musb: fix printf warning in debug code

The debug code in the DMA ISR uses a %d for a size_t when it should be
using %zu. Otherwise gcc whines with:

drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
drivers/usb/musb/musbhsdma.c:288: warning: format '%d' expects type 'int',
but argument 7 has type 'size_t'

Signed-off-by: Mike Frysinger <[email protected]>
---
drivers/usb/musb/musbhsdma.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index c767387..a237550 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -285,7 +285,7 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
channel->actual_len = addr
- musb_channel->start_addr;

- DBG(2, "ch %p, 0x%x -> 0x%x (%d / %d) %s\n",
+ DBG(2, "ch %p, 0x%x -> 0x%x (%zu / %d) %s\n",
channel, musb_channel->start_addr,
addr, channel->actual_len,
musb_channel->len,
--
1.6.5.rc1

2009-09-17 12:31:25

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH 05/11] USB: musb: add notes for Blackfin anomalies

Hello.

Mike Frysinger wrote:

> From: Sonic Zhang <[email protected]>

> Add some helpful notes about how the driver works around different
> anomalies that exist in the on-chip host controller.
>
> Signed-off-by: Sonic Zhang <[email protected]>
> Signed-off-by: Cliff Cai <[email protected]>
> Signed-off-by: Mike Frysinger <[email protected]>

Grammar and style nipicking follows... :-)

> diff --git a/drivers/usb/musb/blackfin.h b/drivers/usb/musb/blackfin.h
> index a240c1e..de62962 100644
> --- a/drivers/usb/musb/blackfin.h
> +++ b/drivers/usb/musb/blackfin.h
> @@ -14,6 +14,35 @@
> * Blackfin specific definitions
> */
>
> +/* Anomalies notes:
> + *
> + * 05000450 - USB DMA Mode 1 Short Packet Data Corruption:
> + * MUSB driver is designed to transfer buffer of N * maxpacket size
> + * in DMA mode 1 and leave rest data to the next transfer in DMA
> + * mode 0, so we never transmit a short packet in DMA mode 1.
> + *
> + * 05000463 - This anomaly doesn't affect this driver,Since it

No comma needed here, and why capitalize "since"?

> + * never uses L1 or L2 memory as data destination.
> + *
> + * 05000464 - This anomaly doesn't affect this driver,Since it

Same here...

> + * never uses L1 or L2 memory as data source.
> + *
> + * 05000465 - Actually,the anomaly still can be seen when SCLK
> + * is over 100 MHz,and there is no way to workaround
> + * for bulk endpoints,because the wMaxPackSize of bulk
> + * is less than or equal to 512,while the fifo size of

Shouldn't there be spaces after commas?

> + * endpoint 5,6,7 is 1024,the double buffer mode is

Either comma doesn't fit here, or "so" is needed after it...

> + * enabled automatically when these endpoints are used
> + * for bulk OUT.
> + *
> + * 05000466 - This anomaly doesn't affect this driver,Since it

No comma or uppercase needed...

> + * never mixs concurrent DMA and core accesses to the

"Mixes"...

> + * TX endpoint FIFOs.

WBR, Sergei

2009-09-17 16:25:34

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH 05/12 v2] USB: musb: add notes for Blackfin anomalies

From: Sonic Zhang <[email protected]>

Add some helpful notes about how the driver works around different
anomalies that exist in the on-chip host controller.

Signed-off-by: Sonic Zhang <[email protected]>
Signed-off-by: Cliff Cai <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
v2
- clean up grammar pointed out by Sergei Shtylyov

drivers/usb/musb/blackfin.h | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/musb/blackfin.h b/drivers/usb/musb/blackfin.h
index a240c1e..b49a362 100644
--- a/drivers/usb/musb/blackfin.h
+++ b/drivers/usb/musb/blackfin.h
@@ -14,6 +14,33 @@
* Blackfin specific definitions
*/

+/* Anomalies notes:
+ *
+ * 05000450 - USB DMA Mode 1 Short Packet Data Corruption:
+ * MUSB driver is designed to transfer buffer of N * maxpacket size
+ * in DMA mode 1 and leave the rest of the data to the next
+ * transfer in DMA mode 0, so we never transmit a short packet in
+ * DMA mode 1.
+ *
+ * 05000463 - This anomaly doesn't affect this driver since it
+ * never uses L1 or L2 memory as data destination.
+ *
+ * 05000464 - This anomaly doesn't affect this driver since it
+ * never uses L1 or L2 memory as data source.
+ *
+ * 05000465 - The anomaly can be seen when SCLK is over 100 MHz, and there is
+ * no way to workaround for bulk endpoints. Since the wMaxPackSize
+ * of bulk is less than or equal to 512, while the fifo size of
+ * endpoint 5, 6, 7 is 1024, the double buffer mode is enabled
+ * automatically when these endpoints are used for bulk OUT.
+ *
+ * 05000466 - This anomaly doesn't affect this driver since it never mixes
+ * concurrent DMA and core accesses to the TX endpoint FIFOs.
+ *
+ * 05000467 - The workaround for this anomaly will introduce another
+ * anomaly - 05000465.
+ */
+
#undef DUMP_FIFO_DATA
#ifdef DUMP_FIFO_DATA
static void dump_fifo_data(u8 *buf, u16 len)
--
1.6.5.rc1