aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2013-05-15 05:51:43 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-06-04 05:12:02 -0400
commitbe2dbb09a014cba5691c8483ad2d0747d3eeb514 (patch)
treefb613c0e895caa3950c4ac61fc765589f946a697
parent95e4bf98520c9a92cd1b87d12c89e8c60c5fe2ca (diff)
usb: musb: ux500: move channel number knowledge into the driver
For all ux500 based platforms the maximum number of end-points are used. Move this knowledge into the driver so we can relinquish the burden from platform data. This also removes quite a bit of complexity from the driver and will aid us when we come to enable the driver for Device Tree. Cc: linux-usb@vger.kernel.org Acked-by: Felipe Balbi <balbi@ti.com> Acked-by: Fabio Baltieri <fabio.baltieri@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--arch/arm/mach-ux500/usb.c14
-rw-r--r--drivers/usb/musb/ux500_dma.c30
-rw-r--r--include/linux/platform_data/usb-musb-ux500.h5
3 files changed, 16 insertions, 33 deletions
diff --git a/arch/arm/mach-ux500/usb.c b/arch/arm/mach-ux500/usb.c
index 72754e369417..a21c2e1b7333 100644
--- a/arch/arm/mach-ux500/usb.c
+++ b/arch/arm/mach-ux500/usb.c
@@ -22,7 +22,7 @@
22 .dir = STEDMA40_MEM_TO_PERIPH, \ 22 .dir = STEDMA40_MEM_TO_PERIPH, \
23 } 23 }
24 24
25static struct stedma40_chan_cfg musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_CHANNELS] 25static struct stedma40_chan_cfg musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS]
26 = { 26 = {
27 MUSB_DMA40_RX_CH, 27 MUSB_DMA40_RX_CH,
28 MUSB_DMA40_RX_CH, 28 MUSB_DMA40_RX_CH,
@@ -34,7 +34,7 @@ static struct stedma40_chan_cfg musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_CHANNELS]
34 MUSB_DMA40_RX_CH 34 MUSB_DMA40_RX_CH
35}; 35};
36 36
37static struct stedma40_chan_cfg musb_dma_tx_ch[UX500_MUSB_DMA_NUM_TX_CHANNELS] 37static struct stedma40_chan_cfg musb_dma_tx_ch[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS]
38 = { 38 = {
39 MUSB_DMA40_TX_CH, 39 MUSB_DMA40_TX_CH,
40 MUSB_DMA40_TX_CH, 40 MUSB_DMA40_TX_CH,
@@ -46,7 +46,7 @@ static struct stedma40_chan_cfg musb_dma_tx_ch[UX500_MUSB_DMA_NUM_TX_CHANNELS]
46 MUSB_DMA40_TX_CH, 46 MUSB_DMA40_TX_CH,
47}; 47};
48 48
49static void *ux500_dma_rx_param_array[UX500_MUSB_DMA_NUM_RX_CHANNELS] = { 49static void *ux500_dma_rx_param_array[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] = {
50 &musb_dma_rx_ch[0], 50 &musb_dma_rx_ch[0],
51 &musb_dma_rx_ch[1], 51 &musb_dma_rx_ch[1],
52 &musb_dma_rx_ch[2], 52 &musb_dma_rx_ch[2],
@@ -57,7 +57,7 @@ static void *ux500_dma_rx_param_array[UX500_MUSB_DMA_NUM_RX_CHANNELS] = {
57 &musb_dma_rx_ch[7] 57 &musb_dma_rx_ch[7]
58}; 58};
59 59
60static void *ux500_dma_tx_param_array[UX500_MUSB_DMA_NUM_TX_CHANNELS] = { 60static void *ux500_dma_tx_param_array[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] = {
61 &musb_dma_tx_ch[0], 61 &musb_dma_tx_ch[0],
62 &musb_dma_tx_ch[1], 62 &musb_dma_tx_ch[1],
63 &musb_dma_tx_ch[2], 63 &musb_dma_tx_ch[2],
@@ -71,8 +71,6 @@ static void *ux500_dma_tx_param_array[UX500_MUSB_DMA_NUM_TX_CHANNELS] = {
71static struct ux500_musb_board_data musb_board_data = { 71static struct ux500_musb_board_data musb_board_data = {
72 .dma_rx_param_array = ux500_dma_rx_param_array, 72 .dma_rx_param_array = ux500_dma_rx_param_array,
73 .dma_tx_param_array = ux500_dma_tx_param_array, 73 .dma_tx_param_array = ux500_dma_tx_param_array,
74 .num_rx_channels = UX500_MUSB_DMA_NUM_RX_CHANNELS,
75 .num_tx_channels = UX500_MUSB_DMA_NUM_TX_CHANNELS,
76 .dma_filter = stedma40_filter, 74 .dma_filter = stedma40_filter,
77}; 75};
78 76
@@ -119,7 +117,7 @@ static inline void ux500_usb_dma_update_rx_ch_config(int *dev_type)
119{ 117{
120 u32 idx; 118 u32 idx;
121 119
122 for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_CHANNELS; idx++) 120 for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; idx++)
123 musb_dma_rx_ch[idx].dev_type = dev_type[idx]; 121 musb_dma_rx_ch[idx].dev_type = dev_type[idx];
124} 122}
125 123
@@ -127,7 +125,7 @@ static inline void ux500_usb_dma_update_tx_ch_config(int *dev_type)
127{ 125{
128 u32 idx; 126 u32 idx;
129 127
130 for (idx = 0; idx < UX500_MUSB_DMA_NUM_TX_CHANNELS; idx++) 128 for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; idx++)
131 musb_dma_tx_ch[idx].dev_type = dev_type[idx]; 129 musb_dma_tx_ch[idx].dev_type = dev_type[idx];
132} 130}
133 131
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index 338120641145..382291b91f7b 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -48,10 +48,8 @@ struct ux500_dma_channel {
48 48
49struct ux500_dma_controller { 49struct ux500_dma_controller {
50 struct dma_controller controller; 50 struct dma_controller controller;
51 struct ux500_dma_channel rx_channel[UX500_MUSB_DMA_NUM_RX_CHANNELS]; 51 struct ux500_dma_channel rx_channel[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS];
52 struct ux500_dma_channel tx_channel[UX500_MUSB_DMA_NUM_TX_CHANNELS]; 52 struct ux500_dma_channel tx_channel[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS];
53 u32 num_rx_channels;
54 u32 num_tx_channels;
55 void *private_data; 53 void *private_data;
56 dma_addr_t phy_base; 54 dma_addr_t phy_base;
57}; 55};
@@ -144,19 +142,15 @@ static struct dma_channel *ux500_dma_channel_allocate(struct dma_controller *c,
144 struct ux500_dma_channel *ux500_channel = NULL; 142 struct ux500_dma_channel *ux500_channel = NULL;
145 struct musb *musb = controller->private_data; 143 struct musb *musb = controller->private_data;
146 u8 ch_num = hw_ep->epnum - 1; 144 u8 ch_num = hw_ep->epnum - 1;
147 u32 max_ch;
148 145
149 /* Max 8 DMA channels (0 - 7). Each DMA channel can only be allocated 146 /* 8 DMA channels (0 - 7). Each DMA channel can only be allocated
150 * to specified hw_ep. For example DMA channel 0 can only be allocated 147 * to specified hw_ep. For example DMA channel 0 can only be allocated
151 * to hw_ep 1 and 9. 148 * to hw_ep 1 and 9.
152 */ 149 */
153 if (ch_num > 7) 150 if (ch_num > 7)
154 ch_num -= 8; 151 ch_num -= 8;
155 152
156 max_ch = is_tx ? controller->num_tx_channels : 153 if (ch_num >= UX500_MUSB_DMA_NUM_RX_TX_CHANNELS)
157 controller->num_rx_channels;
158
159 if (ch_num >= max_ch)
160 return NULL; 154 return NULL;
161 155
162 ux500_channel = is_tx ? &(controller->tx_channel[ch_num]) : 156 ux500_channel = is_tx ? &(controller->tx_channel[ch_num]) :
@@ -264,7 +258,7 @@ static int ux500_dma_controller_stop(struct dma_controller *c)
264 struct dma_channel *channel; 258 struct dma_channel *channel;
265 u8 ch_num; 259 u8 ch_num;
266 260
267 for (ch_num = 0; ch_num < controller->num_rx_channels; ch_num++) { 261 for (ch_num = 0; ch_num < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; ch_num++) {
268 channel = &controller->rx_channel[ch_num].channel; 262 channel = &controller->rx_channel[ch_num].channel;
269 ux500_channel = channel->private_data; 263 ux500_channel = channel->private_data;
270 264
@@ -274,7 +268,7 @@ static int ux500_dma_controller_stop(struct dma_controller *c)
274 dma_release_channel(ux500_channel->dma_chan); 268 dma_release_channel(ux500_channel->dma_chan);
275 } 269 }
276 270
277 for (ch_num = 0; ch_num < controller->num_tx_channels; ch_num++) { 271 for (ch_num = 0; ch_num < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; ch_num++) {
278 channel = &controller->tx_channel[ch_num].channel; 272 channel = &controller->tx_channel[ch_num].channel;
279 ux500_channel = channel->private_data; 273 ux500_channel = channel->private_data;
280 274
@@ -303,26 +297,21 @@ static int ux500_dma_controller_start(struct dma_controller *c)
303 297
304 void **param_array; 298 void **param_array;
305 struct ux500_dma_channel *channel_array; 299 struct ux500_dma_channel *channel_array;
306 u32 ch_count;
307 dma_cap_mask_t mask; 300 dma_cap_mask_t mask;
308 301
309 if ((data->num_rx_channels > UX500_MUSB_DMA_NUM_RX_CHANNELS) ||
310 (data->num_tx_channels > UX500_MUSB_DMA_NUM_TX_CHANNELS))
311 return -EINVAL;
312 302
313 controller->num_rx_channels = data->num_rx_channels;
314 controller->num_tx_channels = data->num_tx_channels;
315 303
316 dma_cap_zero(mask); 304 dma_cap_zero(mask);
317 dma_cap_set(DMA_SLAVE, mask); 305 dma_cap_set(DMA_SLAVE, mask);
318 306
319 /* Prepare the loop for RX channels */ 307 /* Prepare the loop for RX channels */
320 channel_array = controller->rx_channel; 308 channel_array = controller->rx_channel;
321 ch_count = data->num_rx_channels;
322 param_array = data->dma_rx_param_array; 309 param_array = data->dma_rx_param_array;
323 310
324 for (dir = 0; dir < 2; dir++) { 311 for (dir = 0; dir < 2; dir++) {
325 for (ch_num = 0; ch_num < ch_count; ch_num++) { 312 for (ch_num = 0;
313 ch_num < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS;
314 ch_num++) {
326 ux500_channel = &channel_array[ch_num]; 315 ux500_channel = &channel_array[ch_num];
327 ux500_channel->controller = controller; 316 ux500_channel->controller = controller;
328 ux500_channel->ch_num = ch_num; 317 ux500_channel->ch_num = ch_num;
@@ -350,7 +339,6 @@ static int ux500_dma_controller_start(struct dma_controller *c)
350 339
351 /* Prepare the loop for TX channels */ 340 /* Prepare the loop for TX channels */
352 channel_array = controller->tx_channel; 341 channel_array = controller->tx_channel;
353 ch_count = data->num_tx_channels;
354 param_array = data->dma_tx_param_array; 342 param_array = data->dma_tx_param_array;
355 is_tx = 1; 343 is_tx = 1;
356 } 344 }
diff --git a/include/linux/platform_data/usb-musb-ux500.h b/include/linux/platform_data/usb-musb-ux500.h
index 4c1cc50a595a..dd9c83ac7de0 100644
--- a/include/linux/platform_data/usb-musb-ux500.h
+++ b/include/linux/platform_data/usb-musb-ux500.h
@@ -9,14 +9,11 @@
9 9
10#include <linux/dmaengine.h> 10#include <linux/dmaengine.h>
11 11
12#define UX500_MUSB_DMA_NUM_RX_CHANNELS 8 12#define UX500_MUSB_DMA_NUM_RX_TX_CHANNELS 8
13#define UX500_MUSB_DMA_NUM_TX_CHANNELS 8
14 13
15struct ux500_musb_board_data { 14struct ux500_musb_board_data {
16 void **dma_rx_param_array; 15 void **dma_rx_param_array;
17 void **dma_tx_param_array; 16 void **dma_tx_param_array;
18 u32 num_rx_channels;
19 u32 num_tx_channels;
20 bool (*dma_filter)(struct dma_chan *chan, void *filter_param); 17 bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
21}; 18};
22 19