Loading...
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#include <mach/gpio-samsung.h>
26
27static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
28{
29 unsigned int base;
30
31 switch (pdev->id) {
32 case 0:
33 base = S3C64XX_GPD(0);
34 break;
35 case 1:
36 base = S3C64XX_GPE(0);
37 break;
38 case 2:
39 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
40 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
41 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
42 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
43 return 0;
44 default:
45 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
46 pdev->id);
47 return -EINVAL;
48 }
49
50 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
51
52 return 0;
53}
54
55static struct resource s3c64xx_iis0_resource[] = {
56 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
57 [1] = DEFINE_RES_DMA(DMACH_I2S0_OUT),
58 [2] = DEFINE_RES_DMA(DMACH_I2S0_IN),
59};
60
61static struct s3c_audio_pdata i2sv3_pdata = {
62 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
63};
64
65struct platform_device s3c64xx_device_iis0 = {
66 .name = "samsung-i2s",
67 .id = 0,
68 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
69 .resource = s3c64xx_iis0_resource,
70 .dev = {
71 .platform_data = &i2sv3_pdata,
72 },
73};
74EXPORT_SYMBOL(s3c64xx_device_iis0);
75
76static struct resource s3c64xx_iis1_resource[] = {
77 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
78 [1] = DEFINE_RES_DMA(DMACH_I2S1_OUT),
79 [2] = DEFINE_RES_DMA(DMACH_I2S1_IN),
80};
81
82struct platform_device s3c64xx_device_iis1 = {
83 .name = "samsung-i2s",
84 .id = 1,
85 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
86 .resource = s3c64xx_iis1_resource,
87 .dev = {
88 .platform_data = &i2sv3_pdata,
89 },
90};
91EXPORT_SYMBOL(s3c64xx_device_iis1);
92
93static struct resource s3c64xx_iisv4_resource[] = {
94 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
95 [1] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_TX),
96 [2] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_RX),
97};
98
99static struct s3c_audio_pdata i2sv4_pdata = {
100 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
101 .type = {
102 .i2s = {
103 .quirks = QUIRK_PRI_6CHAN,
104 },
105 },
106};
107
108struct platform_device s3c64xx_device_iisv4 = {
109 .name = "samsung-i2s",
110 .id = 2,
111 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
112 .resource = s3c64xx_iisv4_resource,
113 .dev = {
114 .platform_data = &i2sv4_pdata,
115 },
116};
117EXPORT_SYMBOL(s3c64xx_device_iisv4);
118
119
120/* PCM Controller platform_devices */
121
122static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
123{
124 unsigned int base;
125
126 switch (pdev->id) {
127 case 0:
128 base = S3C64XX_GPD(0);
129 break;
130 case 1:
131 base = S3C64XX_GPE(0);
132 break;
133 default:
134 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
135 pdev->id);
136 return -EINVAL;
137 }
138
139 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
140 return 0;
141}
142
143static struct resource s3c64xx_pcm0_resource[] = {
144 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
145 [1] = DEFINE_RES_DMA(DMACH_PCM0_TX),
146 [2] = DEFINE_RES_DMA(DMACH_PCM0_RX),
147};
148
149static struct s3c_audio_pdata s3c_pcm0_pdata = {
150 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
151};
152
153struct platform_device s3c64xx_device_pcm0 = {
154 .name = "samsung-pcm",
155 .id = 0,
156 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
157 .resource = s3c64xx_pcm0_resource,
158 .dev = {
159 .platform_data = &s3c_pcm0_pdata,
160 },
161};
162EXPORT_SYMBOL(s3c64xx_device_pcm0);
163
164static struct resource s3c64xx_pcm1_resource[] = {
165 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
166 [1] = DEFINE_RES_DMA(DMACH_PCM1_TX),
167 [2] = DEFINE_RES_DMA(DMACH_PCM1_RX),
168};
169
170static struct s3c_audio_pdata s3c_pcm1_pdata = {
171 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
172};
173
174struct platform_device s3c64xx_device_pcm1 = {
175 .name = "samsung-pcm",
176 .id = 1,
177 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
178 .resource = s3c64xx_pcm1_resource,
179 .dev = {
180 .platform_data = &s3c_pcm1_pdata,
181 },
182};
183EXPORT_SYMBOL(s3c64xx_device_pcm1);
184
185/* AC97 Controller platform devices */
186
187static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
188{
189 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
190}
191
192static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
193{
194 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
195}
196
197static struct resource s3c64xx_ac97_resource[] = {
198 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
199 [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT),
200 [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN),
201 [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN),
202 [4] = DEFINE_RES_IRQ(IRQ_AC97),
203};
204
205static struct s3c_audio_pdata s3c_ac97_pdata;
206
207static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
208
209struct platform_device s3c64xx_device_ac97 = {
210 .name = "samsung-ac97",
211 .id = -1,
212 .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
213 .resource = s3c64xx_ac97_resource,
214 .dev = {
215 .platform_data = &s3c_ac97_pdata,
216 .dma_mask = &s3c64xx_ac97_dmamask,
217 .coherent_dma_mask = DMA_BIT_MASK(32),
218 },
219};
220EXPORT_SYMBOL(s3c64xx_device_ac97);
221
222void __init s3c64xx_ac97_setup_gpio(int num)
223{
224 if (num == S3C64XX_AC97_GPD)
225 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
226 else
227 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
228}
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
17#include <mach/irqs.h>
18#include <mach/map.h>
19#include <mach/dma.h>
20
21#include <plat/devs.h>
22#include <plat/audio.h>
23#include <plat/gpio-cfg.h>
24
25static const char *rclksrc[] = {
26 [0] = "iis",
27 [1] = "audio-bus",
28};
29
30static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
31{
32 unsigned int base;
33
34 switch (pdev->id) {
35 case 0:
36 base = S3C64XX_GPD(0);
37 break;
38 case 1:
39 base = S3C64XX_GPE(0);
40 break;
41 case 2:
42 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
43 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
44 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
45 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
46 return 0;
47 default:
48 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
49 pdev->id);
50 return -EINVAL;
51 }
52
53 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
54
55 return 0;
56}
57
58static struct resource s3c64xx_iis0_resource[] = {
59 [0] = {
60 .start = S3C64XX_PA_IIS0,
61 .end = S3C64XX_PA_IIS0 + 0x100 - 1,
62 .flags = IORESOURCE_MEM,
63 },
64 [1] = {
65 .start = DMACH_I2S0_OUT,
66 .end = DMACH_I2S0_OUT,
67 .flags = IORESOURCE_DMA,
68 },
69 [2] = {
70 .start = DMACH_I2S0_IN,
71 .end = DMACH_I2S0_IN,
72 .flags = IORESOURCE_DMA,
73 },
74};
75
76static struct s3c_audio_pdata i2sv3_pdata = {
77 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
78 .type = {
79 .i2s = {
80 .src_clk = rclksrc,
81 },
82 },
83};
84
85struct platform_device s3c64xx_device_iis0 = {
86 .name = "samsung-i2s",
87 .id = 0,
88 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
89 .resource = s3c64xx_iis0_resource,
90 .dev = {
91 .platform_data = &i2sv3_pdata,
92 },
93};
94EXPORT_SYMBOL(s3c64xx_device_iis0);
95
96static struct resource s3c64xx_iis1_resource[] = {
97 [0] = {
98 .start = S3C64XX_PA_IIS1,
99 .end = S3C64XX_PA_IIS1 + 0x100 - 1,
100 .flags = IORESOURCE_MEM,
101 },
102 [1] = {
103 .start = DMACH_I2S1_OUT,
104 .end = DMACH_I2S1_OUT,
105 .flags = IORESOURCE_DMA,
106 },
107 [2] = {
108 .start = DMACH_I2S1_IN,
109 .end = DMACH_I2S1_IN,
110 .flags = IORESOURCE_DMA,
111 },
112};
113
114struct platform_device s3c64xx_device_iis1 = {
115 .name = "samsung-i2s",
116 .id = 1,
117 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
118 .resource = s3c64xx_iis1_resource,
119 .dev = {
120 .platform_data = &i2sv3_pdata,
121 },
122};
123EXPORT_SYMBOL(s3c64xx_device_iis1);
124
125static struct resource s3c64xx_iisv4_resource[] = {
126 [0] = {
127 .start = S3C64XX_PA_IISV4,
128 .end = S3C64XX_PA_IISV4 + 0x100 - 1,
129 .flags = IORESOURCE_MEM,
130 },
131 [1] = {
132 .start = DMACH_HSI_I2SV40_TX,
133 .end = DMACH_HSI_I2SV40_TX,
134 .flags = IORESOURCE_DMA,
135 },
136 [2] = {
137 .start = DMACH_HSI_I2SV40_RX,
138 .end = DMACH_HSI_I2SV40_RX,
139 .flags = IORESOURCE_DMA,
140 },
141};
142
143static struct s3c_audio_pdata i2sv4_pdata = {
144 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
145 .type = {
146 .i2s = {
147 .quirks = QUIRK_PRI_6CHAN,
148 .src_clk = rclksrc,
149 },
150 },
151};
152
153struct platform_device s3c64xx_device_iisv4 = {
154 .name = "samsung-i2s",
155 .id = 2,
156 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
157 .resource = s3c64xx_iisv4_resource,
158 .dev = {
159 .platform_data = &i2sv4_pdata,
160 },
161};
162EXPORT_SYMBOL(s3c64xx_device_iisv4);
163
164
165/* PCM Controller platform_devices */
166
167static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
168{
169 unsigned int base;
170
171 switch (pdev->id) {
172 case 0:
173 base = S3C64XX_GPD(0);
174 break;
175 case 1:
176 base = S3C64XX_GPE(0);
177 break;
178 default:
179 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
180 pdev->id);
181 return -EINVAL;
182 }
183
184 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
185 return 0;
186}
187
188static struct resource s3c64xx_pcm0_resource[] = {
189 [0] = {
190 .start = S3C64XX_PA_PCM0,
191 .end = S3C64XX_PA_PCM0 + 0x100 - 1,
192 .flags = IORESOURCE_MEM,
193 },
194 [1] = {
195 .start = DMACH_PCM0_TX,
196 .end = DMACH_PCM0_TX,
197 .flags = IORESOURCE_DMA,
198 },
199 [2] = {
200 .start = DMACH_PCM0_RX,
201 .end = DMACH_PCM0_RX,
202 .flags = IORESOURCE_DMA,
203 },
204};
205
206static struct s3c_audio_pdata s3c_pcm0_pdata = {
207 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
208};
209
210struct platform_device s3c64xx_device_pcm0 = {
211 .name = "samsung-pcm",
212 .id = 0,
213 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
214 .resource = s3c64xx_pcm0_resource,
215 .dev = {
216 .platform_data = &s3c_pcm0_pdata,
217 },
218};
219EXPORT_SYMBOL(s3c64xx_device_pcm0);
220
221static struct resource s3c64xx_pcm1_resource[] = {
222 [0] = {
223 .start = S3C64XX_PA_PCM1,
224 .end = S3C64XX_PA_PCM1 + 0x100 - 1,
225 .flags = IORESOURCE_MEM,
226 },
227 [1] = {
228 .start = DMACH_PCM1_TX,
229 .end = DMACH_PCM1_TX,
230 .flags = IORESOURCE_DMA,
231 },
232 [2] = {
233 .start = DMACH_PCM1_RX,
234 .end = DMACH_PCM1_RX,
235 .flags = IORESOURCE_DMA,
236 },
237};
238
239static struct s3c_audio_pdata s3c_pcm1_pdata = {
240 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
241};
242
243struct platform_device s3c64xx_device_pcm1 = {
244 .name = "samsung-pcm",
245 .id = 1,
246 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
247 .resource = s3c64xx_pcm1_resource,
248 .dev = {
249 .platform_data = &s3c_pcm1_pdata,
250 },
251};
252EXPORT_SYMBOL(s3c64xx_device_pcm1);
253
254/* AC97 Controller platform devices */
255
256static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
257{
258 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
259}
260
261static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
262{
263 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
264}
265
266static struct resource s3c64xx_ac97_resource[] = {
267 [0] = {
268 .start = S3C64XX_PA_AC97,
269 .end = S3C64XX_PA_AC97 + 0x100 - 1,
270 .flags = IORESOURCE_MEM,
271 },
272 [1] = {
273 .start = DMACH_AC97_PCMOUT,
274 .end = DMACH_AC97_PCMOUT,
275 .flags = IORESOURCE_DMA,
276 },
277 [2] = {
278 .start = DMACH_AC97_PCMIN,
279 .end = DMACH_AC97_PCMIN,
280 .flags = IORESOURCE_DMA,
281 },
282 [3] = {
283 .start = DMACH_AC97_MICIN,
284 .end = DMACH_AC97_MICIN,
285 .flags = IORESOURCE_DMA,
286 },
287 [4] = {
288 .start = IRQ_AC97,
289 .end = IRQ_AC97,
290 .flags = IORESOURCE_IRQ,
291 },
292};
293
294static struct s3c_audio_pdata s3c_ac97_pdata;
295
296static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
297
298struct platform_device s3c64xx_device_ac97 = {
299 .name = "samsung-ac97",
300 .id = -1,
301 .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
302 .resource = s3c64xx_ac97_resource,
303 .dev = {
304 .platform_data = &s3c_ac97_pdata,
305 .dma_mask = &s3c64xx_ac97_dmamask,
306 .coherent_dma_mask = DMA_BIT_MASK(32),
307 },
308};
309EXPORT_SYMBOL(s3c64xx_device_ac97);
310
311void __init s3c64xx_ac97_setup_gpio(int num)
312{
313 if (num == S3C64XX_AC97_GPD)
314 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
315 else
316 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
317}