Linux 3.3.2
[zen-stable.git] / arch / arm / mach-s5pc100 / dev-audio.c
blobab2d27172cbcdb10be54a054031e8ad4eb36bdd2
1 /* linux/arch/arm/mach-s5pc100/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 int s5pc100_cfg_i2s(struct platform_device *pdev)
24 /* configure GPIO for i2s port */
25 switch (pdev->id) {
26 case 0: /* Dedicated pins */
27 break;
28 case 1:
29 s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(2));
30 break;
31 case 2:
32 s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(4));
33 break;
34 default:
35 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
36 return -EINVAL;
39 return 0;
42 static const char *rclksrc_v5[] = {
43 [0] = "iis",
44 [1] = "i2sclkd2",
47 static struct s3c_audio_pdata i2sv5_pdata = {
48 .cfg_gpio = s5pc100_cfg_i2s,
49 .type = {
50 .i2s = {
51 .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
52 | QUIRK_NEED_RSTCLR,
53 .src_clk = rclksrc_v5,
58 static struct resource s5pc100_iis0_resource[] = {
59 [0] = {
60 .start = S5PC100_PA_I2S0,
61 .end = S5PC100_PA_I2S0 + 0x100 - 1,
62 .flags = IORESOURCE_MEM,
64 [1] = {
65 .start = DMACH_I2S0_TX,
66 .end = DMACH_I2S0_TX,
67 .flags = IORESOURCE_DMA,
69 [2] = {
70 .start = DMACH_I2S0_RX,
71 .end = DMACH_I2S0_RX,
72 .flags = IORESOURCE_DMA,
74 [3] = {
75 .start = DMACH_I2S0S_TX,
76 .end = DMACH_I2S0S_TX,
77 .flags = IORESOURCE_DMA,
81 struct platform_device s5pc100_device_iis0 = {
82 .name = "samsung-i2s",
83 .id = 0,
84 .num_resources = ARRAY_SIZE(s5pc100_iis0_resource),
85 .resource = s5pc100_iis0_resource,
86 .dev = {
87 .platform_data = &i2sv5_pdata,
91 static const char *rclksrc_v3[] = {
92 [0] = "iis",
93 [1] = "sclk_audio",
96 static struct s3c_audio_pdata i2sv3_pdata = {
97 .cfg_gpio = s5pc100_cfg_i2s,
98 .type = {
99 .i2s = {
100 .src_clk = rclksrc_v3,
105 static struct resource s5pc100_iis1_resource[] = {
106 [0] = {
107 .start = S5PC100_PA_I2S1,
108 .end = S5PC100_PA_I2S1 + 0x100 - 1,
109 .flags = IORESOURCE_MEM,
111 [1] = {
112 .start = DMACH_I2S1_TX,
113 .end = DMACH_I2S1_TX,
114 .flags = IORESOURCE_DMA,
116 [2] = {
117 .start = DMACH_I2S1_RX,
118 .end = DMACH_I2S1_RX,
119 .flags = IORESOURCE_DMA,
123 struct platform_device s5pc100_device_iis1 = {
124 .name = "samsung-i2s",
125 .id = 1,
126 .num_resources = ARRAY_SIZE(s5pc100_iis1_resource),
127 .resource = s5pc100_iis1_resource,
128 .dev = {
129 .platform_data = &i2sv3_pdata,
133 static struct resource s5pc100_iis2_resource[] = {
134 [0] = {
135 .start = S5PC100_PA_I2S2,
136 .end = S5PC100_PA_I2S2 + 0x100 - 1,
137 .flags = IORESOURCE_MEM,
139 [1] = {
140 .start = DMACH_I2S2_TX,
141 .end = DMACH_I2S2_TX,
142 .flags = IORESOURCE_DMA,
144 [2] = {
145 .start = DMACH_I2S2_RX,
146 .end = DMACH_I2S2_RX,
147 .flags = IORESOURCE_DMA,
151 struct platform_device s5pc100_device_iis2 = {
152 .name = "samsung-i2s",
153 .id = 2,
154 .num_resources = ARRAY_SIZE(s5pc100_iis2_resource),
155 .resource = s5pc100_iis2_resource,
156 .dev = {
157 .platform_data = &i2sv3_pdata,
161 /* PCM Controller platform_devices */
163 static int s5pc100_pcm_cfg_gpio(struct platform_device *pdev)
165 switch (pdev->id) {
166 case 0:
167 s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(5));
168 break;
170 case 1:
171 s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(3));
172 break;
174 default:
175 printk(KERN_DEBUG "Invalid PCM Controller number!");
176 return -EINVAL;
179 return 0;
182 static struct s3c_audio_pdata s3c_pcm_pdata = {
183 .cfg_gpio = s5pc100_pcm_cfg_gpio,
186 static struct resource s5pc100_pcm0_resource[] = {
187 [0] = {
188 .start = S5PC100_PA_PCM0,
189 .end = S5PC100_PA_PCM0 + 0x100 - 1,
190 .flags = IORESOURCE_MEM,
192 [1] = {
193 .start = DMACH_PCM0_TX,
194 .end = DMACH_PCM0_TX,
195 .flags = IORESOURCE_DMA,
197 [2] = {
198 .start = DMACH_PCM0_RX,
199 .end = DMACH_PCM0_RX,
200 .flags = IORESOURCE_DMA,
204 struct platform_device s5pc100_device_pcm0 = {
205 .name = "samsung-pcm",
206 .id = 0,
207 .num_resources = ARRAY_SIZE(s5pc100_pcm0_resource),
208 .resource = s5pc100_pcm0_resource,
209 .dev = {
210 .platform_data = &s3c_pcm_pdata,
214 static struct resource s5pc100_pcm1_resource[] = {
215 [0] = {
216 .start = S5PC100_PA_PCM1,
217 .end = S5PC100_PA_PCM1 + 0x100 - 1,
218 .flags = IORESOURCE_MEM,
220 [1] = {
221 .start = DMACH_PCM1_TX,
222 .end = DMACH_PCM1_TX,
223 .flags = IORESOURCE_DMA,
225 [2] = {
226 .start = DMACH_PCM1_RX,
227 .end = DMACH_PCM1_RX,
228 .flags = IORESOURCE_DMA,
232 struct platform_device s5pc100_device_pcm1 = {
233 .name = "samsung-pcm",
234 .id = 1,
235 .num_resources = ARRAY_SIZE(s5pc100_pcm1_resource),
236 .resource = s5pc100_pcm1_resource,
237 .dev = {
238 .platform_data = &s3c_pcm_pdata,
242 /* AC97 Controller platform devices */
244 static int s5pc100_ac97_cfg_gpio(struct platform_device *pdev)
246 return s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(4));
249 static struct resource s5pc100_ac97_resource[] = {
250 [0] = {
251 .start = S5PC100_PA_AC97,
252 .end = S5PC100_PA_AC97 + 0x100 - 1,
253 .flags = IORESOURCE_MEM,
255 [1] = {
256 .start = DMACH_AC97_PCMOUT,
257 .end = DMACH_AC97_PCMOUT,
258 .flags = IORESOURCE_DMA,
260 [2] = {
261 .start = DMACH_AC97_PCMIN,
262 .end = DMACH_AC97_PCMIN,
263 .flags = IORESOURCE_DMA,
265 [3] = {
266 .start = DMACH_AC97_MICIN,
267 .end = DMACH_AC97_MICIN,
268 .flags = IORESOURCE_DMA,
270 [4] = {
271 .start = IRQ_AC97,
272 .end = IRQ_AC97,
273 .flags = IORESOURCE_IRQ,
277 static struct s3c_audio_pdata s3c_ac97_pdata = {
278 .cfg_gpio = s5pc100_ac97_cfg_gpio,
281 static u64 s5pc100_ac97_dmamask = DMA_BIT_MASK(32);
283 struct platform_device s5pc100_device_ac97 = {
284 .name = "samsung-ac97",
285 .id = -1,
286 .num_resources = ARRAY_SIZE(s5pc100_ac97_resource),
287 .resource = s5pc100_ac97_resource,
288 .dev = {
289 .platform_data = &s3c_ac97_pdata,
290 .dma_mask = &s5pc100_ac97_dmamask,
291 .coherent_dma_mask = DMA_BIT_MASK(32),
295 /* S/PDIF Controller platform_device */
296 static int s5pc100_spdif_cfg_gpd(struct platform_device *pdev)
298 s3c_gpio_cfgpin_range(S5PC100_GPD(5), 2, S3C_GPIO_SFN(3));
300 return 0;
303 static int s5pc100_spdif_cfg_gpg3(struct platform_device *pdev)
305 s3c_gpio_cfgpin_range(S5PC100_GPG3(5), 2, S3C_GPIO_SFN(3));
307 return 0;
310 static struct resource s5pc100_spdif_resource[] = {
311 [0] = {
312 .start = S5PC100_PA_SPDIF,
313 .end = S5PC100_PA_SPDIF + 0x100 - 1,
314 .flags = IORESOURCE_MEM,
316 [1] = {
317 .start = DMACH_SPDIF,
318 .end = DMACH_SPDIF,
319 .flags = IORESOURCE_DMA,
323 static struct s3c_audio_pdata s5p_spdif_pdata = {
324 .cfg_gpio = s5pc100_spdif_cfg_gpd,
327 static u64 s5pc100_spdif_dmamask = DMA_BIT_MASK(32);
329 struct platform_device s5pc100_device_spdif = {
330 .name = "samsung-spdif",
331 .id = -1,
332 .num_resources = ARRAY_SIZE(s5pc100_spdif_resource),
333 .resource = s5pc100_spdif_resource,
334 .dev = {
335 .platform_data = &s5p_spdif_pdata,
336 .dma_mask = &s5pc100_spdif_dmamask,
337 .coherent_dma_mask = DMA_BIT_MASK(32),
341 void __init s5pc100_spdif_setup_gpio(int gpio)
343 if (gpio == S5PC100_SPDIF_GPD)
344 s5p_spdif_pdata.cfg_gpio = s5pc100_spdif_cfg_gpd;
345 else
346 s5p_spdif_pdata.cfg_gpio = s5pc100_spdif_cfg_gpg3;