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 <plat/ste_dma40.h>
10 #include <mach/hardware.h>
13 #define MUSB_DMA40_RX_CH { \
14 .mode = STEDMA40_MODE_LOGICAL, \
15 .dir = STEDMA40_PERIPH_TO_MEM, \
16 .dst_dev_type = STEDMA40_DEV_DST_MEMORY, \
17 .src_info.data_width = STEDMA40_WORD_WIDTH, \
18 .dst_info.data_width = STEDMA40_WORD_WIDTH, \
19 .src_info.psize = STEDMA40_PSIZE_LOG_16, \
20 .dst_info.psize = STEDMA40_PSIZE_LOG_16, \
23 #define MUSB_DMA40_TX_CH { \
24 .mode = STEDMA40_MODE_LOGICAL, \
25 .dir = STEDMA40_MEM_TO_PERIPH, \
26 .src_dev_type = STEDMA40_DEV_SRC_MEMORY, \
27 .src_info.data_width = STEDMA40_WORD_WIDTH, \
28 .dst_info.data_width = STEDMA40_WORD_WIDTH, \
29 .src_info.psize = STEDMA40_PSIZE_LOG_16, \
30 .dst_info.psize = STEDMA40_PSIZE_LOG_16, \
33 static struct stedma40_chan_cfg musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_CHANNELS]
45 static struct stedma40_chan_cfg musb_dma_tx_ch[UX500_MUSB_DMA_NUM_TX_CHANNELS]
57 static void *ux500_dma_rx_param_array[UX500_MUSB_DMA_NUM_RX_CHANNELS] = {
68 static void *ux500_dma_tx_param_array[UX500_MUSB_DMA_NUM_TX_CHANNELS] = {
79 static struct ux500_musb_board_data musb_board_data = {
80 .dma_rx_param_array = ux500_dma_rx_param_array,
81 .dma_tx_param_array = ux500_dma_tx_param_array,
82 .num_rx_channels = UX500_MUSB_DMA_NUM_RX_CHANNELS,
83 .num_tx_channels = UX500_MUSB_DMA_NUM_TX_CHANNELS,
84 .dma_filter = stedma40_filter,
87 static u64 ux500_musb_dmamask = DMA_BIT_MASK(32);
89 static struct musb_hdrc_config musb_hdrc_config = {
96 static struct musb_hdrc_platform_data musb_platform_data = {
97 #if defined(CONFIG_USB_MUSB_OTG)
99 #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
100 .mode = MUSB_PERIPHERAL,
101 #else /* defined(CONFIG_USB_MUSB_HOST) */
104 .config = &musb_hdrc_config,
105 .board_data = &musb_board_data,
108 static struct resource usb_resources[] = {
111 .flags = IORESOURCE_MEM,
115 .name = "mc", /* hard-coded in musb */
116 .flags = IORESOURCE_IRQ,
120 struct platform_device ux500_musb_device = {
121 .name = "musb-ux500",
124 .platform_data = &musb_platform_data,
125 .dma_mask = &ux500_musb_dmamask,
126 .coherent_dma_mask = DMA_BIT_MASK(32),
128 .num_resources = ARRAY_SIZE(usb_resources),
129 .resource = usb_resources,
132 static inline void ux500_usb_dma_update_rx_ch_config(int *src_dev_type)
136 for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_CHANNELS; idx++)
137 musb_dma_rx_ch[idx].src_dev_type = src_dev_type[idx];
140 static inline void ux500_usb_dma_update_tx_ch_config(int *dst_dev_type)
144 for (idx = 0; idx < UX500_MUSB_DMA_NUM_TX_CHANNELS; idx++)
145 musb_dma_tx_ch[idx].dst_dev_type = dst_dev_type[idx];
148 void ux500_add_usb(resource_size_t base, int irq, int *dma_rx_cfg,
151 ux500_musb_device.resource[0].start = base;
152 ux500_musb_device.resource[0].end = base + SZ_64K - 1;
153 ux500_musb_device.resource[1].start = irq;
154 ux500_musb_device.resource[1].end = irq;
156 ux500_usb_dma_update_rx_ch_config(dma_rx_cfg);
157 ux500_usb_dma_update_tx_ch_config(dma_tx_cfg);
159 platform_device_register(&ux500_musb_device);