Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: ti: Convert TWL4030 to use GPIO descriptors

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>
Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Link: https://lore.kernel.org/r/20230926-descriptors-asoc-ti-v1-3-60cf4f8adbc5@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Linus Walleij and committed by
Mark Brown
1b8a6293 22041ed1

+8 -15
-3
include/linux/platform_data/omap-twl4030.h
··· 37 37 bool has_digimic0; 38 38 bool has_digimic1; 39 39 u8 has_linein; 40 - 41 - /* Jack detect GPIO or <= 0 if it is not implemented */ 42 - int jack_detect; 43 40 }; 44 41 45 42 #endif /* _OMAP_TWL4030_H_ */
+8 -12
sound/soc/ti/omap-twl4030.c
··· 20 20 #include <linux/platform_data/omap-twl4030.h> 21 21 #include <linux/module.h> 22 22 #include <linux/of.h> 23 - #include <linux/gpio.h> 24 - #include <linux/of_gpio.h> 25 23 26 24 #include <sound/core.h> 27 25 #include <sound/pcm.h> ··· 29 31 #include "omap-mcbsp.h" 30 32 31 33 struct omap_twl4030 { 32 - int jack_detect; /* board can detect jack events */ 33 34 struct snd_soc_jack hs_jack; 34 35 }; 35 36 ··· 127 130 /* Headset jack detection gpios */ 128 131 static struct snd_soc_jack_gpio hs_jack_gpios[] = { 129 132 { 130 - .name = "hsdet-gpio", 133 + .name = "ti,jack-det", 131 134 .report = SND_JACK_HEADSET, 132 135 .debounce_time = 200, 133 136 }, ··· 148 151 struct omap_twl4030 *priv = snd_soc_card_get_drvdata(card); 149 152 int ret = 0; 150 153 151 - /* Headset jack detection only if it is supported */ 152 - if (priv->jack_detect > 0) { 153 - hs_jack_gpios[0].gpio = priv->jack_detect; 154 + /* 155 + * This is a bit of a hack, but the GPIO is optional so we 156 + * only want to add the jack detection if the GPIO is there. 157 + */ 158 + if (of_property_present(card->dev->of_node, "ti,jack-det-gpio")) { 159 + hs_jack_gpios[0].gpiod_dev = card->dev; 160 + hs_jack_gpios[0].idx = 0; 154 161 155 162 ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack", 156 163 SND_JACK_HEADSET, ··· 280 279 omap_twl4030_dai_links[1].platforms->of_node = dai_node; 281 280 } 282 281 283 - priv->jack_detect = of_get_named_gpio(node, 284 - "ti,jack-det-gpio", 0); 285 - 286 282 /* Optional: audio routing can be provided */ 287 283 prop = of_find_property(node, "ti,audio-routing", NULL); 288 284 if (prop) { ··· 300 302 301 303 if (!pdata->voice_connected) 302 304 card->num_links = 1; 303 - 304 - priv->jack_detect = pdata->jack_detect; 305 305 } else { 306 306 dev_err(&pdev->dev, "Missing pdata\n"); 307 307 return -ENODEV;