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 <linux/platform_data/usb-musb-ux500.h>
11 #include <linux/platform_data/dma-ste-dma40.h>
13 #include "db8500-regs.h"
15 #define MUSB_DMA40_RX_CH { \
16 .mode = STEDMA40_MODE_LOGICAL, \
17 .dir = STEDMA40_PERIPH_TO_MEM, \
20 #define MUSB_DMA40_TX_CH { \
21 .mode = STEDMA40_MODE_LOGICAL, \
22 .dir = STEDMA40_MEM_TO_PERIPH, \
25 static struct stedma40_chan_cfg musb_dma_rx_ch[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS]
37 static struct stedma40_chan_cfg musb_dma_tx_ch[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS]
49 static void *ux500_dma_rx_param_array[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] = {
60 static void *ux500_dma_tx_param_array[UX500_MUSB_DMA_NUM_RX_TX_CHANNELS] = {
71 static struct ux500_musb_board_data musb_board_data = {
72 .dma_rx_param_array = ux500_dma_rx_param_array,
73 .dma_tx_param_array = ux500_dma_tx_param_array,
74 .dma_filter = stedma40_filter,
77 static u64 ux500_musb_dmamask = DMA_BIT_MASK(32);
79 static struct musb_hdrc_config musb_hdrc_config = {
86 static struct musb_hdrc_platform_data musb_platform_data = {
88 .config = &musb_hdrc_config,
89 .board_data = &musb_board_data,
92 static struct resource usb_resources[] = {
95 .flags = IORESOURCE_MEM,
99 .name = "mc", /* hard-coded in musb */
100 .flags = IORESOURCE_IRQ,
104 struct platform_device ux500_musb_device = {
105 .name = "musb-ux500",
108 .platform_data = &musb_platform_data,
109 .dma_mask = &ux500_musb_dmamask,
110 .coherent_dma_mask = DMA_BIT_MASK(32),
112 .num_resources = ARRAY_SIZE(usb_resources),
113 .resource = usb_resources,
116 static inline void ux500_usb_dma_update_rx_ch_config(int *dev_type)
120 for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; idx++)
121 musb_dma_rx_ch[idx].dev_type = dev_type[idx];
124 static inline void ux500_usb_dma_update_tx_ch_config(int *dev_type)
128 for (idx = 0; idx < UX500_MUSB_DMA_NUM_RX_TX_CHANNELS; idx++)
129 musb_dma_tx_ch[idx].dev_type = dev_type[idx];
132 void ux500_add_usb(struct device *parent, resource_size_t base, int irq,
133 int *dma_rx_cfg, int *dma_tx_cfg)
135 ux500_musb_device.resource[0].start = base;
136 ux500_musb_device.resource[0].end = base + SZ_64K - 1;
137 ux500_musb_device.resource[1].start = irq;
138 ux500_musb_device.resource[1].end = irq;
140 ux500_usb_dma_update_rx_ch_config(dma_rx_cfg);
141 ux500_usb_dma_update_tx_ch_config(dma_tx_cfg);
143 ux500_musb_device.dev.parent = parent;
145 platform_device_register(&ux500_musb_device);