From: Linus Walleij <linus.walleij@linaro.org>
To: Tony Lindgren <tony@atomide.com>,
Peter Ujfalusi <peter.ujfalusi@gmail.com>,
Jarkko Nikula <jarkko.nikula@bitmer.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>
Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
alsa-devel@alsa-project.org,
Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 3/5] ASoC: ti: Convert TWL4030 to use GPIO descriptors
Date: Tue, 26 Sep 2023 15:25:31 +0200 [thread overview]
Message-ID: <20230926-descriptors-asoc-ti-v1-3-60cf4f8adbc5@linaro.org> (raw)
In-Reply-To: <20230926-descriptors-asoc-ti-v1-0-60cf4f8adbc5@linaro.org>
The TWL4030 is actually only ever populated from the device tree,
so we can just pass the right device and headphone jack GPIO name
to snd_soc_jack_add_gpios() and it will pick the right GPIO right
from the device tree.
The platform data patch is unused (no in-tree users of the pdata
method) but these can use GPIO descriptor tables rather than global
GPIO numbers if they need this.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
include/linux/platform_data/omap-twl4030.h | 3 ---
sound/soc/ti/omap-twl4030.c | 20 ++++++++------------
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/include/linux/platform_data/omap-twl4030.h b/include/linux/platform_data/omap-twl4030.h
index 0dd851ea1c72..7fcb55fe21c9 100644
--- a/include/linux/platform_data/omap-twl4030.h
+++ b/include/linux/platform_data/omap-twl4030.h
@@ -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_ */
diff --git a/sound/soc/ti/omap-twl4030.c b/sound/soc/ti/omap-twl4030.c
index 950eec44503b..c7055bb424e6 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;
--
2.34.1
next prev parent reply other threads:[~2023-09-26 13:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 13:25 [PATCH 0/5] GPIO descriptors for TI ASoC codecs Linus Walleij
2023-09-26 13:25 ` [PATCH 1/5] ASoC: ti: Convert N810 ASoC to GPIO descriptors Linus Walleij
2023-09-26 13:25 ` [PATCH 2/5] ASoC: ti: Convert RX51 to use exclusively " Linus Walleij
2023-10-01 17:48 ` Jarkko Nikula
2023-09-26 13:25 ` Linus Walleij [this message]
2023-09-26 13:25 ` [PATCH 4/5] ASoC: ti: Convert Pandora ASoC to " Linus Walleij
2023-09-26 13:25 ` [PATCH 5/5] ASoC: ti: osk5912: Drop unused include Linus Walleij
2023-10-01 17:49 ` [PATCH 0/5] GPIO descriptors for TI ASoC codecs Jarkko Nikula
2023-10-02 11:45 ` Mark Brown
2023-10-02 16:04 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230926-descriptors-asoc-ti-v1-3-60cf4f8adbc5@linaro.org \
--to=linus.walleij@linaro.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=jarkko.nikula@bitmer.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@gmail.com \
--cc=tiwai@suse.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).