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
[] = {
60 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0
, SZ_256
),
61 [1] = DEFINE_RES_DMA(DMACH_I2S0_OUT
),
62 [2] = DEFINE_RES_DMA(DMACH_I2S0_IN
),
65 static struct s3c_audio_pdata i2sv3_pdata
= {
66 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
74 struct platform_device s3c64xx_device_iis0
= {
75 .name
= "samsung-i2s",
77 .num_resources
= ARRAY_SIZE(s3c64xx_iis0_resource
),
78 .resource
= s3c64xx_iis0_resource
,
80 .platform_data
= &i2sv3_pdata
,
83 EXPORT_SYMBOL(s3c64xx_device_iis0
);
85 static struct resource s3c64xx_iis1_resource
[] = {
86 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1
, SZ_256
),
87 [1] = DEFINE_RES_DMA(DMACH_I2S1_OUT
),
88 [2] = DEFINE_RES_DMA(DMACH_I2S1_IN
),
91 struct platform_device s3c64xx_device_iis1
= {
92 .name
= "samsung-i2s",
94 .num_resources
= ARRAY_SIZE(s3c64xx_iis1_resource
),
95 .resource
= s3c64xx_iis1_resource
,
97 .platform_data
= &i2sv3_pdata
,
100 EXPORT_SYMBOL(s3c64xx_device_iis1
);
102 static struct resource s3c64xx_iisv4_resource
[] = {
103 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4
, SZ_256
),
104 [1] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_TX
),
105 [2] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_RX
),
108 static struct s3c_audio_pdata i2sv4_pdata
= {
109 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
112 .quirks
= QUIRK_PRI_6CHAN
,
118 struct platform_device s3c64xx_device_iisv4
= {
119 .name
= "samsung-i2s",
121 .num_resources
= ARRAY_SIZE(s3c64xx_iisv4_resource
),
122 .resource
= s3c64xx_iisv4_resource
,
124 .platform_data
= &i2sv4_pdata
,
127 EXPORT_SYMBOL(s3c64xx_device_iisv4
);
130 /* PCM Controller platform_devices */
132 static int s3c64xx_pcm_cfg_gpio(struct platform_device
*pdev
)
138 base
= S3C64XX_GPD(0);
141 base
= S3C64XX_GPE(0);
144 printk(KERN_DEBUG
"Invalid PCM Controller number: %d\n",
149 s3c_gpio_cfgpin_range(base
, 5, S3C_GPIO_SFN(2));
153 static struct resource s3c64xx_pcm0_resource
[] = {
154 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0
, SZ_256
),
155 [1] = DEFINE_RES_DMA(DMACH_PCM0_TX
),
156 [2] = DEFINE_RES_DMA(DMACH_PCM0_RX
),
159 static struct s3c_audio_pdata s3c_pcm0_pdata
= {
160 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
163 struct platform_device s3c64xx_device_pcm0
= {
164 .name
= "samsung-pcm",
166 .num_resources
= ARRAY_SIZE(s3c64xx_pcm0_resource
),
167 .resource
= s3c64xx_pcm0_resource
,
169 .platform_data
= &s3c_pcm0_pdata
,
172 EXPORT_SYMBOL(s3c64xx_device_pcm0
);
174 static struct resource s3c64xx_pcm1_resource
[] = {
175 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1
, SZ_256
),
176 [1] = DEFINE_RES_DMA(DMACH_PCM1_TX
),
177 [2] = DEFINE_RES_DMA(DMACH_PCM1_RX
),
180 static struct s3c_audio_pdata s3c_pcm1_pdata
= {
181 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
184 struct platform_device s3c64xx_device_pcm1
= {
185 .name
= "samsung-pcm",
187 .num_resources
= ARRAY_SIZE(s3c64xx_pcm1_resource
),
188 .resource
= s3c64xx_pcm1_resource
,
190 .platform_data
= &s3c_pcm1_pdata
,
193 EXPORT_SYMBOL(s3c64xx_device_pcm1
);
195 /* AC97 Controller platform devices */
197 static int s3c64xx_ac97_cfg_gpd(struct platform_device
*pdev
)
199 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
202 static int s3c64xx_ac97_cfg_gpe(struct platform_device
*pdev
)
204 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
207 static struct resource s3c64xx_ac97_resource
[] = {
208 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97
, SZ_256
),
209 [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT
),
210 [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN
),
211 [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN
),
212 [4] = DEFINE_RES_IRQ(IRQ_AC97
),
215 static struct s3c_audio_pdata s3c_ac97_pdata
;
217 static u64 s3c64xx_ac97_dmamask
= DMA_BIT_MASK(32);
219 struct platform_device s3c64xx_device_ac97
= {
220 .name
= "samsung-ac97",
222 .num_resources
= ARRAY_SIZE(s3c64xx_ac97_resource
),
223 .resource
= s3c64xx_ac97_resource
,
225 .platform_data
= &s3c_ac97_pdata
,
226 .dma_mask
= &s3c64xx_ac97_dmamask
,
227 .coherent_dma_mask
= DMA_BIT_MASK(32),
230 EXPORT_SYMBOL(s3c64xx_device_ac97
);
232 void __init
s3c64xx_ac97_setup_gpio(int num
)
234 if (num
== S3C64XX_AC97_GPD
)
235 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpd
;
237 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpe
;