blob: ff780a8d8366fbe5463b665ea3d53c14d797a569 [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),
57 [1] = DEFINE_RES_DMA(DMACH_I2S0_OUT),
58 [2] = DEFINE_RES_DMA(DMACH_I2S0_IN),
Jassi Brar71269362010-01-06 15:33:44 +090059};
60
Jassi Brar6a62bee2010-11-19 08:49:44 +090061static struct s3c_audio_pdata i2sv3_pdata = {
62 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
Mark Brown52da2192009-06-03 20:08:38 +010063};
64
65struct platform_device s3c64xx_device_iis0 = {
Jassi Brardaea9b42010-11-19 08:49:43 +090066 .name = "samsung-i2s",
Mark Brown52da2192009-06-03 20:08:38 +010067 .id = 0,
68 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
69 .resource = s3c64xx_iis0_resource,
Jassi Brar71269362010-01-06 15:33:44 +090070 .dev = {
Jassi Brar6a62bee2010-11-19 08:49:44 +090071 .platform_data = &i2sv3_pdata,
Jassi Brar71269362010-01-06 15:33:44 +090072 },
Mark Brown52da2192009-06-03 20:08:38 +010073};
74EXPORT_SYMBOL(s3c64xx_device_iis0);
75
76static struct resource s3c64xx_iis1_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +090077 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
78 [1] = DEFINE_RES_DMA(DMACH_I2S1_OUT),
79 [2] = DEFINE_RES_DMA(DMACH_I2S1_IN),
Jassi Brar71269362010-01-06 15:33:44 +090080};
81
Mark Brown52da2192009-06-03 20:08:38 +010082struct platform_device s3c64xx_device_iis1 = {
Jassi Brardaea9b42010-11-19 08:49:43 +090083 .name = "samsung-i2s",
Mark Brown52da2192009-06-03 20:08:38 +010084 .id = 1,
85 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
86 .resource = s3c64xx_iis1_resource,
Jassi Brar71269362010-01-06 15:33:44 +090087 .dev = {
Jassi Brar6a62bee2010-11-19 08:49:44 +090088 .platform_data = &i2sv3_pdata,
Jassi Brar71269362010-01-06 15:33:44 +090089 },
Mark Brown52da2192009-06-03 20:08:38 +010090};
91EXPORT_SYMBOL(s3c64xx_device_iis1);
Mark Brownd06a49e2009-06-03 20:08:39 +010092
93static struct resource s3c64xx_iisv4_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +090094 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
95 [1] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_TX),
96 [2] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_RX),
Jassi Brar71269362010-01-06 15:33:44 +090097};
98
Jassi Brar6a62bee2010-11-19 08:49:44 +090099static struct s3c_audio_pdata i2sv4_pdata = {
100 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
101 .type = {
102 .i2s = {
103 .quirks = QUIRK_PRI_6CHAN,
Jassi Brar6a62bee2010-11-19 08:49:44 +0900104 },
105 },
Mark Brownd06a49e2009-06-03 20:08:39 +0100106};
107
108struct platform_device s3c64xx_device_iisv4 = {
Jassi Brar6a62bee2010-11-19 08:49:44 +0900109 .name = "samsung-i2s",
110 .id = 2,
Mark Brownd06a49e2009-06-03 20:08:39 +0100111 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
112 .resource = s3c64xx_iisv4_resource,
Jassi Brar71269362010-01-06 15:33:44 +0900113 .dev = {
Jassi Brar6a62bee2010-11-19 08:49:44 +0900114 .platform_data = &i2sv4_pdata,
Jassi Brar71269362010-01-06 15:33:44 +0900115 },
Mark Brownd06a49e2009-06-03 20:08:39 +0100116};
117EXPORT_SYMBOL(s3c64xx_device_iisv4);
Jassi Braracf1aef2009-11-17 16:53:56 +0900118
119
120/* PCM Controller platform_devices */
121
122static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
123{
Ben Dooks2618b552010-05-27 15:54:06 +0900124 unsigned int base;
125
Jassi Braracf1aef2009-11-17 16:53:56 +0900126 switch (pdev->id) {
127 case 0:
Ben Dooks2618b552010-05-27 15:54:06 +0900128 base = S3C64XX_GPD(0);
Jassi Braracf1aef2009-11-17 16:53:56 +0900129 break;
130 case 1:
Ben Dooks2618b552010-05-27 15:54:06 +0900131 base = S3C64XX_GPE(0);
Jassi Braracf1aef2009-11-17 16:53:56 +0900132 break;
133 default:
Dimitris Papastamose4b6b742010-08-26 16:07:23 +0100134 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
135 pdev->id);
Jassi Braracf1aef2009-11-17 16:53:56 +0900136 return -EINVAL;
137 }
138
Ben Dooks2618b552010-05-27 15:54:06 +0900139 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
Jassi Braracf1aef2009-11-17 16:53:56 +0900140 return 0;
141}
142
143static struct resource s3c64xx_pcm0_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900144 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
145 [1] = DEFINE_RES_DMA(DMACH_PCM0_TX),
146 [2] = DEFINE_RES_DMA(DMACH_PCM0_RX),
Jassi Braracf1aef2009-11-17 16:53:56 +0900147};
148
Mark Brown43f0de82009-11-27 16:43:53 +0000149static struct s3c_audio_pdata s3c_pcm0_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900150 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
151};
152
153struct platform_device s3c64xx_device_pcm0 = {
154 .name = "samsung-pcm",
155 .id = 0,
156 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
157 .resource = s3c64xx_pcm0_resource,
158 .dev = {
159 .platform_data = &s3c_pcm0_pdata,
160 },
161};
162EXPORT_SYMBOL(s3c64xx_device_pcm0);
163
164static struct resource s3c64xx_pcm1_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900165 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
166 [1] = DEFINE_RES_DMA(DMACH_PCM1_TX),
167 [2] = DEFINE_RES_DMA(DMACH_PCM1_RX),
Jassi Braracf1aef2009-11-17 16:53:56 +0900168};
169
Mark Brown43f0de82009-11-27 16:43:53 +0000170static struct s3c_audio_pdata s3c_pcm1_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900171 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
172};
173
174struct platform_device s3c64xx_device_pcm1 = {
175 .name = "samsung-pcm",
176 .id = 1,
177 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
178 .resource = s3c64xx_pcm1_resource,
179 .dev = {
180 .platform_data = &s3c_pcm1_pdata,
181 },
182};
183EXPORT_SYMBOL(s3c64xx_device_pcm1);
Jassi Brarde6985b2010-02-12 10:38:51 +0000184
185/* AC97 Controller platform devices */
186
187static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
188{
Ben Dooks2618b552010-05-27 15:54:06 +0900189 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
Jassi Brarde6985b2010-02-12 10:38:51 +0000190}
191
192static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
193{
Ben Dooks2618b552010-05-27 15:54:06 +0900194 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
Jassi Brarde6985b2010-02-12 10:38:51 +0000195}
196
197static struct resource s3c64xx_ac97_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900198 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
199 [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT),
200 [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN),
201 [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN),
202 [4] = DEFINE_RES_IRQ(IRQ_AC97),
Jassi Brarde6985b2010-02-12 10:38:51 +0000203};
204
205static struct s3c_audio_pdata s3c_ac97_pdata;
206
207static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
208
209struct platform_device s3c64xx_device_ac97 = {
Jassi Brare6104672010-11-22 15:36:00 +0900210 .name = "samsung-ac97",
Jassi Brarde6985b2010-02-12 10:38:51 +0000211 .id = -1,
212 .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
213 .resource = s3c64xx_ac97_resource,
214 .dev = {
215 .platform_data = &s3c_ac97_pdata,
216 .dma_mask = &s3c64xx_ac97_dmamask,
217 .coherent_dma_mask = DMA_BIT_MASK(32),
218 },
219};
220EXPORT_SYMBOL(s3c64xx_device_ac97);
221
222void __init s3c64xx_ac97_setup_gpio(int num)
223{
224 if (num == S3C64XX_AC97_GPD)
225 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
226 else
227 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
228}