Skip to contentSkip to conversation

Add device tree support of audio codec (ALC5632) on PAZ00 board

PATCH Applied Leon Romanovsky 6 participants 15 messages Feb 2, 2012 – Feb 7, 2012 9 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Add device tree support of audio codec (ALC5632) on PAZ00 board

The following patchset is going to:
* add device tree support of audio codec (ALC5632) on PAZ00 board.
* enable headset autodetection via device tree.
* enable headset microphone via device tree.

Leon Romanovsky (4):
ARM: dt: tegra: Enable device tree audio codec on PAZ00 board.
ARM: dt: tegra: Enable headset autodetection on PAZ00 board.
ASoC: Tegra+ALC5632: Enable headset autodetection on PAZ00 board.
ASoC: tegra: Remove unused DAPM route structure.

 arch/arm/boot/dts/tegra-paz00.dts |   30 ++++++++++++++++----
 sound/soc/tegra/tegra_alc5632.c   |   55 +++++++++++++++++++++++-------------
 2 files changed, 59 insertions(+), 26 deletions(-)

---
Chages since v1:
* Headset autodetection commit was split tp be two independant commits.
* Main commit(enable device tree audio codec) was forgotten in previous patchset.

Signature · 1 line
1.7.3.4
#2 lore raw

PATCH v2 1/4 ARM: dt: tegra: Enable device tree audio codec on PAZ00 board.

In reply to a message not in the archive

This patch adds initial device tree support of ALC5632 sound codec and machine driver for PAZ00 board. The implementation is based on the WM8903 codec.

---
 arch/arm/boot/dts/tegra-paz00.dts |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)
arch/arm/boot/dts/tegra-paz00.dts +23 -6
index 4d1bcdc..e6809b7 100644
@@ -12,6 +12,13 @@
 
 	i2c@7000c000 {
 		clock-frequency = <400000>;
+
+		alc5632: alc5632@1e {
+			compatible = "realtek,alc5632";
+			reg = <0x1e>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
 	};
 
 	i2c@7000c400 {
@@ -37,16 +44,26 @@
 		clock-frequency = <400000>;
 	};
 
-	i2s@70002800 {
-		status = "disable";
-	};
-
 	i2s@70002a00 {
 		status = "disable";
 	};
 
-	das@70000c00 {
-		status = "disable";
+	sound {
+		compatible = "nvidia,tegra-audio-alc5632-paz00",
+			"nvidia,tegra-audio-alc5632";
+
+		nvidia,model = "Compal PAZ00";
+
+		nvidia,audio-routing =
+			"Int Spk", "SPKOUT",
+			"Int Spk", "SPKOUTN",
+			"Headset Mic", "MICBIAS1",
+			"MIC1", "Headset Mic",
+			"Headset Stereophone", "HPR",
+			"Headset Stereophone", "HPL";
+
+		nvidia,audio-codec = <&alc5632>;
+		nvidia,i2s-controller = <&tegra_i2s1>;
 	};
 
 	serial@70006000 {
Signature · 1 line
1.7.3.4
#6 lore raw

PATCH v2 2/4 ARM: dt: tegra: Enable headset autodetection on PAZ00 board.

In reply to a message not in the archive

This patch is adding device tree support of headset autodetection on PAZ00 board.

---
 arch/arm/boot/dts/tegra-paz00.dts |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/boot/dts/tegra-paz00.dts +1 -0
index e6809b7..fa9dd9e 100644
@@ -64,6 +64,7 @@
 
 		nvidia,audio-codec = <&alc5632>;
 		nvidia,i2s-controller = <&tegra_i2s1>;
+		nvidia,hp-det-gpios = <&gpio 178 0>; /* gpio PW2 */
 	};
 
 	serial@70006000 {
Signature · 1 line
1.7.3.4
#17 lore raw

PATCH v2 3/4 ASoC: Tegra+ALC5632: Enable headset autodetection on PAZ00 board.

In reply to a message not in the archive

This patch is adding device tree support of headset autodetection on PAZ00 board.

---
 sound/soc/tegra/tegra_alc5632.c |   39 +++++++++++++++++++++++++++++++++++----
 1 files changed, 35 insertions(+), 4 deletions(-)
sound/soc/tegra/tegra_alc5632.c +35 -4
index c0ba1e4..1794139 100644
@@ -18,6 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/gpio.h>
+#include <linux/of_gpio.h>
 
 #include <sound/core.h>
 #include <sound/jack.h>
@@ -34,9 +35,13 @@
 
 #define DRV_NAME "tegra-alc5632"
 
+#define GPIO_HP_DET     BIT(0)
+
 struct tegra_alc5632 {
 	struct tegra_asoc_utils_data util_data;
 	struct platform_device *pcm_dev;
+	int gpio_requested;
+	int gpio_hp_det;
 };
 
 static int tegra_alc5632_asoc_hw_params(struct snd_pcm_substream *substream,
@@ -86,6 +91,13 @@ static struct snd_soc_jack_pin tegra_alc5632_hs_jack_pins[] = {
 	},
 };
 
+static struct snd_soc_jack_gpio tegra_alc5632_hp_jack_gpio = {
+	.name = "Headset detection",
+	.report = SND_JACK_HEADSET,
+	.debounce_time = 150,
+	.invert = 1,
+};
+
 static const struct snd_soc_dapm_widget tegra_alc5632_dapm_widgets[] = {
 	SND_SOC_DAPM_SPK("Int Spk", NULL),
 	SND_SOC_DAPM_HP("Headset Stereophone", NULL),
@@ -114,6 +126,9 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_dapm_context *dapm = &codec->dapm;
+	struct device_node *np = codec->card->dev->of_node;
+	struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(codec->card);
+	int ret;
 
 	snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET,
 			 &tegra_alc5632_hs_jack);
@@ -121,6 +136,16 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd)
 			ARRAY_SIZE(tegra_alc5632_hs_jack_pins),
 			tegra_alc5632_hs_jack_pins);
 
+	machine->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0);
+
+	if (gpio_is_valid(machine->gpio_hp_det)) {
+		tegra_alc5632_hp_jack_gpio.gpio = machine->gpio_hp_det;
+		snd_soc_jack_add_gpios(&tegra_alc5632_hs_jack,
+						1,
+						&tegra_alc5632_hp_jack_gpio);
+		machine->gpio_requested |= GPIO_HP_DET;
+	}
+
 	snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1");
 
 	return 0;
