Unverified Commit a9b696c8 authored by Mark Brown's avatar Mark Brown
Browse files

GPIO descriptors for TI ASoC codecs



Merge series from Linus Walleij <linus.walleij@linaro.org>:

This cleans up and rewrites the GPIO usage in the TI
ASoC components to use GPIO descriptors exclusively.

Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
---
Linus Walleij (5):
      ASoC: ti: Convert N810 ASoC to GPIO descriptors
      ASoC: ti: Convert RX51 to use exclusively GPIO descriptors
      ASoC: ti: Convert TWL4030 to use GPIO descriptors
      ASoC: ti: Convert Pandora ASoC to GPIO descriptors
      ASoC: ti: osk5912: Drop unused include

 arch/arm/mach-omap2/board-n8x0.c           | 10 +++++
 arch/arm/mach-omap2/pdata-quirks.c         | 10 +++++
 include/linux/platform_data/omap-twl4030.h |  3 --
 sound/soc/ti/n810.c                        | 31 ++++++++-------
 sound/soc/ti/omap-twl4030.c                | 20 ++++------
 sound/soc/ti/omap3pandora.c                | 63 +++++++++++-------------------
 sound/soc/ti/osk5912.c                     |  1 -
 sound/soc/ti/rx51.c                        | 19 ++-------
 8 files changed, 72 insertions(+), 85 deletions(-)
---
base-commit: 0bb80ecc
change-id: 20230922-descriptors-asoc-ti-a852eff479ed

Best regards,
--
Linus Walleij <linus.walleij@linaro.org>
parents 4c556d1e 67ebde42
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -498,6 +498,15 @@ struct menelaus_platform_data n8x0_menelaus_platform_data = {
	.late_init = n8x0_menelaus_late_init,
};

static struct gpiod_lookup_table nokia810_asoc_gpio_table = {
	.dev_id = "soc-audio",
	.table = {
		GPIO_LOOKUP("gpio-0-15", 10, "headset", GPIO_ACTIVE_HIGH),
		GPIO_LOOKUP("gpio-80-111", 21, "speaker", GPIO_ACTIVE_HIGH),
		{ }
	},
};

static int __init n8x0_late_initcall(void)
{
	if (!board_caps)
@@ -505,6 +514,7 @@ static int __init n8x0_late_initcall(void)

	n8x0_mmc_init();
	n8x0_usb_init();
	gpiod_add_lookup_table(&nokia810_asoc_gpio_table);

	return 0;
}
+10 −0
Original line number Diff line number Diff line
@@ -275,9 +275,19 @@ static struct platform_device pandora_backlight = {
	.id	= -1,
};

static struct gpiod_lookup_table pandora_soc_audio_gpios = {
	.dev_id = "soc-audio",
	.table = {
		GPIO_LOOKUP("gpio-112-127", 6, "dac", GPIO_ACTIVE_HIGH),
		GPIO_LOOKUP("gpio-0-15", 14, "amp", GPIO_ACTIVE_HIGH),
		{ }
	},
};

static void __init omap3_pandora_legacy_init(void)
{
	platform_device_register(&pandora_backlight);
	gpiod_add_lookup_table(&pandora_soc_audio_gpios);
}
#endif /* CONFIG_ARCH_OMAP3 */

+0 −3
Original line number Diff line number Diff line
@@ -37,9 +37,6 @@ struct omap_tw4030_pdata {
	bool	has_digimic0;
	bool	has_digimic1;
	u8	has_linein;

	/* Jack detect GPIO or  <= 0 if it is not implemented */
	int jack_detect;
};

#endif /* _OMAP_TWL4030_H_ */
+17 −14
Original line number Diff line number Diff line
@@ -15,14 +15,14 @@
#include <sound/soc.h>

#include <asm/mach-types.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/platform_data/asoc-ti-mcbsp.h>

#include "omap-mcbsp.h"

#define N810_HEADSET_AMP_GPIO	10
#define N810_SPEAKER_AMP_GPIO	101
static struct gpio_desc *n810_headset_amp;
static struct gpio_desc *n810_speaker_amp;

