2 * Copyright (C) ST-Ericsson SA 2011
4 * Author: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
5 * License terms: GNU General Public License (GPL) version 2
7 #include <linux/platform_device.h>
8 #include <linux/usb/musb.h>
9 #include <linux/dma-mapping.h>
10 #include <plat/ste_dma40.h>
11 #include <mach/hardware.h>
14 #define MUSB_DMA40_RX_CH { \
15 .mode = STEDMA40_MODE_LOGICAL, \
16 .dir = STEDMA40_PERIPH_TO_MEM, \
17 .dst_dev_type = STEDMA40_DEV_DST_MEMORY, \
18 .src_info.data_width = STEDMA40_WORD_WIDTH, \
19 .dst_info.data_width = STEDMA40_WORD_WIDTH, \
20 .src_info.psize = STEDMA40_PSIZE_LOG_16, \
21 .dst_info.psize = STEDMA40_PSIZE_LOG_16, \
24 #define MUSB_DMA40_TX_CH { \
25 .mode = STEDMA40_MODE_LOGICAL, \
26 .dir = STEDMA40_MEM_TO_PERIPH, \
27 .src_dev_type = STEDMA40_DEV_SRC_MEMORY, \
28 .src_info.data_width = STEDMA40_WORD_WIDTH, \
29 .dst_info.data_width = STEDMA40_WORD_WIDTH, \
30 .src_info.psize = STEDMA40_PSIZE_LOG_16, \
31 .dst_info.psize = STEDMA40_PSIZE_LOG_16, \
34 static struct stedma40_chan_cfg musb_dma_rx_ch
[UX500_MUSB_DMA_NUM_RX_CHANNELS
]
46 static struct stedma40_chan_cfg musb_dma_tx_ch
[UX500_MUSB_DMA_NUM_TX_CHANNELS
]
58 static void *ux500_dma_rx_param_array
[UX500_MUSB_DMA_NUM_RX_CHANNELS
] = {
69 static void *ux500_dma_tx_param_array
[UX500_MUSB_DMA_NUM_TX_CHANNELS
] = {
80 static struct ux500_musb_board_data musb_board_data
= {
81 .dma_rx_param_array
= ux500_dma_rx_param_array
,
82 .dma_tx_param_array
= ux500_dma_tx_param_array
,
83 .num_rx_channels
= UX500_MUSB_DMA_NUM_RX_CHANNELS
,
84 .num_tx_channels
= UX500_MUSB_DMA_NUM_TX_CHANNELS
,
85 .dma_filter
= stedma40_filter
,
88 static u64 ux500_musb_dmamask
= DMA_BIT_MASK(32);
90 static struct musb_hdrc_config musb_hdrc_config
= {
97 static struct musb_hdrc_platform_data musb_platform_data
= {
99 .config
= &musb_hdrc_config
,
100 .board_data
= &musb_board_data
,
103 static struct resource usb_resources
[] = {
106 .flags
= IORESOURCE_MEM
,
110 .name
= "mc", /* hard-coded in musb */
111 .flags
= IORESOURCE_IRQ
,
115 struct platform_device ux500_musb_device
= {
116 .name
= "musb-ux500",
119 .platform_data
= &musb_platform_data
,
120 .dma_mask
= &ux500_musb_dmamask
,
121 .coherent_dma_mask
= DMA_BIT_MASK(32),
123 .num_resources
= ARRAY_SIZE(usb_resources
),
124 .resource
= usb_resources
,
127 static inline void ux500_usb_dma_update_rx_ch_config(int *src_dev_type
)
131 for (idx
= 0; idx
< UX500_MUSB_DMA_NUM_RX_CHANNELS
; idx
++)
132 musb_dma_rx_ch
[idx
].src_dev_type
= src_dev_type
[idx
];
135 static inline void ux500_usb_dma_update_tx_ch_config(int *dst_dev_type
)
139 for (idx
= 0; idx
< UX500_MUSB_DMA_NUM_TX_CHANNELS
; idx
++)
140 musb_dma_tx_ch
[idx
].dst_dev_type
= dst_dev_type
[idx
];
143 void ux500_add_usb(resource_size_t base
, int irq
, int *dma_rx_cfg
,
146 ux500_musb_device
.resource
[0].start
= base
;
147 ux500_musb_device
.resource
[0].end
= base
+ SZ_64K
- 1;
148 ux500_musb_device
.resource
[1].start
= irq
;
149 ux500_musb_device
.resource
[1].end
= irq
;
151 ux500_usb_dma_update_rx_ch_config(dma_rx_cfg
);
152 ux500_usb_dma_update_tx_ch_config(dma_tx_cfg
);
154 platform_device_register(&ux500_musb_device
);