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 <linux/platform_data/asoc-s3c.h>
19 #include "gpio-samsung.h"
21 static int s3c64xx_i2s_cfg_gpio(struct platform_device
*pdev
)
27 base
= S3C64XX_GPD(0);
30 base
= S3C64XX_GPE(0);
33 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
34 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
35 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
36 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
39 printk(KERN_DEBUG
"Invalid I2S Controller number: %d\n",
44 s3c_gpio_cfgpin_range(base
, 5, S3C_GPIO_SFN(3));
49 static struct resource s3c64xx_iis0_resource
[] = {
50 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0
, SZ_256
),
53 static struct s3c_audio_pdata i2s0_pdata
= {
54 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
57 struct platform_device s3c64xx_device_iis0
= {
58 .name
= "samsung-i2s",
60 .num_resources
= ARRAY_SIZE(s3c64xx_iis0_resource
),
61 .resource
= s3c64xx_iis0_resource
,
63 .platform_data
= &i2s0_pdata
,
66 EXPORT_SYMBOL(s3c64xx_device_iis0
);
68 static struct resource s3c64xx_iis1_resource
[] = {
69 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1
, SZ_256
),
72 static struct s3c_audio_pdata i2s1_pdata
= {
73 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
76 struct platform_device s3c64xx_device_iis1
= {
77 .name
= "samsung-i2s",
79 .num_resources
= ARRAY_SIZE(s3c64xx_iis1_resource
),
80 .resource
= s3c64xx_iis1_resource
,
82 .platform_data
= &i2s1_pdata
,
85 EXPORT_SYMBOL(s3c64xx_device_iis1
);
87 static struct resource s3c64xx_iisv4_resource
[] = {
88 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4
, SZ_256
),
91 static struct s3c_audio_pdata i2sv4_pdata
= {
92 .cfg_gpio
= s3c64xx_i2s_cfg_gpio
,
94 .quirks
= QUIRK_PRI_6CHAN
,
98 struct platform_device s3c64xx_device_iisv4
= {
99 .name
= "samsung-i2s",
101 .num_resources
= ARRAY_SIZE(s3c64xx_iisv4_resource
),
102 .resource
= s3c64xx_iisv4_resource
,
104 .platform_data
= &i2sv4_pdata
,
107 EXPORT_SYMBOL(s3c64xx_device_iisv4
);
110 /* PCM Controller platform_devices */
112 static int s3c64xx_pcm_cfg_gpio(struct platform_device
*pdev
)
118 base
= S3C64XX_GPD(0);
121 base
= S3C64XX_GPE(0);
124 printk(KERN_DEBUG
"Invalid PCM Controller number: %d\n",
129 s3c_gpio_cfgpin_range(base
, 5, S3C_GPIO_SFN(2));
133 static struct resource s3c64xx_pcm0_resource
[] = {
134 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0
, SZ_256
),
137 static struct s3c_audio_pdata s3c_pcm0_pdata
= {
138 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
141 struct platform_device s3c64xx_device_pcm0
= {
142 .name
= "samsung-pcm",
144 .num_resources
= ARRAY_SIZE(s3c64xx_pcm0_resource
),
145 .resource
= s3c64xx_pcm0_resource
,
147 .platform_data
= &s3c_pcm0_pdata
,
150 EXPORT_SYMBOL(s3c64xx_device_pcm0
);
152 static struct resource s3c64xx_pcm1_resource
[] = {
153 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1
, SZ_256
),
156 static struct s3c_audio_pdata s3c_pcm1_pdata
= {
157 .cfg_gpio
= s3c64xx_pcm_cfg_gpio
,
160 struct platform_device s3c64xx_device_pcm1
= {
161 .name
= "samsung-pcm",
163 .num_resources
= ARRAY_SIZE(s3c64xx_pcm1_resource
),
164 .resource
= s3c64xx_pcm1_resource
,
166 .platform_data
= &s3c_pcm1_pdata
,
169 EXPORT_SYMBOL(s3c64xx_device_pcm1
);
171 /* AC97 Controller platform devices */
173 static int s3c64xx_ac97_cfg_gpd(struct platform_device
*pdev
)
175 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
178 static int s3c64xx_ac97_cfg_gpe(struct platform_device
*pdev
)
180 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
183 static struct resource s3c64xx_ac97_resource
[] = {
184 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97
, SZ_256
),
185 [1] = DEFINE_RES_IRQ(IRQ_AC97
),
188 static struct s3c_audio_pdata s3c_ac97_pdata
= {
191 static u64 s3c64xx_ac97_dmamask
= DMA_BIT_MASK(32);
193 struct platform_device s3c64xx_device_ac97
= {
194 .name
= "samsung-ac97",
196 .num_resources
= ARRAY_SIZE(s3c64xx_ac97_resource
),
197 .resource
= s3c64xx_ac97_resource
,
199 .platform_data
= &s3c_ac97_pdata
,
200 .dma_mask
= &s3c64xx_ac97_dmamask
,
201 .coherent_dma_mask
= DMA_BIT_MASK(32),
204 EXPORT_SYMBOL(s3c64xx_device_ac97
);
206 void __init
s3c64xx_ac97_setup_gpio(int num
)
208 if (num
== S3C64XX_AC97_GPD
)
209 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpd
;
211 s3c_ac97_pdata
.cfg_gpio
= s3c64xx_ac97_cfg_gpe
;