summaryrefslogtreecommitdiff
path: root/sound/soc/ti
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2023-10-02 18:17:47 +0300
committerMark Brown <broonie@kernel.org>2023-10-02 18:17:47 +0300
commita9b696c851c226b8fa89faeb56e581a8f077924b (patch)
tree94c4145dd2477545598db562d8a5dbc0a9529eba /sound/soc/ti
parent4c556d1ea5a771a91f946964d931b4974a6b917e (diff)
parent67ebde42034ec8d199ec7877efed4bd08eb0c5e0 (diff)
downloadlinux-a9b696c851c226b8fa89faeb56e581a8f077924b.tar.xz
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: Linus 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: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d change-id: 20230922-descriptors-asoc-ti-a852eff479ed Best regards, -- Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'sound/soc/ti')
-rw-r--r--sound/soc/ti/n810.c31
-rw-r--r--sound/soc/ti/omap-twl4030.c20
-rw-r--r--sound/soc/ti/omap3pandora.c63
-rw-r--r--sound/soc/ti/osk5912.c1
-rw-r--r--sound/soc/ti/rx51.c19
5 files changed, 52 insertions, 82 deletions
diff --git a/sound/soc/ti/n810.c b/sound/soc/ti/n810.c
index 6c72c2a50dec..50a8ec97cf20 100644
--- a/sound/soc/ti/n810.c
+++ b/sound/soc/ti/n810.c
@@ -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 @@ err1:
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);
diff --git a/sound/soc/ti/omap-twl4030.c b/sound/soc/ti/omap-twl4030.c
index a3ad1a2df1c7..a402d66e4f4d 100644
--- a/sound/soc/ti/omap-twl4030.c
+++ b/sound/soc/ti/omap-twl4030.c
@@ -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;
diff --git a/sound/soc/ti/omap3pandora.c b/sound/soc/ti/omap3pandora.c
index 712e8ae5e804..be69476e59d6 100644
--- a/sound/soc/ti/omap3pandora.c
+++ b/sound/soc/ti/omap3pandora.c
@@ -7,7 +7,7 @@
#include <linux/clk.h>
#include <linux/platform_device.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/delay.h>
#include <linux/regulator/consumer.h>
#include <linux/module.h>
@@ -21,12 +21,11 @@
#include "omap-mcbsp.h"
-#define OMAP3_PANDORA_DAC_POWER_GPIO 118
-#define OMAP3_PANDORA_AMP_POWER_GPIO 14
-
#define PREFIX "ASoC omap3pandora: "
static struct regulator *omap3pandora_dac_reg;
+static struct gpio_desc *dac_power_gpio;
+static struct gpio_desc *amp_power_gpio;
static int omap3pandora_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
@@ -78,9 +77,9 @@ static int omap3pandora_dac_event(struct snd_soc_dapm_widget *w,
return ret;
}
mdelay(1);
- gpio_set_value(OMAP3_PANDORA_DAC_POWER_GPIO, 1);
+ gpiod_set_value(dac_power_gpio, 1);
} else {
- gpio_set_value(OMAP3_PANDORA_DAC_POWER_GPIO, 0);
+ gpiod_set_value(dac_power_gpio, 0);
mdelay(1);
regulator_disable(omap3pandora_dac_reg);
}
@@ -92,9 +91,9 @@ static int omap3pandora_hp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event)
{
if (SND_SOC_DAPM_EVENT_ON(event))
- gpio_set_value(OMAP3_PANDORA_AMP_POWER_GPIO, 1);
+ gpiod_set_value(amp_power_gpio, 1);
else
- gpio_set_value(OMAP3_PANDORA_AMP_POWER_GPIO, 0);
+ gpiod_set_value(amp_power_gpio, 0);
return 0;
}
@@ -229,35 +228,10 @@ static int __init omap3pandora_soc_init(void)
pr_info("OMAP3 Pandora SoC init\n");
- ret = gpio_request(OMAP3_PANDORA_DAC_POWER_GPIO, "dac_power");
- if (ret) {
- pr_err(PREFIX "Failed to get DAC power GPIO\n");
- return ret;
- }
-
- ret = gpio_direction_output(OMAP3_PANDORA_DAC_POWER_GPIO, 0);
- if (ret) {
- pr_err(PREFIX "Failed to set DAC power GPIO direction\n");
- goto fail0;
- }
-
- ret = gpio_request(OMAP3_PANDORA_AMP_POWER_GPIO, "amp_power");
- if (ret) {
- pr_err(PREFIX "Failed to get amp power GPIO\n");
- goto fail0;
- }
-
- ret = gpio_direction_output(OMAP3_PANDORA_AMP_POWER_GPIO, 0);
- if (ret) {
- pr_err(PREFIX "Failed to set amp power GPIO direction\n");
- goto fail1;
- }
-
omap3pandora_snd_device = platform_device_alloc("soc-audio", -1);
if (omap3pandora_snd_device == NULL) {
pr_err(PREFIX "Platform device allocation failed\n");
- ret = -ENOMEM;
- goto fail1;
+ return -ENOMEM;
}
platform_set_drvdata(omap3pandora_snd_device, &snd_soc_card_omap3pandora);
@@ -268,6 +242,20 @@ static int __init omap3pandora_soc_init(void)
goto fail2;
}
+ dac_power_gpio = devm_gpiod_get(&omap3pandora_snd_device->dev,
+ "dac", GPIOD_OUT_LOW);
+ if (IS_ERR(dac_power_gpio)) {
+ ret = PTR_ERR(dac_power_gpio);
+ goto fail3;
+ }
+
+ amp_power_gpio = devm_gpiod_get(&omap3pandora_snd_device->dev,
+ "amp", GPIOD_OUT_LOW);
+ if (IS_ERR(amp_power_gpio)) {
+ ret = PTR_ERR(amp_power_gpio);
+ goto fail3;
+ }
+
omap3pandora_dac_reg = regulator_get(&omap3pandora_snd_device->dev, "vcc");
if (IS_ERR(omap3pandora_dac_reg)) {
pr_err(PREFIX "Failed to get DAC regulator from %s: %ld\n",
@@ -283,10 +271,7 @@ fail3:
platform_device_del(omap3pandora_snd_device);
fail2:
platform_device_put(omap3pandora_snd_device);
-fail1:
- gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO);
-fail0:
- gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO);
+
return ret;
}
module_init(omap3pandora_soc_init);
@@ -295,8 +280,6 @@ static void __exit omap3pandora_soc_exit(void)
{
regulator_put(omap3pandora_dac_reg);
platform_device_unregister(omap3pandora_snd_device);
- gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO);
- gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO);
}
module_exit(omap3pandora_soc_exit);
diff --git a/sound/soc/ti/osk5912.c b/sound/soc/ti/osk5912.c
index 5f718f9ec1e5..98714c593496 100644
--- a/sound/soc/ti/osk5912.c
+++ b/sound/soc/ti/osk5912.c
@@ -14,7 +14,6 @@
#include <sound/soc.h>
#include <asm/mach-types.h>
-#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/platform_data/asoc-ti-mcbsp.h>
diff --git a/sound/soc/ti/rx51.c b/sound/soc/ti/rx51.c
index d966c008be4d..77296237575a 100644
--- a/sound/soc/ti/rx51.c
+++ b/sound/soc/ti/rx51.c
@@ -10,7 +10,6 @@
*/
#include <linux/delay.h>
-#include <linux/gpio.h>
#include <linux/platform_device.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
@@ -33,7 +32,6 @@ enum {
struct rx51_audio_pdata {
struct gpio_desc *tvout_selection_gpio;
- struct gpio_desc *jack_detection_gpio;
struct gpio_desc *eci_sw_gpio;
struct gpio_desc *speaker_amp_gpio;
};
@@ -198,7 +196,7 @@ static struct snd_soc_jack rx51_av_jack;
static struct snd_soc_jack_gpio rx51_av_jack_gpios[] = {
{
- .name = "avdet-gpio",
+ .name = "jack-detection",
.report = SND_JACK_HEADSET,
.invert = 1,
.debounce_time = 200,
@@ -263,7 +261,6 @@ static const struct snd_kcontrol_new aic34_rx51_controls[] = {
static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
- struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card);
int err;
snd_soc_limit_volume(card, "TPA6130A2 Headphone Playback Volume", 42);
@@ -283,9 +280,9 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
return err;
}
- /* prepare gpio for snd_soc_jack_add_gpios */
- rx51_av_jack_gpios[0].gpio = desc_to_gpio(pdata->jack_detection_gpio);
- devm_gpiod_put(card->dev, pdata->jack_detection_gpio);
+ rx51_av_jack_gpios[0].gpiod_dev = card->dev;
+ /* Name is assigned in the struct */
+ rx51_av_jack_gpios[0].idx = 0;
err = snd_soc_jack_add_gpios(&rx51_av_jack,
ARRAY_SIZE(rx51_av_jack_gpios),
@@ -425,14 +422,6 @@ static int rx51_soc_probe(struct platform_device *pdev)
return PTR_ERR(pdata->tvout_selection_gpio);
}
- pdata->jack_detection_gpio = devm_gpiod_get(card->dev,
- "jack-detection",
- GPIOD_ASIS);
- if (IS_ERR(pdata->jack_detection_gpio)) {
- dev_err(card->dev, "could not get jack detection gpio\n");
- return PTR_ERR(pdata->jack_detection_gpio);
- }
-
pdata->eci_sw_gpio = devm_gpiod_get(card->dev, "eci-switch",
GPIOD_OUT_HIGH);
if (IS_ERR(pdata->eci_sw_gpio)) {