blob: 3838335f125b65067d9e771b7e48af8ca1b07218 [file] [log] [blame]
Mark Brown52da2192009-06-03 20:08:38 +01001/* linux/arch/arm/plat-s3c/dev-audio.c
2 *
3 * Copyright 2009 Wolfson Microelectronics
4 * Mark Brown <broonie@opensource.wolfsonmicro.com>
5 *
Mark Brown52da2192009-06-03 20:08:38 +01006 * 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>
Jassi Brarde6985b2010-02-12 10:38:51 +000014#include <linux/dma-mapping.h>
Kukjin Kim1c739c72010-08-05 07:54:49 +090015#include <linux/gpio.h>
Mark Brown52da2192009-06-03 20:08:38 +010016
17#include <mach/irqs.h>
18#include <mach/map.h>
Jassi Braracf1aef2009-11-17 16:53:56 +090019#include <mach/dma.h>
Mark Brown52da2192009-06-03 20:08:38 +010020
21#include <plat/devs.h>
Jassi Braracf1aef2009-11-17 16:53:56 +090022#include <plat/audio.h>
Jassi Braracf1aef2009-11-17 16:53:56 +090023#include <plat/gpio-cfg.h>
Mark Brown52da2192009-06-03 20:08:38 +010024
Ben Dooks3501c9a2010-01-26 10:45:40 +090025#include <mach/gpio-bank-c.h>
26#include <mach/gpio-bank-d.h>
27#include <mach/gpio-bank-e.h>
28#include <mach/gpio-bank-h.h>
29
Jassi Brar71269362010-01-06 15:33:44 +090030static int s3c64xx_i2sv3_cfg_gpio(struct platform_device *pdev)
31{
32 switch (pdev->id) {
33 case 0:
34 s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_I2S0_CLK);
35 s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_I2S0_CDCLK);
36 s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_I2S0_LRCLK);
37 s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_I2S0_DI);
38 s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_I2S0_D0);
39 break;
40 case 1:
41 s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_I2S1_CLK);
42 s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_I2S1_CDCLK);
43 s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_I2S1_LRCLK);
44 s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_I2S1_DI);
45 s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_I2S1_D0);
Dimitris Papastamose4b6b742010-08-26 16:07:23 +010046 break;
Jassi Brar71269362010-01-06 15:33:44 +090047 default:
Dimitris Papastamose4b6b742010-08-26 16:07:23 +010048 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
49 pdev->id);
Jassi Brar71269362010-01-06 15:33:44 +090050 return -EINVAL;
51 }
52
53 return 0;
54}
55
56static int s3c64xx_i2sv4_cfg_gpio(struct platform_device *pdev)
57{
Mark Brown1c245222010-01-20 12:05:55 +000058 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C64XX_GPC4_I2S_V40_DO0);
59 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C64XX_GPC5_I2S_V40_DO1);
60 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C64XX_GPC7_I2S_V40_DO2);
Jassi Brar71269362010-01-06 15:33:44 +090061 s3c_gpio_cfgpin(S3C64XX_GPH(6), S3C64XX_GPH6_I2S_V40_BCLK);
62 s3c_gpio_cfgpin(S3C64XX_GPH(7), S3C64XX_GPH7_I2S_V40_CDCLK);
63 s3c_gpio_cfgpin(S3C64XX_GPH(8), S3C64XX_GPH8_I2S_V40_LRCLK);
64 s3c_gpio_cfgpin(S3C64XX_GPH(9), S3C64XX_GPH9_I2S_V40_DI);
65
66 return 0;
67}
68
Mark Brown52da2192009-06-03 20:08:38 +010069static struct resource s3c64xx_iis0_resource[] = {
70 [0] = {
71 .start = S3C64XX_PA_IIS0,
72 .end = S3C64XX_PA_IIS0 + 0x100 - 1,
73 .flags = IORESOURCE_MEM,
74 },
Jassi Brar71269362010-01-06 15:33:44 +090075 [1] = {
76 .start = DMACH_I2S0_OUT,
77 .end = DMACH_I2S0_OUT,
78 .flags = IORESOURCE_DMA,
79 },
80 [2] = {
81 .start = DMACH_I2S0_IN,
82 .end = DMACH_I2S0_IN,
83 .flags = IORESOURCE_DMA,
84 },
85};
86
Mark Brown8dcdd6e2010-01-20 13:06:04 +000087static struct s3c_audio_pdata s3c_i2s0_pdata = {
Jassi Brar71269362010-01-06 15:33:44 +090088 .cfg_gpio = s3c64xx_i2sv3_cfg_gpio,
Mark Brown52da2192009-06-03 20:08:38 +010089};
90
91struct platform_device s3c64xx_device_iis0 = {
92 .name = "s3c64xx-iis",
93 .id = 0,
94 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
95 .resource = s3c64xx_iis0_resource,
Jassi Brar71269362010-01-06 15:33:44 +090096 .dev = {
97 .platform_data = &s3c_i2s0_pdata,
98 },
Mark Brown52da2192009-06-03 20:08:38 +010099};
100EXPORT_SYMBOL(s3c64xx_device_iis0);
101
102static struct resource s3c64xx_iis1_resource[] = {
103 [0] = {
104 .start = S3C64XX_PA_IIS1,
105 .end = S3C64XX_PA_IIS1 + 0x100 - 1,
106 .flags = IORESOURCE_MEM,
107 },
Jassi Brar71269362010-01-06 15:33:44 +0900108 [1] = {
109 .start = DMACH_I2S1_OUT,
110 .end = DMACH_I2S1_OUT,
111 .flags = IORESOURCE_DMA,
112 },
113 [2] = {
114 .start = DMACH_I2S1_IN,
115 .end = DMACH_I2S1_IN,
116 .flags = IORESOURCE_DMA,
117 },
118};
119
Mark Brown8dcdd6e2010-01-20 13:06:04 +0000120static struct s3c_audio_pdata s3c_i2s1_pdata = {
Jassi Brar71269362010-01-06 15:33:44 +0900121 .cfg_gpio = s3c64xx_i2sv3_cfg_gpio,
Mark Brown52da2192009-06-03 20:08:38 +0100122};
123
124struct platform_device s3c64xx_device_iis1 = {
125 .name = "s3c64xx-iis",
126 .id = 1,
127 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
128 .resource = s3c64xx_iis1_resource,
Jassi Brar71269362010-01-06 15:33:44 +0900129 .dev = {
130 .platform_data = &s3c_i2s1_pdata,
131 },
Mark Brown52da2192009-06-03 20:08:38 +0100132};
133EXPORT_SYMBOL(s3c64xx_device_iis1);
Mark Brownd06a49e2009-06-03 20:08:39 +0100134
135static struct resource s3c64xx_iisv4_resource[] = {
136 [0] = {
137 .start = S3C64XX_PA_IISV4,
138 .end = S3C64XX_PA_IISV4 + 0x100 - 1,
139 .flags = IORESOURCE_MEM,
140 },
Jassi Brar71269362010-01-06 15:33:44 +0900141 [1] = {
142 .start = DMACH_HSI_I2SV40_TX,
143 .end = DMACH_HSI_I2SV40_TX,
144 .flags = IORESOURCE_DMA,
145 },
146 [2] = {
147 .start = DMACH_HSI_I2SV40_RX,
148 .end = DMACH_HSI_I2SV40_RX,
149 .flags = IORESOURCE_DMA,
150 },
151};
152
Mark Brown8dcdd6e2010-01-20 13:06:04 +0000153static struct s3c_audio_pdata s3c_i2sv4_pdata = {
Jassi Brar71269362010-01-06 15:33:44 +0900154 .cfg_gpio = s3c64xx_i2sv4_cfg_gpio,
Mark Brownd06a49e2009-06-03 20:08:39 +0100155};
156
157struct platform_device s3c64xx_device_iisv4 = {
158 .name = "s3c64xx-iis-v4",
159 .id = -1,
160 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
161 .resource = s3c64xx_iisv4_resource,
Jassi Brar71269362010-01-06 15:33:44 +0900162 .dev = {
163 .platform_data = &s3c_i2sv4_pdata,
164 },
Mark Brownd06a49e2009-06-03 20:08:39 +0100165};
166EXPORT_SYMBOL(s3c64xx_device_iisv4);
Jassi Braracf1aef2009-11-17 16:53:56 +0900167
168
169/* PCM Controller platform_devices */
170
171static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
172{
173 switch (pdev->id) {
174 case 0:
175 s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_PCM0_SCLK);
176 s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_PCM0_EXTCLK);
177 s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_PCM0_FSYNC);
178 s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_PCM0_SIN);
179 s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_PCM0_SOUT);
180 break;
181 case 1:
182 s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_PCM1_SCLK);
183 s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_PCM1_EXTCLK);
184 s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_PCM1_FSYNC);
185 s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_PCM1_SIN);
186 s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_PCM1_SOUT);
187 break;
188 default:
Dimitris Papastamose4b6b742010-08-26 16:07:23 +0100189 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
190 pdev->id);
Jassi Braracf1aef2009-11-17 16:53:56 +0900191 return -EINVAL;
192 }
193
194 return 0;
195}
196
197static struct resource s3c64xx_pcm0_resource[] = {
198 [0] = {
199 .start = S3C64XX_PA_PCM0,
200 .end = S3C64XX_PA_PCM0 + 0x100 - 1,
201 .flags = IORESOURCE_MEM,
202 },
203 [1] = {
204 .start = DMACH_PCM0_TX,
205 .end = DMACH_PCM0_TX,
206 .flags = IORESOURCE_DMA,
207 },
208 [2] = {
209 .start = DMACH_PCM0_RX,
210 .end = DMACH_PCM0_RX,
211 .flags = IORESOURCE_DMA,
212 },
213};
214
Mark Brown43f0de82009-11-27 16:43:53 +0000215static struct s3c_audio_pdata s3c_pcm0_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900216 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
217};
218
219struct platform_device s3c64xx_device_pcm0 = {
220 .name = "samsung-pcm",
221 .id = 0,
222 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
223 .resource = s3c64xx_pcm0_resource,
224 .dev = {
225 .platform_data = &s3c_pcm0_pdata,
226 },
227};
228EXPORT_SYMBOL(s3c64xx_device_pcm0);
229
230static struct resource s3c64xx_pcm1_resource[] = {
231 [0] = {
232 .start = S3C64XX_PA_PCM1,
233 .end = S3C64XX_PA_PCM1 + 0x100 - 1,
234 .flags = IORESOURCE_MEM,
235 },
236 [1] = {
237 .start = DMACH_PCM1_TX,
238 .end = DMACH_PCM1_TX,
239 .flags = IORESOURCE_DMA,
240 },
241 [2] = {
242 .start = DMACH_PCM1_RX,
243 .end = DMACH_PCM1_RX,
244 .flags = IORESOURCE_DMA,
245 },
246};
247
Mark Brown43f0de82009-11-27 16:43:53 +0000248static struct s3c_audio_pdata s3c_pcm1_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900249 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
250};
251
252struct platform_device s3c64xx_device_pcm1 = {
253 .name = "samsung-pcm",
254 .id = 1,
255 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
256 .resource = s3c64xx_pcm1_resource,
257 .dev = {
258 .platform_data = &s3c_pcm1_pdata,
259 },
260};
261EXPORT_SYMBOL(s3c64xx_device_pcm1);
Jassi Brarde6985b2010-02-12 10:38:51 +0000262
263/* AC97 Controller platform devices */
264
265static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
266{
267 s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_AC97_BITCLK);
268 s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_AC97_nRESET);
269 s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_AC97_SYNC);
270 s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_AC97_SDI);
271 s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_AC97_SDO);
272
273 return 0;
274}
275
276static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
277{
278 s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_AC97_BITCLK);
279 s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_AC97_nRESET);
280 s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_AC97_SYNC);
281 s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_AC97_SDI);
282 s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_AC97_SDO);
283
284 return 0;
285}
286
287static struct resource s3c64xx_ac97_resource[] = {
288 [0] = {
289 .start = S3C64XX_PA_AC97,
290 .end = S3C64XX_PA_AC97 + 0x100 - 1,
291 .flags = IORESOURCE_MEM,
292 },
293 [1] = {
294 .start = DMACH_AC97_PCMOUT,
295 .end = DMACH_AC97_PCMOUT,
296 .flags = IORESOURCE_DMA,
297 },
298 [2] = {
299 .start = DMACH_AC97_PCMIN,
300 .end = DMACH_AC97_PCMIN,
301 .flags = IORESOURCE_DMA,
302 },
303 [3] = {
304 .start = DMACH_AC97_MICIN,
305 .end = DMACH_AC97_MICIN,
306 .flags = IORESOURCE_DMA,
307 },
308 [4] = {
309 .start = IRQ_AC97,
310 .end = IRQ_AC97,
311 .flags = IORESOURCE_IRQ,
312 },
313};
314
315static struct s3c_audio_pdata s3c_ac97_pdata;
316
317static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
318
319struct platform_device s3c64xx_device_ac97 = {
320 .name = "s3c-ac97",
321 .id = -1,
322 .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
323 .resource = s3c64xx_ac97_resource,
324 .dev = {
325 .platform_data = &s3c_ac97_pdata,
326 .dma_mask = &s3c64xx_ac97_dmamask,
327 .coherent_dma_mask = DMA_BIT_MASK(32),
328 },
329};
330EXPORT_SYMBOL(s3c64xx_device_ac97);
331
332void __init s3c64xx_ac97_setup_gpio(int num)
333{
334 if (num == S3C64XX_AC97_GPD)
335 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
336 else
337 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
338}
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000339
340static u64 s3c_device_audio_dmamask = 0xffffffffUL;
341
342struct platform_device s3c_device_pcm = {
343 .name = "s3c24xx-pcm-audio",
344 .id = -1,
345 .dev = {
346 .dma_mask = &s3c_device_audio_dmamask,
347 .coherent_dma_mask = 0xffffffffUL
348 }
349};
350EXPORT_SYMBOL(s3c_device_pcm);
351