[U-Boot] [PATCH 2/5] usb: musb: make fifo support configurable

Mike Frysinger vapier at gentoo.org
Thu Dec 17 04:03:59 CET 2009


From: Bryan Wu <bryan.wu at analog.com>

The dynamic FIFO handling under MUSB is optional, and some parts (like
the Blackfin processor) do not implement support for it.

Due to this, the FIFO reading/writing steps need special handling, so
mark the common versions weak so drivers can override.

Signed-off-by: Bryan Wu <bryan.wu at analog.com>
Signed-off-by: Cliff Cai <cliff.cai at analog.com>
Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 drivers/usb/musb/musb_core.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index ec57fc8..2bad610 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -48,6 +48,16 @@ void musb_start(void)
 #endif
 }
 
+#ifdef MUSB_NO_DYNAMIC_FIFO
+# define config_fifo(dir, idx, addr)
+#else
+# define config_fifo(dir, idx, addr) \
+	do { \
+		writeb(idx, &musbr->dir##fifosz); \
+		writew(fifoaddr >> 3, &musbr->dir##fifoadd); \
+	} while (0)
+#endif
+
 /*
  * This function configures the endpoint configuration. The musb hcd or musb
  * device implementation can use this function to configure the endpoints
@@ -72,8 +82,8 @@ void musb_configure_ep(struct musb_epinfo *epinfo, u8 cnt)
 		writeb(epinfo->epnum, &musbr->index);
 		if (epinfo->epdir) {
 			/* Configure fifo size and fifo base address */
-			writeb(idx, &musbr->txfifosz);
-			writew(fifoaddr >> 3, &musbr->txfifoadd);
+			config_fifo(tx, idx, fifoaddr);
+
 #if defined(CONFIG_MUSB_HCD)
 			/* clear the data toggle bit */
 			csr = readw(&musbr->txcsr);
@@ -85,8 +95,8 @@ void musb_configure_ep(struct musb_epinfo *epinfo, u8 cnt)
 					&musbr->txcsr);
 		} else {
 			/* Configure fifo size and fifo base address */
-			writeb(idx, &musbr->rxfifosz);
-			writew(fifoaddr >> 3, &musbr->rxfifoadd);
+			config_fifo(rx, idx, fifoaddr);
+
 #if defined(CONFIG_MUSB_HCD)
 			/* clear the data toggle bit */
 			csr = readw(&musbr->rxcsr);
@@ -109,6 +119,7 @@ void musb_configure_ep(struct musb_epinfo *epinfo, u8 cnt)
  * length	- number of bytes to write to FIFO
  * fifo_data	- Pointer to data buffer that contains the data to write
  */
+__attribute__((weak))
 void write_fifo(u8 ep, u32 length, void *fifo_data)
 {
 	u8  *data = (u8 *)fifo_data;
@@ -128,6 +139,7 @@ void write_fifo(u8 ep, u32 length, void *fifo_data)
  * length       - number of bytes to read from FIFO
  * fifo_data    - pointer to data buffer into which data is read
  */
+__attribute__((weak))
 void read_fifo(u8 ep, u32 length, void *fifo_data)
 {
 	u8  *data = (u8 *)fifo_data;
-- 
1.6.5.5



More information about the U-Boot mailing list