2 * Copyright (C) ST-Ericsson SA 2010
4 * License terms: GNU General Public License (GPL), version 2
7 #include <linux/platform_device.h>
8 #include <linux/init.h>
9 #include <linux/gpio.h>
10 #include <linux/platform_data/pinctrl-nomadik.h>
11 #include <linux/platform_data/dma-ste-dma40.h>
13 #include <mach/devices.h>
14 #include <mach/hardware.h>
15 #include <mach/irqs.h>
18 #include "ste-dma40-db8500.h"
19 #include "board-mop500.h"
20 #include "devices-db8500.h"
21 #include "pins-db8500.h"
23 static struct stedma40_chan_cfg msp0_dma_rx
= {
24 .high_priority
= true,
25 .dir
= STEDMA40_PERIPH_TO_MEM
,
27 .src_dev_type
= DB8500_DMA_DEV31_MSP0_RX_SLIM0_CH0_RX
,
28 .dst_dev_type
= STEDMA40_DEV_DST_MEMORY
,
30 .src_info
.psize
= STEDMA40_PSIZE_LOG_4
,
31 .dst_info
.psize
= STEDMA40_PSIZE_LOG_4
,
33 /* data_width is set during configuration */
36 static struct stedma40_chan_cfg msp0_dma_tx
= {
37 .high_priority
= true,
38 .dir
= STEDMA40_MEM_TO_PERIPH
,
40 .src_dev_type
= STEDMA40_DEV_DST_MEMORY
,
41 .dst_dev_type
= DB8500_DMA_DEV31_MSP0_TX_SLIM0_CH0_TX
,
43 .src_info
.psize
= STEDMA40_PSIZE_LOG_4
,
44 .dst_info
.psize
= STEDMA40_PSIZE_LOG_4
,
46 /* data_width is set during configuration */
49 struct msp_i2s_platform_data msp0_platform_data
= {
51 .msp_i2s_dma_rx
= &msp0_dma_rx
,
52 .msp_i2s_dma_tx
= &msp0_dma_tx
,
55 static struct stedma40_chan_cfg msp1_dma_rx
= {
56 .high_priority
= true,
57 .dir
= STEDMA40_PERIPH_TO_MEM
,
59 .src_dev_type
= DB8500_DMA_DEV30_MSP3_RX
,
60 .dst_dev_type
= STEDMA40_DEV_DST_MEMORY
,
62 .src_info
.psize
= STEDMA40_PSIZE_LOG_4
,
63 .dst_info
.psize
= STEDMA40_PSIZE_LOG_4
,
65 /* data_width is set during configuration */
68 static struct stedma40_chan_cfg msp1_dma_tx
= {
69 .high_priority
= true,
70 .dir
= STEDMA40_MEM_TO_PERIPH
,
72 .src_dev_type
= STEDMA40_DEV_DST_MEMORY
,
73 .dst_dev_type
= DB8500_DMA_DEV30_MSP1_TX
,
75 .src_info
.psize
= STEDMA40_PSIZE_LOG_4
,
76 .dst_info
.psize
= STEDMA40_PSIZE_LOG_4
,
78 /* data_width is set during configuration */
81 struct msp_i2s_platform_data msp1_platform_data
= {
83 .msp_i2s_dma_rx
= NULL
,
84 .msp_i2s_dma_tx
= &msp1_dma_tx
,
87 static struct stedma40_chan_cfg msp2_dma_rx
= {
88 .high_priority
= true,
89 .dir
= STEDMA40_PERIPH_TO_MEM
,
91 .src_dev_type
= DB8500_DMA_DEV14_MSP2_RX
,
92 .dst_dev_type
= STEDMA40_DEV_DST_MEMORY
,
94 /* MSP2 DMA doesn't work with PSIZE == 4 on DB8500v2 */
95 .src_info
.psize
= STEDMA40_PSIZE_LOG_1
,
96 .dst_info
.psize
= STEDMA40_PSIZE_LOG_1
,
98 /* data_width is set during configuration */
101 static struct stedma40_chan_cfg msp2_dma_tx
= {
102 .high_priority
= true,
103 .dir
= STEDMA40_MEM_TO_PERIPH
,
105 .src_dev_type
= STEDMA40_DEV_DST_MEMORY
,
106 .dst_dev_type
= DB8500_DMA_DEV14_MSP2_TX
,
108 .src_info
.psize
= STEDMA40_PSIZE_LOG_4
,
109 .dst_info
.psize
= STEDMA40_PSIZE_LOG_4
,
111 .use_fixed_channel
= true,
114 /* data_width is set during configuration */
117 static struct platform_device
*db8500_add_msp_i2s(struct device
*parent
,
119 resource_size_t base
, int irq
,
120 struct msp_i2s_platform_data
*pdata
)
122 struct platform_device
*pdev
;
123 struct resource res
[] = {
124 DEFINE_RES_MEM(base
, SZ_4K
),
128 pr_info("Register platform-device 'ux500-msp-i2s', id %d, irq %d\n",
130 pdev
= platform_device_register_resndata(parent
, "ux500-msp-i2s", id
,
131 res
, ARRAY_SIZE(res
),
132 pdata
, sizeof(*pdata
));
134 pr_err("Failed to register platform-device 'ux500-msp-i2s.%d'!\n",
142 /* Platform device for ASoC MOP500 machine */
143 static struct platform_device snd_soc_mop500
= {
144 .name
= "snd-soc-mop500",
147 .platform_data
= NULL
,
151 struct msp_i2s_platform_data msp2_platform_data
= {
153 .msp_i2s_dma_rx
= &msp2_dma_rx
,
154 .msp_i2s_dma_tx
= &msp2_dma_tx
,
157 struct msp_i2s_platform_data msp3_platform_data
= {
159 .msp_i2s_dma_rx
= &msp1_dma_rx
,
160 .msp_i2s_dma_tx
= NULL
,
163 void mop500_audio_init(struct device
*parent
)
165 pr_info("%s: Register platform-device 'snd-soc-mop500'.\n", __func__
);
166 platform_device_register(&snd_soc_mop500
);
168 pr_info("Initialize MSP I2S-devices.\n");
169 db8500_add_msp_i2s(parent
, 0, U8500_MSP0_BASE
, IRQ_DB8500_MSP0
,
170 &msp0_platform_data
);
171 db8500_add_msp_i2s(parent
, 1, U8500_MSP1_BASE
, IRQ_DB8500_MSP1
,
172 &msp1_platform_data
);
173 db8500_add_msp_i2s(parent
, 2, U8500_MSP2_BASE
, IRQ_DB8500_MSP2
,
174 &msp2_platform_data
);
175 db8500_add_msp_i2s(parent
, 3, U8500_MSP3_BASE
, IRQ_DB8500_MSP1
,
176 &msp3_platform_data
);