1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright 2009 Wolfson Microelectronics
4 // Mark Brown <broonie@opensource.wolfsonmicro.com>
6 #include <linux/kernel.h>
7 #include <linux/string.h>
8 #include <linux/platform_device.h>
9 #include <linux/dma-mapping.h>
10 #include <linux/gpio.h>
11 #include <linux/export.h>
13 #include <mach/irqs.h>
17 #include <plat/devs.h>
18 #include <linux/platform_data/asoc-s3c.h>
19 #include <plat/gpio-cfg.h>
20 #include <mach/gpio-samsung.h>
22 static int s3c64xx_i2s_cfg_gpio(struct platform_device
*pdev
)
28 base
= S3C64XX_GPD(0);
31 base
= S3C64XX_GPE(0);
34 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
35 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
36 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
37 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
40 printk(KERN_DEBUG
"Invalid I2S Controller number: %d\n",
45 s3c_gpio_cfgpin_range(base
, 5, S3C_GPIO_SFN(3));
50 static struct resource s3c64xx_iis0_resource
[] = {
51 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0
, SZ_256
),
54 static struct s3c_audio_pdata i2s0_pdata
= {
55 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
58 struct platform_device s3c64xx_device_iis0
= {
59 .name
= "samsung-i2s",
61 .num_resources
= ARRAY_SIZE(s3c64xx_iis0_resource
),
62 .resource
= s3c64xx_iis0_resource
,
64 .platform_data
= &i2s0_pdata
,
67 EXPORT_SYMBOL(s3c64xx_device_iis0
);
69 static struct resource s3c64xx_iis1_resource
[] = {
70 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1
, SZ_256
),
73 static struct s3c_audio_pdata i2s1_pdata
= {
74 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
77 struct platform_device s3c64xx_device_iis1
= {
78 .name
= "samsung-i2s",
80 .num_resources
= ARRAY_SIZE(s3c64xx_iis1_resource
),
81 .resource
= s3c64xx_iis1_resource
,
83 .platform_data
= &i2s1_pdata
,
86 EXPORT_SYMBOL(s3c64xx_device_iis1
);
88 static struct resource s3c64xx_iisv4_resource
[] = {
89 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4
, SZ_256
),
92 static struct s3c_audio_pdata i2sv4_pdata
= {
93 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
95 .quirks
= QUIRK_PRI_6CHAN
,
99 struct platform_device s3c64xx_device_iisv4
= {
100 .name
= "samsung-i2s",
102 .num_resources
= ARRAY_SIZE(s3c64xx_iisv4_resource
),
103 .resource
= s3c64xx_iisv4_resource
,
105 .platform_data
= &i2sv4_pdata
,
108 EXPORT_SYMBOL(s3c64xx_device_iisv4
);
111 /* PCM Controller platform_devices */
113 static int s3c64xx_pcm_cfg_gpio(struct platform_device
*pdev
)
119 base
= S3C64XX_GPD(0);
122 base
= S3C64XX_GPE(0);
125 printk(KERN_DEBUG
"Invalid PCM Controller number: %d\n",
130 s3c_gpio_cfgpin_range(base
, 5, S3C_GPIO_SFN(2));
134 static struct resource s3c64xx_pcm0_resource
[] = {
135 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0
, SZ_256
),
138 static struct s3c_audio_pdata s3c_pcm0_pdata
= {
139 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
142 struct platform_device s3c64xx_device_pcm0
= {
143 .name
= "samsung-pcm",
145 .num_resources
= ARRAY_SIZE(s3c64xx_pcm0_resource
),
146 .resource
= s3c64xx_pcm0_resource
,
148 .platform_data
= &s3c_pcm0_pdata
,
151 EXPORT_SYMBOL(s3c64xx_device_pcm0
);
153 static struct resource s3c64xx_pcm1_resource
[] = {
154 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1
, SZ_256
),
157 static struct s3c_audio_pdata s3c_pcm1_pdata
= {
158 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
161 struct platform_device s3c64xx_device_pcm1
= {
162 .name
= "samsung-pcm",
164 .num_resources
= ARRAY_SIZE(s3c64xx_pcm1_resource
),
165 .resource
= s3c64xx_pcm1_resource
,
167 .platform_data
= &s3c_pcm1_pdata
,
170 EXPORT_SYMBOL(s3c64xx_device_pcm1
);
172 /* AC97 Controller platform devices */
174 static int s3c64xx_ac97_cfg_gpd(struct platform_device
*pdev
)
176 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
179 static int s3c64xx_ac97_cfg_gpe(struct platform_device
*pdev
)
181 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
184 static struct resource s3c64xx_ac97_resource
[] = {
185 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97
, SZ_256
),
186 [1] = DEFINE_RES_IRQ(IRQ_AC97
),
189 static struct s3c_audio_pdata s3c_ac97_pdata
= {
192 static u64 s3c64xx_ac97_dmamask
= DMA_BIT_MASK(32);
194 struct platform_device s3c64xx_device_ac97
= {
195 .name
= "samsung-ac97",
197 .num_resources
= ARRAY_SIZE(s3c64xx_ac97_resource
),
198 .resource
= s3c64xx_ac97_resource
,
200 .platform_data
= &s3c_ac97_pdata
,
201 .dma_mask
= &s3c64xx_ac97_dmamask
,
202 .coherent_dma_mask
= DMA_BIT_MASK(32),
205 EXPORT_SYMBOL(s3c64xx_device_ac97
);
207 void __init
s3c64xx_ac97_setup_gpio(int num
)
209 if (num
== S3C64XX_AC97_GPD
)
210 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpd
;
212 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpe
;