blob: e3c49b5d1355b93e585356b5e347e558e53600f5 [file] [log] [blame]
Krzysztof Kozlowski28a196f2017-12-25 20:54:33 +01001// SPDX-License-Identifier: GPL-2.0
2//
3// Copyright 2009 Wolfson Microelectronics
4// Mark Brown <broonie@opensource.wolfsonmicro.com>
Mark Brown52da2192009-06-03 20:08:38 +01005
6#include <linux/kernel.h>
7#include <linux/string.h>
8#include <linux/platform_device.h>
Jassi Brarde6985b2010-02-12 10:38:51 +00009#include <linux/dma-mapping.h>
Kukjin Kim1c739c72010-08-05 07:54:49 +090010#include <linux/gpio.h>
Paul Gortmakerdc280942011-07-31 16:17:29 -040011#include <linux/export.h>
Mark Brown52da2192009-06-03 20:08:38 +010012
13#include <mach/irqs.h>
14#include <mach/map.h>
Jassi Braracf1aef2009-11-17 16:53:56 +090015#include <mach/dma.h>
Mark Brown52da2192009-06-03 20:08:38 +010016
17#include <plat/devs.h>
Arnd Bergmann436d42c2012-08-24 15:22:12 +020018#include <linux/platform_data/asoc-s3c.h>
Jassi Braracf1aef2009-11-17 16:53:56 +090019#include <plat/gpio-cfg.h>
Linus Walleijb0161ca2014-01-14 14:24:24 +010020#include <mach/gpio-samsung.h>
Mark Brown52da2192009-06-03 20:08:38 +010021
Jassi Brar6a62bee2010-11-19 08:49:44 +090022static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
Jassi Brar71269362010-01-06 15:33:44 +090023{
Ben Dooks2618b552010-05-27 15:54:06 +090024 unsigned int base;
25
Jassi Brar71269362010-01-06 15:33:44 +090026 switch (pdev->id) {
27 case 0:
Ben Dooks2618b552010-05-27 15:54:06 +090028 base = S3C64XX_GPD(0);
Jassi Brar71269362010-01-06 15:33:44 +090029 break;
30 case 1:
Ben Dooks2618b552010-05-27 15:54:06 +090031 base = S3C64XX_GPE(0);
Dimitris Papastamose4b6b742010-08-26 16:07:23 +010032 break;
Jassi Brar6a62bee2010-11-19 08:49:44 +090033 case 2:
34 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
35 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
36 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
37 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
38 return 0;
Jassi Brar71269362010-01-06 15:33:44 +090039 default:
Dimitris Papastamose4b6b742010-08-26 16:07:23 +010040 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
41 pdev->id);
Jassi Brar71269362010-01-06 15:33:44 +090042 return -EINVAL;
43 }
44
Ben Dooks2618b552010-05-27 15:54:06 +090045 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
46
Jassi Brar71269362010-01-06 15:33:44 +090047 return 0;
48}
49
Mark Brown52da2192009-06-03 20:08:38 +010050static struct resource s3c64xx_iis0_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +090051 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
Jassi Brar71269362010-01-06 15:33:44 +090052};
53
Arnd Bergmannb9a1a742015-11-18 15:25:23 +010054static struct s3c_audio_pdata i2s0_pdata = {
Jassi Brar6a62bee2010-11-19 08:49:44 +090055 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
Mark Brown52da2192009-06-03 20:08:38 +010056};
57
58struct platform_device s3c64xx_device_iis0 = {
Jassi Brardaea9b42010-11-19 08:49:43 +090059 .name = "samsung-i2s",
Mark Brown52da2192009-06-03 20:08:38 +010060 .id = 0,
61 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
62 .resource = s3c64xx_iis0_resource,
Jassi Brar71269362010-01-06 15:33:44 +090063 .dev = {
Arnd Bergmannb9a1a742015-11-18 15:25:23 +010064 .platform_data = &i2s0_pdata,
Jassi Brar71269362010-01-06 15:33:44 +090065 },
Mark Brown52da2192009-06-03 20:08:38 +010066};
67EXPORT_SYMBOL(s3c64xx_device_iis0);
68
69static struct resource s3c64xx_iis1_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +090070 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
Arnd Bergmannb9a1a742015-11-18 15:25:23 +010071};
72
73static struct s3c_audio_pdata i2s1_pdata = {
74 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
Jassi Brar71269362010-01-06 15:33:44 +090075};
76
Mark Brown52da2192009-06-03 20:08:38 +010077struct platform_device s3c64xx_device_iis1 = {
Jassi Brardaea9b42010-11-19 08:49:43 +090078 .name = "samsung-i2s",
Mark Brown52da2192009-06-03 20:08:38 +010079 .id = 1,
80 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
81 .resource = s3c64xx_iis1_resource,
Jassi Brar71269362010-01-06 15:33:44 +090082 .dev = {
Arnd Bergmannb9a1a742015-11-18 15:25:23 +010083 .platform_data = &i2s1_pdata,
Jassi Brar71269362010-01-06 15:33:44 +090084 },
Mark Brown52da2192009-06-03 20:08:38 +010085};
86EXPORT_SYMBOL(s3c64xx_device_iis1);
Mark Brownd06a49e2009-06-03 20:08:39 +010087
88static struct resource s3c64xx_iisv4_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +090089 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
Jassi Brar71269362010-01-06 15:33:44 +090090};
91
Jassi Brar6a62bee2010-11-19 08:49:44 +090092static struct s3c_audio_pdata i2sv4_pdata = {
93 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
94 .type = {
Krzysztof Kozlowski409c69b2016-12-10 11:51:11 +020095 .quirks = QUIRK_PRI_6CHAN,
Jassi Brar6a62bee2010-11-19 08:49:44 +090096 },
Mark Brownd06a49e2009-06-03 20:08:39 +010097};
98
99struct platform_device s3c64xx_device_iisv4 = {
Jassi Brar6a62bee2010-11-19 08:49:44 +0900100 .name = "samsung-i2s",
101 .id = 2,
Mark Brownd06a49e2009-06-03 20:08:39 +0100102 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
103 .resource = s3c64xx_iisv4_resource,
Jassi Brar71269362010-01-06 15:33:44 +0900104 .dev = {
Jassi Brar6a62bee2010-11-19 08:49:44 +0900105 .platform_data = &i2sv4_pdata,
Jassi Brar71269362010-01-06 15:33:44 +0900106 },
Mark Brownd06a49e2009-06-03 20:08:39 +0100107};
108EXPORT_SYMBOL(s3c64xx_device_iisv4);
Jassi Braracf1aef2009-11-17 16:53:56 +0900109
110
111/* PCM Controller platform_devices */
112
113static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
114{
Ben Dooks2618b552010-05-27 15:54:06 +0900115 unsigned int base;
116
Jassi Braracf1aef2009-11-17 16:53:56 +0900117 switch (pdev->id) {
118 case 0:
Ben Dooks2618b552010-05-27 15:54:06 +0900119 base = S3C64XX_GPD(0);
Jassi Braracf1aef2009-11-17 16:53:56 +0900120 break;
121 case 1:
Ben Dooks2618b552010-05-27 15:54:06 +0900122 base = S3C64XX_GPE(0);
Jassi Braracf1aef2009-11-17 16:53:56 +0900123 break;
124 default:
Dimitris Papastamose4b6b742010-08-26 16:07:23 +0100125 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
126 pdev->id);
Jassi Braracf1aef2009-11-17 16:53:56 +0900127 return -EINVAL;
128 }
129
Ben Dooks2618b552010-05-27 15:54:06 +0900130 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
Jassi Braracf1aef2009-11-17 16:53:56 +0900131 return 0;
132}
133
134static struct resource s3c64xx_pcm0_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900135 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
Jassi Braracf1aef2009-11-17 16:53:56 +0900136};
137
Mark Brown43f0de82009-11-27 16:43:53 +0000138static struct s3c_audio_pdata s3c_pcm0_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900139 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
140};
141
142struct platform_device s3c64xx_device_pcm0 = {
143 .name = "samsung-pcm",
144 .id = 0,
145 .num_resources = ARRAY_SIZE(s3c64xx_pcm0_resource),
146 .resource = s3c64xx_pcm0_resource,
147 .dev = {
148 .platform_data = &s3c_pcm0_pdata,
149 },
150};
151EXPORT_SYMBOL(s3c64xx_device_pcm0);
152
153static struct resource s3c64xx_pcm1_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900154 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
Jassi Braracf1aef2009-11-17 16:53:56 +0900155};
156
Mark Brown43f0de82009-11-27 16:43:53 +0000157static struct s3c_audio_pdata s3c_pcm1_pdata = {
Jassi Braracf1aef2009-11-17 16:53:56 +0900158 .cfg_gpio = s3c64xx_pcm_cfg_gpio,
159};
160
161struct platform_device s3c64xx_device_pcm1 = {
162 .name = "samsung-pcm",
163 .id = 1,
164 .num_resources = ARRAY_SIZE(s3c64xx_pcm1_resource),
165 .resource = s3c64xx_pcm1_resource,
166 .dev = {
167 .platform_data = &s3c_pcm1_pdata,
168 },
169};
170EXPORT_SYMBOL(s3c64xx_device_pcm1);
Jassi Brarde6985b2010-02-12 10:38:51 +0000171
172/* AC97 Controller platform devices */
173
174static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
175{
Ben Dooks2618b552010-05-27 15:54:06 +0900176 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
Jassi Brarde6985b2010-02-12 10:38:51 +0000177}
178
179static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
180{
Ben Dooks2618b552010-05-27 15:54:06 +0900181 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
Jassi Brarde6985b2010-02-12 10:38:51 +0000182}
183
184static struct resource s3c64xx_ac97_resource[] = {
Tushar Beherac6d884c2012-05-12 16:12:25 +0900185 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
Arnd Bergmannb9a1a742015-11-18 15:25:23 +0100186 [1] = DEFINE_RES_IRQ(IRQ_AC97),
Jassi Brarde6985b2010-02-12 10:38:51 +0000187};
188
Arnd Bergmannb9a1a742015-11-18 15:25:23 +0100189static struct s3c_audio_pdata s3c_ac97_pdata = {
Arnd Bergmannb9a1a742015-11-18 15:25:23 +0100190};
Jassi Brarde6985b2010-02-12 10:38:51 +0000191
192static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
193
194struct platform_device s3c64xx_device_ac97 = {
Jassi Brare6104672010-11-22 15:36:00 +0900195 .name = "samsung-ac97",
Jassi Brarde6985b2010-02-12 10:38:51 +0000196 .id = -1,
197 .num_resources = ARRAY_SIZE(s3c64xx_ac97_resource),
198 .resource = s3c64xx_ac97_resource,
199 .dev = {
200 .platform_data = &s3c_ac97_pdata,
201 .dma_mask = &s3c64xx_ac97_dmamask,
202 .coherent_dma_mask = DMA_BIT_MASK(32),
203 },
204};
205EXPORT_SYMBOL(s3c64xx_device_ac97);
206
207void __init s3c64xx_ac97_setup_gpio(int num)
208{
209 if (num == S3C64XX_AC97_GPD)
210 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpd;
211 else
212 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
213}