blob: aaffb8066707087e4f80f0f23b4b1aa792171205 [file] [log] [blame]
Mark Brown52da2192009-06-03 20:08:38 +01001/* linux/arch/arm/plat-s3c/dev-audio.c
2 *
3 * Copyright 2009 Wolfson Microelectronics
4 * Mark Brown <broonie@opensource.wolfsonmicro.com>
5 *
Mark Brown52da2192009-06-03 20:08:38 +01006 * 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
15#include <mach/irqs.h>
16#include <mach/map.h>
Jassi Braracf1aef2009-11-17 16:53:56 +090017#include <mach/dma.h>
18#include <mach/gpio.h>
Mark Brown52da2192009-06-03 20:08:38 +010019
20#include <plat/devs.h>
Jassi Braracf1aef2009-11-17 16:53:56 +090021#include <plat/audio.h>
Jassi Braracf1aef2009-11-17 16:53:56 +090022#include <plat/gpio-cfg.h>
Mark Brown52da2192009-06-03 20:08:38 +010023
Ben Dooks3501c9a2010-01-26 10:45:40 +090024#include <mach/gpio-bank-c.h>
25#include <mach/gpio-bank-d.h>
26#include <mach/gpio-bank-e.h>
27#include <mach/gpio-bank-h.h>
28
Jassi Brar71269362010-01-06 15:33:44 +090029static int s3c64xx_i2sv3_cfg_gpio(struct platform_device *pdev)
30{
31 switch (pdev->id) {
32 case 0:
33 s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_I2S0_CLK);
34 s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_I2S0_CDCLK);
35 s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_I2S0_LRCLK);
36 s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_I2S0_DI);
37 s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_I2S0_D0);
38 break;
39 case 1:
40 s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_I2S1_CLK);
41 s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_I2S1_CDCLK);
42 s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_I2S1_LRCLK);
43 s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_I2S1_DI);
44 s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_I2S1_D0);
45 default:
46 printk(KERN_DEBUG "Invalid I2S Controller number!");
47 return -EINVAL;
48 }
49
50 return 0;
51}
52
53static int s3c64xx_i2sv4_cfg_gpio(struct platform_device *pdev)
54{
Mark Brown1c245222010-01-20 12:05:55 +000055 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C64XX_GPC4_I2S_V40_DO0);
56 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C64XX_GPC5_I2S_V40_DO1);
57 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C64XX_GPC7_I2S_V40_DO2);
Jassi Brar71269362010-01-06 15:33:44 +090058 s3c_gpio_cfgpin(S3C64XX_GPH(6), S3C64XX_GPH6_I2S_V40_BCLK);
59 s3c_gpio_cfgpin(S3C64XX_GPH(7), S3C64XX_GPH7_I2S_V40_CDCLK);
60 s3c_gpio_cfgpin(S3C64XX_GPH(8), S3C64XX_GPH8_I2S_V40_LRCLK);
61 s3c_gpio_cfgpin(S3C64XX_GPH(9), S3C64XX_GPH9_I2S_V40_DI);
62
63 return 0;
64}
65
Mark Brown52da2192009-06-03 20:08:38 +010066static struct resource s3c64xx_iis0_resource[] = {
67 [0] = {
68 .start = S3C64XX_PA_IIS0,
69 .end = S3C64XX_PA_IIS0 + 0x100 - 1,
70 .flags = IORESOURCE_MEM,
71 },
Jassi Brar71269362010-01-06 15:33:44 +090072 [1] = {
73 .start = DMACH_I2S0_OUT,
74 .end = DMACH_I2S0_OUT,
75 .flags = IORESOURCE_DMA,
76 },
77 [2] = {
78 .start = DMACH_I2S0_IN,
79 .end = DMACH_I2S0_IN,
80 .flags = IORESOURCE_DMA,
81 },
82};
83
Mark Brown8dcdd6e2010-01-20 13:06:04 +000084static struct s3c_audio_pdata s3c_i2s0_pdata = {
Jassi Brar71269362010-01-06 15:33:44 +090085 .cfg_gpio = s3c64xx_i2sv3_cfg_gpio,
Mark Brown52da2192009-06-03 20:08:38 +010086};
87
88struct platform_device s3c64xx_device_iis0 = {
89 .name = "s3c64xx-iis",
90 .id = 0,
91 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
92 .resource = s3c64xx_iis0_resource,
Jassi Brar71269362010-01-06 15:33:44 +090093 .dev = {
94 .platform_data = &s3c_i2s0_pdata,
95 },
Mark Brown52da2192009-06-03 20:08:38 +010096};
97EXPORT_SYMBOL(s3c64xx_device_iis0);
98
99static struct resource s3c64xx_iis1_resource[] = {
100 [0] = {
101 .start = S3C64XX_PA_IIS1,
102 .end = S3C64XX_PA_IIS1 + 0x100 - 1,
103 .flags = IORESOURCE_MEM,
104 },
Jassi Brar71269362010-01-06 15:33:44 +0900105 [1] = {
106 .start = DMACH_I2S1_OUT,
107 .end = DMACH_I2S1_OUT,
108 .flags = IORESOURCE_DMA,
109 },
110 [2] = {
111 .start = DMACH_I2S1_IN,
112 .end = DMACH_I2S1_IN,
113 .flags = IORESOURCE_DMA,
114 },
115};
116
Mark Brown8dcdd6e2010-01-20 13:06:04 +0000117static struct s3c_audio_pdata s3c_i2s1_pdata = {
Jassi Brar71269362010-01-06 15:33:44 +0900118 .cfg_gpio = s3c64xx_i2sv3_cfg_gpio,
Mark Brown52da2192009-06-03 20:08:38 +0100119};
120
121struct platform_device s3c64xx_device_iis1 = {
122 .name = "s3c64xx-iis",
123 .id = 1,
124 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
125 .resource = s3c64xx_iis1_resource,
Jassi Brar71269362010-01-06 15:33:44 +0900126 .dev = {
127 .platform_data = &s3c_i2s1_pdata,
128 },
Mark Brown52da2192009-06-03 20:08:38 +0100129};
130EXPORT_SYMBOL(s3c64xx_device_iis1);
Mark Brownd06a49e2009-06-03 20:08:39 +0100131
132static struct resource s3c64xx_iisv4_resource[] = {
133 [0] = {
134 .start = S3C64XX_PA_IISV4,
135 .end = S3C64XX_PA_IISV4 + 0x100 - 1,
136 .flags = IORESOURCE_MEM,
137 },
Jassi Brar71269362010-01-06 15:33:44 +0900138 [1] = {
139 .start = DMACH_HSI_I2SV40_TX,
140 .end = DMACH_HSI_I2SV40_TX,
141 .flags = IORESOURCE_DMA,
142 },
143 [2] = {
144 .start = DMACH_HSI_I2SV40_RX,
145 .end = DMACH_HSI_I2SV40_RX,
146 .flags = IORESOURCE_DMA,
147 },
148};
149
Mark Brown8dcdd6e2010-01-20 13:06:04 +0000150static struct s3c_audio_pdata s3c_i2sv4_pdata = {
Jassi Brar71269362010-01-06 15:33:44 +0900151 .cfg_gpio = s3c64xx_i2sv4_cfg_gpio,
Mark Brownd06a49e2009-06-03 20:08:39 +0100152};
153
154struct platform_device s3c64xx_device_iisv4 = {
155 .name = "s3c64xx-iis-v4",
156 .id = -1,
157 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
158 .resource = s3c64xx_iisv4_resource,
Jassi Brar71269362010-01-06 15:33:44 +0900159 .dev = {
160 .platform_data = &s3c_i2sv4_pdata,
161 },
Mark Brownd06a49e2009-06-03 20:08:39 +0100162};
163EXPORT_SYMBOL(s3c64xx_device_iisv4);
Jassi Braracf1aef2009-11-17 16:53:56 +0900164
165
166/* PCM Controller platform_devices */
167
168static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
169{
170 switch (pdev->id) {
171 case 0:
172 s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_PCM0_SCLK);
173 s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_PCM0_EXTCLK);
174 s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_PCM0_FSYNC);
175 s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_PCM0_SIN);
176 s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_PCM0_SOUT);
177 break;
178 case 1:
179 s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_PCM1_SCLK);
180 s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_PCM1_EXTCLK);
181 s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_PCM1_FSYNC);
182 s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_PCM1_SIN);
183 s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_PCM1_SOUT);
184 break;
185 default:
186 printk(KERN_DEBUG "Invalid PCM Controller number!");
187 return -EINVAL;
188 }
189
190 return 0;
191}
192
193static struct resource s3c64xx_pcm0_resource[] = {
194 [0] = {
195 .start = S3C64XX_PA_PCM0,
196 .end = S3C64XX_PA_PCM0 + 0x100 - 1,
197 .flags = IORESOURCE_MEM,
198 },
199 [1] = {
200 .start = DMACH_PCM0_TX,
201 .end = DMACH_PCM0_TX,
202 .flags = IORESOURCE_DMA,
203 },
204 [2] = {
205 .start = DMACH_PCM0_RX,
206 .end = DMACH_PCM0_RX,
207 .flags = IORESOURCE_DMA,
208 },
209};
210
Mark Brown43f0de82009-11-27 16:43:53 +0000211static struct s3c_audio_pdata s3c_pcm0_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900212 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
213};
214
215struct platform_device s3c64xx_device_pcm0 = {
216 .name = "samsung-pcm",
217 .id = 0,
218 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
219 .resource = s3c64xx_pcm0_resource,
220 .dev = {
221 .platform_data = &s3c_pcm0_pdata,
222 },
223};
224EXPORT_SYMBOL(s3c64xx_device_pcm0);
225
226static struct resource s3c64xx_pcm1_resource[] = {
227 [0] = {
228 .start = S3C64XX_PA_PCM1,
229 .end = S3C64XX_PA_PCM1 + 0x100 - 1,
230 .flags = IORESOURCE_MEM,
231 },
232 [1] = {
233 .start = DMACH_PCM1_TX,
234 .end = DMACH_PCM1_TX,
235 .flags = IORESOURCE_DMA,
236 },
237 [2] = {
238 .start = DMACH_PCM1_RX,
239 .end = DMACH_PCM1_RX,
240 .flags = IORESOURCE_DMA,
241 },
242};
243
Mark Brown43f0de82009-11-27 16:43:53 +0000244static struct s3c_audio_pdata s3c_pcm1_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900245 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
246};
247
248struct platform_device s3c64xx_device_pcm1 = {
249 .name = "samsung-pcm",
250 .id = 1,
251 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
252 .resource = s3c64xx_pcm1_resource,
253 .dev = {
254 .platform_data = &s3c_pcm1_pdata,
255 },
256};
257EXPORT_SYMBOL(s3c64xx_device_pcm1);