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>
16 #include <linux/export.h>
18 #include <mach/irqs.h>
22 #include <plat/devs.h>
23 #include <plat/audio.h>
24 #include <plat/gpio-cfg.h>
26 static const char *rclksrc
[] = {
31 static int s3c64xx_i2s_cfg_gpio(struct platform_device
*pdev
)
37 base
= S3C64XX_GPD(0);
40 base
= S3C64XX_GPE(0);
43 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
44 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
45 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
46 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
49 printk(KERN_DEBUG
"Invalid I2S Controller number: %d\n",
54 s3c_gpio_cfgpin_range(base
, 5, S3C_GPIO_SFN(3));
59 static struct resource s3c64xx_iis0_resource
[] = {
61 .start
= S3C64XX_PA_IIS0
,
62 .end
= S3C64XX_PA_IIS0
+ 0x100 - 1,
63 .flags
= IORESOURCE_MEM
,
66 .start
= DMACH_I2S0_OUT
,
67 .end
= DMACH_I2S0_OUT
,
68 .flags
= IORESOURCE_DMA
,
71 .start
= DMACH_I2S0_IN
,
73 .flags
= IORESOURCE_DMA
,
77 static struct s3c_audio_pdata i2sv3_pdata
= {
78 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
86 struct platform_device s3c64xx_device_iis0
= {
87 .name
= "samsung-i2s",
89 .num_resources
= ARRAY_SIZE(s3c64xx_iis0_resource
),
90 .resource
= s3c64xx_iis0_resource
,
92 .platform_data
= &i2sv3_pdata
,
95 EXPORT_SYMBOL(s3c64xx_device_iis0
);
97 static struct resource s3c64xx_iis1_resource
[] = {
99 .start
= S3C64XX_PA_IIS1
,
100 .end
= S3C64XX_PA_IIS1
+ 0x100 - 1,
101 .flags
= IORESOURCE_MEM
,
104 .start
= DMACH_I2S1_OUT
,
105 .end
= DMACH_I2S1_OUT
,
106 .flags
= IORESOURCE_DMA
,
109 .start
= DMACH_I2S1_IN
,
110 .end
= DMACH_I2S1_IN
,
111 .flags
= IORESOURCE_DMA
,
115 struct platform_device s3c64xx_device_iis1
= {
116 .name
= "samsung-i2s",
118 .num_resources
= ARRAY_SIZE(s3c64xx_iis1_resource
),
119 .resource
= s3c64xx_iis1_resource
,
121 .platform_data
= &i2sv3_pdata
,
124 EXPORT_SYMBOL(s3c64xx_device_iis1
);
126 static struct resource s3c64xx_iisv4_resource
[] = {
128 .start
= S3C64XX_PA_IISV4
,
129 .end
= S3C64XX_PA_IISV4
+ 0x100 - 1,
130 .flags
= IORESOURCE_MEM
,
133 .start
= DMACH_HSI_I2SV40_TX
,
134 .end
= DMACH_HSI_I2SV40_TX
,
135 .flags
= IORESOURCE_DMA
,
138 .start
= DMACH_HSI_I2SV40_RX
,
139 .end
= DMACH_HSI_I2SV40_RX
,
140 .flags
= IORESOURCE_DMA
,
144 static struct s3c_audio_pdata i2sv4_pdata
= {
145 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
148 .quirks
= QUIRK_PRI_6CHAN
,
154 struct platform_device s3c64xx_device_iisv4
= {
155 .name
= "samsung-i2s",
157 .num_resources
= ARRAY_SIZE(s3c64xx_iisv4_resource
),
158 .resource
= s3c64xx_iisv4_resource
,
160 .platform_data
= &i2sv4_pdata
,
163 EXPORT_SYMBOL(s3c64xx_device_iisv4
);
166 /* PCM Controller platform_devices */
168 static int s3c64xx_pcm_cfg_gpio(struct platform_device
*pdev
)
174 base
= S3C64XX_GPD(0);
177 base
= S3C64XX_GPE(0);
180 printk(KERN_DEBUG
"Invalid PCM Controller number: %d\n",
185 s3c_gpio_cfgpin_range(base
, 5, S3C_GPIO_SFN(2));
189 static struct resource s3c64xx_pcm0_resource
[] = {
191 .start
= S3C64XX_PA_PCM0
,
192 .end
= S3C64XX_PA_PCM0
+ 0x100 - 1,
193 .flags
= IORESOURCE_MEM
,
196 .start
= DMACH_PCM0_TX
,
197 .end
= DMACH_PCM0_TX
,
198 .flags
= IORESOURCE_DMA
,
201 .start
= DMACH_PCM0_RX
,
202 .end
= DMACH_PCM0_RX
,
203 .flags
= IORESOURCE_DMA
,
207 static struct s3c_audio_pdata s3c_pcm0_pdata
= {
208 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
211 struct platform_device s3c64xx_device_pcm0
= {
212 .name
= "samsung-pcm",
214 .num_resources
= ARRAY_SIZE(s3c64xx_pcm0_resource
),
215 .resource
= s3c64xx_pcm0_resource
,
217 .platform_data
= &s3c_pcm0_pdata
,
220 EXPORT_SYMBOL(s3c64xx_device_pcm0
);
222 static struct resource s3c64xx_pcm1_resource
[] = {
224 .start
= S3C64XX_PA_PCM1
,
225 .end
= S3C64XX_PA_PCM1
+ 0x100 - 1,
226 .flags
= IORESOURCE_MEM
,
229 .start
= DMACH_PCM1_TX
,
230 .end
= DMACH_PCM1_TX
,
231 .flags
= IORESOURCE_DMA
,
234 .start
= DMACH_PCM1_RX
,
235 .end
= DMACH_PCM1_RX
,
236 .flags
= IORESOURCE_DMA
,
240 static struct s3c_audio_pdata s3c_pcm1_pdata
= {
241 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
244 struct platform_device s3c64xx_device_pcm1
= {
245 .name
= "samsung-pcm",
247 .num_resources
= ARRAY_SIZE(s3c64xx_pcm1_resource
),
248 .resource
= s3c64xx_pcm1_resource
,
250 .platform_data
= &s3c_pcm1_pdata
,
253 EXPORT_SYMBOL(s3c64xx_device_pcm1
);
255 /* AC97 Controller platform devices */
257 static int s3c64xx_ac97_cfg_gpd(struct platform_device
*pdev
)
259 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
262 static int s3c64xx_ac97_cfg_gpe(struct platform_device
*pdev
)
264 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
267 static struct resource s3c64xx_ac97_resource
[] = {
269 .start
= S3C64XX_PA_AC97
,
270 .end
= S3C64XX_PA_AC97
+ 0x100 - 1,
271 .flags
= IORESOURCE_MEM
,
274 .start
= DMACH_AC97_PCMOUT
,
275 .end
= DMACH_AC97_PCMOUT
,
276 .flags
= IORESOURCE_DMA
,
279 .start
= DMACH_AC97_PCMIN
,
280 .end
= DMACH_AC97_PCMIN
,
281 .flags
= IORESOURCE_DMA
,
284 .start
= DMACH_AC97_MICIN
,
285 .end
= DMACH_AC97_MICIN
,
286 .flags
= IORESOURCE_DMA
,
291 .flags
= IORESOURCE_IRQ
,
295 static struct s3c_audio_pdata s3c_ac97_pdata
;
297 static u64 s3c64xx_ac97_dmamask
= DMA_BIT_MASK(32);
299 struct platform_device s3c64xx_device_ac97
= {
300 .name
= "samsung-ac97",
302 .num_resources
= ARRAY_SIZE(s3c64xx_ac97_resource
),
303 .resource
= s3c64xx_ac97_resource
,
305 .platform_data
= &s3c_ac97_pdata
,
306 .dma_mask
= &s3c64xx_ac97_dmamask
,
307 .coherent_dma_mask
= DMA_BIT_MASK(32),
310 EXPORT_SYMBOL(s3c64xx_device_ac97
);
312 void __init
s3c64xx_ac97_setup_gpio(int num
)
314 if (num
== S3C64XX_AC97_GPD
)
315 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpd
;
317 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpe
;