1 /* linux/arch/arm/plat-s3c/dev-audio.c
2 *
3 * Copyright 2009 Wolfson Microelectronics
4 * Mark Brown <broonie@opensource.wolfsonmicro.com>
5 *
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.
9 */
10
11 #include <linux/kernel.h>
12 #include <linux/string.h>
13 #include <linux/platform_device.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/gpio.h>
16 #include <linux/export.h>
17
18 #include <mach/irqs.h>
19 #include <mach/map.h>
20 #include <mach/dma.h>
21
22 #include <plat/devs.h>
23 #include <linux/platform_data/asoc-s3c.h>
24 #include <plat/gpio-cfg.h>
25
s3c64xx_i2s_cfg_gpio(struct platform_device * pdev)26 static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
27 {
28 unsigned int base;
29
30 switch (pdev->id) {
31 case 0:
32 base = S3C64XX_GPD(0);
33 break;
34 case 1:
35 base = S3C64XX_GPE(0);
36 break;
37 case 2:
38 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
39 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
40 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
41 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
42 return 0;
43 default:
44 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
45 pdev->id);
46 return -EINVAL;
47 }
48
49 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
50
51 return 0;
52 }
53
54 static struct resource s3c64xx_iis0_resource[] = {
55 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
56 [1] = DEFINE_RES_DMA(DMACH_I2S0_OUT),
57 [2] = DEFINE_RES_DMA(DMACH_I2S0_IN),
58 };
59
60 static struct s3c_audio_pdata i2sv3_pdata = {
61 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
62 };
63
64 struct platform_device s3c64xx_device_iis0 = {
65 .name = "samsung-i2s",
66 .id = 0,
67 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
68 .resource = s3c64xx_iis0_resource,
69 .dev = {
70 .platform_data = &i2sv3_pdata,
71 },
72 };
73 EXPORT_SYMBOL(s3c64xx_device_iis0);
74
75 static struct resource s3c64xx_iis1_resource[] = {
76 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
77 [1] = DEFINE_RES_DMA(DMACH_I2S1_OUT),
78 [2] = DEFINE_RES_DMA(DMACH_I2S1_IN),
79 };
80
81 struct platform_device s3c64xx_device_iis1 = {
82 .name = "samsung-i2s",
83 .id = 1,
84 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
85 .resource = s3c64xx_iis1_resource,
86 .dev = {
87 .platform_data = &i2sv3_pdata,
88 },
89 };
90 EXPORT_SYMBOL(s3c64xx_device_iis1);
91
92 static struct resource s3c64xx_iisv4_resource[] = {
93 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
94 [1] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_TX),
95 [2] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_RX),
96 };
97
98 static struct s3c_audio_pdata i2sv4_pdata = {
99 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
100 .type = {
101 .i2s = {
102 .quirks = QUIRK_PRI_6CHAN,
103 },
104 },
105 };
106
107 struct platform_device s3c64xx_device_iisv4 = {
108 .name = "samsung-i2s",
109 .id = 2,
110 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
111 .resource = s3c64xx_iisv4_resource,
112 .dev = {
113 .platform_data = &i2sv4_pdata,
114 },
115 };
116 EXPORT_SYMBOL(s3c64xx_device_iisv4);
117
118
119 /* PCM Controller platform_devices */
120
s3c64xx_pcm_cfg_gpio(struct platform_device * pdev)121 static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
122 {
123 unsigned int base;
124
125 switch (pdev->id) {
126 case 0:
127 base = S3C64XX_GPD(0);
128 break;
129 case 1:
130 base = S3C64XX_GPE(0);
131 break;
132 default:
133 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
134 pdev->id);
135 return -EINVAL;
136 }
137
138 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
139 return 0;
140 }
141
142 static struct resource s3c64xx_pcm0_resource[] = {
143 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
144 [1] = DEFINE_RES_DMA(DMACH_PCM0_TX),
145 [2] = DEFINE_RES_DMA(DMACH_PCM0_RX),
146 };
147
148 static struct s3c_audio_pdata s3c_pcm0_pdata = {
149 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
150 };
151
152 struct platform_device s3c64xx_device_pcm0 = {
153 .name = "samsung-pcm",
154 .id = 0,
155 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
156 .resource = s3c64xx_pcm0_resource,
157 .dev = {
158 .platform_data = &s3c_pcm0_pdata,
159 },
160 };
161 EXPORT_SYMBOL(s3c64xx_device_pcm0);
162
163 static struct resource s3c64xx_pcm1_resource[] = {
164 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
165 [1] = DEFINE_RES_DMA(DMACH_PCM1_TX),
166 [2] = DEFINE_RES_DMA(DMACH_PCM1_RX),
167 };
168
169 static struct s3c_audio_pdata s3c_pcm1_pdata = {
170 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
171 };
172
173 struct platform_device s3c64xx_device_pcm1 = {
174 .name = "samsung-pcm",
175 .id = 1,
176 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
177 .resource = s3c64xx_pcm1_resource,
178 .dev = {
179 .platform_data = &s3c_pcm1_pdata,
180 },
181 };
182 EXPORT_SYMBOL(s3c64xx_device_pcm1);
183
184 /* AC97 Controller platform devices */
185
s3c64xx_ac97_cfg_gpd(struct platform_device * pdev)186 static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
187 {
188 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
189 }
190
s3c64xx_ac97_cfg_gpe(struct platform_device * pdev)191 static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
192 {
193 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
194 }
195
196 static struct resource s3c64xx_ac97_resource[] = {
197 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
198 [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT),
199 [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN),
200 [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN),
201 [4] = DEFINE_RES_IRQ(IRQ_AC97),
202 };
203
204 static struct s3c_audio_pdata s3c_ac97_pdata;
205
206 static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
207
208 struct platform_device s3c64xx_device_ac97 = {
209 .name = "samsung-ac97",
210 .id = -1,
211 .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
212 .resource = s3c64xx_ac97_resource,
213 .dev = {
214 .platform_data = &s3c_ac97_pdata,
215 .dma_mask = &s3c64xx_ac97_dmamask,
216 .coherent_dma_mask = DMA_BIT_MASK(32),
217 },
218 };
219 EXPORT_SYMBOL(s3c64xx_device_ac97);
220
s3c64xx_ac97_setup_gpio(int num)221 void __init s3c64xx_ac97_setup_gpio(int num)
222 {
223 if (num == S3C64XX_AC97_GPD)
224 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
225 else
226 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
227 }
228