aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-08-22 09:28:44 -0400
committerMark Brown <broonie@linaro.org>2013-08-22 09:28:44 -0400
commitfe2a1e53beaf0b8fefd5f89c152f0ff124efe970 (patch)
tree84d20e87774d62c821603c4feaf985ecb288b95d
parent49ffa3b1b211f3404a401bce0d8618f4c41ff01e (diff)
parent673c24e957db4be85a12e4260ace12dea805fa97 (diff)
Merge remote-tracking branch 'asoc/topic/omap' into asoc-next
-rw-r--r--include/linux/platform_data/omap-abe-twl6040.h49
-rw-r--r--sound/soc/omap/Kconfig6
-rw-r--r--sound/soc/omap/omap-abe-twl6040.c133
-rw-r--r--sound/soc/omap/omap-dmic.c9
-rw-r--r--sound/soc/omap/omap-mcbsp.c5
-rw-r--r--sound/soc/omap/omap-mcpdm.c3
6 files changed, 52 insertions, 153 deletions
diff --git a/include/linux/platform_data/omap-abe-twl6040.h b/include/linux/platform_data/omap-abe-twl6040.h
deleted file mode 100644
index 5d298ac10fc2..000000000000
--- a/include/linux/platform_data/omap-abe-twl6040.h
+++ /dev/null
@@ -1,49 +0,0 @@
1/**
2 * omap-abe-twl6040.h - ASoC machine driver OMAP4+ devices, header.
3 *
4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
5 * All rights reserved.
6 *
7 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 */
23
24#ifndef _OMAP_ABE_TWL6040_H_
25#define _OMAP_ABE_TWL6040_H_
26
27/* To select if only one channel is connected in a stereo port */
28#define ABE_TWL6040_LEFT (1 << 0)
29#define ABE_TWL6040_RIGHT (1 << 1)
30
31struct omap_abe_twl6040_data {
32 char *card_name;
33 /* Feature flags for connected audio pins */
34 u8 has_hs;
35 u8 has_hf;
36 bool has_ep;
37 u8 has_aux;
38 u8 has_vibra;
39 bool has_dmic;
40 bool has_hsmic;
41 bool has_mainmic;
42 bool has_submic;
43 u8 has_afm;
44 /* Other features */
45 bool jack_detection; /* board can detect jack events */
46 int mclk_freq; /* MCLK frequency speed for twl6040 */
47};
48
49#endif /* _OMAP_ABE_TWL6040_H_ */
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig
index accd0ff0fbfc..daa78a0095fa 100644
--- a/sound/soc/omap/Kconfig
+++ b/sound/soc/omap/Kconfig
@@ -1,6 +1,6 @@
1config SND_OMAP_SOC 1config SND_OMAP_SOC
2 tristate "SoC Audio for the Texas Instruments OMAP chips" 2 tristate "SoC Audio for the Texas Instruments OMAP chips"
3 depends on ARCH_OMAP && DMA_OMAP 3 depends on (ARCH_OMAP && DMA_OMAP) || (ARCH_ARM && COMPILE_TEST)
4 select SND_DMAENGINE_PCM 4 select SND_DMAENGINE_PCM
5 5
6config SND_OMAP_SOC_DMIC 6config SND_OMAP_SOC_DMIC
@@ -26,7 +26,7 @@ config SND_OMAP_SOC_N810
26 26
27config SND_OMAP_SOC_RX51 27config SND_OMAP_SOC_RX51
28 tristate "SoC Audio support for Nokia RX-51" 28 tristate "SoC Audio support for Nokia RX-51"
29 depends on SND_OMAP_SOC && MACH_NOKIA_RX51 29 depends on SND_OMAP_SOC && ARCH_ARM && (MACH_NOKIA_RX51 || COMPILE_TEST)
30 select SND_OMAP_SOC_MCBSP 30 select SND_OMAP_SOC_MCBSP
31 select SND_SOC_TLV320AIC3X 31 select SND_SOC_TLV320AIC3X
32 select SND_SOC_TPA6130A2 32 select SND_SOC_TPA6130A2
@@ -87,7 +87,7 @@ config SND_OMAP_SOC_OMAP_TWL4030
87 87
88config SND_OMAP_SOC_OMAP_ABE_TWL6040 88config SND_OMAP_SOC_OMAP_ABE_TWL6040
89 tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec" 89 tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec"
90 depends on TWL6040_CORE && SND_OMAP_SOC && ARCH_OMAP4 90 depends on TWL6040_CORE && SND_OMAP_SOC && (ARCH_OMAP4 || COMPILE_TEST)
91 select SND_OMAP_SOC_DMIC 91 select SND_OMAP_SOC_DMIC
92 select SND_OMAP_SOC_MCPDM 92 select SND_OMAP_SOC_MCPDM
93 select SND_SOC_TWL6040 93 select SND_SOC_TWL6040
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
index 70cd5c7b2e14..ebb13906b3a0 100644
--- a/sound/soc/omap/omap-abe-twl6040.c
+++ b/sound/soc/omap/omap-abe-twl6040.c
@@ -23,7 +23,6 @@
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/mfd/twl6040.h> 25#include <linux/mfd/twl6040.h>
26#include <linux/platform_data/omap-abe-twl6040.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <linux/of.h> 27#include <linux/of.h>
29 28
@@ -166,19 +165,10 @@ static const struct snd_soc_dapm_route audio_map[] = {
166 {"AFMR", NULL, "Line In"}, 165 {"AFMR", NULL, "Line In"},
167}; 166};
168 167
169static inline void twl6040_disconnect_pin(struct snd_soc_dapm_context *dapm,
170 int connected, char *pin)
171{
172 if (!connected)
173 snd_soc_dapm_disable_pin(dapm, pin);
174}
175
176static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) 168static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
177{ 169{
178 struct snd_soc_codec *codec = rtd->codec; 170 struct snd_soc_codec *codec = rtd->codec;
179 struct snd_soc_card *card = codec->card; 171 struct snd_soc_card *card = codec->card;
180 struct snd_soc_dapm_context *dapm = &codec->dapm;
181 struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev);
182 struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card); 172 struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card);
183 int hs_trim; 173 int hs_trim;
184 int ret = 0; 174 int ret = 0;
@@ -203,24 +193,6 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
203 twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); 193 twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
204 } 194 }
205 195
206 /*
207 * NULL pdata means we booted with DT. In this case the routing is
208 * provided and the card is fully routed, no need to mark pins.
209 */
210 if (!pdata)
211 return ret;
212
213 /* Disable not connected paths if not used */
214 twl6040_disconnect_pin(dapm, pdata->has_hs, "Headset Stereophone");
215 twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk");
216 twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk");
217 twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out");
218 twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vibrator");
219 twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic");
220 twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic");
221 twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic");
222 twl6040_disconnect_pin(dapm, pdata->has_afm, "Line In");
223
224 return ret; 196 return ret;
225} 197}
226 198
@@ -274,13 +246,18 @@ static struct snd_soc_card omap_abe_card = {
274 246
275static int omap_abe_probe(struct platform_device *pdev) 247static int omap_abe_probe(struct platform_device *pdev)
276{ 248{
277 struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev);
278 struct device_node *node = pdev->dev.of_node; 249 struct device_node *node = pdev->dev.of_node;
279 struct snd_soc_card *card = &omap_abe_card; 250 struct snd_soc_card *card = &omap_abe_card;
251 struct device_node *dai_node;
280 struct abe_twl6040 *priv; 252 struct abe_twl6040 *priv;
281 int num_links = 0; 253 int num_links = 0;
282 int ret = 0; 254 int ret = 0;
283 255
256 if (!node) {
257 dev_err(&pdev->dev, "of node is missing.\n");
258 return -ENODEV;
259 }
260
284 card->dev = &pdev->dev; 261 card->dev = &pdev->dev;
285 262
286 priv = devm_kzalloc(&pdev->dev, sizeof(struct abe_twl6040), GFP_KERNEL); 263 priv = devm_kzalloc(&pdev->dev, sizeof(struct abe_twl6040), GFP_KERNEL);
@@ -289,78 +266,50 @@ static int omap_abe_probe(struct platform_device *pdev)
289 266
290 priv->dmic_codec_dev = ERR_PTR(-EINVAL); 267 priv->dmic_codec_dev = ERR_PTR(-EINVAL);
291 268
292 if (node) { 269 if (snd_soc_of_parse_card_name(card, "ti,model")) {
293 struct device_node *dai_node; 270 dev_err(&pdev->dev, "Card name is not provided\n");
294 271 return -ENODEV;
295 if (snd_soc_of_parse_card_name(card, "ti,model")) { 272 }
296 dev_err(&pdev->dev, "Card name is not provided\n");
297 return -ENODEV;
298 }
299 273
300 ret = snd_soc_of_parse_audio_routing(card, 274 ret = snd_soc_of_parse_audio_routing(card, "ti,audio-routing");
301 "ti,audio-routing"); 275 if (ret) {
302 if (ret) { 276 dev_err(&pdev->dev, "Error while parsing DAPM routing\n");
303 dev_err(&pdev->dev, 277 return ret;
304 "Error while parsing DAPM routing\n"); 278 }
305 return ret;
306 }
307 279
308 dai_node = of_parse_phandle(node, "ti,mcpdm", 0); 280 dai_node = of_parse_phandle(node, "ti,mcpdm", 0);
309 if (!dai_node) { 281 if (!dai_node) {
310 dev_err(&pdev->dev, "McPDM node is not provided\n"); 282 dev_err(&pdev->dev, "McPDM node is not provided\n");
311 return -EINVAL; 283 return -EINVAL;
312 } 284 }
313 abe_twl6040_dai_links[0].cpu_dai_name = NULL; 285 abe_twl6040_dai_links[0].cpu_dai_name = NULL;
314 abe_twl6040_dai_links[0].cpu_of_node = dai_node; 286 abe_twl6040_dai_links[0].cpu_of_node = dai_node;
315 287
316 dai_node = of_parse_phandle(node, "ti,dmic", 0); 288 dai_node = of_parse_phandle(node, "ti,dmic", 0);
317 if (dai_node) { 289 if (dai_node) {
318 num_links = 2; 290 num_links = 2;
319 abe_twl6040_dai_links[1].cpu_dai_name = NULL; 291 abe_twl6040_dai_links[1].cpu_dai_name = NULL;
320 abe_twl6040_dai_links[1].cpu_of_node = dai_node; 292 abe_twl6040_dai_links[1].cpu_of_node = dai_node;
321 293
322 priv->dmic_codec_dev = platform_device_register_simple( 294 priv->dmic_codec_dev = platform_device_register_simple(
323 "dmic-codec", -1, NULL, 0); 295 "dmic-codec", -1, NULL, 0);
324 if (IS_ERR(priv->dmic_codec_dev)) { 296 if (IS_ERR(priv->dmic_codec_dev)) {
325 dev_err(&pdev->dev, 297 dev_err(&pdev->dev, "Can't instantiate dmic-codec\n");
326 "Can't instantiate dmic-codec\n"); 298 return PTR_ERR(priv->dmic_codec_dev);
327 return PTR_ERR(priv->dmic_codec_dev);
328 }
329 } else {
330 num_links = 1;
331 }
332
333 priv->jack_detection = of_property_read_bool(node,
334 "ti,jack-detection");
335 of_property_read_u32(node, "ti,mclk-freq",
336 &priv->mclk_freq);
337 if (!priv->mclk_freq) {
338 dev_err(&pdev->dev, "MCLK frequency not provided\n");
339 ret = -EINVAL;
340 goto err_unregister;
341 } 299 }
342
343 omap_abe_card.fully_routed = 1;
344 } else if (pdata) {
345 if (pdata->card_name) {
346 card->name = pdata->card_name;
347 } else {
348 dev_err(&pdev->dev, "Card name is not provided\n");
349 return -ENODEV;
350 }
351
352 if (pdata->has_dmic)
353 num_links = 2;
354 else
355 num_links = 1;
356
357 priv->jack_detection = pdata->jack_detection;
358 priv->mclk_freq = pdata->mclk_freq;
359 } else { 300 } else {
360 dev_err(&pdev->dev, "Missing pdata\n"); 301 num_links = 1;
361 return -ENODEV; 302 }
303
304 priv->jack_detection = of_property_read_bool(node, "ti,jack-detection");
305 of_property_read_u32(node, "ti,mclk-freq", &priv->mclk_freq);
306 if (!priv->mclk_freq) {
307 dev_err(&pdev->dev, "MCLK frequency not provided\n");
308 ret = -EINVAL;
309 goto err_unregister;
362 } 310 }
363 311
312 card->fully_routed = 1;
364 313
365 if (!priv->mclk_freq) { 314 if (!priv->mclk_freq) {
366 dev_err(&pdev->dev, "MCLK frequency missing\n"); 315 dev_err(&pdev->dev, "MCLK frequency missing\n");
diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
index 4db1f8e6e172..12e566be3793 100644
--- a/sound/soc/omap/omap-dmic.c
+++ b/sound/soc/omap/omap-dmic.c
@@ -480,15 +480,12 @@ static int asoc_dmic_probe(struct platform_device *pdev)
480 dmic->dma_data.filter_data = "up_link"; 480 dmic->dma_data.filter_data = "up_link";
481 481
482 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); 482 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
483 if (!res) { 483 dmic->io_base = devm_ioremap_resource(&pdev->dev, res);
484 dev_err(dmic->dev, "invalid memory resource\n"); 484 if (IS_ERR(dmic->io_base)) {
485 ret = -ENODEV; 485 ret = PTR_ERR(dmic->io_base);
486 goto err_put_clk; 486 goto err_put_clk;
487 } 487 }
488 488
489 dmic->io_base = devm_ioremap_resource(&pdev->dev, res);
490 if (IS_ERR(dmic->io_base))
491 return PTR_ERR(dmic->io_base);
492 489
493 ret = snd_soc_register_component(&pdev->dev, &omap_dmic_component, 490 ret = snd_soc_register_component(&pdev->dev, &omap_dmic_component,
494 &omap_dmic_dai, 1); 491 &omap_dmic_dai, 1);
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 7483efb6dc67..6c19bba23570 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -433,6 +433,11 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
433 /* Sample rate generator drives the FS */ 433 /* Sample rate generator drives the FS */
434 regs->srgr2 |= FSGM; 434 regs->srgr2 |= FSGM;
435 break; 435 break;
436 case SND_SOC_DAIFMT_CBM_CFS:
437 /* McBSP slave. FS clock as output */
438 regs->srgr2 |= FSGM;
439 regs->pcr0 |= FSXM;
440 break;
436 case SND_SOC_DAIFMT_CBM_CFM: 441 case SND_SOC_DAIFMT_CBM_CFM:
437 /* McBSP slave */ 442 /* McBSP slave */
438 break; 443 break;
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index a49dc52f8abc..90d2a7cd2563 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -480,9 +480,6 @@ static int asoc_mcpdm_probe(struct platform_device *pdev)
480 mcpdm->dma_data[1].filter_data = "up_link"; 480 mcpdm->dma_data[1].filter_data = "up_link";
481 481
482 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); 482 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
483 if (res == NULL)
484 return -ENOMEM;
485
486 mcpdm->io_base = devm_ioremap_resource(&pdev->dev, res); 483 mcpdm->io_base = devm_ioremap_resource(&pdev->dev, res);
487 if (IS_ERR(mcpdm->io_base)) 484 if (IS_ERR(mcpdm->io_base))
488 return PTR_ERR(mcpdm->io_base); 485 return PTR_ERR(mcpdm->io_base);