Add linux-next specific files for 20110516
[linux-2.6/next.git] / arch / arm / mach-s5pv210 / dev-audio.c
blob8d58f1926241d3358d8a48aea2ef253b2bf4f4c3
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>
22 static const char *rclksrc[] = {
23 [0] = "busclk",
24 [1] = "i2sclk",
27 static int s5pv210_cfg_i2s(struct platform_device *pdev)
29 /* configure GPIO for i2s port */
30 switch (pdev->id) {
31 case 0:
32 s3c_gpio_cfgpin_range(S5PV210_GPI(0), 7, S3C_GPIO_SFN(2));
33 break;
34 case 1:
35 s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(2));
36 break;
37 case 2:
38 s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 5, S3C_GPIO_SFN(4));
39 break;
40 default:
41 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
42 return -EINVAL;
45 return 0;
48 static struct s3c_audio_pdata i2sv5_pdata = {
49 .cfg_gpio = s5pv210_cfg_i2s,
50 .type = {
51 .i2s = {
52 .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
53 | QUIRK_NEED_RSTCLR,
54 .src_clk = rclksrc,
59 static struct resource s5pv210_iis0_resource[] = {
60 [0] = {
61 .start = S5PV210_PA_IIS0,
62 .end = S5PV210_PA_IIS0 + 0x100 - 1,
63 .flags = IORESOURCE_MEM,
65 [1] = {
66 .start = DMACH_I2S0_TX,
67 .end = DMACH_I2S0_TX,
68 .flags = IORESOURCE_DMA,
70 [2] = {
71 .start = DMACH_I2S0_RX,
72 .end = DMACH_I2S0_RX,
73 .flags = IORESOURCE_DMA,
75 [3] = {
76 .start = DMACH_I2S0S_TX,
77 .end = DMACH_I2S0S_TX,
78 .flags = IORESOURCE_DMA,
82 struct platform_device s5pv210_device_iis0 = {
83 .name = "samsung-i2s",
84 .id = 0,
85 .num_resources = ARRAY_SIZE(s5pv210_iis0_resource),
86 .resource = s5pv210_iis0_resource,
87 .dev = {
88 .platform_data = &i2sv5_pdata,
92 static const char *rclksrc_v3[] = {
93 [0] = "iis",
94 [1] = "audio-bus",
97 static struct s3c_audio_pdata i2sv3_pdata = {
98 .cfg_gpio = s5pv210_cfg_i2s,
99 .type = {
100 .i2s = {
101 .src_clk = rclksrc_v3,
106 static struct resource s5pv210_iis1_resource[] = {
107 [0] = {
108 .start = S5PV210_PA_IIS1,
109 .end = S5PV210_PA_IIS1 + 0x100 - 1,
110 .flags = IORESOURCE_MEM,
112 [1] = {
113 .start = DMACH_I2S1_TX,
114 .end = DMACH_I2S1_TX,
115 .flags = IORESOURCE_DMA,
117 [2] = {
118 .start = DMACH_I2S1_RX,
119 .end = DMACH_I2S1_RX,
120 .flags = IORESOURCE_DMA,
124 struct platform_device s5pv210_device_iis1 = {
125 .name = "samsung-i2s",
126 .id = 1,
127 .num_resources = ARRAY_SIZE(s5pv210_iis1_resource),
128 .resource = s5pv210_iis1_resource,
129 .dev = {
130 .platform_data = &i2sv3_pdata,
134 static struct resource s5pv210_iis2_resource[] = {
135 [0] = {
136 .start = S5PV210_PA_IIS2,
137 .end = S5PV210_PA_IIS2 + 0x100 - 1,
138 .flags = IORESOURCE_MEM,
140 [1] = {
141 .start = DMACH_I2S2_TX,
142 .end = DMACH_I2S2_TX,
143 .flags = IORESOURCE_DMA,
145 [2] = {
146 .start = DMACH_I2S2_RX,
147 .end = DMACH_I2S2_RX,
148 .flags = IORESOURCE_DMA,
152 struct platform_device s5pv210_device_iis2 = {
153 .name = "samsung-i2s",
154 .id = 2,
155 .num_resources = ARRAY_SIZE(s5pv210_iis2_resource),
156 .resource = s5pv210_iis2_resource,
157 .dev = {
158 .platform_data = &i2sv3_pdata,
162 /* PCM Controller platform_devices */
164 static int s5pv210_pcm_cfg_gpio(struct platform_device *pdev)
166 switch (pdev->id) {
167 case 0:
168 s3c_gpio_cfgpin_range(S5PV210_GPI(0), 5, S3C_GPIO_SFN(3));
169 break;
170 case 1:
171 s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(3));
172 break;
173 case 2:
174 s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 5, S3C_GPIO_SFN(2));
175 break;
176 default:
177 printk(KERN_DEBUG "Invalid PCM Controller number!");
178 return -EINVAL;
181 return 0;
184 static struct s3c_audio_pdata s3c_pcm_pdata = {
185 .cfg_gpio = s5pv210_pcm_cfg_gpio,
188 static struct resource s5pv210_pcm0_resource[] = {
189 [0] = {
190 .start = S5PV210_PA_PCM0,
191 .end = S5PV210_PA_PCM0 + 0x100 - 1,
192 .flags = IORESOURCE_MEM,
194 [1] = {
195 .start = DMACH_PCM0_TX,
196 .end = DMACH_PCM0_TX,
197 .flags = IORESOURCE_DMA,
199 [2] = {
200 .start = DMACH_PCM0_RX,
201 .end = DMACH_PCM0_RX,
202 .flags = IORESOURCE_DMA,
206 struct platform_device s5pv210_device_pcm0 = {
207 .name = "samsung-pcm",
208 .id = 0,
209 .num_resources = ARRAY_SIZE(s5pv210_pcm0_resource),
210 .resource = s5pv210_pcm0_resource,
211 .dev = {
212 .platform_data = &s3c_pcm_pdata,
216 static struct resource s5pv210_pcm1_resource[] = {
217 [0] = {
218 .start = S5PV210_PA_PCM1,
219 .end = S5PV210_PA_PCM1 + 0x100 - 1,
220 .flags = IORESOURCE_MEM,
222 [1] = {
223 .start = DMACH_PCM1_TX,
224 .end = DMACH_PCM1_TX,
225 .flags = IORESOURCE_DMA,
227 [2] = {
228 .start = DMACH_PCM1_RX,
229 .end = DMACH_PCM1_RX,
230 .flags = IORESOURCE_DMA,
234 struct platform_device s5pv210_device_pcm1 = {
235 .name = "samsung-pcm",
236 .id = 1,
237 .num_resources = ARRAY_SIZE(s5pv210_pcm1_resource),
238 .resource = s5pv210_pcm1_resource,
239 .dev = {
240 .platform_data = &s3c_pcm_pdata,
244 static struct resource s5pv210_pcm2_resource[] = {
245 [0] = {
246 .start = S5PV210_PA_PCM2,
247 .end = S5PV210_PA_PCM2 + 0x100 - 1,
248 .flags = IORESOURCE_MEM,
250 [1] = {
251 .start = DMACH_PCM2_TX,
252 .end = DMACH_PCM2_TX,
253 .flags = IORESOURCE_DMA,
255 [2] = {
256 .start = DMACH_PCM2_RX,
257 .end = DMACH_PCM2_RX,
258 .flags = IORESOURCE_DMA,
262 struct platform_device s5pv210_device_pcm2 = {
263 .name = "samsung-pcm",
264 .id = 2,
265 .num_resources = ARRAY_SIZE(s5pv210_pcm2_resource),
266 .resource = s5pv210_pcm2_resource,
267 .dev = {
268 .platform_data = &s3c_pcm_pdata,
272 /* AC97 Controller platform devices */
274 static int s5pv210_ac97_cfg_gpio(struct platform_device *pdev)
276 return s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(4));
279 static struct resource s5pv210_ac97_resource[] = {
280 [0] = {
281 .start = S5PV210_PA_AC97,
282 .end = S5PV210_PA_AC97 + 0x100 - 1,
283 .flags = IORESOURCE_MEM,
285 [1] = {
286 .start = DMACH_AC97_PCMOUT,
287 .end = DMACH_AC97_PCMOUT,
288 .flags = IORESOURCE_DMA,
290 [2] = {
291 .start = DMACH_AC97_PCMIN,
292 .end = DMACH_AC97_PCMIN,
293 .flags = IORESOURCE_DMA,
295 [3] = {
296 .start = DMACH_AC97_MICIN,
297 .end = DMACH_AC97_MICIN,
298 .flags = IORESOURCE_DMA,
300 [4] = {
301 .start = IRQ_AC97,
302 .end = IRQ_AC97,
303 .flags = IORESOURCE_IRQ,
307 static struct s3c_audio_pdata s3c_ac97_pdata = {
308 .cfg_gpio = s5pv210_ac97_cfg_gpio,
311 static u64 s5pv210_ac97_dmamask = DMA_BIT_MASK(32);
313 struct platform_device s5pv210_device_ac97 = {
314 .name = "samsung-ac97",
315 .id = -1,
316 .num_resources = ARRAY_SIZE(s5pv210_ac97_resource),
317 .resource = s5pv210_ac97_resource,
318 .dev = {
319 .platform_data = &s3c_ac97_pdata,
320 .dma_mask = &s5pv210_ac97_dmamask,
321 .coherent_dma_mask = DMA_BIT_MASK(32),
325 /* S/PDIF Controller platform_device */
327 static int s5pv210_spdif_cfg_gpio(struct platform_device *pdev)
329 s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 2, S3C_GPIO_SFN(3));
331 return 0;
334 static struct resource s5pv210_spdif_resource[] = {
335 [0] = {
336 .start = S5PV210_PA_SPDIF,
337 .end = S5PV210_PA_SPDIF + 0x100 - 1,
338 .flags = IORESOURCE_MEM,
340 [1] = {
341 .start = DMACH_SPDIF,
342 .end = DMACH_SPDIF,
343 .flags = IORESOURCE_DMA,
347 static struct s3c_audio_pdata samsung_spdif_pdata = {
348 .cfg_gpio = s5pv210_spdif_cfg_gpio,
351 static u64 s5pv210_spdif_dmamask = DMA_BIT_MASK(32);
353 struct platform_device s5pv210_device_spdif = {
354 .name = "samsung-spdif",
355 .id = -1,
356 .num_resources = ARRAY_SIZE(s5pv210_spdif_resource),
357 .resource = s5pv210_spdif_resource,
358 .dev = {
359 .platform_data = &samsung_spdif_pdata,
360 .dma_mask = &s5pv210_spdif_dmamask,
361 .coherent_dma_mask = DMA_BIT_MASK(32),