Lines Matching +full:headset +full:- +full:detect +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0-only
3 * omap-twl4030.c -- SoC audio for TI SoC based boards with twl4030 codec
5 * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com
20 #include <linux/platform_data/omap-twl4030.h>
31 #include "omap-mcbsp.h"
34 int jack_detect; /* board can detect jack events */
56 return -EINVAL; in omap_twl4030_hw_params()
69 SND_SOC_DAPM_HP("Headset Stereophone", NULL),
75 SND_SOC_DAPM_MIC("Headset Mic", NULL),
83 /* Headset Stereophone: HSOL, HSOR */
84 {"Headset Stereophone", NULL, "HSOL"},
85 {"Headset Stereophone", NULL, "HSOR"},
103 /* Headset Mic: HSMIC with bias */
104 {"HSMIC", NULL, "Headset Mic"},
105 {"Headset Mic", NULL, "Headset Mic Bias"},
118 /* Headset jack detection DAPM pins */
121 .pin = "Headset Mic",
125 .pin = "Headset Stereophone",
130 /* Headset jack detection gpios */
133 .name = "hsdet-gpio",
148 struct snd_soc_card *card = rtd->card; in omap_twl4030_init()
149 struct snd_soc_dapm_context *dapm = &card->dapm; in omap_twl4030_init()
150 struct omap_tw4030_pdata *pdata = dev_get_platdata(card->dev); in omap_twl4030_init()
154 /* Headset jack detection only if it is supported */ in omap_twl4030_init()
155 if (priv->jack_detect > 0) { in omap_twl4030_init()
156 hs_jack_gpios[0].gpio = priv->jack_detect; in omap_twl4030_init()
158 ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", in omap_twl4030_init()
159 SND_JACK_HEADSET, &priv->hs_jack, in omap_twl4030_init()
165 ret = snd_soc_jack_add_gpios(&priv->hs_jack, in omap_twl4030_init()
176 if (!pdata || !pdata->custom_routing) in omap_twl4030_init()
180 twl4030_disconnect_pin(dapm, pdata->has_ear, "Earpiece Spk"); in omap_twl4030_init()
181 twl4030_disconnect_pin(dapm, pdata->has_hf, "Handsfree Spk"); in omap_twl4030_init()
182 twl4030_disconnect_pin(dapm, pdata->has_hs, "Headset Stereophone"); in omap_twl4030_init()
183 twl4030_disconnect_pin(dapm, pdata->has_predriv, "Ext Spk"); in omap_twl4030_init()
184 twl4030_disconnect_pin(dapm, pdata->has_carkit, "Carkit Spk"); in omap_twl4030_init()
186 twl4030_disconnect_pin(dapm, pdata->has_mainmic, "Main Mic"); in omap_twl4030_init()
187 twl4030_disconnect_pin(dapm, pdata->has_submic, "Sub Mic"); in omap_twl4030_init()
188 twl4030_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic"); in omap_twl4030_init()
189 twl4030_disconnect_pin(dapm, pdata->has_carkitmic, "Carkit Mic"); in omap_twl4030_init()
190 twl4030_disconnect_pin(dapm, pdata->has_digimic0, "Digital0 Mic"); in omap_twl4030_init()
191 twl4030_disconnect_pin(dapm, pdata->has_digimic1, "Digital1 Mic"); in omap_twl4030_init()
192 twl4030_disconnect_pin(dapm, pdata->has_linein, "Line In"); in omap_twl4030_init()
197 /* Digital audio interface glue - connects codec <--> CPU */
199 DAILINK_COMP_ARRAY(COMP_CPU("omap-mcbsp.2")),
200 DAILINK_COMP_ARRAY(COMP_CODEC("twl4030-codec", "twl4030-hifi")),
201 DAILINK_COMP_ARRAY(COMP_PLATFORM("omap-mcbsp.2")));
204 DAILINK_COMP_ARRAY(COMP_CPU("omap-mcbsp.3")),
205 DAILINK_COMP_ARRAY(COMP_CODEC("twl4030-codec", "twl4030-voice")),
206 DAILINK_COMP_ARRAY(COMP_PLATFORM("omap-mcbsp.3")));
239 struct omap_tw4030_pdata *pdata = dev_get_platdata(&pdev->dev); in omap_twl4030_probe()
240 struct device_node *node = pdev->dev.of_node; in omap_twl4030_probe()
245 card->dev = &pdev->dev; in omap_twl4030_probe()
247 priv = devm_kzalloc(&pdev->dev, sizeof(struct omap_twl4030), GFP_KERNEL); in omap_twl4030_probe()
249 return -ENOMEM; in omap_twl4030_probe()
256 dev_err(&pdev->dev, "Card name is not provided\n"); in omap_twl4030_probe()
257 return -ENODEV; in omap_twl4030_probe()
262 dev_err(&pdev->dev, "McBSP node is not provided\n"); in omap_twl4030_probe()
263 return -EINVAL; in omap_twl4030_probe()
265 omap_twl4030_dai_links[0].cpus->dai_name = NULL; in omap_twl4030_probe()
266 omap_twl4030_dai_links[0].cpus->of_node = dai_node; in omap_twl4030_probe()
268 omap_twl4030_dai_links[0].platforms->name = NULL; in omap_twl4030_probe()
269 omap_twl4030_dai_links[0].platforms->of_node = dai_node; in omap_twl4030_probe()
271 dai_node = of_parse_phandle(node, "ti,mcbsp-voice", 0); in omap_twl4030_probe()
273 card->num_links = 1; in omap_twl4030_probe()
275 omap_twl4030_dai_links[1].cpus->dai_name = NULL; in omap_twl4030_probe()
276 omap_twl4030_dai_links[1].cpus->of_node = dai_node; in omap_twl4030_probe()
278 omap_twl4030_dai_links[1].platforms->name = NULL; in omap_twl4030_probe()
279 omap_twl4030_dai_links[1].platforms->of_node = dai_node; in omap_twl4030_probe()
282 priv->jack_detect = of_get_named_gpio(node, in omap_twl4030_probe()
283 "ti,jack-det-gpio", 0); in omap_twl4030_probe()
286 prop = of_find_property(node, "ti,audio-routing", NULL); in omap_twl4030_probe()
289 "ti,audio-routing"); in omap_twl4030_probe()
293 card->fully_routed = 1; in omap_twl4030_probe()
296 if (pdata->card_name) { in omap_twl4030_probe()
297 card->name = pdata->card_name; in omap_twl4030_probe()
299 dev_err(&pdev->dev, "Card name is not provided\n"); in omap_twl4030_probe()
300 return -ENODEV; in omap_twl4030_probe()
303 if (!pdata->voice_connected) in omap_twl4030_probe()
304 card->num_links = 1; in omap_twl4030_probe()
306 priv->jack_detect = pdata->jack_detect; in omap_twl4030_probe()
308 dev_err(&pdev->dev, "Missing pdata\n"); in omap_twl4030_probe()
309 return -ENODEV; in omap_twl4030_probe()
313 ret = devm_snd_soc_register_card(&pdev->dev, card); in omap_twl4030_probe()
315 dev_err(&pdev->dev, "devm_snd_soc_register_card() failed: %d\n", in omap_twl4030_probe()
324 {.compatible = "ti,omap-twl4030", },
331 .name = "omap-twl4030",
343 MODULE_ALIAS("platform:omap-twl4030");