[PATCH v2 15/27] usb: musb: same MUSB_OFFSET/musb_ep_select for all controller

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ming Lei <tom.leiming@xxxxxxxxx>

The patch uses the information about hw endpoint register address
mapping from hw glue driver to implement MUSB_OFFSET/musb_ep_select
for different cases.

Signed-off-by: Ming Lei <tom.leiming@xxxxxxxxx>
---
 drivers/usb/musb/am35x.c     |    1 +
 drivers/usb/musb/blackfin.c  |    1 +
 drivers/usb/musb/da8xx.c     |    1 +
 drivers/usb/musb/davinci.c   |    1 +
 drivers/usb/musb/musb_core.h |   26 +++++++-------------------
 drivers/usb/musb/musb_regs.h |    7 +++++++
 drivers/usb/musb/omap2430.c  |    1 +
 drivers/usb/musb/tusb6010.c  |    2 +-
 8 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 20231f3..f14198d 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -443,6 +443,7 @@ static void am35x_musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
 
 static const struct musb_platform_ops am35x_ops = {
 	.fifo_mode	= 4,
+	.flags		= MUSB_GLUE_EP_ADDR_FLAT_MAPPING,
 	.init		= am35x_musb_init,
 	.exit		= am35x_musb_exit,
 
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index bc075bd..3bef818 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -419,6 +419,7 @@ static int bfin_musb_exit(struct musb *musb)
 
 static const struct musb_platform_ops bfin_ops = {
 	.fifo_mode	= 2,
+	.flags		= MUSB_GLUE_EP_ADDR_FLAT_MAPPING,
 	.init		= bfin_musb_init,
 	.exit		= bfin_musb_exit,
 
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 8ea5a71..be4d3ca 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -471,6 +471,7 @@ static int da8xx_musb_exit(struct musb *musb)
 
 static const struct musb_platform_ops da8xx_ops = {
 	.fifo_mode	= 2,
+	.flags		= MUSB_GLUE_EP_ADDR_FLAT_MAPPING,
 	.init		= da8xx_musb_init,
 	.exit		= da8xx_musb_exit,
 
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 3c7f39a..8ce8c97 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -506,6 +506,7 @@ static int davinci_musb_exit(struct musb *musb)
 
 static const struct musb_platform_ops davinci_ops = {
 	.fifo_mode	= 2,
+	.flags		= MUSB_GLUE_EP_ADDR_FLAT_MAPPING,
 	.init		= davinci_musb_init,
 	.exit		= davinci_musb_exit,
 
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 35f1334..e0c3376 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -215,26 +215,12 @@ enum musb_g_ep0_state {
  * directly with the "flat" model, or after setting up an index register.
  */
 
-#if defined(CONFIG_ARCH_DAVINCI) || defined(CONFIG_ARCH_OMAP2430) \
-		|| defined(CONFIG_ARCH_OMAP3430) || defined(CONFIG_BLACKFIN) \
-		|| defined(CONFIG_ARCH_OMAP4)
-/* REVISIT indexed access seemed to
- * misbehave (on DaVinci) for at least peripheral IN ...
- */
-#define	MUSB_FLAT_REG
-#endif
-
-/* "flat" mapping: each endpoint has its own i/o address */
-#ifdef	MUSB_FLAT_REG
-#define musb_ep_select(_musb, _mbase, _epnum)	(((void)(_mbase)), ((void)(_epnum)))
-#define	MUSB_EP_OFFSET			MUSB_FLAT_OFFSET
+#define musb_ep_select(_musb, _mbase, _epnum) do { \
+	if (_musb->ops->flags & MUSB_GLUE_EP_ADDR_INDEXED_MAPPING) \
+		musb_writeb((_mbase), MUSB_INDEX, (_epnum)); \
+} while (0)
 
-/* "indexed" mapping: INDEX register controls register bank select */
-#else
-#define musb_ep_select(_musb, _mbase, _epnum) \
-	musb_writeb((_mbase), MUSB_INDEX, (_epnum))
-#define	MUSB_EP_OFFSET			MUSB_INDEXED_OFFSET
-#endif
+#define	MUSB_EP_OFFSET			MUSB_OFFSET
 
 /****************************** FUNCTIONS ********************************/
 
@@ -251,6 +237,8 @@ enum musb_g_ep0_state {
 /******************************** TYPES *************************************/
 
 #define     MUSB_GLUE_TUSB_STYLE   0x0001
+#define     MUSB_GLUE_EP_ADDR_FLAT_MAPPING	0x0002
+#define     MUSB_GLUE_EP_ADDR_INDEXED_MAPPING	0x0004
 
 /**
  * struct musb_platform_ops - Operations passed to musb_core by HW glue layer
diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h
index 1af0ea9..b222c08 100644
--- a/drivers/usb/musb/musb_regs.h
+++ b/drivers/usb/musb/musb_regs.h
@@ -284,6 +284,7 @@
 #define MUSB_FIFOSIZE		0x0F
 #define MUSB_CONFIGDATA		MUSB_FIFOSIZE	/* Re-used for EP0 */
 
+#if 0
 /* Offsets to endpoint registers in indexed model (using INDEX register) */
 #define MUSB_INDEXED_OFFSET(_musb, _epnum, _offset)	\
 	(0x10 + (_offset))
@@ -291,6 +292,12 @@
 /* Offsets to endpoint registers in flat models */
 #define MUSB_FLAT_OFFSET(_musb, _epnum, _offset)	\
 	(0x100 + (0x10*(_epnum)) + (_offset))
+#endif
+
+#define MUSB_OFFSET(_musb, _epnum, _offset)	\
+	((_musb)->ops->flags & MUSB_GLUE_EP_ADDR_INDEXED_MAPPING ? \
+		(0x10 + (_offset)) : (0x100 + (0x10*(_epnum)) + (_offset)))
+
 
 #include "tusb6010.h"		/* Needed "only" for TUSB_EP0_CONF */
 
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index ccb63c3..c94f230 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -371,6 +371,7 @@ static int omap2430_musb_exit(struct musb *musb)
 
 static const struct musb_platform_ops omap2430_ops = {
 	.fifo_mode	= 4,
+	.flags		= MUSB_GLUE_EP_ADDR_FLAT_MAPPING,
 	.init		= omap2430_musb_init,
 	.exit		= omap2430_musb_exit,
 
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 9d4189b..75c8e8a 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1165,7 +1165,7 @@ static int tusb_musb_exit(struct musb *musb)
 
 static const struct musb_platform_ops tusb_ops = {
 	.fifo_mode	= 4,
-	.flags		= MUSB_GLUE_TUSB_STYLE,
+	.flags		= MUSB_GLUE_TUSB_STYLE | MUSB_GLUE_EP_ADDR_INDEXED_MAPPING,
 	.init		= tusb_musb_init,
 	.exit		= tusb_musb_exit,
 
-- 
1.7.3

--
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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux