diff options
author | Tony Lindgren <tony@atomide.com> | 2014-11-24 14:05:03 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-11-25 09:47:06 -0500 |
commit | d026e9c76aac3632af174cf02d5c94defa5e6026 (patch) | |
tree | 2eee0a3c62ae59c3e5a366f61172c7ff2b883a2a | |
parent | 1b40fc57a517878cf4c2e16ce29cc9a066dc1064 (diff) |
usb: musb: Change end point selection to use new IO access
This allows the endpoints to work when multiple MUSB glue
layers are built in.
Cc: Fabio Baltieri <fabio.baltieri@linaro.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Apelete Seketeli <apelete@seketeli.net>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/musb/am35x.c | 1 | ||||
-rw-r--r-- | drivers/usb/musb/da8xx.c | 1 | ||||
-rw-r--r-- | drivers/usb/musb/jz4740.c | 1 | ||||
-rw-r--r-- | drivers/usb/musb/musb_core.c | 38 | ||||
-rw-r--r-- | drivers/usb/musb/musb_core.h | 37 | ||||
-rw-r--r-- | drivers/usb/musb/musb_dsps.c | 1 | ||||
-rw-r--r-- | drivers/usb/musb/musb_io.h | 2 | ||||
-rw-r--r-- | drivers/usb/musb/musb_regs.h | 11 | ||||
-rw-r--r-- | drivers/usb/musb/musbhsdma.c | 7 | ||||
-rw-r--r-- | drivers/usb/musb/tusb6010.c | 13 | ||||
-rw-r--r-- | drivers/usb/musb/ux500.c | 1 |
11 files changed, 62 insertions, 51 deletions
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index 7fc8d47ce18e..220fd4d3b41c 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c | |||
@@ -438,6 +438,7 @@ static void am35x_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) | |||
438 | } | 438 | } |
439 | 439 | ||
440 | static const struct musb_platform_ops am35x_ops = { | 440 | static const struct musb_platform_ops am35x_ops = { |
441 | .quirks = MUSB_INDEXED_EP, | ||
441 | .init = am35x_musb_init, | 442 | .init = am35x_musb_init, |
442 | .exit = am35x_musb_exit, | 443 | .exit = am35x_musb_exit, |
443 | 444 | ||
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 527c7fe60ece..9a6171300931 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c | |||
@@ -458,6 +458,7 @@ static int da8xx_musb_exit(struct musb *musb) | |||
458 | } | 458 | } |
459 | 459 | ||
460 | static const struct musb_platform_ops da8xx_ops = { | 460 | static const struct musb_platform_ops da8xx_ops = { |
461 | .quirks = MUSB_INDEXED_EP, | ||
461 | .init = da8xx_musb_init, | 462 | .init = da8xx_musb_init, |
462 | .exit = da8xx_musb_exit, | 463 | .exit = da8xx_musb_exit, |
463 | 464 | ||
diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c index d1187290d4e3..40e98747d17f 100644 --- a/drivers/usb/musb/jz4740.c +++ b/drivers/usb/musb/jz4740.c | |||
@@ -106,6 +106,7 @@ static int jz4740_musb_exit(struct musb *musb) | |||
106 | } | 106 | } |
107 | 107 | ||
108 | static const struct musb_platform_ops jz4740_musb_ops = { | 108 | static const struct musb_platform_ops jz4740_musb_ops = { |
109 | .quirks = MUSB_INDEXED_EP, | ||
109 | .init = jz4740_musb_init, | 110 | .init = jz4740_musb_init, |
110 | .exit = jz4740_musb_exit, | 111 | .exit = jz4740_musb_exit, |
111 | }; | 112 | }; |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 1c1a9a12fdc7..1ff944a07359 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -229,6 +229,27 @@ static u32 musb_default_fifo_offset(u8 epnum) | |||
229 | return 0x20 + (epnum * 4); | 229 | return 0x20 + (epnum * 4); |
230 | } | 230 | } |
231 | 231 | ||
232 | /* "flat" mapping: each endpoint has its own i/o address */ | ||
233 | static void musb_flat_ep_select(void __iomem *mbase, u8 epnum) | ||
234 | { | ||
235 | } | ||
236 | |||
237 | static u32 musb_flat_ep_offset(u8 epnum, u16 offset) | ||
238 | { | ||
239 | return 0x100 + (0x10 * epnum) + offset; | ||
240 | } | ||
241 | |||
242 | /* "indexed" mapping: INDEX register controls register bank select */ | ||
243 | static void musb_indexed_ep_select(void __iomem *mbase, u8 epnum) | ||
244 | { | ||
245 | musb_writeb(mbase, MUSB_INDEX, epnum); | ||
246 | } | ||
247 | |||
248 | static u32 musb_indexed_ep_offset(u8 epnum, u16 offset) | ||
249 | { | ||
250 | return 0x10 + offset; | ||
251 | } | ||
252 | |||
232 | static u8 musb_default_readb(const void __iomem *addr, unsigned offset) | 253 | static u8 musb_default_readb(const void __iomem *addr, unsigned offset) |
233 | { | 254 | { |
234 | return __raw_readb(addr + offset); | 255 | return __raw_readb(addr + offset); |
@@ -1537,7 +1558,7 @@ static int musb_core_init(u16 musb_type, struct musb *musb) | |||
1537 | } | 1558 | } |
1538 | #endif | 1559 | #endif |
1539 | 1560 | ||
1540 | hw_ep->regs = MUSB_EP_OFFSET(i, 0) + mbase; | 1561 | hw_ep->regs = musb->io.ep_offset(i, 0) + mbase; |
1541 | hw_ep->target_regs = musb_read_target_reg_base(i, mbase); | 1562 | hw_ep->target_regs = musb_read_target_reg_base(i, mbase); |
1542 | hw_ep->rx_reinit = 1; | 1563 | hw_ep->rx_reinit = 1; |
1543 | hw_ep->tx_reinit = 1; | 1564 | hw_ep->tx_reinit = 1; |
@@ -2007,6 +2028,21 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
2007 | if (musb->ops->quirks) | 2028 | if (musb->ops->quirks) |
2008 | musb->io.quirks = musb->ops->quirks; | 2029 | musb->io.quirks = musb->ops->quirks; |
2009 | 2030 | ||
2031 | /* At least tusb6010 has it's own offsets.. */ | ||
2032 | if (musb->ops->ep_offset) | ||
2033 | musb->io.ep_offset = musb->ops->ep_offset; | ||
2034 | if (musb->ops->ep_select) | ||
2035 | musb->io.ep_select = musb->ops->ep_select; | ||
2036 | |||
2037 | /* ..and some devices use indexed offset or flat offset */ | ||
2038 | if (musb->io.quirks & MUSB_INDEXED_EP) { | ||
2039 | musb->io.ep_offset = musb_indexed_ep_offset; | ||
2040 | musb->io.ep_select = musb_indexed_ep_select; | ||
2041 | } else { | ||
2042 | musb->io.ep_offset = musb_flat_ep_offset; | ||
2043 | musb->io.ep_select = musb_flat_ep_select; | ||
2044 | } | ||
2045 | |||
2010 | if (musb->ops->fifo_offset) | 2046 | if (musb->ops->fifo_offset) |
2011 | musb->io.fifo_offset = musb->ops->fifo_offset; | 2047 | musb->io.fifo_offset = musb->ops->fifo_offset; |
2012 | else | 2048 | else |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index e5410bc67df6..d9248fdd9158 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -124,41 +124,6 @@ enum musb_g_ep0_state { | |||
124 | #define OTG_TIME_A_AIDL_BDIS 200 /* min 200 msec */ | 124 | #define OTG_TIME_A_AIDL_BDIS 200 /* min 200 msec */ |
125 | #define OTG_TIME_B_ASE0_BRST 100 /* min 3.125 ms */ | 125 | #define OTG_TIME_B_ASE0_BRST 100 /* min 3.125 ms */ |
126 | 126 | ||
127 | |||
128 | /*************************** REGISTER ACCESS ********************************/ | ||
129 | |||
130 | /* Endpoint registers (other than dynfifo setup) can be accessed either | ||
131 | * directly with the "flat" model, or after setting up an index register. | ||
132 | */ | ||
133 | |||
134 | #if defined(CONFIG_ARCH_DAVINCI) || defined(CONFIG_SOC_OMAP2430) \ | ||
135 | || defined(CONFIG_SOC_OMAP3430) || defined(CONFIG_BLACKFIN) \ | ||
136 | || defined(CONFIG_ARCH_OMAP4) | ||
137 | /* REVISIT indexed access seemed to | ||
138 | * misbehave (on DaVinci) for at least peripheral IN ... | ||
139 | */ | ||
140 | #define MUSB_FLAT_REG | ||
141 | #endif | ||
142 | |||
143 | /* TUSB mapping: "flat" plus ep0 special cases */ | ||
144 | #if defined(CONFIG_USB_MUSB_TUSB6010) || \ | ||
145 | defined(CONFIG_USB_MUSB_TUSB6010_MODULE) | ||
146 | #define musb_ep_select(_mbase, _epnum) \ | ||
147 | musb_writeb((_mbase), MUSB_INDEX, (_epnum)) | ||
148 | #define MUSB_EP_OFFSET MUSB_TUSB_OFFSET | ||
149 | |||
150 | /* "flat" mapping: each endpoint has its own i/o address */ | ||
151 | #elif defined(MUSB_FLAT_REG) | ||
152 | #define musb_ep_select(_mbase, _epnum) (((void)(_mbase)), ((void)(_epnum))) | ||
153 | #define MUSB_EP_OFFSET MUSB_FLAT_OFFSET | ||
154 | |||
155 | /* "indexed" mapping: INDEX register controls register bank select */ | ||
156 | #else | ||
157 | #define musb_ep_select(_mbase, _epnum) \ | ||
158 | musb_writeb((_mbase), MUSB_INDEX, (_epnum)) | ||
159 | #define MUSB_EP_OFFSET MUSB_INDEXED_OFFSET | ||
160 | #endif | ||
161 | |||
162 | /****************************** FUNCTIONS ********************************/ | 127 | /****************************** FUNCTIONS ********************************/ |
163 | 128 | ||
164 | #define MUSB_HST_MODE(_musb)\ | 129 | #define MUSB_HST_MODE(_musb)\ |
@@ -515,7 +480,7 @@ static inline int musb_read_fifosize(struct musb *musb, | |||
515 | u8 reg = 0; | 480 | u8 reg = 0; |
516 | 481 | ||
517 | /* read from core using indexed model */ | 482 | /* read from core using indexed model */ |
518 | reg = musb_readb(mbase, MUSB_EP_OFFSET(epnum, MUSB_FIFOSIZE)); | 483 | reg = musb_readb(mbase, musb->io.ep_offset(epnum, MUSB_FIFOSIZE)); |
519 | /* 0's returned when no more endpoints */ | 484 | /* 0's returned when no more endpoints */ |
520 | if (!reg) | 485 | if (!reg) |
521 | return -ENODEV; | 486 | return -ENODEV; |
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 440333fcf3a7..53bd0e71d19f 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c | |||
@@ -633,6 +633,7 @@ static int dsps_musb_reset(struct musb *musb) | |||
633 | } | 633 | } |
634 | 634 | ||
635 | static struct musb_platform_ops dsps_ops = { | 635 | static struct musb_platform_ops dsps_ops = { |
636 | .quirks = MUSB_INDEXED_EP, | ||
636 | .init = dsps_musb_init, | 637 | .init = dsps_musb_init, |
637 | .exit = dsps_musb_exit, | 638 | .exit = dsps_musb_exit, |
638 | 639 | ||
diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h index 14aa21747b0a..8a57a6f4b3a6 100644 --- a/drivers/usb/musb/musb_io.h +++ b/drivers/usb/musb/musb_io.h | |||
@@ -37,6 +37,8 @@ | |||
37 | 37 | ||
38 | #include <linux/io.h> | 38 | #include <linux/io.h> |
39 | 39 | ||
40 | #define musb_ep_select(_mbase, _epnum) musb->io.ep_select((_mbase), (_epnum)) | ||
41 | |||
40 | /** | 42 | /** |
41 | * struct musb_io - IO functions for MUSB | 43 | * struct musb_io - IO functions for MUSB |
42 | * @quirks: platform specific flags | 44 | * @quirks: platform specific flags |
diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h index b2b1f736392e..92b4c3df9ffa 100644 --- a/drivers/usb/musb/musb_regs.h +++ b/drivers/usb/musb/musb_regs.h | |||
@@ -287,19 +287,8 @@ | |||
287 | #define MUSB_FIFOSIZE 0x0F | 287 | #define MUSB_FIFOSIZE 0x0F |
288 | #define MUSB_CONFIGDATA MUSB_FIFOSIZE /* Re-used for EP0 */ | 288 | #define MUSB_CONFIGDATA MUSB_FIFOSIZE /* Re-used for EP0 */ |
289 | 289 | ||
290 | /* Offsets to endpoint registers in indexed model (using INDEX register) */ | ||
291 | #define MUSB_INDEXED_OFFSET(_epnum, _offset) \ | ||
292 | (0x10 + (_offset)) | ||
293 | |||
294 | /* Offsets to endpoint registers in flat models */ | ||
295 | #define MUSB_FLAT_OFFSET(_epnum, _offset) \ | ||
296 | (0x100 + (0x10*(_epnum)) + (_offset)) | ||
297 | |||
298 | #if defined(CONFIG_USB_MUSB_TUSB6010) || \ | 290 | #if defined(CONFIG_USB_MUSB_TUSB6010) || \ |
299 | defined(CONFIG_USB_MUSB_TUSB6010_MODULE) | 291 | defined(CONFIG_USB_MUSB_TUSB6010_MODULE) |
300 | /* TUSB6010 EP0 configuration register is special */ | ||
301 | #define MUSB_TUSB_OFFSET(_epnum, _offset) \ | ||
302 | (0x10 + _offset) | ||
303 | #include "tusb6010.h" /* Needed "only" for TUSB_EP0_CONF */ | 292 | #include "tusb6010.h" /* Needed "only" for TUSB_EP0_CONF */ |
304 | #endif | 293 | #endif |
305 | 294 | ||
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c index e8e9f9aab203..ab7ec09a8afe 100644 --- a/drivers/usb/musb/musbhsdma.c +++ b/drivers/usb/musb/musbhsdma.c | |||
@@ -195,6 +195,7 @@ static int dma_channel_abort(struct dma_channel *channel) | |||
195 | { | 195 | { |
196 | struct musb_dma_channel *musb_channel = channel->private_data; | 196 | struct musb_dma_channel *musb_channel = channel->private_data; |
197 | void __iomem *mbase = musb_channel->controller->base; | 197 | void __iomem *mbase = musb_channel->controller->base; |
198 | struct musb *musb = musb_channel->controller->private_data; | ||
198 | 199 | ||
199 | u8 bchannel = musb_channel->idx; | 200 | u8 bchannel = musb_channel->idx; |
200 | int offset; | 201 | int offset; |
@@ -202,7 +203,7 @@ static int dma_channel_abort(struct dma_channel *channel) | |||
202 | 203 | ||
203 | if (channel->status == MUSB_DMA_STATUS_BUSY) { | 204 | if (channel->status == MUSB_DMA_STATUS_BUSY) { |
204 | if (musb_channel->transmit) { | 205 | if (musb_channel->transmit) { |
205 | offset = MUSB_EP_OFFSET(musb_channel->epnum, | 206 | offset = musb->io.ep_offset(musb_channel->epnum, |
206 | MUSB_TXCSR); | 207 | MUSB_TXCSR); |
207 | 208 | ||
208 | /* | 209 | /* |
@@ -215,7 +216,7 @@ static int dma_channel_abort(struct dma_channel *channel) | |||
215 | csr &= ~MUSB_TXCSR_DMAMODE; | 216 | csr &= ~MUSB_TXCSR_DMAMODE; |
216 | musb_writew(mbase, offset, csr); | 217 | musb_writew(mbase, offset, csr); |
217 | } else { | 218 | } else { |
218 | offset = MUSB_EP_OFFSET(musb_channel->epnum, | 219 | offset = musb->io.ep_offset(musb_channel->epnum, |
219 | MUSB_RXCSR); | 220 | MUSB_RXCSR); |
220 | 221 | ||
221 | csr = musb_readw(mbase, offset); | 222 | csr = musb_readw(mbase, offset); |
@@ -326,7 +327,7 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data) | |||
326 | (musb_channel->max_packet_sz - 1))) | 327 | (musb_channel->max_packet_sz - 1))) |
327 | ) { | 328 | ) { |
328 | u8 epnum = musb_channel->epnum; | 329 | u8 epnum = musb_channel->epnum; |
329 | int offset = MUSB_EP_OFFSET(epnum, | 330 | int offset = musb->io.ep_offset(epnum, |
330 | MUSB_TXCSR); | 331 | MUSB_TXCSR); |
331 | u16 txcsr; | 332 | u16 txcsr; |
332 | 333 | ||
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 16c4475e640c..3a5ffd575438 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c | |||
@@ -131,6 +131,17 @@ static u32 tusb_fifo_offset(u8 epnum) | |||
131 | return 0x200 + (epnum * 0x20); | 131 | return 0x200 + (epnum * 0x20); |
132 | } | 132 | } |
133 | 133 | ||
134 | static u32 tusb_ep_offset(u8 epnum, u16 offset) | ||
135 | { | ||
136 | return 0x10 + offset; | ||
137 | } | ||
138 | |||
139 | /* TUSB mapping: "flat" plus ep0 special cases */ | ||
140 | static void tusb_ep_select(void __iomem *mbase, u8 epnum) | ||
141 | { | ||
142 | musb_writeb(mbase, MUSB_INDEX, epnum); | ||
143 | } | ||
144 | |||
134 | /* | 145 | /* |
135 | * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum. | 146 | * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum. |
136 | */ | 147 | */ |
@@ -1174,6 +1185,8 @@ static const struct musb_platform_ops tusb_ops = { | |||
1174 | .init = tusb_musb_init, | 1185 | .init = tusb_musb_init, |
1175 | .exit = tusb_musb_exit, | 1186 | .exit = tusb_musb_exit, |
1176 | 1187 | ||
1188 | .ep_offset = tusb_ep_offset, | ||
1189 | .ep_select = tusb_ep_select, | ||
1177 | .fifo_offset = tusb_fifo_offset, | 1190 | .fifo_offset = tusb_fifo_offset, |
1178 | .readb = tusb_readb, | 1191 | .readb = tusb_readb, |
1179 | .writeb = tusb_writeb, | 1192 | .writeb = tusb_writeb, |
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c index 1d631d5f4a27..06e8b3523a0a 100644 --- a/drivers/usb/musb/ux500.c +++ b/drivers/usb/musb/ux500.c | |||
@@ -188,6 +188,7 @@ static int ux500_musb_exit(struct musb *musb) | |||
188 | } | 188 | } |
189 | 189 | ||
190 | static const struct musb_platform_ops ux500_ops = { | 190 | static const struct musb_platform_ops ux500_ops = { |
191 | .quirks = MUSB_INDEXED_EP, | ||
191 | .init = ux500_musb_init, | 192 | .init = ux500_musb_init, |
192 | .exit = ux500_musb_exit, | 193 | .exit = ux500_musb_exit, |
193 | 194 | ||