]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/blob - arch/arm/mach-s3c64xx/dev-audio.c
Merge tag 'armsoc-fixes-nc' of git://git.kernel.org/pub/scm/linux/kernel/git/arm...
[mirror_ubuntu-disco-kernel.git] / arch / arm / mach-s3c64xx / dev-audio.c
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
27 static 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
55 static struct resource s3c64xx_iis0_resource[] = {
56 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
57 };
58
59 static struct s3c_audio_pdata i2s0_pdata = {
60 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
61 .dma_filter = pl08x_filter_id,
62 .dma_playback = DMACH_I2S0_OUT,
63 .dma_capture = DMACH_I2S0_IN,
64 };
65
66 struct platform_device s3c64xx_device_iis0 = {
67 .name = "samsung-i2s",
68 .id = 0,
69 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
70 .resource = s3c64xx_iis0_resource,
71 .dev = {
72 .platform_data = &i2s0_pdata,
73 },
74 };
75 EXPORT_SYMBOL(s3c64xx_device_iis0);
76
77 static struct resource s3c64xx_iis1_resource[] = {
78 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
79 };
80
81 static struct s3c_audio_pdata i2s1_pdata = {
82 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
83 .dma_filter = pl08x_filter_id,
84 .dma_playback = DMACH_I2S1_OUT,
85 .dma_capture = DMACH_I2S1_IN,
86 };
87
88 struct platform_device s3c64xx_device_iis1 = {
89 .name = "samsung-i2s",
90 .id = 1,
91 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
92 .resource = s3c64xx_iis1_resource,
93 .dev = {
94 .platform_data = &i2s1_pdata,
95 },
96 };
97 EXPORT_SYMBOL(s3c64xx_device_iis1);
98
99 static struct resource s3c64xx_iisv4_resource[] = {
100 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
101 };
102
103 static struct s3c_audio_pdata i2sv4_pdata = {
104 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
105 .dma_filter = pl08x_filter_id,
106 .dma_playback = DMACH_HSI_I2SV40_TX,
107 .dma_capture = DMACH_HSI_I2SV40_RX,
108 .type = {
109 .quirks = QUIRK_PRI_6CHAN,
110 },
111 };
112
113 struct platform_device s3c64xx_device_iisv4 = {
114 .name = "samsung-i2s",
115 .id = 2,
116 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
117 .resource = s3c64xx_iisv4_resource,
118 .dev = {
119 .platform_data = &i2sv4_pdata,
120 },
121 };
122 EXPORT_SYMBOL(s3c64xx_device_iisv4);
123
124
125 /* PCM Controller platform_devices */
126
127 static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
128 {
129 unsigned int base;
130
131 switch (pdev->id) {
132 case 0:
133 base = S3C64XX_GPD(0);
134 break;
135 case 1:
136 base = S3C64XX_GPE(0);
137 break;
138 default:
139 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
140 pdev->id);
141 return -EINVAL;
142 }
143
144 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
145 return 0;
146 }
147
148 static struct resource s3c64xx_pcm0_resource[] = {
149 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
150 };
151
152 static struct s3c_audio_pdata s3c_pcm0_pdata = {
153 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
154 .dma_filter = pl08x_filter_id,
155 .dma_capture = DMACH_PCM0_RX,
156 .dma_playback = DMACH_PCM0_TX,
157 };
158
159 struct platform_device s3c64xx_device_pcm0 = {
160 .name = "samsung-pcm",
161 .id = 0,
162 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
163 .resource = s3c64xx_pcm0_resource,
164 .dev = {
165 .platform_data = &s3c_pcm0_pdata,
166 },
167 };
168 EXPORT_SYMBOL(s3c64xx_device_pcm0);
169
170 static struct resource s3c64xx_pcm1_resource[] = {
171 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
172 };
173
174 static struct s3c_audio_pdata s3c_pcm1_pdata = {
175 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
176 .dma_filter = pl08x_filter_id,
177 .dma_playback = DMACH_PCM1_TX,
178 .dma_capture = DMACH_PCM1_RX,
179 };
180
181 struct platform_device s3c64xx_device_pcm1 = {
182 .name = "samsung-pcm",
183 .id = 1,
184 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
185 .resource = s3c64xx_pcm1_resource,
186 .dev = {
187 .platform_data = &s3c_pcm1_pdata,
188 },
189 };
190 EXPORT_SYMBOL(s3c64xx_device_pcm1);
191
192 /* AC97 Controller platform devices */
193
194 static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
195 {
196 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
197 }
198
199 static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
200 {
201 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
202 }
203
204 static struct resource s3c64xx_ac97_resource[] = {
205 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
206 [1] = DEFINE_RES_IRQ(IRQ_AC97),
207 };
208
209 static struct s3c_audio_pdata s3c_ac97_pdata = {
210 .dma_playback = DMACH_AC97_PCMOUT,
211 .dma_filter = pl08x_filter_id,
212 .dma_capture = DMACH_AC97_PCMIN,
213 .dma_capture_mic = DMACH_AC97_MICIN,
214 };
215
216 static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
217
218 struct platform_device s3c64xx_device_ac97 = {
219 .name = "samsung-ac97",
220 .id = -1,
221 .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
222 .resource = s3c64xx_ac97_resource,
223 .dev = {
224 .platform_data = &s3c_ac97_pdata,
225 .dma_mask = &s3c64xx_ac97_dmamask,
226 .coherent_dma_mask = DMA_BIT_MASK(32),
227 },
228 };
229 EXPORT_SYMBOL(s3c64xx_device_ac97);
230
231 void __init s3c64xx_ac97_setup_gpio(int num)
232 {
233 if (num == S3C64XX_AC97_GPD)
234 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
235 else
236 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
237 }