1
2
3
4
5
6#include <linux/kernel.h>
7#include <linux/string.h>
8#include <linux/platform_device.h>
9#include <linux/dma-mapping.h>
10#include <linux/gpio.h>
11#include <linux/export.h>
12
13#include <mach/irqs.h>
14#include <mach/map.h>
15#include <mach/dma.h>
16
17#include <plat/devs.h>
18#include <linux/platform_data/asoc-s3c.h>
19#include <plat/gpio-cfg.h>
20#include <mach/gpio-samsung.h>
21
22static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
23{
24 unsigned int base;
25
26 switch (pdev->id) {
27 case 0:
28 base = S3C64XX_GPD(0);
29 break;
30 case 1:
31 base = S3C64XX_GPE(0);
32 break;
33 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;
39 default:
40 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
41 pdev->id);
42 return -EINVAL;
43 }
44
45 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
46
47 return 0;
48}
49
50static struct resource s3c64xx_iis0_resource[] = {
51 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256),
52};
53
54static struct s3c_audio_pdata i2s0_pdata = {
55 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
56};
57
58struct platform_device s3c64xx_device_iis0 = {
59 .name = "samsung-i2s",
60 .id = 0,
61 .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
62 .resource = s3c64xx_iis0_resource,
63 .dev = {
64 .platform_data = &i2s0_pdata,
65 },
66};
67EXPORT_SYMBOL(s3c64xx_device_iis0);
68
69static struct resource s3c64xx_iis1_resource[] = {
70 [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256),
71};
72
73static struct s3c_audio_pdata i2s1_pdata = {
74 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
75};
76
77struct platform_device s3c64xx_device_iis1 = {
78 .name = "samsung-i2s",
79 .id = 1,
80 .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
81 .resource = s3c64xx_iis1_resource,
82 .dev = {
83 .platform_data = &i2s1_pdata,
84 },
85};
86EXPORT_SYMBOL(s3c64xx_device_iis1);
87
88static struct resource s3c64xx_iisv4_resource[] = {
89 [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256),
90};
91
92static struct s3c_audio_pdata i2sv4_pdata = {
93 .cfg_gpio = s3c64xx_i2s_cfg_gpio,
94 .type = {
95 .quirks = QUIRK_PRI_6CHAN,
96 },
97};
98
99struct platform_device s3c64xx_device_iisv4 = {
100 .name = "samsung-i2s",
101 .id = 2,
102 .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
103 .resource = s3c64xx_iisv4_resource,
104 .dev = {
105 .platform_data = &i2sv4_pdata,
106 },
107};
108EXPORT_SYMBOL(s3c64xx_device_iisv4);
109
110
111
112
113static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
114{
115 unsigned int base;
116
117 switch (pdev->id) {
118 case 0:
119 base = S3C64XX_GPD(0);
120 break;
121 case 1:
122 base = S3C64XX_GPE(0);
123 break;
124 default:
125 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
126 pdev->id);
127 return -EINVAL;
128 }
129
130 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
131 return 0;
132}
133
134static struct resource s3c64xx_pcm0_resource[] = {
135 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256),
136};
137
138static struct s3c_audio_pdata s3c_pcm0_pdata = {
139 .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[] = {
154 [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256),
155};
156
157static struct s3c_audio_pdata s3c_pcm1_pdata = {
158 .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);
171
172
173
174static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
175{
176 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
177}
178
179static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
180{
181 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
182}
183
184static struct resource s3c64xx_ac97_resource[] = {
185 [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256),
186 [1] = DEFINE_RES_IRQ(IRQ_AC97),
187};
188
189static struct s3c_audio_pdata s3c_ac97_pdata = {
190};
191
192static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
193
194struct platform_device s3c64xx_device_ac97 = {
195 .name = "samsung-ac97",
196 .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}
214