All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] omap-abe-twl6040: Device tree support
@ 2012-05-08 12:15 Peter Ujfalusi
  2012-05-08 12:15 ` [PATCH 1/4] ASoC: omap-abe-twl6040: Keep only one snd_soc_dai_link structure Peter Ujfalusi
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Peter Ujfalusi @ 2012-05-08 12:15 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: alsa-devel, Misael Lopez Cruz

Hello,

The following series adds device tree support for OMAP4+ based boards with
twl6040 codec.
The first three patch is for preparing the driver to be used with DT based
probing.

The dts structure used for this machine driver uses some of the features already
available in the core (thanks to the Tegra DT support).
The DAPM routing information is coming from dts.
The DAI link configuration also comes via DTS.
In order to handle the different number of PCMs (dai links) the dts file has to
tell the number of links (abe-twl6040,number-of-links) and has to contain the
same number of dai link phandle configuration in the form of:
dai-linkX,codec = <phandle to codec>;
dai-linkX,dai = <phandle to CPU dai>;

Where X is a number from 1...

In this way the driver can enumerate and fix up the dai link structure.

As an example of the dts section (SDP4430):

sound { /* ASoC */
	compatible = "ti,abe-twl6040";
	abe-twl6040,model = "SDP4430";

	abe-twl6040,jack_detection = <1>;
	abe-twl6040,mclk_freq = <38400000>;

	/* Number of DAI link connections */
	abe-twl6040,number-of-links = <2>;

	dai-link1,codec = <&twl6040_codec>;
	dai-link1,dai = <&mcpdm>;

	dai-link2,codec = <&dmic_codec>;
	dai-link2,dai = <&dmic>;

	/* Audio routing */
	abe-twl6040,audio-routing =
		"Headset Stereophone", "HSOL",
		"Headset Stereophone", "HSOR",
		"Earphone Spk", "EP",
		"Ext Spk", "HFL",
		"Ext Spk", "HFR",
		"Line Out", "AUXL",
		"Line Out", "AUXR",
		"Vibrator", "VIBRAL",
		"Vibrator", "VIBRAR",
		"HSMIC", "Headset Mic",
		"Headset Mic", "Headset Mic Bias",
		"MAINMIC", "Main Handset Mic",
		"Main Handset Mic", "Main Mic Bias",
		"SUBMIC", "Sub Handset Mic",
		"Sub Handset Mic", "Main Mic Bias",
		"AFML", "Line In",
		"AFMR", "Line In",
		"DMic", "Digital Mic",
		"Digital Mic", "Digital Mic1 Bias";
};


Regards,
Peter
---
Peter Ujfalusi (4):
  ASoC: omap-abe-twl6040: Keep only one snd_soc_dai_link structure
  ASoC: omap-abe-twl6040: Move Digital Mic widget into dapm table
  ASoC: omap-abe-twl6040: Introduce driver data for runtime parameters
  ASoC: omap-abe-twl6040: Add device tree support

 .../devicetree/bindings/sound/omap-abe-twl6040.txt |   57 ++++++
 sound/soc/omap/omap-abe-twl6040.c                  |  199 ++++++++++++++-----
 2 files changed, 203 insertions(+), 53 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/omap-abe-twl6040.txt

-- 
1.7.8.6

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] ASoC: omap-abe-twl6040: Keep only one snd_soc_dai_link structure
  2012-05-08 12:15 [PATCH 0/4] omap-abe-twl6040: Device tree support Peter Ujfalusi
@ 2012-05-08 12:15 ` Peter Ujfalusi
  2012-05-08 15:52   ` Mark Brown
  2012-05-08 12:15 ` [PATCH 2/4] ASoC: omap-abe-twl6040: Move Digital Mic widget into dapm table Peter Ujfalusi
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Peter Ujfalusi @ 2012-05-08 12:15 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: alsa-devel, Misael Lopez Cruz

There is no need to have two snd_soc_dai_link structure for the two setup
the machine driver supports.
We can just tell core to register only the first link if the DMIC link is
not in use on the device.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-abe-twl6040.c |   30 +++++++++---------------------
 1 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
