Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Lee Jones and committed by
Linus Walleij
be2dbb09 95e4bf98

+16 -33
+6 -8
arch/arm/mach-ux500/usb.c
··· 22 22 .dir = STEDMA40_MEM_TO_PERIPH, \ 23 23 } 24 24 25 - static struct stedma40_chan_cfg musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_CHANNELS] 25 + static struct stedma40_chan_cfg musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] 26 26 = { 27 27 MUSB_DMA40_RX_CH, 28 28 MUSB_DMA40_RX_CH, ··· 34 34 MUSB_DMA40_RX_CH 35 35 }; 36 36 37 - static struct stedma40_chan_cfg musb_dma_tx_ch[UX500_MUSB_DMA_NUM_TX_CHANNELS] 37 + static struct stedma40_chan_cfg musb_dma_tx_ch[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] 38 38 = { 39 39 MUSB_DMA40_TX_CH, 40 40 MUSB_DMA40_TX_CH, ··· 46 46 MUSB_DMA40_TX_CH, 47 47 }; 48 48 49 - static void *ux500_dma_rx_param_array[UX500_MUSB_DMA_NUM_RX_CHANNELS] = { 49 + static void *ux500_dma_rx_param_array[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] = { 50 50 &musb_dma_rx_ch[0], 51 51 &musb_dma_rx_ch[1], 52 52 &musb_dma_rx_ch[2], ··· 57 57 &musb_dma_rx_ch[7] 58 58 }; 59 59 60 - static void *ux500_dma_tx_param_array[UX500_MUSB_DMA_NUM_TX_CHANNELS] = { 60 + static void *ux500_dma_tx_param_array[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] = { 61 61 &musb_dma_tx_ch[0], 62 62 &musb_dma_tx_ch[1], 63 63 &musb_dma_tx_ch[2], ··· 71 71 static struct ux500_musb_board_data musb_board_data = { 72 72 .dma_rx_param_array = ux500_dma_rx_param_array, 73 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 74 .dma_filter = stedma40_filter, 77 75 }; 78 76 ··· 117 119 { 118 120 u32 idx; 119 121 120 - for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_CHANNELS; idx++) 122 + for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; idx++) 121 123 musb_dma_rx_ch[idx].dev_type = dev_type[idx]; 122 124 } 123 125 ··· 125 127 { 126 128 u32 idx; 127 129 128 - for (idx = 0; idx < UX500_MUSB_DMA_NUM_TX_CHANNELS; idx++) 130 + for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; idx++) 129 131 musb_dma_tx_ch[idx].dev_type = dev_type[idx]; 130 132 } 131 133
+9 -21
drivers/usb/musb/ux500_dma.c
··· 48 48 49 49 struct ux500_dma_controller { 50 50 struct dma_controller controller; 51 - struct ux500_dma_channel rx_channel[UX500_MUSB_DMA_NUM_RX_CHANNELS]; 52 - struct ux500_dma_channel tx_channel[UX500_MUSB_DMA_NUM_TX_CHANNELS]; 53 - u32 num_rx_channels; 54 - u32 num_tx_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_RX_TX_CHANNELS]; 55 53 void *private_data; 56 54 dma_addr_t phy_base; 57 55 }; ··· 142 144 struct ux500_dma_channel *ux500_channel = NULL; 143 145 struct musb *musb = controller->private_data; 144 146 u8 ch_num = hw_ep->epnum - 1; 145 - u32 max_ch; 146 147 147 - /* Max 8 DMA channels (0 - 7). Each DMA channel can only be allocated 148 + /* 8 DMA channels (0 - 7). Each DMA channel can only be allocated 148 149 * to specified hw_ep. For example DMA channel 0 can only be allocated 149 150 * to hw_ep 1 and 9. 150 151 */ 151 152 if (ch_num > 7) 152 153 ch_num -= 8; 153 154 154 - max_ch = is_tx ? controller->num_tx_channels : 155 - controller->num_rx_channels; 156 - 157 - if (ch_num >= max_ch) 155 + if (ch_num >= UX500_MUSB_DMA_NUM_RX_TX_CHANNELS) 158 156 return NULL; 159 157 160 158 ux500_channel = is_tx ? &(controller->tx_channel[ch_num]) : ··· 258 264 struct dma_channel *channel; 259 265 u8 ch_num; 260 266 261 - for (ch_num = 0; ch_num < controller->num_rx_channels; ch_num++) { 267 + for (ch_num = 0; ch_num < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; ch_num++) { 262 268 channel = &controller->rx_channel[ch_num].channel; 263 269 ux500_channel = channel->private_data; 264 270 ··· 268 274 dma_release_channel(ux500_channel->dma_chan); 269 275 } 270 276 271 - for (ch_num = 0; ch_num < controller->num_tx_channels; ch_num++) { 277 + for (ch_num = 0; ch_num < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; ch_num++) { 272 278 channel = &controller->tx_channel[ch_num].channel; 273 279 ux500_channel = channel->private_data; 274 280 ··· 297 303 298 304 void **param_array; 299 305 struct ux500_dma_channel *channel_array; 300 - u32 ch_count; 301 306 dma_cap_mask_t mask; 302 307 303 - if ((data->num_rx_channels > UX500_MUSB_DMA_NUM_RX_CHANNELS) || 304 - (data->num_tx_channels > UX500_MUSB_DMA_NUM_TX_CHANNELS)) 305 - return -EINVAL; 306 308 307 - controller->num_rx_channels = data->num_rx_channels; 308 - controller->num_tx_channels = data->num_tx_channels; 309 309 310 310 dma_cap_zero(mask); 311 311 dma_cap_set(DMA_SLAVE, mask); 312 312 313 313 /* Prepare the loop for RX channels */ 314 314 channel_array = controller->rx_channel; 315 - ch_count = data->num_rx_channels; 316 315 param_array = data->dma_rx_param_array; 317 316 318 317 for (dir = 0; dir < 2; dir++) { 319 - for (ch_num = 0; ch_num < ch_count; ch_num++) { 318 + for (ch_num = 0; 319 + ch_num < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; 320 + ch_num++) { 320 321 ux500_channel = &channel_array[ch_num]; 321 322 ux500_channel->controller = controller; 322 323 ux500_channel->ch_num = ch_num; ··· 339 350 340 351 /* Prepare the loop for TX channels */ 341 352 channel_array = controller->tx_channel; 342 - ch_count = data->num_tx_channels; 343 353 param_array = data->dma_tx_param_array; 344 354 is_tx = 1; 345 355 }
+1 -4
include/linux/platform_data/usb-musb-ux500.h
··· 9 9 10 10 #include <linux/dmaengine.h> 11 11 12 - #define UX500_MUSB_DMA_NUM_RX_CHANNELS 8 13 - #define UX500_MUSB_DMA_NUM_TX_CHANNELS 8 12 + #define UX500_MUSB_DMA_NUM_RX_TX_CHANNELS 8 14 13 15 14 struct ux500_musb_board_data { 16 15 void **dma_rx_param_array; 17 16 void **dma_tx_param_array; 18 - u32 num_rx_channels; 19 - u32 num_tx_channels; 20 17 bool (*dma_filter)(struct dma_chan *chan, void *filter_param); 21 18 }; 22 19