From: Ming Lei <tom.leiming@gmail.com>
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@gmail.com>
---
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 | 12 +++++++++++-
drivers/usb/musb/musb_regs.h | 7 +++++++
drivers/usb/musb/omap2430.c | 1 +
drivers/usb/musb/tusb6010.c | 2 +-
8 files changed, 24 insertions(+), 2 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 f6127ef8..6f5b6e6 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -417,6 +417,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 5cc7881..7b1a2ae 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 14bb3ca..ae92e3c 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -214,7 +214,7 @@ enum musb_g_ep0_state {
/* Endpoint registers (other than dynfifo setup) can be accessed either
* directly with the "flat" model, or after setting up an index register.
*/
-
+#if 0
#if defined(CONFIG_ARCH_DAVINCI) || defined(CONFIG_ARCH_OMAP2430) \
|| defined(CONFIG_ARCH_OMAP3430) || defined(CONFIG_BLACKFIN) \
|| defined(CONFIG_ARCH_OMAP4)
@@ -235,6 +235,14 @@ enum musb_g_ep0_state {
musb_writeb((_mbase), MUSB_INDEX, (_epnum))
#define MUSB_EP_OFFSET MUSB_INDEXED_OFFSET
#endif
+#endif
+
+#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)
+
+#define MUSB_EP_OFFSET MUSB_OFFSET
/****************************** FUNCTIONS ********************************/
@@ -251,6 +259,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 f3a2d48..a7883b8 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -284,6 +284,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 f3318ba..9fa1766 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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html