@@ -239,13 +264,19 @@ err:
 static int __devexit tegra_alc5632_remove(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = platform_get_drvdata(pdev);
-	struct tegra_alc5632 *alc5632 = snd_soc_card_get_drvdata(card);
+	struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card);
+
+	if (machine->gpio_requested & GPIO_HP_DET)
+		snd_soc_jack_free_gpios(&tegra_alc5632_hs_jack,
+					1,
+					&tegra_alc5632_hp_jack_gpio);
+	machine->gpio_requested = 0;
 
 	snd_soc_unregister_card(card);
 
-	tegra_asoc_utils_fini(&alc5632->util_data);
-	if (!IS_ERR(alc5632->pcm_dev))
-		platform_device_unregister(alc5632->pcm_dev);
+	tegra_asoc_utils_fini(&machine->util_data);
+	if (!IS_ERR(machine->pcm_dev))
+		platform_device_unregister(machine->pcm_dev);
 
 	return 0;
 }
Signature · 1 line
1.7.3.4
#21 lore raw

PATCH v2 4/4 ASoC: tegra: Remove unused DAPM route structure.

In reply to a message not in the archive

All DAPM routes are configured via device tree, and there is no need in DAPM route structures in board file.

---
 sound/soc/tegra/tegra_alc5632.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)
sound/soc/tegra/tegra_alc5632.c +0 -16
index 1794139..c000f51 100644
@@ -104,20 +104,6 @@ static const struct snd_soc_dapm_widget tegra_alc5632_dapm_widgets[] = {
 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
 };
 
-static const struct snd_soc_dapm_route tegra_alc5632_audio_map[] = {
-	/* Internal Speaker */
-	{"Int Spk", NULL, "SPKOUT"},
-	{"Int Spk", NULL, "SPKOUTN"},
-
-	/* Headset Mic */
-	{"MIC1", NULL, "MICBIAS1"},
-	{"MICBIAS1", NULL, "Headset Mic"},
-
-	/* Headset Stereophone */
-	{"Headset Stereophone", NULL, "HPR"},
-	{"Headset Stereophone", NULL, "HPL"},
-};
-
 static const struct snd_kcontrol_new tegra_alc5632_controls[] = {
 	SOC_DAPM_PIN_SWITCH("Int Spk"),
 };
