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 <linux/platform_data/asoc-s3c.h>
24 #include <plat/gpio-cfg.h>
25 #include <mach/gpio-samsung.h>
27 static int s3c64xx_i2s_cfg_gpio(struct platform_device
*pdev
)
33 base
= S3C64XX_GPD(0);
36 base
= S3C64XX_GPE(0);
39 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
40 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
41 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
42 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
45 printk(KERN_DEBUG
"Invalid I2S Controller number: %d\n",
50 s3c_gpio_cfgpin_range(base
, 5, S3C_GPIO_SFN(3));
55 static struct resource s3c64xx_iis0_resource
[] = {
56 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0
, SZ_256
),
57 [1] = DEFINE_RES_DMA(DMACH_I2S0_OUT
),
58 [2] = DEFINE_RES_DMA(DMACH_I2S0_IN
),
61 static struct s3c_audio_pdata i2sv3_pdata
= {
62 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
65 struct platform_device s3c64xx_device_iis0
= {
66 .name
= "samsung-i2s",
68 .num_resources
= ARRAY_SIZE(s3c64xx_iis0_resource
),
69 .resource
= s3c64xx_iis0_resource
,
71 .platform_data
= &i2sv3_pdata
,
74 EXPORT_SYMBOL(s3c64xx_device_iis0
);
76 static struct resource s3c64xx_iis1_resource
[] = {
77 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1
, SZ_256
),
78 [1] = DEFINE_RES_DMA(DMACH_I2S1_OUT
),
79 [2] = DEFINE_RES_DMA(DMACH_I2S1_IN
),
82 struct platform_device s3c64xx_device_iis1
= {
83 .name
= "samsung-i2s",
85 .num_resources
= ARRAY_SIZE(s3c64xx_iis1_resource
),
86 .resource
= s3c64xx_iis1_resource
,
88 .platform_data
= &i2sv3_pdata
,
91 EXPORT_SYMBOL(s3c64xx_device_iis1
);
93 static struct resource s3c64xx_iisv4_resource
[] = {
94 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4
, SZ_256
),
95 [1] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_TX
),
96 [2] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_RX
),
99 static struct s3c_audio_pdata i2sv4_pdata
= {
100 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
103 .quirks
= QUIRK_PRI_6CHAN
,
108 struct platform_device s3c64xx_device_iisv4
= {
109 .name
= "samsung-i2s",
111 .num_resources
= ARRAY_SIZE(s3c64xx_iisv4_resource
),
112 .resource
= s3c64xx_iisv4_resource
,
114 .platform_data
= &i2sv4_pdata
,
117 EXPORT_SYMBOL(s3c64xx_device_iisv4
);
120 /* PCM Controller platform_devices */
122 static int s3c64xx_pcm_cfg_gpio(struct platform_device
*pdev
)
128 base
= S3C64XX_GPD(0);
131 base
= S3C64XX_GPE(0);
134 printk(KERN_DEBUG
"Invalid PCM Controller number: %d\n",
139 s3c_gpio_cfgpin_range(base
, 5, S3C_GPIO_SFN(2));
143 static struct resource s3c64xx_pcm0_resource
[] = {
144 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0
, SZ_256
),
145 [1] = DEFINE_RES_DMA(DMACH_PCM0_TX
),
146 [2] = DEFINE_RES_DMA(DMACH_PCM0_RX
),
149 static struct s3c_audio_pdata s3c_pcm0_pdata
= {
150 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
153 struct platform_device s3c64xx_device_pcm0
= {
154 .name
= "samsung-pcm",
156 .num_resources
= ARRAY_SIZE(s3c64xx_pcm0_resource
),
157 .resource
= s3c64xx_pcm0_resource
,
159 .platform_data
= &s3c_pcm0_pdata
,
162 EXPORT_SYMBOL(s3c64xx_device_pcm0
);
164 static struct resource s3c64xx_pcm1_resource
[] = {
165 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1
, SZ_256
),
166 [1] = DEFINE_RES_DMA(DMACH_PCM1_TX
),
167 [2] = DEFINE_RES_DMA(DMACH_PCM1_RX
),
170 static struct s3c_audio_pdata s3c_pcm1_pdata
= {
171 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
174 struct platform_device s3c64xx_device_pcm1
= {
175 .name
= "samsung-pcm",
177 .num_resources
= ARRAY_SIZE(s3c64xx_pcm1_resource
),
178 .resource
= s3c64xx_pcm1_resource
,
180 .platform_data
= &s3c_pcm1_pdata
,
183 EXPORT_SYMBOL(s3c64xx_device_pcm1
);
185 /* AC97 Controller platform devices */
187 static int s3c64xx_ac97_cfg_gpd(struct platform_device
*pdev
)
189 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
192 static int s3c64xx_ac97_cfg_gpe(struct platform_device
*pdev
)
194 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
197 static struct resource s3c64xx_ac97_resource
[] = {
198 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97
, SZ_256
),
199 [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT
),
200 [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN
),
201 [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN
),
202 [4] = DEFINE_RES_IRQ(IRQ_AC97
),
205 static struct s3c_audio_pdata s3c_ac97_pdata
;
207 static u64 s3c64xx_ac97_dmamask
= DMA_BIT_MASK(32);
209 struct platform_device s3c64xx_device_ac97
= {
210 .name
= "samsung-ac97",
212 .num_resources
= ARRAY_SIZE(s3c64xx_ac97_resource
),
213 .resource
= s3c64xx_ac97_resource
,
215 .platform_data
= &s3c_ac97_pdata
,
216 .dma_mask
= &s3c64xx_ac97_dmamask
,
217 .coherent_dma_mask
= DMA_BIT_MASK(32),
220 EXPORT_SYMBOL(s3c64xx_device_ac97
);
222 void __init
s3c64xx_ac97_setup_gpio(int num
)
224 if (num
== S3C64XX_AC97_GPD
)
225 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpd
;
227 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpe
;