enum {
	N810_JACK_DISABLED,
@@ -187,9 +187,9 @@ static int n810_spk_event(struct snd_soc_dapm_widget *w,
			  struct snd_kcontrol *k, int event)
{
	if (SND_SOC_DAPM_EVENT_ON(event))
		gpio_set_value(N810_SPEAKER_AMP_GPIO, 1);
		gpiod_set_value(n810_speaker_amp, 1);
	else
		gpio_set_value(N810_SPEAKER_AMP_GPIO, 0);
		gpiod_set_value(n810_speaker_amp, 0);

	return 0;
}
@@ -198,9 +198,9 @@ static int n810_jack_event(struct snd_soc_dapm_widget *w,
			   struct snd_kcontrol *k, int event)
{
	if (SND_SOC_DAPM_EVENT_ON(event))
		gpio_set_value(N810_HEADSET_AMP_GPIO, 1);
		gpiod_set_value(n810_headset_amp, 1);
	else
		gpio_set_value(N810_HEADSET_AMP_GPIO, 0);
		gpiod_set_value(n810_headset_amp, 0);

	return 0;
}
@@ -327,14 +327,19 @@ static int __init n810_soc_init(void)
	clk_set_parent(sys_clkout2_src, func96m_clk);
	clk_set_rate(sys_clkout2, 12000000);

	if (WARN_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) ||
		    (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0))) {
		err = -EINVAL;
	n810_headset_amp = devm_gpiod_get(&n810_snd_device->dev,
					  "headphone", GPIOD_OUT_LOW);
	if (IS_ERR(n810_headset_amp)) {
		err = PTR_ERR(n810_headset_amp);
		goto err4;
	}

	gpio_direction_output(N810_HEADSET_AMP_GPIO, 0);
	gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0);
	n810_speaker_amp = devm_gpiod_get(&n810_snd_device->dev,
					  "speaker", GPIOD_OUT_LOW);
	if (IS_ERR(n810_speaker_amp)) {
		err = PTR_ERR(n810_speaker_amp);
		goto err4;
	}

	return 0;
err4:
@@ -351,8 +356,6 @@ static int __init n810_soc_init(void)

static void __exit n810_soc_exit(void)
{
	gpio_free(N810_SPEAKER_AMP_GPIO);
	gpio_free(N810_HEADSET_AMP_GPIO);
	clk_put(sys_clkout2_src);
	clk_put(sys_clkout2);
	clk_put(func96m_clk);
+8 −12
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@
#include <linux/platform_data/omap-twl4030.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>

#include <sound/core.h>
#include <sound/pcm.h>
@@ -31,7 +29,6 @@
#include "omap-mcbsp.h"

struct omap_twl4030 {
	int jack_detect;	/* board can detect jack events */
	struct snd_soc_jack hs_jack;
};

@@ -130,7 +127,7 @@ static struct snd_soc_jack_pin hs_jack_pins[] = {
/* Headset jack detection gpios */
static struct snd_soc_jack_gpio hs_jack_gpios[] = {
	{
		.name = "hsdet-gpio",
		.name = "ti,jack-det",
		.report = SND_JACK_HEADSET,
		.debounce_time = 200,
	},
@@ -151,9 +148,13 @@ static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd)
	struct omap_twl4030 *priv = snd_soc_card_get_drvdata(card);
	int ret = 0;

	/* Headset jack detection only if it is supported */
	if (priv->jack_detect > 0) {
		hs_jack_gpios[0].gpio = priv->jack_detect;
	/*
	 * This is a bit of a hack, but the GPIO is optional so we
	 * only want to add the jack detection if the GPIO is there.
	 */
	if (of_property_present(card->dev->of_node, "ti,jack-det-gpio")) {
		hs_jack_gpios[0].gpiod_dev = card->dev;
		hs_jack_gpios[0].idx = 0;

		ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
						 SND_JACK_HEADSET,
@@ -279,9 +280,6 @@ static int omap_twl4030_probe(struct platform_device *pdev)
			omap_twl4030_dai_links[1].platforms->of_node = dai_node;
		}

		priv->jack_detect = of_get_named_gpio(node,
						      "ti,jack-det-gpio", 0);

		/* Optional: audio routing can be provided */
		prop = of_find_property(node, "ti,audio-routing", NULL);
		if (prop) {
@@ -302,8 +300,6 @@ static int omap_twl4030_probe(struct platform_device *pdev)

		if (!pdata->voice_connected)
			card->num_links = 1;

		priv->jack_detect = pdata->jack_detect;
	} else {
		dev_err(&pdev->dev, "Missing pdata\n");
		return -ENODEV;
Loading