@@ -172,8 +158,6 @@ static struct snd_soc_card snd_soc_tegra_alc5632 = {
 	.num_controls = ARRAY_SIZE(tegra_alc5632_controls),
 	.dapm_widgets = tegra_alc5632_dapm_widgets,
 	.num_dapm_widgets = ARRAY_SIZE(tegra_alc5632_dapm_widgets),
-	.dapm_routes = tegra_alc5632_audio_map,
-	.num_dapm_routes = ARRAY_SIZE(tegra_alc5632_audio_map),
 	.fully_routed = true,
 };
 
Signature · 1 line
1.7.3.4
Acked-by on v2 1/4
#3 lore raw

Re: [PATCH v2 1/4] ARM: dt: tegra: Enable device tree audio codec on PAZ00 board.

In reply to Leon Romanovsky

Leon Romanovsky wrote at Thursday, February 02, 2012 1:14 PM:

Quoted 2 lines

This patch adds initial device tree support of ALC5632 sound codec and machine driver for PAZ00 board. The implementation is based on the WM8903 codec.

This patch description seems a little unclear, since this is just adding the .dts changes to instantiate the drivers that already support DT, and mentioning WM8903 is a little confusing, since that's more relevant to the commit where you wrote the binding docs and implemented the driver changes.

Aside from that, the series,

Signature · 1 line
nvpublic
Reviewed-by
#5 lore raw

Re: [PATCH v2 1/4] ARM: dt: tegra: Enable device tree audio codec on PAZ00 board.

In reply to a message not in the archive
Quoted 2 lines · Leon Romanovsky

This patch adds initial device tree support of ALC5632 sound codec and machine driver for PAZ00 board. The implementation is based on the WM8903 codec.

No direct dependencies on any ASoC stuff so I guess it's easier if this goes via the Tegra tree. I'm happy to apply it to ASoC if people would prefer that.

Applied
#18 lore raw

Re: [PATCH v2 3/4] ASoC: Tegra+ALC5632: Enable headset autodetection on PAZ00 board.

In reply to Leon Romanovsky
Quoted 1 line · Leon Romanovsky

This patch is adding device tree support of headset autodetection on PAZ00 board.

Applied, thanks. I wonder if we ought to have a standard binding for GPIO based headset detect... can be tricky, though, when it gets integrated with more advanced mechanisms.

Applied
#23 lore raw

Re: [PATCH v2 4/4] ASoC: tegra: Remove unused DAPM route structure.

In reply to a message not in the archive
Quoted 2 lines · Leon Romanovsky

All DAPM routes are configured via device tree, and there is no need in DAPM route structures in board file.

Applied, thanks.

#20 lore raw

Re: [alsa-devel] [PATCH v2 3/4] ASoC: Tegra+ALC5632: Enable headsetautodetection on PAZ00 board.

In reply to a message not in the archive
Quoted 6 lines · On Thursday 02 February 2012 22:44:02 Mark Brown wrote:
Quoted 2 lines · Leon Romanovsky

This patch is adding device tree support of headset autodetection on PAZ00 board.

Applied, thanks. I wonder if we ought to have a standard binding for GPIO based headset detect... can be tricky, though, when it gets integrated with more advanced mechanisms.

arrr, I was too slow. Small nit below.

Quoted 62 lines
(quoted diff) +0 -0

b/sound/soc/tegra/tegra_alc5632.c index c0ba1e4..1794139 100644

sound/soc/tegra/tegra_alc5632.c +1 -0
@@ -18,6 +18,7 @@
 
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/gpio.h>
 
+#include <linux/of_gpio.h>
 

#include <sound/core.h>
#include <sound/jack.h>

sound/soc/tegra/tegra_alc5632.c +4 -0
@@ -34,9 +35,13 @@
 
 #define DRV_NAME "tegra-alc5632"
 
+#define GPIO_HP_DET     BIT(0)
+
 
 struct tegra_alc5632 {
 
        struct tegra_asoc_utils_data util_data;
        struct platform_device *pcm_dev;
 
+       int gpio_requested;
+       int gpio_hp_det;

};

