blob: b57783371d525976946f3f47a2b37933308756f9 [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>
Linus Walleijb0161ca2014-01-14 14:24:24 +010025#include <mach/gpio-samsung.h>
Mark Brown52da2192009-06-03 20:08:38 +010026
Jassi Brar6a62bee2010-11-19 08:49:44 +090027static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
Jassi Brar71269362010-01-06 15:33:44 +090028{
Ben Dooks2618b552010-05-27 15:54:06 +090029 unsigned int base;
30
Jassi Brar71269362010-01-06 15:33:44 +090031 switch (pdev->id) {
32 case 0:
Ben Dooks2618b552010-05-27 15:54:06 +090033 base = S3C64XX_GPD(0);
Jassi Brar71269362010-01-06 15:33:44 +090034 break;
35 case 1:
Ben Dooks2618b552010-05-27 15:54:06 +090036 base = S3C64XX_GPE(0);
Dimitris Papastamose4b6b742010-08-26 16:07:23 +010037 break;
Jassi Brar6a62bee2010-11-19 08:49:44 +090038 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;
Jassi Brar71269362010-01-06 15:33:44 +090044 default:
Dimitris Papastamose4b6b742010-08-26 16:07:23 +010045 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
46 pdev->id);
Jassi Brar71269362010-01-06 15:33:44 +090047 return -EINVAL;
48 }
49
Ben Dooks2618b552010-05-27 15:54:06 +090050 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
51
Jassi Brar71269362010-01-06 15:33:44 +090052 return 0;
53}
54
Mark Brown52da2192009-06-03 20:08:38 +010055static struct resource s3c64xx_iis0_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +090056 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
Jassi Brar71269362010-01-06 15:33:44 +090057};
58
Arnd Bergmannb9a1a742015-11-18 15:25:23 +010059static struct s3c_audio_pdata i2s0_pdata = {
Jassi Brar6a62bee2010-11-19 08:49:44 +090060 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
Arnd Bergmann9bdca822015-11-18 22:31:11 +010061 .dma_filter = pl08x_filter_id,
Arnd Bergmannb9a1a742015-11-18 15:25:23 +010062 .dma_playback = DMACH_I2S0_OUT,
63 .dma_capture = DMACH_I2S0_IN,
Mark Brown52da2192009-06-03 20:08:38 +010064};
65
66struct platform_device s3c64xx_device_iis0 = {
Jassi Brardaea9b42010-11-19 08:49:43 +090067 .name = "samsung-i2s",
Mark Brown52da2192009-06-03 20:08:38 +010068 .id = 0,
69 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
70 .resource = s3c64xx_iis0_resource,
Jassi Brar71269362010-01-06 15:33:44 +090071 .dev = {
Arnd Bergmannb9a1a742015-11-18 15:25:23 +010072 .platform_data = &i2s0_pdata,
Jassi Brar71269362010-01-06 15:33:44 +090073 },
Mark Brown52da2192009-06-03 20:08:38 +010074};
75EXPORT_SYMBOL(s3c64xx_device_iis0);
76
77static struct resource s3c64xx_iis1_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +090078 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
Arnd Bergmannb9a1a742015-11-18 15:25:23 +010079};
80
81static struct s3c_audio_pdata i2s1_pdata = {
82 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
Arnd Bergmann9bdca822015-11-18 22:31:11 +010083 .dma_filter = pl08x_filter_id,
Arnd Bergmannb9a1a742015-11-18 15:25:23 +010084 .dma_playback = DMACH_I2S1_OUT,
85 .dma_capture = DMACH_I2S1_IN,
Jassi Brar71269362010-01-06 15:33:44 +090086};
87
Mark Brown52da2192009-06-03 20:08:38 +010088struct platform_device s3c64xx_device_iis1 = {
Jassi Brardaea9b42010-11-19 08:49:43 +090089 .name = "samsung-i2s",
Mark Brown52da2192009-06-03 20:08:38 +010090 .id = 1,
91 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
92 .resource = s3c64xx_iis1_resource,
Jassi Brar71269362010-01-06 15:33:44 +090093 .dev = {
Arnd Bergmannb9a1a742015-11-18 15:25:23 +010094 .platform_data = &i2s1_pdata,
Jassi Brar71269362010-01-06 15:33:44 +090095 },
Mark Brown52da2192009-06-03 20:08:38 +010096};
97EXPORT_SYMBOL(s3c64xx_device_iis1);
Mark Brownd06a49e2009-06-03 20:08:39 +010098
99static struct resource s3c64xx_iisv4_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900100 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
Jassi Brar71269362010-01-06 15:33:44 +0900101};
102
Jassi Brar6a62bee2010-11-19 08:49:44 +0900103static struct s3c_audio_pdata i2sv4_pdata = {
104 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
Arnd Bergmann9bdca822015-11-18 22:31:11 +0100105 .dma_filter = pl08x_filter_id,
Arnd Bergmannb9a1a742015-11-18 15:25:23 +0100106 .dma_playback = DMACH_HSI_I2SV40_TX,
107 .dma_capture = DMACH_HSI_I2SV40_RX,
Jassi Brar6a62bee2010-11-19 08:49:44 +0900108 .type = {
109 .i2s = {
110 .quirks = QUIRK_PRI_6CHAN,
Jassi Brar6a62bee2010-11-19 08:49:44 +0900111 },
112 },
Mark Brownd06a49e2009-06-03 20:08:39 +0100113};
114
115struct platform_device s3c64xx_device_iisv4 = {
Jassi Brar6a62bee2010-11-19 08:49:44 +0900116 .name = "samsung-i2s",
117 .id = 2,
Mark Brownd06a49e2009-06-03 20:08:39 +0100118 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
119 .resource = s3c64xx_iisv4_resource,
Jassi Brar71269362010-01-06 15:33:44 +0900120 .dev = {
Jassi Brar6a62bee2010-11-19 08:49:44 +0900121 .platform_data = &i2sv4_pdata,
Jassi Brar71269362010-01-06 15:33:44 +0900122 },
Mark Brownd06a49e2009-06-03 20:08:39 +0100123};
124EXPORT_SYMBOL(s3c64xx_device_iisv4);
Jassi Braracf1aef2009-11-17 16:53:56 +0900125
126
127/* PCM Controller platform_devices */
128
129static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
130{
Ben Dooks2618b552010-05-27 15:54:06 +0900131 unsigned int base;
132
Jassi Braracf1aef2009-11-17 16:53:56 +0900133 switch (pdev->id) {
134 case 0:
Ben Dooks2618b552010-05-27 15:54:06 +0900135 base = S3C64XX_GPD(0);
Jassi Braracf1aef2009-11-17 16:53:56 +0900136 break;
137 case 1:
Ben Dooks2618b552010-05-27 15:54:06 +0900138 base = S3C64XX_GPE(0);
Jassi Braracf1aef2009-11-17 16:53:56 +0900139 break;
140 default:
Dimitris Papastamose4b6b742010-08-26 16:07:23 +0100141 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
142 pdev->id);
Jassi Braracf1aef2009-11-17 16:53:56 +0900143 return -EINVAL;
144 }
145
Ben Dooks2618b552010-05-27 15:54:06 +0900146 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
Jassi Braracf1aef2009-11-17 16:53:56 +0900147 return 0;
148}
149
150static struct resource s3c64xx_pcm0_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900151 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
Jassi Braracf1aef2009-11-17 16:53:56 +0900152};
153
Mark Brown43f0de82009-11-27 16:43:53 +0000154static struct s3c_audio_pdata s3c_pcm0_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900155 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
Arnd Bergmann9bdca822015-11-18 22:31:11 +0100156 .dma_filter = pl08x_filter_id,
Arnd Bergmannb9a1a742015-11-18 15:25:23 +0100157 .dma_capture = DMACH_PCM0_RX,
158 .dma_playback = DMACH_PCM0_TX,
Jassi Braracf1aef2009-11-17 16:53:56 +0900159};
160
161struct 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};
170EXPORT_SYMBOL(s3c64xx_device_pcm0);
171
172static struct resource s3c64xx_pcm1_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900173 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
Jassi Braracf1aef2009-11-17 16:53:56 +0900174};
175
Mark Brown43f0de82009-11-27 16:43:53 +0000176static struct s3c_audio_pdata s3c_pcm1_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900177 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
Arnd Bergmann9bdca822015-11-18 22:31:11 +0100178 .dma_filter = pl08x_filter_id,
Arnd Bergmannb9a1a742015-11-18 15:25:23 +0100179 .dma_playback = DMACH_PCM1_TX,
180 .dma_capture = DMACH_PCM1_RX,
Jassi Braracf1aef2009-11-17 16:53:56 +0900181};
182
183struct 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};
192EXPORT_SYMBOL(s3c64xx_device_pcm1);
Jassi Brarde6985b2010-02-12 10:38:51 +0000193
194/* AC97 Controller platform devices */
195
196static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
197{
Ben Dooks2618b552010-05-27 15:54:06 +0900198 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
Jassi Brarde6985b2010-02-12 10:38:51 +0000199}
200
201static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
202{
Ben Dooks2618b552010-05-27 15:54:06 +0900203 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
Jassi Brarde6985b2010-02-12 10:38:51 +0000204}
205
206static struct resource s3c64xx_ac97_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900207 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
Arnd Bergmannb9a1a742015-11-18 15:25:23 +0100208 [1] = DEFINE_RES_IRQ(IRQ_AC97),
Jassi Brarde6985b2010-02-12 10:38:51 +0000209};
210
Arnd Bergmannb9a1a742015-11-18 15:25:23 +0100211static struct s3c_audio_pdata s3c_ac97_pdata = {
212 .dma_playback = DMACH_AC97_PCMOUT,
Arnd Bergmann9bdca822015-11-18 22:31:11 +0100213 .dma_filter = pl08x_filter_id,
Arnd Bergmannb9a1a742015-11-18 15:25:23 +0100214 .dma_capture = DMACH_AC97_PCMIN,
215 .dma_capture_mic = DMACH_AC97_MICIN,
216};
Jassi Brarde6985b2010-02-12 10:38:51 +0000217
218static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
219
220struct platform_device s3c64xx_device_ac97 = {
Jassi Brare6104672010-11-22 15:36:00 +0900221 .name = "samsung-ac97",
Jassi Brarde6985b2010-02-12 10:38:51 +0000222 .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};
231EXPORT_SYMBOL(s3c64xx_device_ac97);
232
233void __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}