blob: 9d4bde3f11104b45db3f14b8c5ac69047679e7d6 [file] [log] [blame]
Jassi Brar9e4ed5c32010-05-18 16:02:39 +09001/* linux/arch/arm/mach-s5pc100/dev-audio.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co. Ltd
4 * Jaswinder Singh <jassi.brar@samsung.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/platform_device.h>
12#include <linux/dma-mapping.h>
Kukjin Kim1c739c72010-08-05 07:54:49 +090013#include <linux/gpio.h>
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090014
15#include <plat/gpio-cfg.h>
16#include <plat/audio.h>
17
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090018#include <mach/map.h>
19#include <mach/dma.h>
20#include <mach/irqs.h>
21
22static int s5pc100_cfg_i2s(struct platform_device *pdev)
23{
24 /* configure GPIO for i2s port */
25 switch (pdev->id) {
Jassi Brar651cba52010-11-19 08:49:44 +090026 case 0: /* Dedicated pins */
27 break;
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090028 case 1:
Ben Dooksce8f9ab2010-10-01 14:20:55 +090029 s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(2));
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090030 break;
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090031 case 2:
Ben Dooksce8f9ab2010-10-01 14:20:55 +090032 s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(4));
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090033 break;
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090034 default:
35 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
36 return -EINVAL;
37 }
38
39 return 0;
40}
41
Jassi Brar651cba52010-11-19 08:49:44 +090042static const char *rclksrc_v5[] = {
43 [0] = "iis",
44 [1] = "i2sclkd2",
45};
46
47static struct s3c_audio_pdata i2sv5_pdata = {
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090048 .cfg_gpio = s5pc100_cfg_i2s,
Jassi Brar651cba52010-11-19 08:49:44 +090049 .type = {
50 .i2s = {
51 .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
52 | QUIRK_NEED_RSTCLR,
53 .src_clk = rclksrc_v5,
54 },
55 },
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090056};
57
58static struct resource s5pc100_iis0_resource[] = {
Tushar Behera98230002012-05-12 16:12:30 +090059 [0] = DEFINE_RES_MEM(S5PC100_PA_I2S0, SZ_256),
60 [1] = DEFINE_RES_DMA(DMACH_I2S0_TX),
61 [2] = DEFINE_RES_DMA(DMACH_I2S0_RX),
62 [3] = DEFINE_RES_DMA(DMACH_I2S0S_TX),
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090063};
64
65struct platform_device s5pc100_device_iis0 = {
Jassi Brar651cba52010-11-19 08:49:44 +090066 .name = "samsung-i2s",
67 .id = 0,
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090068 .num_resources = ARRAY_SIZE(s5pc100_iis0_resource),
69 .resource = s5pc100_iis0_resource,
70 .dev = {
Jassi Brar651cba52010-11-19 08:49:44 +090071 .platform_data = &i2sv5_pdata,
72 },
73};
74
75static const char *rclksrc_v3[] = {
76 [0] = "iis",
77 [1] = "sclk_audio",
78};
79
80static struct s3c_audio_pdata i2sv3_pdata = {
81 .cfg_gpio = s5pc100_cfg_i2s,
82 .type = {
83 .i2s = {
84 .src_clk = rclksrc_v3,
85 },
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090086 },
87};
88
89static struct resource s5pc100_iis1_resource[] = {
Tushar Behera98230002012-05-12 16:12:30 +090090 [0] = DEFINE_RES_MEM(S5PC100_PA_I2S1, SZ_256),
91 [1] = DEFINE_RES_DMA(DMACH_I2S1_TX),
92 [2] = DEFINE_RES_DMA(DMACH_I2S1_RX),
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090093};
94
95struct platform_device s5pc100_device_iis1 = {
Jassi Brardaea9b42010-11-19 08:49:43 +090096 .name = "samsung-i2s",
Jassi Brar9e4ed5c32010-05-18 16:02:39 +090097 .id = 1,
98 .num_resources = ARRAY_SIZE(s5pc100_iis1_resource),
99 .resource = s5pc100_iis1_resource,
100 .dev = {
Jassi Brar651cba52010-11-19 08:49:44 +0900101 .platform_data = &i2sv3_pdata,
Jassi Brar9e4ed5c32010-05-18 16:02:39 +0900102 },
103};
104
105static struct resource s5pc100_iis2_resource[] = {
Tushar Behera98230002012-05-12 16:12:30 +0900106 [0] = DEFINE_RES_MEM(S5PC100_PA_I2S2, SZ_256),
107 [1] = DEFINE_RES_DMA(DMACH_I2S2_TX),
108 [2] = DEFINE_RES_DMA(DMACH_I2S2_RX),
Jassi Brar9e4ed5c32010-05-18 16:02:39 +0900109};
110
111struct platform_device s5pc100_device_iis2 = {
Jassi Brardaea9b42010-11-19 08:49:43 +0900112 .name = "samsung-i2s",
Jassi Brar9e4ed5c32010-05-18 16:02:39 +0900113 .id = 2,
114 .num_resources = ARRAY_SIZE(s5pc100_iis2_resource),
115 .resource = s5pc100_iis2_resource,
116 .dev = {
Jassi Brar651cba52010-11-19 08:49:44 +0900117 .platform_data = &i2sv3_pdata,
Jassi Brar9e4ed5c32010-05-18 16:02:39 +0900118 },
119};
120
121/* PCM Controller platform_devices */
122
123static int s5pc100_pcm_cfg_gpio(struct platform_device *pdev)
124{
125 switch (pdev->id) {
126 case 0:
Ben Dooksce8f9ab2010-10-01 14:20:55 +0900127 s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(5));
Jassi Brar9e4ed5c32010-05-18 16:02:39 +0900128 break;
129
130 case 1:
Ben Dooksce8f9ab2010-10-01 14:20:55 +0900131 s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(3));
Jassi Brar9e4ed5c32010-05-18 16:02:39 +0900132 break;
133
134 default:
135 printk(KERN_DEBUG "Invalid PCM Controller number!");
136 return -EINVAL;
137 }
138
139 return 0;
140}
141
142static struct s3c_audio_pdata s3c_pcm_pdata = {
143 .cfg_gpio = s5pc100_pcm_cfg_gpio,
144};
145
146static struct resource s5pc100_pcm0_resource[] = {
Tushar Behera98230002012-05-12 16:12:30 +0900147 [0] = DEFINE_RES_MEM(S5PC100_PA_PCM0, SZ_256),
148 [1] = DEFINE_RES_DMA(DMACH_PCM0_TX),
149 [2] = DEFINE_RES_DMA(DMACH_PCM0_RX),
Jassi Brar9e4ed5c32010-05-18 16:02:39 +0900150};
151
152struct platform_device s5pc100_device_pcm0 = {
153 .name = "samsung-pcm",
154 .id = 0,
155 .num_resources = ARRAY_SIZE(s5pc100_pcm0_resource),
156 .resource = s5pc100_pcm0_resource,
157 .dev = {
158 .platform_data = &s3c_pcm_pdata,
159 },
160};
161
162static struct resource s5pc100_pcm1_resource[] = {
Tushar Behera98230002012-05-12 16:12:30 +0900163 [0] = DEFINE_RES_MEM(S5PC100_PA_PCM1, SZ_256),
164 [1] = DEFINE_RES_DMA(DMACH_PCM1_TX),
165 [2] = DEFINE_RES_DMA(DMACH_PCM1_RX),
Jassi Brar9e4ed5c32010-05-18 16:02:39 +0900166};
167
168struct platform_device s5pc100_device_pcm1 = {
169 .name = "samsung-pcm",
170 .id = 1,
171 .num_resources = ARRAY_SIZE(s5pc100_pcm1_resource),
172 .resource = s5pc100_pcm1_resource,
173 .dev = {
174 .platform_data = &s3c_pcm_pdata,
175 },
176};
177
178/* AC97 Controller platform devices */
179
180static int s5pc100_ac97_cfg_gpio(struct platform_device *pdev)
181{
Ben Dooksce8f9ab2010-10-01 14:20:55 +0900182 return s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(4));
Jassi Brar9e4ed5c32010-05-18 16:02:39 +0900183}
184
185static struct resource s5pc100_ac97_resource[] = {
Tushar Behera98230002012-05-12 16:12:30 +0900186 [0] = DEFINE_RES_MEM(S5PC100_PA_AC97, SZ_256),
187 [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT),
188 [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN),
189 [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN),
190 [4] = DEFINE_RES_IRQ(IRQ_AC97),
Jassi Brar9e4ed5c32010-05-18 16:02:39 +0900191};
192
193static struct s3c_audio_pdata s3c_ac97_pdata = {
194 .cfg_gpio = s5pc100_ac97_cfg_gpio,
195};
196
197static u64 s5pc100_ac97_dmamask = DMA_BIT_MASK(32);
198
199struct platform_device s5pc100_device_ac97 = {
Jassi Brare6104672010-11-22 15:36:00 +0900200 .name = "samsung-ac97",
Jassi Brar9e4ed5c32010-05-18 16:02:39 +0900201 .id = -1,
202 .num_resources = ARRAY_SIZE(s5pc100_ac97_resource),
203 .resource = s5pc100_ac97_resource,
204 .dev = {
205 .platform_data = &s3c_ac97_pdata,
206 .dma_mask = &s5pc100_ac97_dmamask,
207 .coherent_dma_mask = DMA_BIT_MASK(32),
208 },
209};
Seungwhan Youn068b4322010-10-14 10:35:23 +0900210
211/* S/PDIF Controller platform_device */
212static int s5pc100_spdif_cfg_gpd(struct platform_device *pdev)
213{
214 s3c_gpio_cfgpin_range(S5PC100_GPD(5), 2, S3C_GPIO_SFN(3));
215
216 return 0;
217}
218
219static int s5pc100_spdif_cfg_gpg3(struct platform_device *pdev)
220{
221 s3c_gpio_cfgpin_range(S5PC100_GPG3(5), 2, S3C_GPIO_SFN(3));
222
223 return 0;
224}
225
226static struct resource s5pc100_spdif_resource[] = {
Tushar Behera98230002012-05-12 16:12:30 +0900227 [0] = DEFINE_RES_MEM(S5PC100_PA_SPDIF, SZ_256),
228 [1] = DEFINE_RES_DMA(DMACH_SPDIF),
Seungwhan Youn068b4322010-10-14 10:35:23 +0900229};
230
231static struct s3c_audio_pdata s5p_spdif_pdata = {
232 .cfg_gpio = s5pc100_spdif_cfg_gpd,
233};
234
235static u64 s5pc100_spdif_dmamask = DMA_BIT_MASK(32);
236
237struct platform_device s5pc100_device_spdif = {
238 .name = "samsung-spdif",
239 .id = -1,
240 .num_resources = ARRAY_SIZE(s5pc100_spdif_resource),
241 .resource = s5pc100_spdif_resource,
242 .dev = {
243 .platform_data = &s5p_spdif_pdata,
244 .dma_mask = &s5pc100_spdif_dmamask,
245 .coherent_dma_mask = DMA_BIT_MASK(32),
246 },
247};
248
249void __init s5pc100_spdif_setup_gpio(int gpio)
250{
251 if (gpio == S5PC100_SPDIF_GPD)
252 s5p_spdif_pdata.cfg_gpio = s5pc100_spdif_cfg_gpd;
253 else
254 s5p_spdif_pdata.cfg_gpio = s5pc100_spdif_cfg_gpg3;
255}