static int tegra_alc5632_asoc_hw_params(struct snd_pcm_substream *substream,>

sound/soc/tegra/tegra_alc5632.c +0 -0
@@ -86,6 +91,13 @@ static struct snd_soc_jack_pin

tegra_alc5632_hs_jack_pins[] = {>

        },

};

sound/soc/tegra/tegra_alc5632.c +7 -0
+static struct snd_soc_jack_gpio tegra_alc5632_hp_jack_gpio = {
+       .name = "Headset detection",
+       .report = SND_JACK_HEADSET,
+       .debounce_time = 150,
+       .invert = 1,
+};
+
 
 static const struct snd_soc_dapm_widget tegra_alc5632_dapm_widgets[] = {
 
        SND_SOC_DAPM_SPK("Int Spk", NULL),
        SND_SOC_DAPM_HP("Headset Stereophone", NULL),
@@ -114,6 +126,9 @@ static int tegra_alc5632_asoc_init(struct

snd_soc_pcm_runtime *rtd)>
{

        struct snd_soc_codec *codec = rtd->codec;
        struct snd_soc_dapm_context *dapm = &codec->dapm;
sound/soc/tegra/tegra_alc5632.c +2 -0
+       struct device_node *np = codec->card->dev->of_node;
+       struct tegra_alc5632 *machine =
Quoted 2 lines

snd_soc_card_get_drvdata(codec->card);
+ int ret;

This one isn't used, but non critical (just creates a warning).

Marc

#10 lore raw

Re: [PATCH v2 2/4] ARM: dt: tegra: Enable headset autodetection on PAZ00 board.

In reply to a message not in the archive
Quoted 9 lines · Mark Brown
Quoted 3 lines · Leon Romanovsky

This patch is adding device tree support of headset autodetection on PAZ00 board.

Same as the last patch - happy to merge via ASoC if people prefer that.

Mark,
I think for dts changes the tegra tree is a better place.

--
Leon Romanovsky | Independent Linux Consultant www.leon.nu | leon-2ukJVAZIZ/[email protected]

#12 lore raw

Re: [PATCH v2 2/4] ARM: dt: tegra: Enable headset autodetection on PAZ00 board.

In reply to a message not in the archive
Quoted 6 lines · Leon Romanovsky
Quoted 4 lines · Mark Brown
Quoted 2 lines · Leon Romanovsky

This patch is adding device tree support of headset autodetection on PAZ00 board.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Same as the last patch - happy to merge via ASoC if people prefer that.

Mark,
I think for dts changes the tegra tree is a better place.

Ok, applying the series to the tegra tree. Thanks!

-Olof

#14 lore raw

Re: [PATCH v2 2/4] ARM: dt: tegra: Enable headset autodetection on PAZ00 board.

In reply to a message not in the archive
Quoted 9 lines · Olof Johansson
Quoted 8 lines · Leon Romanovsky
Quoted 6 lines · Mark Brown
Quoted 3 lines · Leon Romanovsky

This patch is adding device tree support of headset autodetection on PAZ00 board.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Same as the last patch - happy to merge via ASoC if people prefer that.

Mark,
I think for dts changes the tegra tree is a better place.

Ok, applying the series to the tegra tree. Thanks!

Uh, and with "series", I of course mean only the first two patches. :)

-Olof

#16 lore raw

Re: [PATCH v2 2/4] ARM: dt: tegra: Enable headset autodetection on PAZ00 board.

In reply to a message not in the archive
Quoted 18 lines · Olof Johansson
Quoted 16 lines · Olof Johansson
Quoted 14 lines · Leon Romanovsky
Quoted 9 lines · Mark Brown
Quoted 3 lines · Leon Romanovsky

This patch is adding device tree support of headset autodetection on PAZ00 board.

Same as the last patch - happy to merge via ASoC if people prefer that.

Mark,
I think for dts changes the tegra tree is a better place.

Quoted 6 lines
Quoted 1 line

Ok, applying the series to the tegra tree. Thanks!

Uh, and with "series", I of course mean only the first two patches. :)

-Olof

Thanks.

--
Leon Romanovsky | Independent Linux Consultant www.leon.nu | leon-2ukJVAZIZ/[email protected]