Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / arm / mach-s3c / dev-audio-s3c64xx.c
blobfc2f077afd2411b930aec7af8fe763fdf43d8ef0
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 "map.h"
16 #include "devs.h"
17 #include <linux/platform_data/asoc-s3c.h>
18 #include "gpio-cfg.h"
19 #include "gpio-samsung.h"
21 static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
23 unsigned int base;
25 switch (pdev->id) {
26 case 0:
27 base = S3C64XX_GPD(0);
28 break;
29 case 1:
30 base = S3C64XX_GPE(0);
31 break;
32 case 2:
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));
37 return 0;
38 default:
39 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
40 pdev->id);
41 return -EINVAL;
44 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
46 return 0;
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",
59 .id = 0,
60 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
61 .resource = s3c64xx_iis0_resource,
62 .dev = {
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",
78 .id = 1,
79 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
80 .resource = s3c64xx_iis1_resource,
81 .dev = {
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,
93 .type = {
94 .quirks = QUIRK_PRI_6CHAN,
98 struct platform_device s3c64xx_device_iisv4 = {
99 .name = "samsung-i2s",
100 .id = 2,
101 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
102 .resource = s3c64xx_iisv4_resource,
103 .dev = {
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)
114 unsigned int base;
116 switch (pdev->id) {
117 case 0:
118 base = S3C64XX_GPD(0);
119 break;
120 case 1:
121 base = S3C64XX_GPE(0);
122 break;
123 default:
124 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
125 pdev->id);
126 return -EINVAL;
129 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
130 return 0;
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",
143 .id = 0,
144 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
145 .resource = s3c64xx_pcm0_resource,
146 .dev = {
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",
162 .id = 1,
163 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
164 .resource = s3c64xx_pcm1_resource,
165 .dev = {
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",
195 .id = -1,
196 .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
197 .resource = s3c64xx_ac97_resource,
198 .dev = {
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;
210 else
211 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;