[alsa-devel] [PATCH v2 0/4] 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.

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.
Signed-off-by: Marc Dietrich marvin24@gmx.de Signed-off-by: Leon Romanovsky leon@leon.nu --- arch/arm/boot/dts/tegra-paz00.dts | 29 +++++++++++++++++++++++------ 1 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/arch/arm/boot/dts/tegra-paz00.dts b/arch/arm/boot/dts/tegra-paz00.dts index 4d1bcdc..e6809b7 100644 --- a/arch/arm/boot/dts/tegra-paz00.dts +++ b/arch/arm/boot/dts/tegra-paz00.dts @@ -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 {

Leon Romanovsky wrote at Thursday, February 02, 2012 1:14 PM:
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,
Acked-by: Stephen Warren swarren@nvidia.com

On Thu, Feb 02, 2012 at 10:13:35PM +0200, Leon Romanovsky wrote:
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.
Reviewed-by: Mark Brown broonie@opensource.wolfsonmicro.com
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.

This patch is adding device tree support of headset autodetection on PAZ00 board.
Signed-off-by: Leon Romanovsky leon@leon.nu --- arch/arm/boot/dts/tegra-paz00.dts | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/tegra-paz00.dts b/arch/arm/boot/dts/tegra-paz00.dts index e6809b7..fa9dd9e 100644 --- a/arch/arm/boot/dts/tegra-paz00.dts +++ b/arch/arm/boot/dts/tegra-paz00.dts @@ -64,6 +64,7 @@
nvidia,audio-codec = <&alc5632>; nvidia,i2s-controller = <&tegra_i2s1>; + nvidia,hp-det-gpios = <&gpio 178 0>; /* gpio PW2 */ };
serial@70006000 {

On Thu, Feb 02, 2012 at 10:13:36PM +0200, Leon Romanovsky wrote:
This patch is adding device tree support of headset autodetection on PAZ00 board.
Signed-off-by: Leon Romanovsky leon@leon.nu
Reviewed-by: Mark Brown broonie@opensource.wolfsonmicro.com
Same as the last patch - happy to merge via ASoC if people prefer that.

On Fri, Feb 3, 2012 at 00:42, Mark Brown broonie@opensource.wolfsonmicro.com wrote:
On Thu, Feb 02, 2012 at 10:13:36PM +0200, Leon Romanovsky wrote:
This patch is adding device tree support of headset autodetection on PAZ00 board.
Signed-off-by: Leon Romanovsky leon@leon.nu
Reviewed-by: Mark Brown broonie@opensource.wolfsonmicro.com
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@leon.nu

On Fri, Feb 03, 2012 at 11:44:00PM +0200, Leon Romanovsky wrote:
On Fri, Feb 3, 2012 at 00:42, Mark Brown broonie@opensource.wolfsonmicro.com wrote:
On Thu, Feb 02, 2012 at 10:13:36PM +0200, Leon Romanovsky wrote:
This patch is adding device tree support of headset autodetection on PAZ00 board.
Signed-off-by: Leon Romanovsky leon@leon.nu
Reviewed-by: Mark Brown broonie@opensource.wolfsonmicro.com
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

On Mon, Feb 6, 2012 at 6:06 PM, Olof Johansson olof@lixom.net wrote:
On Fri, Feb 03, 2012 at 11:44:00PM +0200, Leon Romanovsky wrote:
On Fri, Feb 3, 2012 at 00:42, Mark Brown broonie@opensource.wolfsonmicro.com wrote:
On Thu, Feb 02, 2012 at 10:13:36PM +0200, Leon Romanovsky wrote:
This patch is adding device tree support of headset autodetection on PAZ00 board.
Signed-off-by: Leon Romanovsky leon@leon.nu
Reviewed-by: Mark Brown broonie@opensource.wolfsonmicro.com
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

On Tue, Feb 7, 2012 at 04:09, Olof Johansson olof@lixom.net wrote:
On Mon, Feb 6, 2012 at 6:06 PM, Olof Johansson olof@lixom.net wrote:
On Fri, Feb 03, 2012 at 11:44:00PM +0200, Leon Romanovsky wrote:
On Fri, Feb 3, 2012 at 00:42, Mark Brown broonie@opensource.wolfsonmicro.com wrote:
On Thu, Feb 02, 2012 at 10:13:36PM +0200, Leon Romanovsky wrote:
This patch is adding device tree support of headset autodetection on PAZ00 board.
Signed-off-by: Leon Romanovsky leon@leon.nu
Reviewed-by: Mark Brown broonie@opensource.wolfsonmicro.com
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
Thanks.
-- Leon Romanovsky | Independent Linux Consultant www.leon.nu | leon@leon.nu

This patch is adding device tree support of headset autodetection on PAZ00 board.
Signed-off-by: Leon Romanovsky leon@leon.nu --- sound/soc/tegra/tegra_alc5632.c | 39 +++++++++++++++++++++++++++++++++++---- 1 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c index c0ba1e4..1794139 100644 --- a/sound/soc/tegra/tegra_alc5632.c +++ b/sound/soc/tegra/tegra_alc5632.c @@ -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; }

On Thu, Feb 02, 2012 at 10:13:37PM +0200, Leon Romanovsky wrote:
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.

On Thursday 02 February 2012 22:44:02 Mark Brown wrote:
On Thu, Feb 02, 2012 at 10:13:37PM +0200, Leon Romanovsky wrote:
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.
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c index c0ba1e4..1794139 100644 --- a/sound/soc/tegra/tegra_alc5632.c +++ b/sound/soc/tegra/tegra_alc5632.c @@ -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;
This one isn't used, but non critical (just creates a warning).
Marc

All DAPM routes are configured via device tree, and there is no need in DAPM route structures in board file.
Signed-off-by: Leon Romanovsky leon@leon.nu --- sound/soc/tegra/tegra_alc5632.c | 16 ---------------- 1 files changed, 0 insertions(+), 16 deletions(-)
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c index 1794139..c000f51 100644 --- a/sound/soc/tegra/tegra_alc5632.c +++ b/sound/soc/tegra/tegra_alc5632.c @@ -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, };

On Thu, Feb 02, 2012 at 10:13:38PM +0200, Leon Romanovsky wrote:
All DAPM routes are configured via device tree, and there is no need in DAPM route structures in board file.
Applied, thanks.
participants (5)
-
Leon Romanovsky
-
Marc Dietrich
-
Mark Brown
-
Olof Johansson
-
Stephen Warren