Linux 5.7.7
[linux/fpc-iii.git] / arch / arm / mach-s3c64xx / dev-audio.c
blobe3c49b5d1355b93e585356b5e347e558e53600f5
1 // SPDX-License-Identifier: GPL-2.0
2 //
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>
14 #include <mach/map.h>
15 #include <mach/dma.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)
24 unsigned int base;
26 switch (pdev->id) {
27 case 0:
28 base = S3C64XX_GPD(0);
29 break;
30 case 1:
31 base = S3C64XX_GPE(0);
32 break;
33 case 2:
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));
38 return 0;
39 default:
40 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
41 pdev->id);
42 return -EINVAL;
45 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
47 return 0;
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",
60 .id = 0,
61 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
62 .resource = s3c64xx_iis0_resource,
63 .dev = {
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",
79 .id = 1,
80 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
81 .resource = s3c64xx_iis1_resource,
82 .dev = {
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,
94 .type = {
95 .quirks = QUIRK_PRI_6CHAN,
99 struct platform_device s3c64xx_device_iisv4 = {
100 .name = "samsung-i2s",
101 .id = 2,
102 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
103 .resource = s3c64xx_iisv4_resource,
104 .dev = {
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)
115 unsigned int base;
117 switch (pdev->id) {
118 case 0:
119 base = S3C64XX_GPD(0);
120 break;
121 case 1:
122 base = S3C64XX_GPE(0);
123 break;
124 default:
125 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
126 pdev->id);
127 return -EINVAL;
130 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
131 return 0;
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",
144 .id = 0,
145 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
146 .resource = s3c64xx_pcm0_resource,
147 .dev = {
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",
163 .id = 1,
164 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
165 .resource = s3c64xx_pcm1_resource,
166 .dev = {
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",
196 .id = -1,
197 .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
198 .resource = s3c64xx_ac97_resource,
199 .dev = {
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;
211 else
212 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;