blob: c662c89794b2d6f3d3647f0047b0fe9565591def [file] [log] [blame]
Kukjin Kim3db3ae52011-02-14 16:22:36 +09001/* linux/arch/arm/mach-exynos4/dev-audio.c
2 *
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * Copyright (c) 2010 Samsung Electronics Co. Ltd
7 * Jaswinder Singh <jassi.brar@samsung.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/platform_device.h>
15#include <linux/dma-mapping.h>
16#include <linux/gpio.h>
Jingoo Hanf034d852012-11-07 08:11:30 +090017#include <linux/platform_data/asoc-s3c.h>
Kukjin Kim3db3ae52011-02-14 16:22:36 +090018
19#include <plat/gpio-cfg.h>
Kukjin Kim3db3ae52011-02-14 16:22:36 +090020
21#include <mach/map.h>
22#include <mach/dma.h>
23#include <mach/irqs.h>
Kukjin Kim6ccb2ae2013-01-01 16:23:07 -080024
25#define EXYNOS4_AUDSS_INT_MEM (0x03000000)
Kukjin Kim3db3ae52011-02-14 16:22:36 +090026
Kukjin Kim3db3ae52011-02-14 16:22:36 +090027static int exynos4_cfg_i2s(struct platform_device *pdev)
28{
29 /* configure GPIO for i2s port */
30 switch (pdev->id) {
31 case 0:
32 s3c_gpio_cfgpin_range(EXYNOS4_GPZ(0), 7, S3C_GPIO_SFN(2));
33 break;
34 case 1:
35 s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(2));
36 break;
37 case 2:
38 s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 5, S3C_GPIO_SFN(4));
39 break;
40 default:
41 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
42 return -EINVAL;
43 }
44
45 return 0;
46}
47
48static struct s3c_audio_pdata i2sv5_pdata = {
49 .cfg_gpio = exynos4_cfg_i2s,
50 .type = {
51 .i2s = {
52 .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI
53 | QUIRK_NEED_RSTCLR,
Sangbeom Kim2839cc12011-07-21 14:12:19 +090054 .idma_addr = EXYNOS4_AUDSS_INT_MEM,
Kukjin Kim3db3ae52011-02-14 16:22:36 +090055 },
56 },
57};
58
59static struct resource exynos4_i2s0_resource[] = {
Tushar Beherad1e819e2012-05-12 16:12:20 +090060 [0] = DEFINE_RES_MEM(EXYNOS4_PA_I2S0, SZ_256),
61 [1] = DEFINE_RES_DMA(DMACH_I2S0_TX),
62 [2] = DEFINE_RES_DMA(DMACH_I2S0_RX),
63 [3] = DEFINE_RES_DMA(DMACH_I2S0S_TX),
Kukjin Kim3db3ae52011-02-14 16:22:36 +090064};
65
66struct platform_device exynos4_device_i2s0 = {
67 .name = "samsung-i2s",
68 .id = 0,
69 .num_resources = ARRAY_SIZE(exynos4_i2s0_resource),
70 .resource = exynos4_i2s0_resource,
71 .dev = {
72 .platform_data = &i2sv5_pdata,
73 },
74};
75
Kukjin Kim3db3ae52011-02-14 16:22:36 +090076static struct s3c_audio_pdata i2sv3_pdata = {
77 .cfg_gpio = exynos4_cfg_i2s,
78 .type = {
79 .i2s = {
80 .quirks = QUIRK_NO_MUXPSR,
Kukjin Kim3db3ae52011-02-14 16:22:36 +090081 },
82 },
83};
84
85static struct resource exynos4_i2s1_resource[] = {
Tushar Beherad1e819e2012-05-12 16:12:20 +090086 [0] = DEFINE_RES_MEM(EXYNOS4_PA_I2S1, SZ_256),
87 [1] = DEFINE_RES_DMA(DMACH_I2S1_TX),
88 [2] = DEFINE_RES_DMA(DMACH_I2S1_RX),
Kukjin Kim3db3ae52011-02-14 16:22:36 +090089};
90
91struct platform_device exynos4_device_i2s1 = {
92 .name = "samsung-i2s",
93 .id = 1,
94 .num_resources = ARRAY_SIZE(exynos4_i2s1_resource),
95 .resource = exynos4_i2s1_resource,
96 .dev = {
97 .platform_data = &i2sv3_pdata,
98 },
99};
100
101static struct resource exynos4_i2s2_resource[] = {
Tushar Beherad1e819e2012-05-12 16:12:20 +0900102 [0] = DEFINE_RES_MEM(EXYNOS4_PA_I2S2, SZ_256),
103 [1] = DEFINE_RES_DMA(DMACH_I2S2_TX),
104 [2] = DEFINE_RES_DMA(DMACH_I2S2_RX),
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900105};
106
107struct platform_device exynos4_device_i2s2 = {
108 .name = "samsung-i2s",
109 .id = 2,
110 .num_resources = ARRAY_SIZE(exynos4_i2s2_resource),
111 .resource = exynos4_i2s2_resource,
112 .dev = {
113 .platform_data = &i2sv3_pdata,
114 },
115};
116
117/* PCM Controller platform_devices */
118
119static int exynos4_pcm_cfg_gpio(struct platform_device *pdev)
120{
121 switch (pdev->id) {
122 case 0:
123 s3c_gpio_cfgpin_range(EXYNOS4_GPZ(0), 5, S3C_GPIO_SFN(3));
124 break;
125 case 1:
126 s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(3));
127 break;
128 case 2:
129 s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 5, S3C_GPIO_SFN(3));
130 break;
131 default:
132 printk(KERN_DEBUG "Invalid PCM Controller number!");
133 return -EINVAL;
134 }
135
136 return 0;
137}
138
139static struct s3c_audio_pdata s3c_pcm_pdata = {
140 .cfg_gpio = exynos4_pcm_cfg_gpio,
141};
142
143static struct resource exynos4_pcm0_resource[] = {
Tushar Beherad1e819e2012-05-12 16:12:20 +0900144 [0] = DEFINE_RES_MEM(EXYNOS4_PA_PCM0, SZ_256),
145 [1] = DEFINE_RES_DMA(DMACH_PCM0_TX),
146 [2] = DEFINE_RES_DMA(DMACH_PCM0_RX),
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900147};
148
149struct platform_device exynos4_device_pcm0 = {
150 .name = "samsung-pcm",
151 .id = 0,
152 .num_resources = ARRAY_SIZE(exynos4_pcm0_resource),
153 .resource = exynos4_pcm0_resource,
154 .dev = {
155 .platform_data = &s3c_pcm_pdata,
156 },
157};
158
159static struct resource exynos4_pcm1_resource[] = {
Tushar Beherad1e819e2012-05-12 16:12:20 +0900160 [0] = DEFINE_RES_MEM(EXYNOS4_PA_PCM1, SZ_256),
161 [1] = DEFINE_RES_DMA(DMACH_PCM1_TX),
162 [2] = DEFINE_RES_DMA(DMACH_PCM1_RX),
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900163};
164
165struct platform_device exynos4_device_pcm1 = {
166 .name = "samsung-pcm",
167 .id = 1,
168 .num_resources = ARRAY_SIZE(exynos4_pcm1_resource),
169 .resource = exynos4_pcm1_resource,
170 .dev = {
171 .platform_data = &s3c_pcm_pdata,
172 },
173};
174
175static struct resource exynos4_pcm2_resource[] = {
Tushar Beherad1e819e2012-05-12 16:12:20 +0900176 [0] = DEFINE_RES_MEM(EXYNOS4_PA_PCM2, SZ_256),
177 [1] = DEFINE_RES_DMA(DMACH_PCM2_TX),
178 [2] = DEFINE_RES_DMA(DMACH_PCM2_RX),
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900179};
180
181struct platform_device exynos4_device_pcm2 = {
182 .name = "samsung-pcm",
183 .id = 2,
184 .num_resources = ARRAY_SIZE(exynos4_pcm2_resource),
185 .resource = exynos4_pcm2_resource,
186 .dev = {
187 .platform_data = &s3c_pcm_pdata,
188 },
189};
190
191/* AC97 Controller platform devices */
192
193static int exynos4_ac97_cfg_gpio(struct platform_device *pdev)
194{
195 return s3c_gpio_cfgpin_range(EXYNOS4_GPC0(0), 5, S3C_GPIO_SFN(4));
196}
197
198static struct resource exynos4_ac97_resource[] = {
Tushar Beherad1e819e2012-05-12 16:12:20 +0900199 [0] = DEFINE_RES_MEM(EXYNOS4_PA_AC97, SZ_256),
200 [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT),
201 [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN),
202 [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN),
203 [4] = DEFINE_RES_IRQ(EXYNOS4_IRQ_AC97),
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900204};
205
206static struct s3c_audio_pdata s3c_ac97_pdata = {
207 .cfg_gpio = exynos4_ac97_cfg_gpio,
208};
209
210static u64 exynos4_ac97_dmamask = DMA_BIT_MASK(32);
211
212struct platform_device exynos4_device_ac97 = {
213 .name = "samsung-ac97",
214 .id = -1,
215 .num_resources = ARRAY_SIZE(exynos4_ac97_resource),
216 .resource = exynos4_ac97_resource,
217 .dev = {
218 .platform_data = &s3c_ac97_pdata,
219 .dma_mask = &exynos4_ac97_dmamask,
220 .coherent_dma_mask = DMA_BIT_MASK(32),
221 },
222};
223
224/* S/PDIF Controller platform_device */
225
226static int exynos4_spdif_cfg_gpio(struct platform_device *pdev)
227{
Naveen Krishna Chatradhia3df1d42011-06-16 19:33:29 +0900228 s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 2, S3C_GPIO_SFN(4));
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900229
230 return 0;
231}
232
233static struct resource exynos4_spdif_resource[] = {
Tushar Beherad1e819e2012-05-12 16:12:20 +0900234 [0] = DEFINE_RES_MEM(EXYNOS4_PA_SPDIF, SZ_256),
235 [1] = DEFINE_RES_DMA(DMACH_SPDIF),
Kukjin Kim3db3ae52011-02-14 16:22:36 +0900236};
237
238static struct s3c_audio_pdata samsung_spdif_pdata = {
239 .cfg_gpio = exynos4_spdif_cfg_gpio,
240};
241
242static u64 exynos4_spdif_dmamask = DMA_BIT_MASK(32);
243
244struct platform_device exynos4_device_spdif = {
245 .name = "samsung-spdif",
246 .id = -1,
247 .num_resources = ARRAY_SIZE(exynos4_spdif_resource),
248 .resource = exynos4_spdif_resource,
249 .dev = {
250 .platform_data = &samsung_spdif_pdata,
251 .dma_mask = &exynos4_spdif_dmamask,
252 .coherent_dma_mask = DMA_BIT_MASK(32),
253 },
254};