Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dev-audio.c
Go to the documentation of this file.
1 /* linux/arch/arm/plat-s3c/dev-audio.c
2  *
3  * Copyright 2009 Wolfson Microelectronics
4  * Mark Brown <[email protected]>
5  *
6  * 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>
14 #include <linux/dma-mapping.h>
15 #include <linux/gpio.h>
16 #include <linux/export.h>
17 
18 #include <mach/irqs.h>
19 #include <mach/map.h>
20 #include <mach/dma.h>
21 
22 #include <plat/devs.h>
24 #include <plat/gpio-cfg.h>
25 
26 static const char *rclksrc[] = {
27  [0] = "iis",
28  [1] = "audio-bus",
29 };
30 
31 static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
32 {
33  unsigned int base;
34 
35  switch (pdev->id) {
36  case 0:
37  base = S3C64XX_GPD(0);
38  break;
39  case 1:
40  base = S3C64XX_GPE(0);
41  break;
42  case 2:
47  return 0;
48  default:
49  printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
50  pdev->id);
51  return -EINVAL;
52  }
53 
55 
56  return 0;
57 }
58 
59 static struct resource s3c64xx_iis0_resource[] = {
63 };
64 
65 static struct s3c_audio_pdata i2sv3_pdata = {
66  .cfg_gpio = s3c64xx_i2s_cfg_gpio,
67  .type = {
68  .i2s = {
69  .src_clk = rclksrc,
70  },
71  },
72 };
73 
75  .name = "samsung-i2s",
76  .id = 0,
77  .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource),
78  .resource = s3c64xx_iis0_resource,
79  .dev = {
80  .platform_data = &i2sv3_pdata,
81  },
82 };
83 EXPORT_SYMBOL(s3c64xx_device_iis0);
84 
85 static struct resource s3c64xx_iis1_resource[] = {
89 };
90 
92  .name = "samsung-i2s",
93  .id = 1,
94  .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource),
95  .resource = s3c64xx_iis1_resource,
96  .dev = {
97  .platform_data = &i2sv3_pdata,
98  },
99 };
100 EXPORT_SYMBOL(s3c64xx_device_iis1);
101 
102 static struct resource s3c64xx_iisv4_resource[] = {
106 };
107 
108 static 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  },
116 };
117 
119  .name = "samsung-i2s",
120  .id = 2,
121  .num_resources = ARRAY_SIZE(s3c64xx_iisv4_resource),
122  .resource = s3c64xx_iisv4_resource,
123  .dev = {
124  .platform_data = &i2sv4_pdata,
125  },
126 };
127 EXPORT_SYMBOL(s3c64xx_device_iisv4);
128 
129 
130 /* PCM Controller platform_devices */
131 
132 static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
133 {
134  unsigned int base;
135 
136  switch (pdev->id) {
137  case 0:
138  base = S3C64XX_GPD(0);
139  break;
140  case 1:
141  base = S3C64XX_GPE(0);
142  break;
143  default:
144  printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
145  pdev->id);
146  return -EINVAL;
147  }
148 
149  s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
150  return 0;
151 }
152 
153 static struct resource s3c64xx_pcm0_resource[] = {
157 };
158 
159 static struct s3c_audio_pdata s3c_pcm0_pdata = {
160  .cfg_gpio = s3c64xx_pcm_cfg_gpio,
161 };
162 
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 };
172 EXPORT_SYMBOL(s3c64xx_device_pcm0);
173 
174 static struct resource s3c64xx_pcm1_resource[] = {
178 };
179 
180 static struct s3c_audio_pdata s3c_pcm1_pdata = {
181  .cfg_gpio = s3c64xx_pcm_cfg_gpio,
182 };
183 
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 };
193 EXPORT_SYMBOL(s3c64xx_device_pcm1);
194 
195 /* AC97 Controller platform devices */
196 
197 static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
198 {
200 }
201 
202 static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
203 {
205 }
206 
207 static struct resource s3c64xx_ac97_resource[] = {
212  [4] = DEFINE_RES_IRQ(IRQ_AC97),
213 };
214 
215 static struct s3c_audio_pdata s3c_ac97_pdata;
216 
217 static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32);
218 
220  .name = "samsung-ac97",
221  .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 };
230 EXPORT_SYMBOL(s3c64xx_device_ac97);
231 
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 }