index 93bb8ee..31ab6fe 100644
--- a/sound/soc/omap/omap-abe-twl6040.c
+++ b/sound/soc/omap/omap-abe-twl6040.c
@@ -235,7 +235,7 @@ static int omap_abe_dmic_init(struct snd_soc_pcm_runtime *rtd)
 }
 
 /* Digital audio interface glue - connects codec <--> CPU */
-static struct snd_soc_dai_link twl6040_dmic_dai[] = {
+static struct snd_soc_dai_link abe_twl6040_dai_links[] = {
 	{
 		.name = "TWL6040",
 		.stream_name = "TWL6040",
@@ -258,19 +258,6 @@ static struct snd_soc_dai_link twl6040_dmic_dai[] = {
 	},
 };
 
-static struct snd_soc_dai_link twl6040_only_dai[] = {
-	{
-		.name = "TWL6040",
-		.stream_name = "TWL6040",
-		.cpu_dai_name = "omap-mcpdm",
-		.codec_dai_name = "twl6040-legacy",
-		.platform_name = "omap-pcm-audio",
-		.codec_name = "twl6040-codec",
-		.init = omap_abe_twl6040_init,
-		.ops = &omap_abe_ops,
-	},
-};
-
 /* Audio machine driver */
 static struct snd_soc_card omap_abe_card = {
 	.owner = THIS_MODULE,
@@ -285,6 +272,7 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
 {
 	struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev);
 	struct snd_soc_card *card = &omap_abe_card;
+	int num_links = 0;
 	int ret;
 
 	card->dev = &pdev->dev;
@@ -306,13 +294,13 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	if (pdata->has_dmic) {
-		card->dai_link = twl6040_dmic_dai;
-		card->num_links = ARRAY_SIZE(twl6040_dmic_dai);
-	} else {
-		card->dai_link = twl6040_only_dai;
-		card->num_links = ARRAY_SIZE(twl6040_only_dai);
-	}
+	if (pdata->has_dmic)
+		num_links = 2;
+	else
+		num_links = 1;
+
+	card->dai_link = abe_twl6040_dai_links;
+	card->num_links = num_links;
 
 	ret = snd_soc_register_card(card);
 	if (ret)
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] ASoC: omap-abe-twl6040: Move Digital Mic widget into dapm table
  2012-05-08 12:15 [PATCH 0/4] omap-abe-twl6040: Device tree support Peter Ujfalusi
  2012-05-08 12:15 ` [PATCH 1/4] ASoC: omap-abe-twl6040: Keep only one snd_soc_dai_link structure Peter Ujfalusi
@ 2012-05-08 12:15 ` Peter Ujfalusi
  2012-05-08 18:30   ` Mark Brown
  2012-05-08 12:15 ` [PATCH 3/4] ASoC: omap-abe-twl6040: Introduce driver data for runtime parameters Peter Ujfalusi
  2012-05-08 12:15 ` [PATCH 4/4] ASoC: omap-abe-twl6040: Add device tree support Peter Ujfalusi
  3 siblings, 1 reply; 11+ messages in thread
From: Peter Ujfalusi @ 2012-05-08 12:15 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: alsa-devel, Misael Lopez Cruz

The needed change in routing will be done runtime for the non
twl6040 connected widgets, like the Digital microphone.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-abe-twl6040.c |   13 +++----------
 1 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
index 31ab6fe..4388de9 100644
--- a/sound/soc/omap/omap-abe-twl6040.c
+++ b/sound/soc/omap/omap-abe-twl6040.c
@@ -128,6 +128,9 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = {
 	SND_SOC_DAPM_MIC("Main Handset Mic", NULL),
 	SND_SOC_DAPM_MIC("Sub Handset Mic", NULL),
 	SND_SOC_DAPM_LINE("Line In", NULL),
+
+	/* Digital microphones */
+	SND_SOC_DAPM_MIC("Digital Mic", NULL),
 };
 
 static const struct snd_soc_dapm_route audio_map[] = {
@@ -210,10 +213,6 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
 	return ret;
 }
 
-static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = {
-	SND_SOC_DAPM_MIC("Digital Mic", NULL),
-};
-
 static const struct snd_soc_dapm_route dmic_audio_map[] = {
 	{"DMic", NULL, "Digital Mic"},
 	{"Digital Mic", NULL, "Digital Mic1 Bias"},
@@ -223,12 +222,6 @@ static int omap_abe_dmic_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_dapm_context *dapm = &codec->dapm;
-	int ret;
-
-	ret = snd_soc_dapm_new_controls(dapm, dmic_dapm_widgets,
-				ARRAY_SIZE(dmic_dapm_widgets));
-	if (ret)
-		return ret;
 
 	return snd_soc_dapm_add_routes(dapm, dmic_audio_map,
 				ARRAY_SIZE(dmic_audio_map));
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] ASoC: omap-abe-twl6040: Introduce driver data for runtime parameters
  2012-05-08 12:15 [PATCH 0/4] omap-abe-twl6040: Device tree support Peter Ujfalusi
  2012-05-08 12:15 ` [PATCH 1/4] ASoC: omap-abe-twl6040: Keep only one snd_soc_dai_link structure Peter Ujfalusi
  2012-05-08 12:15 ` [PATCH 2/4] ASoC: omap-abe-twl6040: Move Digital Mic widget into dapm table Peter Ujfalusi
@ 2012-05-08 12:15 ` Peter Ujfalusi
  2012-05-08 18:31   ` Mark Brown
  2012-05-08 12:15 ` [PATCH 4/4] ASoC: omap-abe-twl6040: Add device tree support Peter Ujfalusi
  3 siblings, 1 reply; 11+ messages in thread
From: Peter Ujfalusi @ 2012-05-08 12:15 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: alsa-devel, Misael Lopez Cruz

In preparation to Device Tree support.
With DT booted kernel we can not rely on pdata which used to
hold information needed for the driver at runtime.
Use the card's driver data to hold these informations from now on.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/omap-abe-twl6040.c |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
index 4388de9..9d93793 100644
--- a/sound/soc/omap/omap-abe-twl6040.c
+++ b/sound/soc/omap/omap-abe-twl6040.c
@@ -40,6 +40,11 @@
 #include "omap-pcm.h"
 #include "../codecs/twl6040.h"
 
+struct abe_twl6040 {
+	int	jack_detection;	/* board can detect jack events */
+	int	mclk_freq;	/* MCLK frequency speed for twl6040 */
+};
+
 static int omap_abe_hw_params(struct snd_pcm_substream *substream,
 	struct snd_pcm_hw_params *params)
 {
@@ -47,13 +52,13 @@ static int omap_abe_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_card *card = codec->card;
-	struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev);
+	struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card);
 	int clk_id, freq;
 	int ret;
 
 	clk_id = twl6040_get_clk_id(rtd->codec);
 	if (clk_id == TWL6040_SYSCLK_SEL_HPPLL)
-		freq = pdata->mclk_freq;
+		freq = priv->mclk_freq;
 	else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL)
 		freq = 32768;
 	else
