1 /* linux/arch/arm/mach-s5pc100/dev-audio.c
3 * Copyright (c) 2010 Samsung Electronics Co. Ltd
4 * Jaswinder Singh <jassi.brar@samsung.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/platform_device.h>
12 #include <linux/dma-mapping.h>
13 #include <linux/gpio.h>
15 #include <plat/gpio-cfg.h>
16 #include <linux/platform_data/asoc-s3c.h>
20 #include <mach/irqs.h>
22 static int s5pc100_cfg_i2s(struct platform_device
*pdev
)
24 /* configure GPIO for i2s port */
26 case 0: /* Dedicated pins */
29 s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(2));
32 s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(4));
35 printk(KERN_ERR
"Invalid Device %d\n", pdev
->id
);
42 static const char *rclksrc_v5
[] = {
47 static struct s3c_audio_pdata i2sv5_pdata
= {
48 .cfg_gpio
= s5pc100_cfg_i2s
,
51 .quirks
= QUIRK_PRI_6CHAN
| QUIRK_SEC_DAI
53 .src_clk
= rclksrc_v5
,
58 static struct resource s5pc100_iis0_resource
[] = {
59 [0] = DEFINE_RES_MEM(S5PC100_PA_I2S0
, SZ_256
),
60 [1] = DEFINE_RES_DMA(DMACH_I2S0_TX
),
61 [2] = DEFINE_RES_DMA(DMACH_I2S0_RX
),
62 [3] = DEFINE_RES_DMA(DMACH_I2S0S_TX
),
65 struct platform_device s5pc100_device_iis0
= {
66 .name
= "samsung-i2s",
68 .num_resources
= ARRAY_SIZE(s5pc100_iis0_resource
),
69 .resource
= s5pc100_iis0_resource
,
71 .platform_data
= &i2sv5_pdata
,
75 static const char *rclksrc_v3
[] = {
80 static struct s3c_audio_pdata i2sv3_pdata
= {
81 .cfg_gpio
= s5pc100_cfg_i2s
,
84 .src_clk
= rclksrc_v3
,
89 static struct resource s5pc100_iis1_resource
[] = {
90 [0] = DEFINE_RES_MEM(S5PC100_PA_I2S1
, SZ_256
),
91 [1] = DEFINE_RES_DMA(DMACH_I2S1_TX
),
92 [2] = DEFINE_RES_DMA(DMACH_I2S1_RX
),
95 struct platform_device s5pc100_device_iis1
= {
96 .name
= "samsung-i2s",
98 .num_resources
= ARRAY_SIZE(s5pc100_iis1_resource
),
99 .resource
= s5pc100_iis1_resource
,
101 .platform_data
= &i2sv3_pdata
,
105 static struct resource s5pc100_iis2_resource
[] = {
106 [0] = DEFINE_RES_MEM(S5PC100_PA_I2S2
, SZ_256
),
107 [1] = DEFINE_RES_DMA(DMACH_I2S2_TX
),
108 [2] = DEFINE_RES_DMA(DMACH_I2S2_RX
),
111 struct platform_device s5pc100_device_iis2
= {
112 .name
= "samsung-i2s",
114 .num_resources
= ARRAY_SIZE(s5pc100_iis2_resource
),
115 .resource
= s5pc100_iis2_resource
,
117 .platform_data
= &i2sv3_pdata
,
121 /* PCM Controller platform_devices */
123 static int s5pc100_pcm_cfg_gpio(struct platform_device
*pdev
)
127 s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(5));
131 s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(3));
135 printk(KERN_DEBUG
"Invalid PCM Controller number!");
142 static struct s3c_audio_pdata s3c_pcm_pdata
= {
143 .cfg_gpio
= s5pc100_pcm_cfg_gpio
,
146 static struct resource s5pc100_pcm0_resource
[] = {
147 [0] = DEFINE_RES_MEM(S5PC100_PA_PCM0
, SZ_256
),
148 [1] = DEFINE_RES_DMA(DMACH_PCM0_TX
),
149 [2] = DEFINE_RES_DMA(DMACH_PCM0_RX
),
152 struct platform_device s5pc100_device_pcm0
= {
153 .name
= "samsung-pcm",
155 .num_resources
= ARRAY_SIZE(s5pc100_pcm0_resource
),
156 .resource
= s5pc100_pcm0_resource
,
158 .platform_data
= &s3c_pcm_pdata
,
162 static struct resource s5pc100_pcm1_resource
[] = {
163 [0] = DEFINE_RES_MEM(S5PC100_PA_PCM1
, SZ_256
),
164 [1] = DEFINE_RES_DMA(DMACH_PCM1_TX
),
165 [2] = DEFINE_RES_DMA(DMACH_PCM1_RX
),
168 struct platform_device s5pc100_device_pcm1
= {
169 .name
= "samsung-pcm",
171 .num_resources
= ARRAY_SIZE(s5pc100_pcm1_resource
),
172 .resource
= s5pc100_pcm1_resource
,
174 .platform_data
= &s3c_pcm_pdata
,
178 /* AC97 Controller platform devices */
180 static int s5pc100_ac97_cfg_gpio(struct platform_device
*pdev
)
182 return s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(4));
185 static struct resource s5pc100_ac97_resource
[] = {
186 [0] = DEFINE_RES_MEM(S5PC100_PA_AC97
, SZ_256
),
187 [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT
),
188 [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN
),
189 [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN
),
190 [4] = DEFINE_RES_IRQ(IRQ_AC97
),
193 static struct s3c_audio_pdata s3c_ac97_pdata
= {
194 .cfg_gpio
= s5pc100_ac97_cfg_gpio
,
197 static u64 s5pc100_ac97_dmamask
= DMA_BIT_MASK(32);
199 struct platform_device s5pc100_device_ac97
= {
200 .name
= "samsung-ac97",
202 .num_resources
= ARRAY_SIZE(s5pc100_ac97_resource
),
203 .resource
= s5pc100_ac97_resource
,
205 .platform_data
= &s3c_ac97_pdata
,
206 .dma_mask
= &s5pc100_ac97_dmamask
,
207 .coherent_dma_mask
= DMA_BIT_MASK(32),
211 /* S/PDIF Controller platform_device */
212 static int s5pc100_spdif_cfg_gpd(struct platform_device
*pdev
)
214 s3c_gpio_cfgpin_range(S5PC100_GPD(5), 2, S3C_GPIO_SFN(3));
219 static int s5pc100_spdif_cfg_gpg3(struct platform_device
*pdev
)
221 s3c_gpio_cfgpin_range(S5PC100_GPG3(5), 2, S3C_GPIO_SFN(3));
226 static struct resource s5pc100_spdif_resource
[] = {
227 [0] = DEFINE_RES_MEM(S5PC100_PA_SPDIF
, SZ_256
),
228 [1] = DEFINE_RES_DMA(DMACH_SPDIF
),
231 static struct s3c_audio_pdata s5p_spdif_pdata
= {
232 .cfg_gpio
= s5pc100_spdif_cfg_gpd
,
235 static u64 s5pc100_spdif_dmamask
= DMA_BIT_MASK(32);
237 struct platform_device s5pc100_device_spdif
= {
238 .name
= "samsung-spdif",
240 .num_resources
= ARRAY_SIZE(s5pc100_spdif_resource
),
241 .resource
= s5pc100_spdif_resource
,
243 .platform_data
= &s5p_spdif_pdata
,
244 .dma_mask
= &s5pc100_spdif_dmamask
,
245 .coherent_dma_mask
= DMA_BIT_MASK(32),
249 void __init
s5pc100_spdif_setup_gpio(int gpio
)
251 if (gpio
== S5PC100_SPDIF_GPD
)
252 s5p_spdif_pdata
.cfg_gpio
= s5pc100_spdif_cfg_gpd
;
254 s5p_spdif_pdata
.cfg_gpio
= s5pc100_spdif_cfg_gpg3
;