]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/arm/mach-ux500/board-mop500-audio.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
[karo-tx-linux.git] / arch / arm / mach-ux500 / board-mop500-audio.c
1 /*
2  * Copyright (C) ST-Ericsson SA 2010
3  *
4  * License terms: GNU General Public License (GPL), version 2
5  */
6
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
12 #include <plat/ste_dma40.h>
13
14 #include <mach/devices.h>
15 #include <mach/hardware.h>
16 #include <mach/irqs.h>
17 #include <mach/msp.h>
18
19 #include "ste-dma40-db8500.h"
20 #include "board-mop500.h"
21 #include "devices-db8500.h"
22 #include "pins-db8500.h"
23
24 static struct stedma40_chan_cfg msp0_dma_rx = {
25         .high_priority = true,
26         .dir = STEDMA40_PERIPH_TO_MEM,
27
28         .src_dev_type = DB8500_DMA_DEV31_MSP0_RX_SLIM0_CH0_RX,
29         .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
30
31         .src_info.psize = STEDMA40_PSIZE_LOG_4,
32         .dst_info.psize = STEDMA40_PSIZE_LOG_4,
33
34         /* data_width is set during configuration */
35 };
36
37 static struct stedma40_chan_cfg msp0_dma_tx = {
38         .high_priority = true,
39         .dir = STEDMA40_MEM_TO_PERIPH,
40
41         .src_dev_type = STEDMA40_DEV_DST_MEMORY,
42         .dst_dev_type = DB8500_DMA_DEV31_MSP0_TX_SLIM0_CH0_TX,
43
44         .src_info.psize = STEDMA40_PSIZE_LOG_4,
45         .dst_info.psize = STEDMA40_PSIZE_LOG_4,
46
47         /* data_width is set during configuration */
48 };
49
50 struct msp_i2s_platform_data msp0_platform_data = {
51         .id = MSP_I2S_0,
52         .msp_i2s_dma_rx = &msp0_dma_rx,
53         .msp_i2s_dma_tx = &msp0_dma_tx,
54 };
55
56 static struct stedma40_chan_cfg msp1_dma_rx = {
57         .high_priority = true,
58         .dir = STEDMA40_PERIPH_TO_MEM,
59
60         .src_dev_type = DB8500_DMA_DEV30_MSP3_RX,
61         .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
62
63         .src_info.psize = STEDMA40_PSIZE_LOG_4,
64         .dst_info.psize = STEDMA40_PSIZE_LOG_4,
65
66         /* data_width is set during configuration */
67 };
68
69 static struct stedma40_chan_cfg msp1_dma_tx = {
70         .high_priority = true,
71         .dir = STEDMA40_MEM_TO_PERIPH,
72
73         .src_dev_type = STEDMA40_DEV_DST_MEMORY,
74         .dst_dev_type = DB8500_DMA_DEV30_MSP1_TX,
75
76         .src_info.psize = STEDMA40_PSIZE_LOG_4,
77         .dst_info.psize = STEDMA40_PSIZE_LOG_4,
78
79         /* data_width is set during configuration */
80 };
81
82 struct msp_i2s_platform_data msp1_platform_data = {
83         .id = MSP_I2S_1,
84         .msp_i2s_dma_rx = NULL,
85         .msp_i2s_dma_tx = &msp1_dma_tx,
86 };
87
88 static struct stedma40_chan_cfg msp2_dma_rx = {
89         .high_priority = true,
90         .dir = STEDMA40_PERIPH_TO_MEM,
91
92         .src_dev_type = DB8500_DMA_DEV14_MSP2_RX,
93         .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
94
95         /* MSP2 DMA doesn't work with PSIZE == 4 on DB8500v2 */
96         .src_info.psize = STEDMA40_PSIZE_LOG_1,
97         .dst_info.psize = STEDMA40_PSIZE_LOG_1,
98
99         /* data_width is set during configuration */
100 };
101
102 static struct stedma40_chan_cfg msp2_dma_tx = {
103         .high_priority = true,
104         .dir = STEDMA40_MEM_TO_PERIPH,
105
106         .src_dev_type = STEDMA40_DEV_DST_MEMORY,
107         .dst_dev_type = DB8500_DMA_DEV14_MSP2_TX,
108
109         .src_info.psize = STEDMA40_PSIZE_LOG_4,
110         .dst_info.psize = STEDMA40_PSIZE_LOG_4,
111
112         .use_fixed_channel = true,
113         .phy_channel = 1,
114
115         /* data_width is set during configuration */
116 };
117
118 static struct platform_device *db8500_add_msp_i2s(struct device *parent,
119                         int id,
120                         resource_size_t base, int irq,
121                         struct msp_i2s_platform_data *pdata)
122 {
123         struct platform_device *pdev;
124         struct resource res[] = {
125                 DEFINE_RES_MEM(base, SZ_4K),
126                 DEFINE_RES_IRQ(irq),
127         };
128
129         pr_info("Register platform-device 'ux500-msp-i2s', id %d, irq %d\n",
130                 id, irq);
131         pdev = platform_device_register_resndata(parent, "ux500-msp-i2s", id,
132                                                 res, ARRAY_SIZE(res),
133                                                 pdata, sizeof(*pdata));
134         if (!pdev) {
135                 pr_err("Failed to register platform-device 'ux500-msp-i2s.%d'!\n",
136                         id);
137                 return NULL;
138         }
139
140         return pdev;
141 }
142
143 /* Platform device for ASoC MOP500 machine */
144 static struct platform_device snd_soc_mop500 = {
145         .name = "snd-soc-mop500",
146         .id = 0,
147         .dev = {
148                 .platform_data = NULL,
149         },
150 };
151
152 /* Platform device for Ux500-PCM */
153 static struct platform_device ux500_pcm = {
154                 .name = "ux500-pcm",
155                 .id = 0,
156                 .dev = {
157                         .platform_data = NULL,
158                 },
159 };
160
161 struct msp_i2s_platform_data msp2_platform_data = {
162         .id = MSP_I2S_2,
163         .msp_i2s_dma_rx = &msp2_dma_rx,
164         .msp_i2s_dma_tx = &msp2_dma_tx,
165 };
166
167 struct msp_i2s_platform_data msp3_platform_data = {
168         .id             = MSP_I2S_3,
169         .msp_i2s_dma_rx = &msp1_dma_rx,
170         .msp_i2s_dma_tx = NULL,
171 };
172
173 void mop500_audio_init(struct device *parent)
174 {
175         pr_info("%s: Register platform-device 'snd-soc-mop500'.\n", __func__);
176         platform_device_register(&snd_soc_mop500);
177
178         pr_info("Initialize MSP I2S-devices.\n");
179         db8500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0,
180                            &msp0_platform_data);
181         db8500_add_msp_i2s(parent, 1, U8500_MSP1_BASE, IRQ_DB8500_MSP1,
182                            &msp1_platform_data);
183         db8500_add_msp_i2s(parent, 2, U8500_MSP2_BASE, IRQ_DB8500_MSP2,
184                            &msp2_platform_data);
185         db8500_add_msp_i2s(parent, 3, U8500_MSP3_BASE, IRQ_DB8500_MSP1,
186                            &msp3_platform_data);
187 }
188
189 /* Due for removal once the MSP driver has been fully DT:ed. */
190 void mop500_of_audio_init(struct device *parent)
191 {
192         pr_info("%s: Register platform-device 'ux500-pcm'\n", __func__);
193         platform_device_register(&ux500_pcm);
194 }