kvm tools, setup: Create private directory
[linux-2.6/next.git] / arch / arm / mach-exynos4 / dev-audio.c
blob1eed5f9f7bd318bee8be3270239d684bd7b69824
1 /* linux/arch/arm/mach-exynos4/dev-audio.c
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
6 * Copyright (c) 2010 Samsung Electronics Co. Ltd
7 * Jaswinder Singh <jassi.brar@samsung.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/platform_device.h>
15 #include <linux/dma-mapping.h>
16 #include <linux/gpio.h>
18 #include <plat/gpio-cfg.h>
19 #include <plat/audio.h>
21 #include <mach/map.h>
22 #include <mach/dma.h>
23 #include <mach/irqs.h>
25 static const char *rclksrc[] = {
26 [0] = "busclk",
27 [1] = "i2sclk",
30 static int exynos4_cfg_i2s(struct platform_device *pdev)
32 /* configure GPIO for i2s port */
33 switch (pdev->id) {
34 case 0:
35 s3c_gpio_cfgpin_range(EXYNOS4_GPZ(0), 7, S3C_GPIO_SFN(2));
36 break;
37 case 1:
38 s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(2));
39 break;
40 case 2:
41 s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 5, S3C_GPIO_SFN(4));
42 break;
43 default:
44 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
45 return -EINVAL;
48 return 0;
51 static struct s3c_audio_pdata i2sv5_pdata = {
52 .cfg_gpio = exynos4_cfg_i2s,
53 .type = {
54 .i2s = {
55 .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
56 | QUIRK_NEED_RSTCLR,
57 .src_clk = rclksrc,
62 static struct resource exynos4_i2s0_resource[] = {
63 [0] = {
64 .start = EXYNOS4_PA_I2S0,
65 .end = EXYNOS4_PA_I2S0 + 0x100 - 1,
66 .flags = IORESOURCE_MEM,
68 [1] = {
69 .start = DMACH_I2S0_TX,
70 .end = DMACH_I2S0_TX,
71 .flags = IORESOURCE_DMA,
73 [2] = {
74 .start = DMACH_I2S0_RX,
75 .end = DMACH_I2S0_RX,
76 .flags = IORESOURCE_DMA,
78 [3] = {
79 .start = DMACH_I2S0S_TX,
80 .end = DMACH_I2S0S_TX,
81 .flags = IORESOURCE_DMA,
85 struct platform_device exynos4_device_i2s0 = {
86 .name = "samsung-i2s",
87 .id = 0,
88 .num_resources = ARRAY_SIZE(exynos4_i2s0_resource),
89 .resource = exynos4_i2s0_resource,
90 .dev = {
91 .platform_data = &i2sv5_pdata,
95 static const char *rclksrc_v3[] = {
96 [0] = "sclk_i2s",
97 [1] = "no_such_clock",
100 static struct s3c_audio_pdata i2sv3_pdata = {
101 .cfg_gpio = exynos4_cfg_i2s,
102 .type = {
103 .i2s = {
104 .quirks = QUIRK_NO_MUXPSR,
105 .src_clk = rclksrc_v3,
110 static struct resource exynos4_i2s1_resource[] = {
111 [0] = {
112 .start = EXYNOS4_PA_I2S1,
113 .end = EXYNOS4_PA_I2S1 + 0x100 - 1,
114 .flags = IORESOURCE_MEM,
116 [1] = {
117 .start = DMACH_I2S1_TX,
118 .end = DMACH_I2S1_TX,
119 .flags = IORESOURCE_DMA,
121 [2] = {
122 .start = DMACH_I2S1_RX,
123 .end = DMACH_I2S1_RX,
124 .flags = IORESOURCE_DMA,
128 struct platform_device exynos4_device_i2s1 = {
129 .name = "samsung-i2s",
130 .id = 1,
131 .num_resources = ARRAY_SIZE(exynos4_i2s1_resource),
132 .resource = exynos4_i2s1_resource,
133 .dev = {
134 .platform_data = &i2sv3_pdata,
138 static struct resource exynos4_i2s2_resource[] = {
139 [0] = {
140 .start = EXYNOS4_PA_I2S2,
141 .end = EXYNOS4_PA_I2S2 + 0x100 - 1,
142 .flags = IORESOURCE_MEM,
144 [1] = {
145 .start = DMACH_I2S2_TX,
146 .end = DMACH_I2S2_TX,
147 .flags = IORESOURCE_DMA,
149 [2] = {
150 .start = DMACH_I2S2_RX,
151 .end = DMACH_I2S2_RX,
152 .flags = IORESOURCE_DMA,
156 struct platform_device exynos4_device_i2s2 = {
157 .name = "samsung-i2s",
158 .id = 2,
159 .num_resources = ARRAY_SIZE(exynos4_i2s2_resource),
160 .resource = exynos4_i2s2_resource,
161 .dev = {
162 .platform_data = &i2sv3_pdata,
166 /* PCM Controller platform_devices */
168 static int exynos4_pcm_cfg_gpio(struct platform_device *pdev)
170 switch (pdev->id) {
171 case 0:
172 s3c_gpio_cfgpin_range(EXYNOS4_GPZ(0), 5, S3C_GPIO_SFN(3));
173 break;
174 case 1:
175 s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(3));
176 break;
177 case 2:
178 s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 5, S3C_GPIO_SFN(3));
179 break;
180 default:
181 printk(KERN_DEBUG "Invalid PCM Controller number!");
182 return -EINVAL;
185 return 0;
188 static struct s3c_audio_pdata s3c_pcm_pdata = {
189 .cfg_gpio = exynos4_pcm_cfg_gpio,
192 static struct resource exynos4_pcm0_resource[] = {
193 [0] = {
194 .start = EXYNOS4_PA_PCM0,
195 .end = EXYNOS4_PA_PCM0 + 0x100 - 1,
196 .flags = IORESOURCE_MEM,
198 [1] = {
199 .start = DMACH_PCM0_TX,
200 .end = DMACH_PCM0_TX,
201 .flags = IORESOURCE_DMA,
203 [2] = {
204 .start = DMACH_PCM0_RX,
205 .end = DMACH_PCM0_RX,
206 .flags = IORESOURCE_DMA,
210 struct platform_device exynos4_device_pcm0 = {
211 .name = "samsung-pcm",
212 .id = 0,
213 .num_resources = ARRAY_SIZE(exynos4_pcm0_resource),
214 .resource = exynos4_pcm0_resource,
215 .dev = {
216 .platform_data = &s3c_pcm_pdata,
220 static struct resource exynos4_pcm1_resource[] = {
221 [0] = {
222 .start = EXYNOS4_PA_PCM1,
223 .end = EXYNOS4_PA_PCM1 + 0x100 - 1,
224 .flags = IORESOURCE_MEM,
226 [1] = {
227 .start = DMACH_PCM1_TX,
228 .end = DMACH_PCM1_TX,
229 .flags = IORESOURCE_DMA,
231 [2] = {
232 .start = DMACH_PCM1_RX,
233 .end = DMACH_PCM1_RX,
234 .flags = IORESOURCE_DMA,
238 struct platform_device exynos4_device_pcm1 = {
239 .name = "samsung-pcm",
240 .id = 1,
241 .num_resources = ARRAY_SIZE(exynos4_pcm1_resource),
242 .resource = exynos4_pcm1_resource,
243 .dev = {
244 .platform_data = &s3c_pcm_pdata,
248 static struct resource exynos4_pcm2_resource[] = {
249 [0] = {
250 .start = EXYNOS4_PA_PCM2,
251 .end = EXYNOS4_PA_PCM2 + 0x100 - 1,
252 .flags = IORESOURCE_MEM,
254 [1] = {
255 .start = DMACH_PCM2_TX,
256 .end = DMACH_PCM2_TX,
257 .flags = IORESOURCE_DMA,
259 [2] = {
260 .start = DMACH_PCM2_RX,
261 .end = DMACH_PCM2_RX,
262 .flags = IORESOURCE_DMA,
266 struct platform_device exynos4_device_pcm2 = {
267 .name = "samsung-pcm",
268 .id = 2,
269 .num_resources = ARRAY_SIZE(exynos4_pcm2_resource),
270 .resource = exynos4_pcm2_resource,
271 .dev = {
272 .platform_data = &s3c_pcm_pdata,
276 /* AC97 Controller platform devices */
278 static int exynos4_ac97_cfg_gpio(struct platform_device *pdev)
280 return s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(4));
283 static struct resource exynos4_ac97_resource[] = {
284 [0] = {
285 .start = EXYNOS4_PA_AC97,
286 .end = EXYNOS4_PA_AC97 + 0x100 - 1,
287 .flags = IORESOURCE_MEM,
289 [1] = {
290 .start = DMACH_AC97_PCMOUT,
291 .end = DMACH_AC97_PCMOUT,
292 .flags = IORESOURCE_DMA,
294 [2] = {
295 .start = DMACH_AC97_PCMIN,
296 .end = DMACH_AC97_PCMIN,
297 .flags = IORESOURCE_DMA,
299 [3] = {
300 .start = DMACH_AC97_MICIN,
301 .end = DMACH_AC97_MICIN,
302 .flags = IORESOURCE_DMA,
304 [4] = {
305 .start = IRQ_AC97,
306 .end = IRQ_AC97,
307 .flags = IORESOURCE_IRQ,
311 static struct s3c_audio_pdata s3c_ac97_pdata = {
312 .cfg_gpio = exynos4_ac97_cfg_gpio,
315 static u64 exynos4_ac97_dmamask = DMA_BIT_MASK(32);
317 struct platform_device exynos4_device_ac97 = {
318 .name = "samsung-ac97",
319 .id = -1,
320 .num_resources = ARRAY_SIZE(exynos4_ac97_resource),
321 .resource = exynos4_ac97_resource,
322 .dev = {
323 .platform_data = &s3c_ac97_pdata,
324 .dma_mask = &exynos4_ac97_dmamask,
325 .coherent_dma_mask = DMA_BIT_MASK(32),
329 /* S/PDIF Controller platform_device */
331 static int exynos4_spdif_cfg_gpio(struct platform_device *pdev)
333 s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 2, S3C_GPIO_SFN(3));
335 return 0;
338 static struct resource exynos4_spdif_resource[] = {
339 [0] = {
340 .start = EXYNOS4_PA_SPDIF,
341 .end = EXYNOS4_PA_SPDIF + 0x100 - 1,
342 .flags = IORESOURCE_MEM,
344 [1] = {
345 .start = DMACH_SPDIF,
346 .end = DMACH_SPDIF,
347 .flags = IORESOURCE_DMA,
351 static struct s3c_audio_pdata samsung_spdif_pdata = {
352 .cfg_gpio = exynos4_spdif_cfg_gpio,
355 static u64 exynos4_spdif_dmamask = DMA_BIT_MASK(32);
357 struct platform_device exynos4_device_spdif = {
358 .name = "samsung-spdif",
359 .id = -1,
360 .num_resources = ARRAY_SIZE(exynos4_spdif_resource),
361 .resource = exynos4_spdif_resource,
362 .dev = {
363 .platform_data = &samsung_spdif_pdata,
364 .dma_mask = &exynos4_spdif_dmamask,
365 .coherent_dma_mask = DMA_BIT_MASK(32),