diff options
Diffstat (limited to 'extras/recipes-kernel/linux/linux-omap-psp-2.6.32/omap3-touchbook/0013-ASoC-add-driver-for-omap3-touchbook.patch')
-rw-r--r-- | extras/recipes-kernel/linux/linux-omap-psp-2.6.32/omap3-touchbook/0013-ASoC-add-driver-for-omap3-touchbook.patch | 350 |
1 files changed, 350 insertions, 0 deletions
diff --git a/extras/recipes-kernel/linux/linux-omap-psp-2.6.32/omap3-touchbook/0013-ASoC-add-driver-for-omap3-touchbook.patch b/extras/recipes-kernel/linux/linux-omap-psp-2.6.32/omap3-touchbook/0013-ASoC-add-driver-for-omap3-touchbook.patch new file mode 100644 index 00000000..2da7354e --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap-psp-2.6.32/omap3-touchbook/0013-ASoC-add-driver-for-omap3-touchbook.patch | |||
@@ -0,0 +1,350 @@ | |||
1 | From 96ce6261efe4c194d9188e0f352803bcd92f1c59 Mon Sep 17 00:00:00 2001 | ||
2 | From: Gregoire Gentil <gregoire@gentil.com> | ||
3 | Date: Wed, 31 Mar 2010 11:14:04 +0200 | ||
4 | Subject: [PATCH 13/17] ASoC: add driver for omap3-touchbook | ||
5 | |||
6 | --- | ||
7 | sound/soc/omap/Kconfig | 8 + | ||
8 | sound/soc/omap/Makefile | 2 + | ||
9 | sound/soc/omap/omap3touchbook.c | 291 +++++++++++++++++++++++++++++++++++++++ | ||
10 | 3 files changed, 301 insertions(+), 0 deletions(-) | ||
11 | create mode 100644 sound/soc/omap/omap3touchbook.c | ||
12 | |||
13 | diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig | ||
14 | index 61952aa..a7c06ab 100644 | ||
15 | --- a/sound/soc/omap/Kconfig | ||
16 | +++ b/sound/soc/omap/Kconfig | ||
17 | @@ -101,6 +101,14 @@ config SND_OMAP_SOC_OMAP3_BEAGLE | ||
18 | help | ||
19 | Say Y if you want to add support for SoC audio on the Beagleboard. | ||
20 | |||
21 | +config SND_OMAP_SOC_OMAP3_TOUCHBOOK | ||
22 | + tristate "SoC Audio support for OMAP3 Touch Book" | ||
23 | + depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP3_TOUCHBOOK | ||
24 | + select SND_OMAP_SOC_MCBSP | ||
25 | + select SND_SOC_TWL4030 | ||
26 | + help | ||
27 | + Say Y if you want to add support for SoC audio on the Touch Book. | ||
28 | + | ||
29 | config SND_OMAP_SOC_ZOOM2 | ||
30 | tristate "SoC Audio support for Zoom2" | ||
31 | depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_ZOOM2 | ||
32 | diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile | ||
33 | index 19283e5..e3f172f 100644 | ||
34 | --- a/sound/soc/omap/Makefile | ||
35 | +++ b/sound/soc/omap/Makefile | ||
36 | @@ -16,6 +16,7 @@ snd-soc-am3517evm-objs := am3517evm.o | ||
37 | snd-soc-sdp3430-objs := sdp3430.o | ||
38 | snd-soc-omap3pandora-objs := omap3pandora.o | ||
39 | snd-soc-omap3beagle-objs := omap3beagle.o | ||
40 | +snd-soc-omap3touchbook-objs := omap3touchbook.o | ||
41 | snd-soc-zoom2-objs := zoom2.o | ||
42 | snd-soc-igep0020-objs := igep0020.o | ||
43 | |||
44 | @@ -29,5 +30,6 @@ obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o | ||
45 | obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o | ||
46 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o | ||
47 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o | ||
48 | +obj-$(CONFIG_SND_OMAP_SOC_OMAP3_TOUCHBOOK) += snd-soc-omap3touchbook.o | ||
49 | obj-$(CONFIG_SND_OMAP_SOC_ZOOM2) += snd-soc-zoom2.o | ||
50 | obj-$(CONFIG_SND_OMAP_SOC_IGEP0020) += snd-soc-igep0020.o | ||
51 | diff --git a/sound/soc/omap/omap3touchbook.c b/sound/soc/omap/omap3touchbook.c | ||
52 | new file mode 100644 | ||
53 | index 0000000..c5e6eaa | ||
54 | --- /dev/null | ||
55 | +++ b/sound/soc/omap/omap3touchbook.c | ||
56 | @@ -0,0 +1,291 @@ | ||
57 | +/* | ||
58 | + * omap3touchbook.c -- SoC audio for Touch Book | ||
59 | + * | ||
60 | + * Copyright (C) 2009-2010 Always Innovating | ||
61 | + * | ||
62 | + * Author: Gregoire Gentil <gregoire@gentil.com> | ||
63 | + * | ||
64 | + * Based on: | ||
65 | + * Author: Steve Sakoman <steve@sakoman.com> | ||
66 | + * Author: Misael Lopez Cruz <x0052729@ti.com> | ||
67 | + * | ||
68 | + * This program is free software; you can redistribute it and/or | ||
69 | + * modify it under the terms of the GNU General Public License | ||
70 | + * version 2 as published by the Free Software Foundation. | ||
71 | + * | ||
72 | + * This program is distributed in the hope that it will be useful, but | ||
73 | + * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
74 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
75 | + * General Public License for more details. | ||
76 | + * | ||
77 | + * You should have received a copy of the GNU General Public License | ||
78 | + * along with this program; if not, write to the Free Software | ||
79 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
80 | + * 02110-1301 USA | ||
81 | + * | ||
82 | + */ | ||
83 | + | ||
84 | +#include <linux/clk.h> | ||
85 | +#include <linux/platform_device.h> | ||
86 | +#include <linux/i2c/twl.h> | ||
87 | +#include <sound/core.h> | ||
88 | +#include <sound/pcm.h> | ||
89 | +#include <sound/soc.h> | ||
90 | +#include <sound/soc-dapm.h> | ||
91 | +#include <sound/jack.h> | ||
92 | + | ||
93 | +#include <asm/mach-types.h> | ||
94 | +#include <mach/hardware.h> | ||
95 | +#include <mach/gpio.h> | ||
96 | +#include <plat/mcbsp.h> | ||
97 | + | ||
98 | +#include "omap-mcbsp.h" | ||
99 | +#include "omap-pcm.h" | ||
100 | +#include "../codecs/twl4030.h" | ||
101 | + | ||
102 | +static struct snd_soc_card snd_soc_omap3touchbook; | ||
103 | + | ||
104 | +static int omap3touchbook_hw_params(struct snd_pcm_substream *substream, | ||
105 | + struct snd_pcm_hw_params *params) | ||
106 | +{ | ||
107 | + struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
108 | + struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
109 | + struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
110 | + unsigned int fmt; | ||
111 | + int ret; | ||
112 | + | ||
113 | + switch (params_channels(params)) { | ||
114 | + case 2: /* Stereo I2S mode */ | ||
115 | + fmt = SND_SOC_DAIFMT_I2S | | ||
116 | + SND_SOC_DAIFMT_NB_NF | | ||
117 | + SND_SOC_DAIFMT_CBM_CFM; | ||
118 | + break; | ||
119 | + case 4: /* Four channel TDM mode */ | ||
120 | + fmt = SND_SOC_DAIFMT_DSP_A | | ||
121 | + SND_SOC_DAIFMT_IB_NF | | ||
122 | + SND_SOC_DAIFMT_CBM_CFM; | ||
123 | + break; | ||
124 | + default: | ||
125 | + return -EINVAL; | ||
126 | + } | ||
127 | + | ||
128 | + /* Set codec DAI configuration */ | ||
129 | + ret = snd_soc_dai_set_fmt(codec_dai, fmt); | ||
130 | + if (ret < 0) { | ||
131 | + printk(KERN_ERR "can't set codec DAI configuration\n"); | ||
132 | + return ret; | ||
133 | + } | ||
134 | + | ||
135 | + /* Set cpu DAI configuration */ | ||
136 | + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); | ||
137 | + if (ret < 0) { | ||
138 | + printk(KERN_ERR "can't set cpu DAI configuration\n"); | ||
139 | + return ret; | ||
140 | + } | ||
141 | + | ||
142 | + /* Set the codec system clock for DAC and ADC */ | ||
143 | + ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000, | ||
144 | + SND_SOC_CLOCK_IN); | ||
145 | + if (ret < 0) { | ||
146 | + printk(KERN_ERR "can't set codec system clock\n"); | ||
147 | + return ret; | ||
148 | + } | ||
149 | + | ||
150 | + return 0; | ||
151 | +} | ||
152 | + | ||
153 | +static struct snd_soc_ops omap3touchbook_ops = { | ||
154 | + .hw_params = omap3touchbook_hw_params, | ||
155 | +}; | ||
156 | + | ||
157 | +/* Headset jack */ | ||
158 | +static struct snd_soc_jack hs_jack; | ||
159 | + | ||
160 | +/* Headset jack detection DAPM pins */ | ||
161 | +static struct snd_soc_jack_pin hs_jack_pins[] = { | ||
162 | + { | ||
163 | + .pin = "Headset Stereo", | ||
164 | + .mask = SND_JACK_HEADPHONE, | ||
165 | + }, | ||
166 | + { | ||
167 | + .pin = "Headset Mic", | ||
168 | + .mask = SND_JACK_HEADPHONE, | ||
169 | + }, | ||
170 | + { | ||
171 | + .pin = "External Speakers", | ||
172 | + .mask = SND_JACK_HEADPHONE, | ||
173 | + .invert = 1, | ||
174 | + }, | ||
175 | +}; | ||
176 | + | ||
177 | +/* Headset jack detection gpios */ | ||
178 | +static struct snd_soc_jack_gpio hs_jack_gpios[] = { | ||
179 | + { | ||
180 | + .gpio = 56, | ||
181 | + .name = "hsdet-gpio", | ||
182 | + .report = SND_JACK_HEADSET, | ||
183 | + .debounce_time = 200, | ||
184 | + }, | ||
185 | +}; | ||
186 | + | ||
187 | +/* omap3touchbook machine DAPM */ | ||
188 | +static const struct snd_soc_dapm_widget omap3touchbook_twl4030_dapm_widgets[] = { | ||
189 | + SND_SOC_DAPM_SPK("External Speakers", NULL), | ||
190 | + SND_SOC_DAPM_HP("Headset Stereo", NULL), | ||
191 | + SND_SOC_DAPM_MIC("Headset Mic", NULL), | ||
192 | + SND_SOC_DAPM_LINE("Line In", NULL), | ||
193 | +}; | ||
194 | + | ||
195 | +static const struct snd_soc_dapm_route audio_map[] = { | ||
196 | + /* External Speakers: HFL, HFR */ | ||
197 | + {"External Speakers", NULL, "HFL"}, | ||
198 | + {"External Speakers", NULL, "HFR"}, | ||
199 | + | ||
200 | + /* Headset Stereo: HSOL, HSOR */ | ||
201 | + {"Headset Stereo", NULL, "HSOL"}, | ||
202 | + {"Headset Stereo", NULL, "HSOR"}, | ||
203 | + | ||
204 | + /* Micro: HSMIC */ | ||
205 | + {"HSMIC", NULL, "Headset Mic Bias"}, | ||
206 | + {"Headset Mic Bias", NULL, "Headset Mic"}, | ||
207 | + | ||
208 | + /* Line In: AUXL, AUXR */ | ||
209 | + {"AUXL", NULL, "Line In"}, | ||
210 | + {"AUXR", NULL, "Line In"}, | ||
211 | +}; | ||
212 | + | ||
213 | +static int omap3touchbook_twl4030_init(struct snd_soc_codec *codec) | ||
214 | +{ | ||
215 | + int ret; | ||
216 | + | ||
217 | + /* Add omap3touchbook specific widgets */ | ||
218 | + ret = snd_soc_dapm_new_controls(codec, omap3touchbook_twl4030_dapm_widgets, | ||
219 | + ARRAY_SIZE(omap3touchbook_twl4030_dapm_widgets)); | ||
220 | + if (ret) | ||
221 | + return ret; | ||
222 | + | ||
223 | + /* Set up omap3touchbook specific audio path audio_map */ | ||
224 | + snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | ||
225 | + | ||
226 | + /* omap3touchbook connected pins */ | ||
227 | + snd_soc_dapm_enable_pin(codec, "External Speakers"); | ||
228 | + snd_soc_dapm_enable_pin(codec, "Headset Stereo"); | ||
229 | + snd_soc_dapm_enable_pin(codec, "Headset Mic"); | ||
230 | + snd_soc_dapm_enable_pin(codec, "Line In"); | ||
231 | + | ||
232 | + /* omap3touchbook not connected pins */ | ||
233 | + snd_soc_dapm_nc_pin(codec, "CARKITMIC"); | ||
234 | + snd_soc_dapm_nc_pin(codec, "MAINMIC"); | ||
235 | + snd_soc_dapm_nc_pin(codec, "SUBMIC"); | ||
236 | + snd_soc_dapm_nc_pin(codec, "DIGIMIC0"); | ||
237 | + snd_soc_dapm_nc_pin(codec, "DIGIMIC1"); | ||
238 | + snd_soc_dapm_nc_pin(codec, "OUTL"); | ||
239 | + snd_soc_dapm_nc_pin(codec, "OUTR"); | ||
240 | + snd_soc_dapm_nc_pin(codec, "EARPIECE"); | ||
241 | + snd_soc_dapm_nc_pin(codec, "PREDRIVEL"); | ||
242 | + snd_soc_dapm_nc_pin(codec, "PREDRIVER"); | ||
243 | + snd_soc_dapm_nc_pin(codec, "CARKITL"); | ||
244 | + snd_soc_dapm_nc_pin(codec, "CARKITR"); | ||
245 | + snd_soc_dapm_nc_pin(codec, "VIBRA"); | ||
246 | + | ||
247 | + ret = snd_soc_dapm_sync(codec); | ||
248 | + if (ret) | ||
249 | + return ret; | ||
250 | + | ||
251 | + /* Headset jack detection */ | ||
252 | + ret = snd_soc_jack_new(&snd_soc_omap3touchbook, "Headset Jack", | ||
253 | + SND_JACK_HEADSET, &hs_jack); | ||
254 | + if (ret) | ||
255 | + return ret; | ||
256 | + | ||
257 | + ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), | ||
258 | + hs_jack_pins); | ||
259 | + if (ret) | ||
260 | + return ret; | ||
261 | + | ||
262 | + ret = snd_soc_jack_add_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios), | ||
263 | + hs_jack_gpios); | ||
264 | + | ||
265 | + return ret; | ||
266 | +} | ||
267 | + | ||
268 | +/* Digital audio interface glue - connects codec <--> CPU */ | ||
269 | +static struct snd_soc_dai_link omap3touchbook_dai = { | ||
270 | + .name = "TWL4030 I2S", | ||
271 | + .stream_name = "TWL4030 Audio", | ||
272 | + .cpu_dai = &omap_mcbsp_dai[0], | ||
273 | + .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], | ||
274 | + .init = omap3touchbook_twl4030_init, | ||
275 | + .ops = &omap3touchbook_ops, | ||
276 | +}; | ||
277 | + | ||
278 | +/* Audio machine driver */ | ||
279 | +static struct snd_soc_card snd_soc_omap3touchbook = { | ||
280 | + .name = "omap3touchbook", | ||
281 | + .platform = &omap_soc_platform, | ||
282 | + .dai_link = &omap3touchbook_dai, | ||
283 | + .num_links = 1, | ||
284 | +}; | ||
285 | + | ||
286 | +/* twl4030 setup */ | ||
287 | +static struct twl4030_setup_data twl4030_setup = { | ||
288 | + .ramp_delay_value = 3, | ||
289 | + .sysclk = 26000, | ||
290 | + .hs_extmute = 1, | ||
291 | +}; | ||
292 | + | ||
293 | +/* Audio subsystem */ | ||
294 | +static struct snd_soc_device omap3touchbook_snd_devdata = { | ||
295 | + .card = &snd_soc_omap3touchbook, | ||
296 | + .codec_dev = &soc_codec_dev_twl4030, | ||
297 | + .codec_data = &twl4030_setup, | ||
298 | +}; | ||
299 | + | ||
300 | +static struct platform_device *omap3touchbook_snd_device; | ||
301 | + | ||
302 | +static int __init omap3touchbook_soc_init(void) | ||
303 | +{ | ||
304 | + int ret; | ||
305 | + u8 pin_mux; | ||
306 | + | ||
307 | + if (!machine_is_touchbook()) { | ||
308 | + pr_debug("Not Touch Book!\n"); | ||
309 | + //return -ENODEV; | ||
310 | + } | ||
311 | + printk(KERN_INFO "Touch Book SoC init\n"); | ||
312 | + | ||
313 | + omap3touchbook_snd_device = platform_device_alloc("soc-audio", -1); | ||
314 | + if (!omap3touchbook_snd_device) { | ||
315 | + printk(KERN_ERR "Platform device allocation failed\n"); | ||
316 | + return -ENOMEM; | ||
317 | + } | ||
318 | + | ||
319 | + platform_set_drvdata(omap3touchbook_snd_device, &omap3touchbook_snd_devdata); | ||
320 | + omap3touchbook_snd_devdata.dev = &omap3touchbook_snd_device->dev; | ||
321 | + *(unsigned int *)omap3touchbook_dai.cpu_dai->private_data = 1; /* McBSP2 */ | ||
322 | + | ||
323 | + ret = platform_device_add(omap3touchbook_snd_device); | ||
324 | + if (ret) | ||
325 | + goto err1; | ||
326 | + | ||
327 | + return 0; | ||
328 | + | ||
329 | +err1: | ||
330 | + printk(KERN_ERR "Unable to add platform device\n"); | ||
331 | + platform_device_put(omap3touchbook_snd_device); | ||
332 | + | ||
333 | + return ret; | ||
334 | +} | ||
335 | +module_init(omap3touchbook_soc_init); | ||
336 | + | ||
337 | +static void __exit omap3touchbook_soc_exit(void) | ||
338 | +{ | ||
339 | + snd_soc_jack_free_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios), | ||
340 | + hs_jack_gpios); | ||
341 | + | ||
342 | + platform_device_unregister(omap3touchbook_snd_device); | ||
343 | +} | ||
344 | +module_exit(omap3touchbook_soc_exit); | ||
345 | + | ||
346 | +MODULE_AUTHOR("Gregoire Gentil <gregoire@gentil.com>"); | ||
347 | +MODULE_LICENSE("GPL"); | ||
348 | -- | ||
349 | 1.6.6.1 | ||
350 | |||