1 /* linux/arch/arm/plat-s3c/dev-audio.c
3 * Copyright 2009 Wolfson Microelectronics
4 * Mark Brown <broonie@opensource.wolfsonmicro.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.
11 #include <linux/kernel.h>
12 #include <linux/string.h>
13 #include <linux/platform_device.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/gpio.h>
17 #include <mach/irqs.h>
21 #include <plat/devs.h>
22 #include <plat/audio.h>
23 #include <plat/gpio-cfg.h>
25 static const char *rclksrc
[] = {
30 static int s3c64xx_i2s_cfg_gpio(struct platform_device
*pdev
)
36 base
= S3C64XX_GPD(0);
39 base
= S3C64XX_GPE(0);
42 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
43 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
44 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
45 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
48 printk(KERN_DEBUG
"Invalid I2S Controller number: %d\n",
53 s3c_gpio_cfgpin_range(base
, 5, S3C_GPIO_SFN(3));
58 static struct resource s3c64xx_iis0_resource
[] = {
60 .start
= S3C64XX_PA_IIS0
,
61 .end
= S3C64XX_PA_IIS0
+ 0x100 - 1,
62 .flags
= IORESOURCE_MEM
,
65 .start
= DMACH_I2S0_OUT
,
66 .end
= DMACH_I2S0_OUT
,
67 .flags
= IORESOURCE_DMA
,
70 .start
= DMACH_I2S0_IN
,
72 .flags
= IORESOURCE_DMA
,
76 static struct s3c_audio_pdata i2sv3_pdata
= {
77 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
85 struct platform_device s3c64xx_device_iis0
= {
86 .name
= "samsung-i2s",
88 .num_resources
= ARRAY_SIZE(s3c64xx_iis0_resource
),
89 .resource
= s3c64xx_iis0_resource
,
91 .platform_data
= &i2sv3_pdata
,
94 EXPORT_SYMBOL(s3c64xx_device_iis0
);
96 static struct resource s3c64xx_iis1_resource
[] = {
98 .start
= S3C64XX_PA_IIS1
,
99 .end
= S3C64XX_PA_IIS1
+ 0x100 - 1,
100 .flags
= IORESOURCE_MEM
,
103 .start
= DMACH_I2S1_OUT
,
104 .end
= DMACH_I2S1_OUT
,
105 .flags
= IORESOURCE_DMA
,
108 .start
= DMACH_I2S1_IN
,
109 .end
= DMACH_I2S1_IN
,
110 .flags
= IORESOURCE_DMA
,
114 struct platform_device s3c64xx_device_iis1
= {
115 .name
= "samsung-i2s",
117 .num_resources
= ARRAY_SIZE(s3c64xx_iis1_resource
),
118 .resource
= s3c64xx_iis1_resource
,
120 .platform_data
= &i2sv3_pdata
,
123 EXPORT_SYMBOL(s3c64xx_device_iis1
);
125 static struct resource s3c64xx_iisv4_resource
[] = {
127 .start
= S3C64XX_PA_IISV4
,
128 .end
= S3C64XX_PA_IISV4
+ 0x100 - 1,
129 .flags
= IORESOURCE_MEM
,
132 .start
= DMACH_HSI_I2SV40_TX
,
133 .end
= DMACH_HSI_I2SV40_TX
,
134 .flags
= IORESOURCE_DMA
,
137 .start
= DMACH_HSI_I2SV40_RX
,
138 .end
= DMACH_HSI_I2SV40_RX
,
139 .flags
= IORESOURCE_DMA
,
143 static struct s3c_audio_pdata i2sv4_pdata
= {
144 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
147 .quirks
= QUIRK_PRI_6CHAN
,
153 struct platform_device s3c64xx_device_iisv4
= {
154 .name
= "samsung-i2s",
156 .num_resources
= ARRAY_SIZE(s3c64xx_iisv4_resource
),
157 .resource
= s3c64xx_iisv4_resource
,
159 .platform_data
= &i2sv4_pdata
,
162 EXPORT_SYMBOL(s3c64xx_device_iisv4
);
165 /* PCM Controller platform_devices */
167 static int s3c64xx_pcm_cfg_gpio(struct platform_device
*pdev
)
173 base
= S3C64XX_GPD(0);
176 base
= S3C64XX_GPE(0);
179 printk(KERN_DEBUG
"Invalid PCM Controller number: %d\n",
184 s3c_gpio_cfgpin_range(base
, 5, S3C_GPIO_SFN(2));
188 static struct resource s3c64xx_pcm0_resource
[] = {
190 .start
= S3C64XX_PA_PCM0
,
191 .end
= S3C64XX_PA_PCM0
+ 0x100 - 1,
192 .flags
= IORESOURCE_MEM
,
195 .start
= DMACH_PCM0_TX
,
196 .end
= DMACH_PCM0_TX
,
197 .flags
= IORESOURCE_DMA
,
200 .start
= DMACH_PCM0_RX
,
201 .end
= DMACH_PCM0_RX
,
202 .flags
= IORESOURCE_DMA
,
206 static struct s3c_audio_pdata s3c_pcm0_pdata
= {
207 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
210 struct platform_device s3c64xx_device_pcm0
= {
211 .name
= "samsung-pcm",
213 .num_resources
= ARRAY_SIZE(s3c64xx_pcm0_resource
),
214 .resource
= s3c64xx_pcm0_resource
,
216 .platform_data
= &s3c_pcm0_pdata
,
219 EXPORT_SYMBOL(s3c64xx_device_pcm0
);
221 static struct resource s3c64xx_pcm1_resource
[] = {
223 .start
= S3C64XX_PA_PCM1
,
224 .end
= S3C64XX_PA_PCM1
+ 0x100 - 1,
225 .flags
= IORESOURCE_MEM
,
228 .start
= DMACH_PCM1_TX
,
229 .end
= DMACH_PCM1_TX
,
230 .flags
= IORESOURCE_DMA
,
233 .start
= DMACH_PCM1_RX
,
234 .end
= DMACH_PCM1_RX
,
235 .flags
= IORESOURCE_DMA
,
239 static struct s3c_audio_pdata s3c_pcm1_pdata
= {
240 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
243 struct platform_device s3c64xx_device_pcm1
= {
244 .name
= "samsung-pcm",
246 .num_resources
= ARRAY_SIZE(s3c64xx_pcm1_resource
),
247 .resource
= s3c64xx_pcm1_resource
,
249 .platform_data
= &s3c_pcm1_pdata
,
252 EXPORT_SYMBOL(s3c64xx_device_pcm1
);
254 /* AC97 Controller platform devices */
256 static int s3c64xx_ac97_cfg_gpd(struct platform_device
*pdev
)
258 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
261 static int s3c64xx_ac97_cfg_gpe(struct platform_device
*pdev
)
263 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
266 static struct resource s3c64xx_ac97_resource
[] = {
268 .start
= S3C64XX_PA_AC97
,
269 .end
= S3C64XX_PA_AC97
+ 0x100 - 1,
270 .flags
= IORESOURCE_MEM
,
273 .start
= DMACH_AC97_PCMOUT
,
274 .end
= DMACH_AC97_PCMOUT
,
275 .flags
= IORESOURCE_DMA
,
278 .start
= DMACH_AC97_PCMIN
,
279 .end
= DMACH_AC97_PCMIN
,
280 .flags
= IORESOURCE_DMA
,
283 .start
= DMACH_AC97_MICIN
,
284 .end
= DMACH_AC97_MICIN
,
285 .flags
= IORESOURCE_DMA
,
290 .flags
= IORESOURCE_IRQ
,
294 static struct s3c_audio_pdata s3c_ac97_pdata
;
296 static u64 s3c64xx_ac97_dmamask
= DMA_BIT_MASK(32);
298 struct platform_device s3c64xx_device_ac97
= {
299 .name
= "samsung-ac97",
301 .num_resources
= ARRAY_SIZE(s3c64xx_ac97_resource
),
302 .resource
= s3c64xx_ac97_resource
,
304 .platform_data
= &s3c_ac97_pdata
,
305 .dma_mask
= &s3c64xx_ac97_dmamask
,
306 .coherent_dma_mask
= DMA_BIT_MASK(32),
309 EXPORT_SYMBOL(s3c64xx_device_ac97
);
311 void __init
s3c64xx_ac97_setup_gpio(int num
)
313 if (num
== S3C64XX_AC97_GPD
)
314 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpd
;
316 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpe
;