blob: 447e4e7179ac9420f2fec549ea36094c4b9d08ff [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
Jassi Brar71269362010-01-06 15:33:44 +090025static int s3c64xx_i2sv3_cfg_gpio(struct platform_device *pdev)
26{
Ben Dooks2618b552010-05-27 15:54:06 +090027 unsigned int base;
28
Jassi Brar71269362010-01-06 15:33:44 +090029 switch (pdev->id) {
30 case 0:
Ben Dooks2618b552010-05-27 15:54:06 +090031 base = S3C64XX_GPD(0);
Jassi Brar71269362010-01-06 15:33:44 +090032 break;
33 case 1:
Ben Dooks2618b552010-05-27 15:54:06 +090034 base = S3C64XX_GPE(0);
Dimitris Papastamose4b6b742010-08-26 16:07:23 +010035 break;
Jassi Brar71269362010-01-06 15:33:44 +090036 default:
Dimitris Papastamose4b6b742010-08-26 16:07:23 +010037 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
38 pdev->id);
Jassi Brar71269362010-01-06 15:33:44 +090039 return -EINVAL;
40 }
41
Ben Dooks2618b552010-05-27 15:54:06 +090042 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
43
Jassi Brar71269362010-01-06 15:33:44 +090044 return 0;
45}
46
47static int s3c64xx_i2sv4_cfg_gpio(struct platform_device *pdev)
48{
Ben Dooksf5321762010-05-27 14:57:27 +090049 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));
Mark Browndff21262010-10-14 07:53:12 +090052 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
Jassi Brar71269362010-01-06 15:33:44 +090053
54 return 0;
55}
56
Mark Brown52da2192009-06-03 20:08:38 +010057static struct resource s3c64xx_iis0_resource[] = {
58 [0] = {
59 .start = S3C64XX_PA_IIS0,
60 .end = S3C64XX_PA_IIS0 + 0x100 - 1,
61 .flags = IORESOURCE_MEM,
62 },
Jassi Brar71269362010-01-06 15:33:44 +090063 [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
Mark Brown8dcdd6e2010-01-20 13:06:04 +000075static struct s3c_audio_pdata s3c_i2s0_pdata = {
Jassi Brar71269362010-01-06 15:33:44 +090076 .cfg_gpio = s3c64xx_i2sv3_cfg_gpio,
Mark Brown52da2192009-06-03 20:08:38 +010077};
78
79struct platform_device s3c64xx_device_iis0 = {
Jassi Brardaea9b42010-11-19 08:49:43 +090080 .name = "samsung-i2s",
Mark Brown52da2192009-06-03 20:08:38 +010081 .id = 0,
82 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
83 .resource = s3c64xx_iis0_resource,
Jassi Brar71269362010-01-06 15:33:44 +090084 .dev = {
85 .platform_data = &s3c_i2s0_pdata,
86 },
Mark Brown52da2192009-06-03 20:08:38 +010087};
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 },
Jassi Brar71269362010-01-06 15:33:44 +090096 [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
Mark Brown8dcdd6e2010-01-20 13:06:04 +0000108static struct s3c_audio_pdata s3c_i2s1_pdata = {
Jassi Brar71269362010-01-06 15:33:44 +0900109 .cfg_gpio = s3c64xx_i2sv3_cfg_gpio,
Mark Brown52da2192009-06-03 20:08:38 +0100110};
111
112struct platform_device s3c64xx_device_iis1 = {
Jassi Brardaea9b42010-11-19 08:49:43 +0900113 .name = "samsung-i2s",
Mark Brown52da2192009-06-03 20:08:38 +0100114 .id = 1,
115 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
116 .resource = s3c64xx_iis1_resource,
Jassi Brar71269362010-01-06 15:33:44 +0900117 .dev = {
118 .platform_data = &s3c_i2s1_pdata,
119 },
Mark Brown52da2192009-06-03 20:08:38 +0100120};
121EXPORT_SYMBOL(s3c64xx_device_iis1);
Mark Brownd06a49e2009-06-03 20:08:39 +0100122
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 },
Jassi Brar71269362010-01-06 15:33:44 +0900129 [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
Mark Brown8dcdd6e2010-01-20 13:06:04 +0000141static struct s3c_audio_pdata s3c_i2sv4_pdata = {
Jassi Brar71269362010-01-06 15:33:44 +0900142 .cfg_gpio = s3c64xx_i2sv4_cfg_gpio,
Mark Brownd06a49e2009-06-03 20:08:39 +0100143};
144
145struct platform_device s3c64xx_device_iisv4 = {
Jassi Brardaea9b42010-11-19 08:49:43 +0900146 .name = "samsung-i2s-v4",
Mark Brownd06a49e2009-06-03 20:08:39 +0100147 .id = -1,
148 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
149 .resource = s3c64xx_iisv4_resource,
Jassi Brar71269362010-01-06 15:33:44 +0900150 .dev = {
151 .platform_data = &s3c_i2sv4_pdata,
152 },
Mark Brownd06a49e2009-06-03 20:08:39 +0100153};
154EXPORT_SYMBOL(s3c64xx_device_iisv4);
Jassi Braracf1aef2009-11-17 16:53:56 +0900155
156
157/* PCM Controller platform_devices */
158
159static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
160{
Ben Dooks2618b552010-05-27 15:54:06 +0900161 unsigned int base;
162
Jassi Braracf1aef2009-11-17 16:53:56 +0900163 switch (pdev->id) {
164 case 0:
Ben Dooks2618b552010-05-27 15:54:06 +0900165 base = S3C64XX_GPD(0);
Jassi Braracf1aef2009-11-17 16:53:56 +0900166 break;
167 case 1:
Ben Dooks2618b552010-05-27 15:54:06 +0900168 base = S3C64XX_GPE(0);
Jassi Braracf1aef2009-11-17 16:53:56 +0900169 break;
170 default:
Dimitris Papastamose4b6b742010-08-26 16:07:23 +0100171 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
172 pdev->id);
Jassi Braracf1aef2009-11-17 16:53:56 +0900173 return -EINVAL;
174 }
175
Ben Dooks2618b552010-05-27 15:54:06 +0900176 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
Jassi Braracf1aef2009-11-17 16:53:56 +0900177 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
Mark Brown43f0de82009-11-27 16:43:53 +0000198static struct s3c_audio_pdata s3c_pcm0_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900199 .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
Mark Brown43f0de82009-11-27 16:43:53 +0000231static struct s3c_audio_pdata s3c_pcm1_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900232 .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);
Jassi Brarde6985b2010-02-12 10:38:51 +0000245
246/* AC97 Controller platform devices */
247
248static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
249{
Ben Dooks2618b552010-05-27 15:54:06 +0900250 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
Jassi Brarde6985b2010-02-12 10:38:51 +0000251}
252
253static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
254{
Ben Dooks2618b552010-05-27 15:54:06 +0900255 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
Jassi Brarde6985b2010-02-12 10:38:51 +0000256}
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}
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000310
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