@@ -176,6 +181,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
 	struct snd_soc_card *card = codec->card;
 	struct snd_soc_dapm_context *dapm = &codec->dapm;
 	struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev);
+	struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card);
 	int hs_trim;
 	int ret = 0;
 
@@ -199,7 +205,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
 					TWL6040_HSF_TRIM_RIGHT(hs_trim));
 
 	/* Headset jack detection only if it is supported */
-	if (pdata->jack_detection) {
+	if (priv->jack_detection) {
 		ret = snd_soc_jack_new(codec, "Headset Jack",
 					SND_JACK_HEADSET, &hs_jack);
 		if (ret)
@@ -265,6 +271,7 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
 {
 	struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev);
 	struct snd_soc_card *card = &omap_abe_card;
+	struct abe_twl6040 *priv;
 	int num_links = 0;
 	int ret;
 
@@ -275,6 +282,10 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	priv = devm_kzalloc(&pdev->dev, sizeof(struct abe_twl6040), GFP_KERNEL);
+	if (priv == NULL)
+		return -ENOMEM;
+
 	if (pdata->card_name) {
 		card->name = pdata->card_name;
 	} else {
@@ -282,7 +293,11 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	if (!pdata->mclk_freq) {
+	priv->jack_detection = pdata->jack_detection;
+	priv->mclk_freq = pdata->mclk_freq;
+
+
+	if (!priv->mclk_freq) {
 		dev_err(&pdev->dev, "MCLK frequency missing\n");
 		return -ENODEV;
 	}
@@ -295,6 +310,8 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
 	card->dai_link = abe_twl6040_dai_links;
 	card->num_links = num_links;
 
+	snd_soc_card_set_drvdata(card, priv);
+
 	ret = snd_soc_register_card(card);
 	if (ret)
 		dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] ASoC: omap-abe-twl6040: Add device tree support
  2012-05-08 12:15 [PATCH 0/4] omap-abe-twl6040: Device tree support Peter Ujfalusi
                   ` (2 preceding siblings ...)
  2012-05-08 12:15 ` [PATCH 3/4] ASoC: omap-abe-twl6040: Introduce driver data for runtime parameters Peter Ujfalusi
@ 2012-05-08 12:15 ` Peter Ujfalusi
  2012-05-08 13:59   ` Mark Brown
  3 siblings, 1 reply; 11+ messages in thread
From: Peter Ujfalusi @ 2012-05-08 12:15 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: alsa-devel, Misael Lopez Cruz

When the board boots with device tree the driver will receive the name of
the card, DAPM routing map, number of DAI links, the DAI link connections,
mclk speed, and the possibility of detecting the jack detection.

The card will be set up based on this information.
Since the routing is provided via DT we can mark the card fully routed so
core can take care of disconnecting the unused pins.

Example of dts section for audio support:

sound: sound { /* ASoC */
	compatible = "ti,abe-twl6040";
	abe-twl6040,model = "PandaBoard";

	abe-twl6040,jack_detection = <0>;
	abe-twl6040,mclk_freq = <38400000>;

	/* Number of DAI link connections */
	abe-twl6040,number-of-links = <1>;

	dai-link1,codec = <&twl6040_codec>;
	dai-link1,dai = <&mcpdm>;

	/* Audio routing */
	abe-twl6040,audio-routing =
		"Headset Stereophone", "HSOL",
		"Headset Stereophone", "HSOR",
		"Ext Spk", "HFL",
		"Ext Spk", "HFR",
		"Line Out", "AUXL",
		"Line Out", "AUXR",
		"HSMIC", "Headset Mic",
		"Headset Mic", "Headset Mic Bias",
		"AFML", "Line In",
		"AFMR", "Line In";
};

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 .../devicetree/bindings/sound/omap-abe-twl6040.txt |   57 ++++++++
 sound/soc/omap/omap-abe-twl6040.c                  |  149 ++++++++++++++++----
 2 files changed, 179 insertions(+), 27 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/omap-abe-twl6040.txt

diff --git a/Documentation/devicetree/bindings/sound/omap-abe-twl6040.txt b/Documentation/devicetree/bindings/sound/omap-abe-twl6040.txt
new file mode 100644
index 0000000..80eddb3
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/omap-abe-twl6040.txt
@@ -0,0 +1,57 @@
+* Texas Instruments OMAP4+ and twl6040 based audio setups
+
+Required properties:
+- compatible: "ti,abe-twl6040"
+- abe-twl6040,model: Name of the sound card ( for example "SDP4430")
+- abe-twl6040,mclk_freq: MCLK frequency for HPPLL operation
+- abe-twl6040,number-of-links: Number of dai links on the card
+- dai-linkX,codec: phandle for the codec on dai link X (X = 1, 2, ...)
+- dai-linkX,dai: phandle for the CPU dai on dai link X (X = 1, 2, ...)
+- abe-twl6040,audio-routing: List of connections between audio components.
+  Each entry is a pair of strings, the first being the connection's sink,
+  the second being the connection's source.
+
+Optional properties:
+- abe-twl6040,jack_detection: Need to be set to <1> if the board capable to
+  detect jack insertion, removal.
+
+Example:
+
+sound { /* ASoC */
+	compatible = "ti,abe-twl6040";
+	abe-twl6040,model = "SDP4430";
+
+	abe-twl6040,jack_detection = <1>;
+	abe-twl6040,mclk_freq = <38400000>;
+
+	/* Number of DAI link connections */
+	abe-twl6040,number-of-links = <2>;
+
+	dai-link1,codec = <&twl6040_codec>;
+	dai-link1,dai = <&mcpdm>;
+
+	dai-link2,codec = <&dmic_codec>;
+	dai-link2,dai = <&dmic>;
+
+	/* Audio routing */
+	abe-twl6040,audio-routing =
+		"Headset Stereophone", "HSOL",
+		"Headset Stereophone", "HSOR",
+		"Earphone Spk", "EP",
+		"Ext Spk", "HFL",
+		"Ext Spk", "HFR",
+		"Line Out", "AUXL",
+		"Line Out", "AUXR",
+		"Vibrator", "VIBRAL",
+		"Vibrator", "VIBRAR",
+		"HSMIC", "Headset Mic",
+		"Headset Mic", "Headset Mic Bias",
+		"MAINMIC", "Main Handset Mic",
+		"Main Handset Mic", "Main Mic Bias",
+		"SUBMIC", "Sub Handset Mic",
+		"Sub Handset Mic", "Main Mic Bias",
+		"AFML", "Line In",
+		"AFMR", "Line In",
+		"DMic", "Digital Mic",
+		"Digital Mic", "Digital Mic1 Bias";
+};
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
index 9d93793..f0aeda0 100644
--- a/sound/soc/omap/omap-abe-twl6040.c
+++ b/sound/soc/omap/omap-abe-twl6040.c
@@ -25,6 +25,7 @@
 #include <linux/mfd/twl6040.h>
 #include <linux/platform_data/omap-abe-twl6040.h>
 #include <linux/module.h>
+#include <linux/of.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -185,17 +186,6 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
 	int hs_trim;
 	int ret = 0;
 
-	/* Disable not connected paths if not used */
-	twl6040_disconnect_pin(dapm, pdata->has_hs, "Headset Stereophone");
-	twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk");
-	twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk");
-	twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out");
-	twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vinrator");
-	twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic");
-	twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic");
-	twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic");
-	twl6040_disconnect_pin(dapm, pdata->has_afm, "Line In");
-
 	/*
 	 * Configure McPDM offset cancellation based on the HSOTRIM value from
 	 * twl6040.
@@ -216,6 +206,24 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
 		twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
 	}
 
+	/*
+	 * NULL pdata means we booted with DT. In this case the routing is
+	 * provided and the card is fully routed, no need to mark pins.
+	 */
+	if (!pdata)
+		return ret;
+
+	/* Disable not connected paths if not used */
+	twl6040_disconnect_pin(dapm, pdata->has_hs, "Headset Stereophone");
+	twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk");
+	twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk");
+	twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out");
+	twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vinrator");
+	twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic");
+	twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic");
+	twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic");
+	twl6040_disconnect_pin(dapm, pdata->has_afm, "Line In");
+
 	return ret;
 }
 
@@ -267,9 +275,49 @@ static struct snd_soc_card omap_abe_card = {
 	.num_dapm_routes = ARRAY_SIZE(audio_map),
 };
 
+inline const struct device_node *omap_abe_of_get_node(
+	struct snd_soc_card *card, int id, char *component)
+{
+	struct device_node *node;
+	char property[64];
+
+	snprintf(property, sizeof(property), "dai-link%d,%s", id, component);
+
+	node = of_parse_phandle(card->dev->of_node, property, 0);
+	if (!node)
+		dev_err(card->dev, "Invalid property: %s\n", property);
+
+	return node;
+}
+
+static __devinit int omap_abe_of_get_link_config(struct snd_soc_card *card,
+						int count)
+{
+	int i;
+
+	for (i = 0; i < count; i++) {
+		abe_twl6040_dai_links[i].codec_name = NULL;
+		abe_twl6040_dai_links[i].codec_of_node = omap_abe_of_get_node(
+							card, i + 1, "codec");
+		if (!abe_twl6040_dai_links[i].codec_of_node)
+			return -EINVAL;
+
+		abe_twl6040_dai_links[i].cpu_dai_name = NULL;
+		abe_twl6040_dai_links[i].cpu_dai_of_node = omap_abe_of_get_node(
+							card, i + 1, "dai");
+		if (!abe_twl6040_dai_links[i].cpu_dai_of_node)
+			return -EINVAL;
+
+		if (i)
+			abe_twl6040_dai_links[i].init = NULL;
+	}
+	return 0;
+}
+
 static __devinit int omap_abe_probe(struct platform_device *pdev)
 {
 	struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev);
+	struct device_node *node = pdev->dev.of_node;
 	struct snd_soc_card *card = &omap_abe_card;
 	struct abe_twl6040 *priv;
 	int num_links = 0;
@@ -277,36 +325,76 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
 
 	card->dev = &pdev->dev;
 
-	if (!pdata) {
-		dev_err(&pdev->dev, "Missing pdata\n");
-		return -ENODEV;
-	}
-
 	priv = devm_kzalloc(&pdev->dev, sizeof(struct abe_twl6040), GFP_KERNEL);
 	if (priv == NULL)
 		return -ENOMEM;
 
-	if (pdata->card_name) {
-		card->name = pdata->card_name;
+	if (node) {
+		if (snd_soc_of_parse_card_name(card, "abe-twl6040,model")) {
+			dev_err(&pdev->dev, "Card name is not provided\n");
+			return -ENODEV;
+		}
+
+		ret = snd_soc_of_parse_audio_routing(card,
+						"abe-twl6040,audio-routing");
+		if (ret) {
+			dev_err(&pdev->dev,
+				"Error while parsing DAPM routing\n");
+			return -EINVAL;
+		}
+
+		of_property_read_u32(node, "abe-twl6040,number-of-links",
+				     &num_links);
+		if (num_links <= 0 ||
+		    num_links > ARRAY_SIZE(abe_twl6040_dai_links)) {
+			dev_err(&pdev->dev, "Invalid number of links: %d\n",
+				num_links);
+			return -EINVAL;
+		}
+
+		ret = omap_abe_of_get_link_config(card, num_links);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"Failed to get link configuration\n");
+			return -EINVAL;
+		}
+
+		of_property_read_u32(node, "abe-twl6040,jack_detection",
+				     &priv->jack_detection);
+		of_property_read_u32(node, "abe-twl6040,mclk_freq",
+				     &priv->mclk_freq);
+		if (!priv->mclk_freq) {
+			dev_err(&pdev->dev, "MCLK frequency not provided\n");
+			return -EINVAL;
+		}
+
+		omap_abe_card.fully_routed = 1;
+	} else if (pdata) {
+		if (pdata->card_name) {
+			card->name = pdata->card_name;
+		} else {
+			dev_err(&pdev->dev, "Card name is not provided\n");
+			return -ENODEV;
+		}
+
+		if (pdata->has_dmic)
+			num_links = 2;
+		else
+			num_links = 1;
+
+		priv->jack_detection = pdata->jack_detection;
+		priv->mclk_freq = pdata->mclk_freq;
 	} else {
-		dev_err(&pdev->dev, "Card name is not provided\n");
+		dev_err(&pdev->dev, "Missing pdata\n");
 		return -ENODEV;
 	}
 
-	priv->jack_detection = pdata->jack_detection;
-	priv->mclk_freq = pdata->mclk_freq;
-
 
 	if (!priv->mclk_freq) {
 		dev_err(&pdev->dev, "MCLK frequency missing\n");
 		return -ENODEV;
 	}
 
-	if (pdata->has_dmic)
-		num_links = 2;
-	else
-		num_links = 1;
-
 	card->dai_link = abe_twl6040_dai_links;
 	card->num_links = num_links;
 
@@ -329,11 +417,18 @@ static int __devexit omap_abe_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct of_device_id omap_abe_of_match[] = {
+	{.compatible = "ti,abe-twl6040", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, omap_abe_of_match);
+
 static struct platform_driver omap_abe_driver = {
 	.driver = {
 		.name = "omap-abe-twl6040",
 		.owner = THIS_MODULE,
 		.pm = &snd_soc_pm_ops,
+		.of_match_table = omap_abe_of_match,
 	},
 	.probe = omap_abe_probe,
 	.remove = __devexit_p(omap_abe_remove),
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] ASoC: omap-abe-twl6040: Add device tree support
  2012-05-08 12:15 ` [PATCH 4/4] ASoC: omap-abe-twl6040: Add device tree support Peter Ujfalusi
@ 2012-05-08 13:59   ` Mark Brown
  2012-05-09 11:45     ` Peter Ujfalusi
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Brown @ 2012-05-08 13:59 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, Liam Girdwood, Misael Lopez Cruz


[-- Attachment #1.1: Type: text/plain, Size: 900 bytes --]

On Tue, May 08, 2012 at 03:15:14PM +0300, Peter Ujfalusi wrote:

> 	abe-twl6040,jack_detection = <0>;

Shouldn't this be a boolean property that simply needs to be present to
flag detection?

> 	dai-link1,codec = <&twl6040_codec>;
> 	dai-link1,dai = <&mcpdm>;

This seems like it ought to be an array of nodes, one per link, instead
of having an index in the property name.  It should certainly be easier
to parse.

It also seems like it's not at all board specific and should be factored
out.

> 	abe-twl6040,audio-routing =
> 		"Headset Stereophone", "HSOL",
> 		"Headset Stereophone", "HSOR",

Binding should document what the board-defined nodes are.

> +Example:
> +
> +sound { /* ASoC */
> +	compatible = "ti,abe-twl6040";
> +	abe-twl6040,model = "SDP4430";

Please don't repeat your binding documentation in the changelog, it's
already in the patch and means it comes after the documentation.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] ASoC: omap-abe-twl6040: Keep only one snd_soc_dai_link structure
  2012-05-08 12:15 ` [PATCH 1/4] ASoC: omap-abe-twl6040: Keep only one snd_soc_dai_link structure Peter Ujfalusi
@ 2012-05-08 15:52   ` Mark Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2012-05-08 15:52 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, Liam Girdwood, Misael Lopez Cruz


[-- Attachment #1.1: Type: text/plain, Size: 335 bytes --]

On Tue, May 08, 2012 at 03:15:11PM +0300, Peter Ujfalusi wrote:
> There is no need to have two snd_soc_dai_link structure for the two setup
> the machine driver supports.
> We can just tell core to register only the first link if the DMIC link is
> not in use on the device.

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] ASoC: omap-abe-twl6040: Move Digital Mic widget into dapm table
  2012-05-08 12:15 ` [PATCH 2/4] ASoC: omap-abe-twl6040: Move Digital Mic widget into dapm table Peter Ujfalusi
@ 2012-05-08 18:30   ` Mark Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2012-05-08 18:30 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, Liam Girdwood, Misael Lopez Cruz


[-- Attachment #1.1: Type: text/plain, Size: 246 bytes --]

On Tue, May 08, 2012 at 03:15:12PM +0300, Peter Ujfalusi wrote:
> The needed change in routing will be done runtime for the non
> twl6040 connected widgets, like the Digital microphone.

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] ASoC: omap-abe-twl6040: Introduce driver data for runtime parameters
  2012-05-08 12:15 ` [PATCH 3/4] ASoC: omap-abe-twl6040: Introduce driver data for runtime parameters Peter Ujfalusi
@ 2012-05-08 18:31   ` Mark Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2012-05-08 18:31 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, Liam Girdwood, Misael Lopez Cruz


[-- Attachment #1.1: Type: text/plain, Size: 350 bytes --]

On Tue, May 08, 2012 at 03:15:13PM +0300, Peter Ujfalusi wrote:
> In preparation to Device Tree support.
> With DT booted kernel we can not rely on pdata which used to
> hold information needed for the driver at runtime.
> Use the card's driver data to hold these informations from now on.

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] ASoC: omap-abe-twl6040: Add device tree support
  2012-05-08 13:59   ` Mark Brown
@ 2012-05-09 11:45     ` Peter Ujfalusi
  2012-05-09 15:59       ` Mark Brown
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Ujfalusi @ 2012-05-09 11:45 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, Liam Girdwood, Misael Lopez Cruz

On 05/08/2012 04:59 PM, Mark Brown wrote:
> On Tue, May 08, 2012 at 03:15:14PM +0300, Peter Ujfalusi wrote:
> 
>> 	abe-twl6040,jack_detection = <0>;
> 
> Shouldn't this be a boolean property that simply needs to be present to
> flag detection?

It does work like that as well. This property only need to be there (and
to be set to 1) if the board can detect the jack.

> 
>> 	dai-link1,codec = <&twl6040_codec>;
>> 	dai-link1,dai = <&mcpdm>;
> 
> This seems like it ought to be an array of nodes, one per link, instead
> of having an index in the property name.  It should certainly be easier
> to parse.

Very true. We can handle this in a similar way as we handle the
routings. It might be a good idea to add this as a generic ASoC core
feature?

Something like:
abe-twl6040,dai-link =
		<&twl6040_codec>, <&mcpdm>;

Other platforms could use this and we could handle it with the same code
in the core.

> It also seems like it's not at all board specific and should be factored
> out.
> 
>> 	abe-twl6040,audio-routing =
>> 		"Headset Stereophone", "HSOL",
>> 		"Headset Stereophone", "HSOR",
> 
> Binding should document what the board-defined nodes are.

OK, I'll update the documentation (also covering the codec)

> 
>> +Example:
>> +
>> +sound { /* ASoC */
>> +	compatible = "ti,abe-twl6040";
>> +	abe-twl6040,model = "SDP4430";
> 
> Please don't repeat your binding documentation in the changelog, it's
> already in the patch and means it comes after the documentation.

OK, I'll remove the examples from the changelog.

-- 
Péter

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] ASoC: omap-abe-twl6040: Add device tree support
  2012-05-09 11:45     ` Peter Ujfalusi
@ 2012-05-09 15:59       ` Mark Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2012-05-09 15:59 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, Liam Girdwood, Misael Lopez Cruz


[-- Attachment #1.1: Type: text/plain, Size: 571 bytes --]

On Wed, May 09, 2012 at 02:45:17PM +0300, Peter Ujfalusi wrote:
> On 05/08/2012 04:59 PM, Mark Brown wrote:

> > This seems like it ought to be an array of nodes, one per link, instead
> > of having an index in the property name.  It should certainly be easier
> > to parse.

> Very true. We can handle this in a similar way as we handle the
> routings. It might be a good idea to add this as a generic ASoC core
> feature?

Yes, that'd be great.  Something like how the routing is done, with an
optional library thing that machine drivers can include in their
bindings.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-05-09 16:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-08 12:15 [PATCH 0/4] omap-abe-twl6040: Device tree support Peter Ujfalusi
2012-05-08 12:15 ` [PATCH 1/4] ASoC: omap-abe-twl6040: Keep only one snd_soc_dai_link structure Peter Ujfalusi
2012-05-08 15:52   ` Mark Brown
2012-05-08 12:15 ` [PATCH 2/4] ASoC: omap-abe-twl6040: Move Digital Mic widget into dapm table Peter Ujfalusi
2012-05-08 18:30   ` Mark Brown
2012-05-08 12:15 ` [PATCH 3/4] ASoC: omap-abe-twl6040: Introduce driver data for runtime parameters Peter Ujfalusi
2012-05-08 18:31   ` Mark Brown
2012-05-08 12:15 ` [PATCH 4/4] ASoC: omap-abe-twl6040: Add device tree support Peter Ujfalusi
2012-05-08 13:59   ` Mark Brown
2012-05-09 11:45     ` Peter Ujfalusi
2012-05-09 15:59       ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.