blob: 35f3e07eaccc494729b82582c82062cd4bea0a6a [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>
Jassi Brarde6985b2010-02-12 10:38:51 +000014#include <linux/dma-mapping.h>
Kukjin Kim1c739c72010-08-05 07:54:49 +090015#include <linux/gpio.h>
Paul Gortmakerdc280942011-07-31 16:17:29 -040016#include <linux/export.h>
Mark Brown52da2192009-06-03 20:08:38 +010017
18#include <mach/irqs.h>
19#include <mach/map.h>
Jassi Braracf1aef2009-11-17 16:53:56 +090020#include <mach/dma.h>
Mark Brown52da2192009-06-03 20:08:38 +010021
22#include <plat/devs.h>
Arnd Bergmann436d42c2012-08-24 15:22:12 +020023#include <linux/platform_data/asoc-s3c.h>
Jassi Braracf1aef2009-11-17 16:53:56 +090024#include <plat/gpio-cfg.h>
Mark Brown52da2192009-06-03 20:08:38 +010025
Jassi Brar6a62bee2010-11-19 08:49:44 +090026static const char *rclksrc[] = {
27 [0] = "iis",
28 [1] = "audio-bus",
29};
30
31static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
Jassi Brar71269362010-01-06 15:33:44 +090032{
Ben Dooks2618b552010-05-27 15:54:06 +090033 unsigned int base;
34
Jassi Brar71269362010-01-06 15:33:44 +090035 switch (pdev->id) {
36 case 0:
Ben Dooks2618b552010-05-27 15:54:06 +090037 base = S3C64XX_GPD(0);
Jassi Brar71269362010-01-06 15:33:44 +090038 break;
39 case 1:
Ben Dooks2618b552010-05-27 15:54:06 +090040 base = S3C64XX_GPE(0);
Dimitris Papastamose4b6b742010-08-26 16:07:23 +010041 break;
Jassi Brar6a62bee2010-11-19 08:49:44 +090042 case 2:
43 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
44 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
45 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
46 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
47 return 0;
Jassi Brar71269362010-01-06 15:33:44 +090048 default:
Dimitris Papastamose4b6b742010-08-26 16:07:23 +010049 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
50 pdev->id);
Jassi Brar71269362010-01-06 15:33:44 +090051 return -EINVAL;
52 }
53
Ben Dooks2618b552010-05-27 15:54:06 +090054 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
55
Jassi Brar71269362010-01-06 15:33:44 +090056 return 0;
57}
58
Mark Brown52da2192009-06-03 20:08:38 +010059static struct resource s3c64xx_iis0_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +090060 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
61 [1] = DEFINE_RES_DMA(DMACH_I2S0_OUT),
62 [2] = DEFINE_RES_DMA(DMACH_I2S0_IN),
Jassi Brar71269362010-01-06 15:33:44 +090063};
64
Jassi Brar6a62bee2010-11-19 08:49:44 +090065static struct s3c_audio_pdata i2sv3_pdata = {
66 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
67 .type = {
68 .i2s = {
69 .src_clk = rclksrc,
70 },
71 },
Mark Brown52da2192009-06-03 20:08:38 +010072};
73
74struct platform_device s3c64xx_device_iis0 = {
Jassi Brardaea9b42010-11-19 08:49:43 +090075 .name = "samsung-i2s",
Mark Brown52da2192009-06-03 20:08:38 +010076 .id = 0,
77 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
78 .resource = s3c64xx_iis0_resource,
Jassi Brar71269362010-01-06 15:33:44 +090079 .dev = {
Jassi Brar6a62bee2010-11-19 08:49:44 +090080 .platform_data = &i2sv3_pdata,
Jassi Brar71269362010-01-06 15:33:44 +090081 },
Mark Brown52da2192009-06-03 20:08:38 +010082};
83EXPORT_SYMBOL(s3c64xx_device_iis0);
84
85static struct resource s3c64xx_iis1_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +090086 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
87 [1] = DEFINE_RES_DMA(DMACH_I2S1_OUT),
88 [2] = DEFINE_RES_DMA(DMACH_I2S1_IN),
Jassi Brar71269362010-01-06 15:33:44 +090089};
90
Mark Brown52da2192009-06-03 20:08:38 +010091struct platform_device s3c64xx_device_iis1 = {
Jassi Brardaea9b42010-11-19 08:49:43 +090092 .name = "samsung-i2s",
Mark Brown52da2192009-06-03 20:08:38 +010093 .id = 1,
94 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
95 .resource = s3c64xx_iis1_resource,
Jassi Brar71269362010-01-06 15:33:44 +090096 .dev = {
Jassi Brar6a62bee2010-11-19 08:49:44 +090097 .platform_data = &i2sv3_pdata,
Jassi Brar71269362010-01-06 15:33:44 +090098 },
Mark Brown52da2192009-06-03 20:08:38 +010099};
100EXPORT_SYMBOL(s3c64xx_device_iis1);
Mark Brownd06a49e2009-06-03 20:08:39 +0100101
102static struct resource s3c64xx_iisv4_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900103 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
104 [1] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_TX),
105 [2] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_RX),
Jassi Brar71269362010-01-06 15:33:44 +0900106};
107
Jassi Brar6a62bee2010-11-19 08:49:44 +0900108static struct s3c_audio_pdata i2sv4_pdata = {
109 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
110 .type = {
111 .i2s = {
112 .quirks = QUIRK_PRI_6CHAN,
113 .src_clk = rclksrc,
114 },
115 },
Mark Brownd06a49e2009-06-03 20:08:39 +0100116};
117
118struct platform_device s3c64xx_device_iisv4 = {
Jassi Brar6a62bee2010-11-19 08:49:44 +0900119 .name = "samsung-i2s",
120 .id = 2,
Mark Brownd06a49e2009-06-03 20:08:39 +0100121 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
122 .resource = s3c64xx_iisv4_resource,
Jassi Brar71269362010-01-06 15:33:44 +0900123 .dev = {
Jassi Brar6a62bee2010-11-19 08:49:44 +0900124 .platform_data = &i2sv4_pdata,
Jassi Brar71269362010-01-06 15:33:44 +0900125 },
Mark Brownd06a49e2009-06-03 20:08:39 +0100126};
127EXPORT_SYMBOL(s3c64xx_device_iisv4);
Jassi Braracf1aef2009-11-17 16:53:56 +0900128
129
130/* PCM Controller platform_devices */
131
132static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
133{
Ben Dooks2618b552010-05-27 15:54:06 +0900134 unsigned int base;
135
Jassi Braracf1aef2009-11-17 16:53:56 +0900136 switch (pdev->id) {
137 case 0:
Ben Dooks2618b552010-05-27 15:54:06 +0900138 base = S3C64XX_GPD(0);
Jassi Braracf1aef2009-11-17 16:53:56 +0900139 break;
140 case 1:
Ben Dooks2618b552010-05-27 15:54:06 +0900141 base = S3C64XX_GPE(0);
Jassi Braracf1aef2009-11-17 16:53:56 +0900142 break;
143 default:
Dimitris Papastamose4b6b742010-08-26 16:07:23 +0100144 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
145 pdev->id);
Jassi Braracf1aef2009-11-17 16:53:56 +0900146 return -EINVAL;
147 }
148
Ben Dooks2618b552010-05-27 15:54:06 +0900149 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
Jassi Braracf1aef2009-11-17 16:53:56 +0900150 return 0;
151}
152
153static struct resource s3c64xx_pcm0_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900154 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
155 [1] = DEFINE_RES_DMA(DMACH_PCM0_TX),
156 [2] = DEFINE_RES_DMA(DMACH_PCM0_RX),
Jassi Braracf1aef2009-11-17 16:53:56 +0900157};
158
Mark Brown43f0de82009-11-27 16:43:53 +0000159static struct s3c_audio_pdata s3c_pcm0_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900160 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
161};
162
163struct platform_device s3c64xx_device_pcm0 = {
164 .name = "samsung-pcm",
165 .id = 0,
166 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
167 .resource = s3c64xx_pcm0_resource,
168 .dev = {
169 .platform_data = &s3c_pcm0_pdata,
170 },
171};
172EXPORT_SYMBOL(s3c64xx_device_pcm0);
173
174static struct resource s3c64xx_pcm1_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900175 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
176 [1] = DEFINE_RES_DMA(DMACH_PCM1_TX),
177 [2] = DEFINE_RES_DMA(DMACH_PCM1_RX),
Jassi Braracf1aef2009-11-17 16:53:56 +0900178};
179
Mark Brown43f0de82009-11-27 16:43:53 +0000180static struct s3c_audio_pdata s3c_pcm1_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900181 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
182};
183
184struct platform_device s3c64xx_device_pcm1 = {
185 .name = "samsung-pcm",
186 .id = 1,
187 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
188 .resource = s3c64xx_pcm1_resource,
189 .dev = {
190 .platform_data = &s3c_pcm1_pdata,
191 },
192};
193EXPORT_SYMBOL(s3c64xx_device_pcm1);
Jassi Brarde6985b2010-02-12 10:38:51 +0000194
195/* AC97 Controller platform devices */
196
197static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
198{
Ben Dooks2618b552010-05-27 15:54:06 +0900199 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
Jassi Brarde6985b2010-02-12 10:38:51 +0000200}
201
202static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
203{
Ben Dooks2618b552010-05-27 15:54:06 +0900204 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
Jassi Brarde6985b2010-02-12 10:38:51 +0000205}
206
207static struct resource s3c64xx_ac97_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900208 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
209 [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT),
210 [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN),
211 [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN),
212 [4] = DEFINE_RES_IRQ(IRQ_AC97),
Jassi Brarde6985b2010-02-12 10:38:51 +0000213};
214
215static struct s3c_audio_pdata s3c_ac97_pdata;
216
217static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
218
219struct platform_device s3c64xx_device_ac97 = {
Jassi Brare6104672010-11-22 15:36:00 +0900220 .name = "samsung-ac97",
Jassi Brarde6985b2010-02-12 10:38:51 +0000221 .id = -1,
222 .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
223 .resource = s3c64xx_ac97_resource,
224 .dev = {
225 .platform_data = &s3c_ac97_pdata,
226 .dma_mask = &s3c64xx_ac97_dmamask,
227 .coherent_dma_mask = DMA_BIT_MASK(32),
228 },
229};
230EXPORT_SYMBOL(s3c64xx_device_ac97);
231
232void __init s3c64xx_ac97_setup_gpio(int num)
233{
234 if (num == S3C64XX_AC97_GPD)
235 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
236 else
237 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
238}