]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/mach-s3c64xx/dev-audio.c
Merge branch 'audit.b64' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit...
[net-next-2.6.git] / arch / arm / mach-s3c64xx / dev-audio.c
CommitLineData
52da219e
MB
1/* linux/arch/arm/plat-s3c/dev-audio.c
2 *
3 * Copyright 2009 Wolfson Microelectronics
4 * Mark Brown <broonie@opensource.wolfsonmicro.com>
5 *
52da219e
MB
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 */
10
11#include <linux/kernel.h>
12#include <linux/string.h>
13#include <linux/platform_device.h>
de6985be 14#include <linux/dma-mapping.h>
1c739c7f 15#include <linux/gpio.h>
52da219e
MB
16
17#include <mach/irqs.h>
18#include <mach/map.h>
acf1aef9 19#include <mach/dma.h>
52da219e
MB
20
21#include <plat/devs.h>
acf1aef9 22#include <plat/audio.h>
acf1aef9 23#include <plat/gpio-cfg.h>
52da219e 24
71269364
JB
25static int s3c64xx_i2sv3_cfg_gpio(struct platform_device *pdev)
26{
2618b555
BD
27 unsigned int base;
28
71269364
JB
29 switch (pdev->id) {
30 case 0:
2618b555 31 base = S3C64XX_GPD(0);
71269364
JB
32 break;
33 case 1:
2618b555 34 base = S3C64XX_GPE(0);
e4b6b74f 35 break;
71269364 36 default:
e4b6b74f
DP
37 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
38 pdev->id);
71269364
JB
39 return -EINVAL;
40 }
41
2618b555
BD
42 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
43
71269364
JB
44 return 0;
45}
46
47static int s3c64xx_i2sv4_cfg_gpio(struct platform_device *pdev)
48{
f5321760
BD
49 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
50 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
51 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
dff2126c 52 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
71269364
JB
53
54 return 0;
55}
56
52da219e
MB
57static struct resource s3c64xx_iis0_resource[] = {
58 [0] = {
59 .start = S3C64XX_PA_IIS0,
60 .end = S3C64XX_PA_IIS0 + 0x100 - 1,
61 .flags = IORESOURCE_MEM,
62 },
71269364
JB
63 [1] = {
64 .start = DMACH_I2S0_OUT,
65 .end = DMACH_I2S0_OUT,
66 .flags = IORESOURCE_DMA,
67 },
68 [2] = {
69 .start = DMACH_I2S0_IN,
70 .end = DMACH_I2S0_IN,
71 .flags = IORESOURCE_DMA,
72 },
73};
74
8dcdd6e6 75static struct s3c_audio_pdata s3c_i2s0_pdata = {
71269364 76 .cfg_gpio = s3c64xx_i2sv3_cfg_gpio,
52da219e
MB
77};
78
79struct platform_device s3c64xx_device_iis0 = {
80 .name = "s3c64xx-iis",
81 .id = 0,
82 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
83 .resource = s3c64xx_iis0_resource,
71269364
JB
84 .dev = {
85 .platform_data = &s3c_i2s0_pdata,
86 },
52da219e
MB
87};
88EXPORT_SYMBOL(s3c64xx_device_iis0);
89
90static struct resource s3c64xx_iis1_resource[] = {
91 [0] = {
92 .start = S3C64XX_PA_IIS1,
93 .end = S3C64XX_PA_IIS1 + 0x100 - 1,
94 .flags = IORESOURCE_MEM,
95 },
71269364
JB
96 [1] = {
97 .start = DMACH_I2S1_OUT,
98 .end = DMACH_I2S1_OUT,
99 .flags = IORESOURCE_DMA,
100 },
101 [2] = {
102 .start = DMACH_I2S1_IN,
103 .end = DMACH_I2S1_IN,
104 .flags = IORESOURCE_DMA,
105 },
106};
107
8dcdd6e6 108static struct s3c_audio_pdata s3c_i2s1_pdata = {
71269364 109 .cfg_gpio = s3c64xx_i2sv3_cfg_gpio,
52da219e
MB
110};
111
112struct platform_device s3c64xx_device_iis1 = {
113 .name = "s3c64xx-iis",
114 .id = 1,
115 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
116 .resource = s3c64xx_iis1_resource,
71269364
JB
117 .dev = {
118 .platform_data = &s3c_i2s1_pdata,
119 },
52da219e
MB
120};
121EXPORT_SYMBOL(s3c64xx_device_iis1);
d06a49ee
MB
122
123static struct resource s3c64xx_iisv4_resource[] = {
124 [0] = {
125 .start = S3C64XX_PA_IISV4,
126 .end = S3C64XX_PA_IISV4 + 0x100 - 1,
127 .flags = IORESOURCE_MEM,
128 },
71269364
JB
129 [1] = {
130 .start = DMACH_HSI_I2SV40_TX,
131 .end = DMACH_HSI_I2SV40_TX,
132 .flags = IORESOURCE_DMA,
133 },
134 [2] = {
135 .start = DMACH_HSI_I2SV40_RX,
136 .end = DMACH_HSI_I2SV40_RX,
137 .flags = IORESOURCE_DMA,
138 },
139};
140
8dcdd6e6 141static struct s3c_audio_pdata s3c_i2sv4_pdata = {
71269364 142 .cfg_gpio = s3c64xx_i2sv4_cfg_gpio,
d06a49ee
MB
143};
144
145struct platform_device s3c64xx_device_iisv4 = {
146 .name = "s3c64xx-iis-v4",
147 .id = -1,
148 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
149 .resource = s3c64xx_iisv4_resource,
71269364
JB
150 .dev = {
151 .platform_data = &s3c_i2sv4_pdata,
152 },
d06a49ee
MB
153};
154EXPORT_SYMBOL(s3c64xx_device_iisv4);
acf1aef9
JB
155
156
157/* PCM Controller platform_devices */
158
159static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
160{
2618b555
BD
161 unsigned int base;
162
acf1aef9
JB
163 switch (pdev->id) {
164 case 0:
2618b555 165 base = S3C64XX_GPD(0);
acf1aef9
JB
166 break;
167 case 1:
2618b555 168 base = S3C64XX_GPE(0);
acf1aef9
JB
169 break;
170 default:
e4b6b74f
DP
171 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
172 pdev->id);
acf1aef9
JB
173 return -EINVAL;
174 }
175
2618b555 176 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
acf1aef9
JB
177 return 0;
178}
179
180static struct resource s3c64xx_pcm0_resource[] = {
181 [0] = {
182 .start = S3C64XX_PA_PCM0,
183 .end = S3C64XX_PA_PCM0 + 0x100 - 1,
184 .flags = IORESOURCE_MEM,
185 },
186 [1] = {
187 .start = DMACH_PCM0_TX,
188 .end = DMACH_PCM0_TX,
189 .flags = IORESOURCE_DMA,
190 },
191 [2] = {
192 .start = DMACH_PCM0_RX,
193 .end = DMACH_PCM0_RX,
194 .flags = IORESOURCE_DMA,
195 },
196};
197
43f0de8d 198static struct s3c_audio_pdata s3c_pcm0_pdata = {
acf1aef9
JB
199 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
200};
201
202struct platform_device s3c64xx_device_pcm0 = {
203 .name = "samsung-pcm",
204 .id = 0,
205 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
206 .resource = s3c64xx_pcm0_resource,
207 .dev = {
208 .platform_data = &s3c_pcm0_pdata,
209 },
210};
211EXPORT_SYMBOL(s3c64xx_device_pcm0);
212
213static struct resource s3c64xx_pcm1_resource[] = {
214 [0] = {
215 .start = S3C64XX_PA_PCM1,
216 .end = S3C64XX_PA_PCM1 + 0x100 - 1,
217 .flags = IORESOURCE_MEM,
218 },
219 [1] = {
220 .start = DMACH_PCM1_TX,
221 .end = DMACH_PCM1_TX,
222 .flags = IORESOURCE_DMA,
223 },
224 [2] = {
225 .start = DMACH_PCM1_RX,
226 .end = DMACH_PCM1_RX,
227 .flags = IORESOURCE_DMA,
228 },
229};
230
43f0de8d 231static struct s3c_audio_pdata s3c_pcm1_pdata = {
acf1aef9
JB
232 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
233};
234
235struct platform_device s3c64xx_device_pcm1 = {
236 .name = "samsung-pcm",
237 .id = 1,
238 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
239 .resource = s3c64xx_pcm1_resource,
240 .dev = {
241 .platform_data = &s3c_pcm1_pdata,
242 },
243};
244EXPORT_SYMBOL(s3c64xx_device_pcm1);
de6985be
JB
245
246/* AC97 Controller platform devices */
247
248static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
249{
2618b555 250 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
de6985be
JB
251}
252
253static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
254{
2618b555 255 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
de6985be
JB
256}
257
258static struct resource s3c64xx_ac97_resource[] = {
259 [0] = {
260 .start = S3C64XX_PA_AC97,
261 .end = S3C64XX_PA_AC97 + 0x100 - 1,
262 .flags = IORESOURCE_MEM,
263 },
264 [1] = {
265 .start = DMACH_AC97_PCMOUT,
266 .end = DMACH_AC97_PCMOUT,
267 .flags = IORESOURCE_DMA,
268 },
269 [2] = {
270 .start = DMACH_AC97_PCMIN,
271 .end = DMACH_AC97_PCMIN,
272 .flags = IORESOURCE_DMA,
273 },
274 [3] = {
275 .start = DMACH_AC97_MICIN,
276 .end = DMACH_AC97_MICIN,
277 .flags = IORESOURCE_DMA,
278 },
279 [4] = {
280 .start = IRQ_AC97,
281 .end = IRQ_AC97,
282 .flags = IORESOURCE_IRQ,
283 },
284};
285
286static struct s3c_audio_pdata s3c_ac97_pdata;
287
288static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
289
290struct platform_device s3c64xx_device_ac97 = {
291 .name = "s3c-ac97",
292 .id = -1,
293 .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
294 .resource = s3c64xx_ac97_resource,
295 .dev = {
296 .platform_data = &s3c_ac97_pdata,
297 .dma_mask = &s3c64xx_ac97_dmamask,
298 .coherent_dma_mask = DMA_BIT_MASK(32),
299 },
300};
301EXPORT_SYMBOL(s3c64xx_device_ac97);
302
303void __init s3c64xx_ac97_setup_gpio(int num)
304{
305 if (num == S3C64XX_AC97_GPD)
306 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
307 else
308 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
309}
f0fba2ad
LG
310
311static u64 s3c_device_audio_dmamask = 0xffffffffUL;
312
313struct platform_device s3c_device_pcm = {
314 .name = "s3c24xx-pcm-audio",
315 .id = -1,
316 .dev = {
317 .dma_mask = &s3c_device_audio_dmamask,
318 .coherent_dma_mask = 0xffffffffUL
319 }
320};
321EXPORT_SYMBOL(s3c_device_pcm);
322