Merge branch 'next/soc-exynos5250-arch' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6.git] / arch / arm / mach-s5pv210 / dev-audio.c
1 /* linux/arch/arm/mach-s5pv210/dev-audio.c
2  *
3  * Copyright (c) 2010 Samsung Electronics Co. Ltd
4  *      Jaswinder Singh <jassi.brar@samsung.com>
5  *
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/platform_device.h>
12 #include <linux/dma-mapping.h>
13 #include <linux/gpio.h>
14
15 #include <plat/gpio-cfg.h>
16 #include <plat/audio.h>
17
18 #include <mach/map.h>
19 #include <mach/dma.h>
20 #include <mach/irqs.h>
21 #include <mach/regs-audss.h>
22
23 static const char *rclksrc[] = {
24         [0] = "busclk",
25         [1] = "i2sclk",
26 };
27
28 static int s5pv210_cfg_i2s(struct platform_device *pdev)
29 {
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;
44         }
45
46         return 0;
47 }
48
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,
57                 },
58         },
59 };
60
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,
66         },
67         [1] = {
68                 .start = DMACH_I2S0_TX,
69                 .end   = DMACH_I2S0_TX,
70                 .flags = IORESOURCE_DMA,
71         },
72         [2] = {
73                 .start = DMACH_I2S0_RX,
74                 .end   = DMACH_I2S0_RX,
75                 .flags = IORESOURCE_DMA,
76         },
77         [3] = {
78                 .start = DMACH_I2S0S_TX,
79                 .end = DMACH_I2S0S_TX,
80                 .flags = IORESOURCE_DMA,
81         },
82 };
83
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,
91         },
92 };
93
94 static const char *rclksrc_v3[] = {
95         [0] = "iis",
96         [1] = "audio-bus",
97 };
98
99 static struct s3c_audio_pdata i2sv3_pdata = {
100         .cfg_gpio = s5pv210_cfg_i2s,
101         .type = {
102                 .i2s = {
103                         .src_clk = rclksrc_v3,
104                 },
105         },
106 };
107
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,
113         },
114         [1] = {
115                 .start = DMACH_I2S1_TX,
116                 .end   = DMACH_I2S1_TX,
117                 .flags = IORESOURCE_DMA,
118         },
119         [2] = {
120                 .start = DMACH_I2S1_RX,
121                 .end   = DMACH_I2S1_RX,
122                 .flags = IORESOURCE_DMA,
123         },
124 };
125
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,
133         },
134 };
135
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,
141         },
142         [1] = {
143                 .start = DMACH_I2S2_TX,
144                 .end   = DMACH_I2S2_TX,
145                 .flags = IORESOURCE_DMA,
146         },
147         [2] = {
148                 .start = DMACH_I2S2_RX,
149                 .end   = DMACH_I2S2_RX,
150                 .flags = IORESOURCE_DMA,
151         },
152 };
153
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,
161         },
162 };
163
164 /* PCM Controller platform_devices */
165
166 static int s5pv210_pcm_cfg_gpio(struct platform_device *pdev)
167 {
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;
181         }
182
183         return 0;
184 }
185
186 static struct s3c_audio_pdata s3c_pcm_pdata = {
187         .cfg_gpio = s5pv210_pcm_cfg_gpio,
188 };
189
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,
195         },
196         [1] = {
197                 .start = DMACH_PCM0_TX,
198                 .end   = DMACH_PCM0_TX,
199                 .flags = IORESOURCE_DMA,
200         },
201         [2] = {
202                 .start = DMACH_PCM0_RX,
203                 .end   = DMACH_PCM0_RX,
204                 .flags = IORESOURCE_DMA,
205         },
206 };
207
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,
215         },
216 };
217
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,
223         },
224         [1] = {
225                 .start = DMACH_PCM1_TX,
226                 .end   = DMACH_PCM1_TX,
227                 .flags = IORESOURCE_DMA,
228         },
229         [2] = {
230                 .start = DMACH_PCM1_RX,
231                 .end   = DMACH_PCM1_RX,
232                 .flags = IORESOURCE_DMA,
233         },
234 };
235
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,
243         },
244 };
245
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,
251         },
252         [1] = {
253                 .start = DMACH_PCM2_TX,
254                 .end   = DMACH_PCM2_TX,
255                 .flags = IORESOURCE_DMA,
256         },
257         [2] = {
258                 .start = DMACH_PCM2_RX,
259                 .end   = DMACH_PCM2_RX,
260                 .flags = IORESOURCE_DMA,
261         },
262 };
263
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,
271         },
272 };
273
274 /* AC97 Controller platform devices */
275
276 static int s5pv210_ac97_cfg_gpio(struct platform_device *pdev)
277 {
278         return s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(4));
279 }
280
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,
286         },
287         [1] = {
288                 .start = DMACH_AC97_PCMOUT,
289                 .end   = DMACH_AC97_PCMOUT,
290                 .flags = IORESOURCE_DMA,
291         },
292         [2] = {
293                 .start = DMACH_AC97_PCMIN,
294                 .end   = DMACH_AC97_PCMIN,
295                 .flags = IORESOURCE_DMA,
296         },
297         [3] = {
298                 .start = DMACH_AC97_MICIN,
299                 .end   = DMACH_AC97_MICIN,
300                 .flags = IORESOURCE_DMA,
301         },
302         [4] = {
303                 .start = IRQ_AC97,
304                 .end   = IRQ_AC97,
305                 .flags = IORESOURCE_IRQ,
306         },
307 };
308
309 static struct s3c_audio_pdata s3c_ac97_pdata = {
310         .cfg_gpio = s5pv210_ac97_cfg_gpio,
311 };
312
313 static u64 s5pv210_ac97_dmamask = DMA_BIT_MASK(32);
314
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),
324         },
325 };
326
327 /* S/PDIF Controller platform_device */
328
329 static int s5pv210_spdif_cfg_gpio(struct platform_device *pdev)
330 {
331         s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 2, S3C_GPIO_SFN(3));
332
333         return 0;
334 }
335
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,
341         },
342         [1] = {
343                 .start  = DMACH_SPDIF,
344                 .end    = DMACH_SPDIF,
345                 .flags  = IORESOURCE_DMA,
346         },
347 };
348
349 static struct s3c_audio_pdata samsung_spdif_pdata = {
350         .cfg_gpio = s5pv210_spdif_cfg_gpio,
351 };
352
353 static u64 s5pv210_spdif_dmamask = DMA_BIT_MASK(32);
354
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),
364         },
365 };