Merge branch 'next' of git://selinuxproject.org/~jmorris/linux-security
[linux-btrfs-devel.git] / arch / arm / mach-s5pv210 / dev-audio.c
blob63f5d82004b547671122ff6e29ee3a3bdbd779d0
1 /* linux/arch/arm/mach-s5pv210/dev-audio.c
3 * Copyright (c) 2010 Samsung Electronics Co. Ltd
4 * Jaswinder Singh <jassi.brar@samsung.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
11 #include <linux/platform_device.h>
12 #include <linux/dma-mapping.h>
13 #include <linux/gpio.h>
15 #include <plat/gpio-cfg.h>
16 #include <plat/audio.h>
18 #include <mach/map.h>
19 #include <mach/dma.h>
20 #include <mach/irqs.h>
21 #include <mach/regs-audss.h>
23 static const char *rclksrc[] = {
24 [0] = "busclk",
25 [1] = "i2sclk",
28 static int s5pv210_cfg_i2s(struct platform_device *pdev)
30 /* configure GPIO for i2s port */
31 switch (pdev->id) {
32 case 0:
33 s3c_gpio_cfgpin_range(S5PV210_GPI(0), 7, S3C_GPIO_SFN(2));
34 break;
35 case 1:
36 s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(2));
37 break;
38 case 2:
39 s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 5, S3C_GPIO_SFN(4));
40 break;
41 default:
42 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
43 return -EINVAL;
46 return 0;
49 static struct s3c_audio_pdata i2sv5_pdata = {
50 .cfg_gpio = s5pv210_cfg_i2s,
51 .type = {
52 .i2s = {
53 .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
54 | QUIRK_NEED_RSTCLR,
55 .src_clk = rclksrc,
56 .idma_addr = S5PV210_AUDSS_INT_MEM,
61 static struct resource s5pv210_iis0_resource[] = {
62 [0] = {
63 .start = S5PV210_PA_IIS0,
64 .end = S5PV210_PA_IIS0 + 0x100 - 1,
65 .flags = IORESOURCE_MEM,
67 [1] = {
68 .start = DMACH_I2S0_TX,
69 .end = DMACH_I2S0_TX,
70 .flags = IORESOURCE_DMA,
72 [2] = {
73 .start = DMACH_I2S0_RX,
74 .end = DMACH_I2S0_RX,
75 .flags = IORESOURCE_DMA,
77 [3] = {
78 .start = DMACH_I2S0S_TX,
79 .end = DMACH_I2S0S_TX,
80 .flags = IORESOURCE_DMA,
84 struct platform_device s5pv210_device_iis0 = {
85 .name = "samsung-i2s",
86 .id = 0,
87 .num_resources = ARRAY_SIZE(s5pv210_iis0_resource),
88 .resource = s5pv210_iis0_resource,
89 .dev = {
90 .platform_data = &i2sv5_pdata,
94 static const char *rclksrc_v3[] = {
95 [0] = "iis",
96 [1] = "audio-bus",
99 static struct s3c_audio_pdata i2sv3_pdata = {
100 .cfg_gpio = s5pv210_cfg_i2s,
101 .type = {
102 .i2s = {
103 .src_clk = rclksrc_v3,
108 static struct resource s5pv210_iis1_resource[] = {
109 [0] = {
110 .start = S5PV210_PA_IIS1,
111 .end = S5PV210_PA_IIS1 + 0x100 - 1,
112 .flags = IORESOURCE_MEM,
114 [1] = {
115 .start = DMACH_I2S1_TX,
116 .end = DMACH_I2S1_TX,
117 .flags = IORESOURCE_DMA,
119 [2] = {
120 .start = DMACH_I2S1_RX,
121 .end = DMACH_I2S1_RX,
122 .flags = IORESOURCE_DMA,
126 struct platform_device s5pv210_device_iis1 = {
127 .name = "samsung-i2s",
128 .id = 1,
129 .num_resources = ARRAY_SIZE(s5pv210_iis1_resource),
130 .resource = s5pv210_iis1_resource,
131 .dev = {
132 .platform_data = &i2sv3_pdata,
136 static struct resource s5pv210_iis2_resource[] = {
137 [0] = {
138 .start = S5PV210_PA_IIS2,
139 .end = S5PV210_PA_IIS2 + 0x100 - 1,
140 .flags = IORESOURCE_MEM,
142 [1] = {
143 .start = DMACH_I2S2_TX,
144 .end = DMACH_I2S2_TX,
145 .flags = IORESOURCE_DMA,
147 [2] = {
148 .start = DMACH_I2S2_RX,
149 .end = DMACH_I2S2_RX,
150 .flags = IORESOURCE_DMA,
154 struct platform_device s5pv210_device_iis2 = {
155 .name = "samsung-i2s",
156 .id = 2,
157 .num_resources = ARRAY_SIZE(s5pv210_iis2_resource),
158 .resource = s5pv210_iis2_resource,
159 .dev = {
160 .platform_data = &i2sv3_pdata,
164 /* PCM Controller platform_devices */
166 static int s5pv210_pcm_cfg_gpio(struct platform_device *pdev)
168 switch (pdev->id) {
169 case 0:
170 s3c_gpio_cfgpin_range(S5PV210_GPI(0), 5, S3C_GPIO_SFN(3));
171 break;
172 case 1:
173 s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(3));
174 break;
175 case 2:
176 s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 5, S3C_GPIO_SFN(2));
177 break;
178 default:
179 printk(KERN_DEBUG "Invalid PCM Controller number!");
180 return -EINVAL;
183 return 0;
186 static struct s3c_audio_pdata s3c_pcm_pdata = {
187 .cfg_gpio = s5pv210_pcm_cfg_gpio,
190 static struct resource s5pv210_pcm0_resource[] = {
191 [0] = {
192 .start = S5PV210_PA_PCM0,
193 .end = S5PV210_PA_PCM0 + 0x100 - 1,
194 .flags = IORESOURCE_MEM,
196 [1] = {
197 .start = DMACH_PCM0_TX,
198 .end = DMACH_PCM0_TX,
199 .flags = IORESOURCE_DMA,
201 [2] = {
202 .start = DMACH_PCM0_RX,
203 .end = DMACH_PCM0_RX,
204 .flags = IORESOURCE_DMA,
208 struct platform_device s5pv210_device_pcm0 = {
209 .name = "samsung-pcm",
210 .id = 0,
211 .num_resources = ARRAY_SIZE(s5pv210_pcm0_resource),
212 .resource = s5pv210_pcm0_resource,
213 .dev = {
214 .platform_data = &s3c_pcm_pdata,
218 static struct resource s5pv210_pcm1_resource[] = {
219 [0] = {
220 .start = S5PV210_PA_PCM1,
221 .end = S5PV210_PA_PCM1 + 0x100 - 1,
222 .flags = IORESOURCE_MEM,
224 [1] = {
225 .start = DMACH_PCM1_TX,
226 .end = DMACH_PCM1_TX,
227 .flags = IORESOURCE_DMA,
229 [2] = {
230 .start = DMACH_PCM1_RX,
231 .end = DMACH_PCM1_RX,
232 .flags = IORESOURCE_DMA,
236 struct platform_device s5pv210_device_pcm1 = {
237 .name = "samsung-pcm",
238 .id = 1,
239 .num_resources = ARRAY_SIZE(s5pv210_pcm1_resource),
240 .resource = s5pv210_pcm1_resource,
241 .dev = {
242 .platform_data = &s3c_pcm_pdata,
246 static struct resource s5pv210_pcm2_resource[] = {
247 [0] = {
248 .start = S5PV210_PA_PCM2,
249 .end = S5PV210_PA_PCM2 + 0x100 - 1,
250 .flags = IORESOURCE_MEM,
252 [1] = {
253 .start = DMACH_PCM2_TX,
254 .end = DMACH_PCM2_TX,
255 .flags = IORESOURCE_DMA,
257 [2] = {
258 .start = DMACH_PCM2_RX,
259 .end = DMACH_PCM2_RX,
260 .flags = IORESOURCE_DMA,
264 struct platform_device s5pv210_device_pcm2 = {
265 .name = "samsung-pcm",
266 .id = 2,
267 .num_resources = ARRAY_SIZE(s5pv210_pcm2_resource),
268 .resource = s5pv210_pcm2_resource,
269 .dev = {
270 .platform_data = &s3c_pcm_pdata,
274 /* AC97 Controller platform devices */
276 static int s5pv210_ac97_cfg_gpio(struct platform_device *pdev)
278 return s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(4));
281 static struct resource s5pv210_ac97_resource[] = {
282 [0] = {
283 .start = S5PV210_PA_AC97,
284 .end = S5PV210_PA_AC97 + 0x100 - 1,
285 .flags = IORESOURCE_MEM,
287 [1] = {
288 .start = DMACH_AC97_PCMOUT,
289 .end = DMACH_AC97_PCMOUT,
290 .flags = IORESOURCE_DMA,
292 [2] = {
293 .start = DMACH_AC97_PCMIN,
294 .end = DMACH_AC97_PCMIN,
295 .flags = IORESOURCE_DMA,
297 [3] = {
298 .start = DMACH_AC97_MICIN,
299 .end = DMACH_AC97_MICIN,
300 .flags = IORESOURCE_DMA,
302 [4] = {
303 .start = IRQ_AC97,
304 .end = IRQ_AC97,
305 .flags = IORESOURCE_IRQ,
309 static struct s3c_audio_pdata s3c_ac97_pdata = {
310 .cfg_gpio = s5pv210_ac97_cfg_gpio,
313 static u64 s5pv210_ac97_dmamask = DMA_BIT_MASK(32);
315 struct platform_device s5pv210_device_ac97 = {
316 .name = "samsung-ac97",
317 .id = -1,
318 .num_resources = ARRAY_SIZE(s5pv210_ac97_resource),
319 .resource = s5pv210_ac97_resource,
320 .dev = {
321 .platform_data = &s3c_ac97_pdata,
322 .dma_mask = &s5pv210_ac97_dmamask,
323 .coherent_dma_mask = DMA_BIT_MASK(32),
327 /* S/PDIF Controller platform_device */
329 static int s5pv210_spdif_cfg_gpio(struct platform_device *pdev)
331 s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 2, S3C_GPIO_SFN(3));
333 return 0;
336 static struct resource s5pv210_spdif_resource[] = {
337 [0] = {
338 .start = S5PV210_PA_SPDIF,
339 .end = S5PV210_PA_SPDIF + 0x100 - 1,
340 .flags = IORESOURCE_MEM,
342 [1] = {
343 .start = DMACH_SPDIF,
344 .end = DMACH_SPDIF,
345 .flags = IORESOURCE_DMA,
349 static struct s3c_audio_pdata samsung_spdif_pdata = {
350 .cfg_gpio = s5pv210_spdif_cfg_gpio,
353 static u64 s5pv210_spdif_dmamask = DMA_BIT_MASK(32);
355 struct platform_device s5pv210_device_spdif = {
356 .name = "samsung-spdif",
357 .id = -1,
358 .num_resources = ARRAY_SIZE(s5pv210_spdif_resource),
359 .resource = s5pv210_spdif_resource,
360 .dev = {
361 .platform_data = &samsung_spdif_pdata,
362 .dma_mask = &s5pv210_spdif_dmamask,
363 .coherent_dma_mask = DMA_BIT_MASK(32),