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