aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sound/soc/ti
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2023-09-26 15:25:29 +0200
committerMark Brown <broonie@kernel.org>2023-10-02 14:06:19 +0100
commit22041ed154aaf89f31306014a305dde516c308ea (patch)
tree2e33d91b7459d7264593ef8f4f57e8d1b5aa2fb8 /sound/soc/ti
parentASoC: ti: Convert RX51 to use exclusively GPIO descriptors (diff)
downloadwireguard-linux-22041ed154aaf89f31306014a305dde516c308ea.tar.xz
wireguard-linux-22041ed154aaf89f31306014a305dde516c308ea.zip
ASoC: ti: Convert N810 ASoC to GPIO descriptors
The N810 uses GPIO descriptors pretty much exclusively, but not for ASoC, so let's fix it. Register the pins in a descriptor table in the machine since the ASoC device is not using device tree. Use static locals for the GPIO descriptors because I'm not able to experient with better state storage on any real hardware. Others using the N810 can come afterwards and improve this. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com> Link: https://lore.kernel.org/r/20230926-descriptors-asoc-ti-v1-1-60cf4f8adbc5@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/ti')
-rw-r--r--sound/soc/ti/n810.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/sound/soc/ti/n810.c b/sound/soc/ti/n810.c
index ed217b34f846..71a2a90bad2b 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);