Commit 9766a1cf authored by Dylan Reid's avatar Dylan Reid Committed by Mark Brown

ASoC: tegra: add mic detect gpio to tegra_max98090

Add an optional mic detect gpio property.  If specified in device tree
there will be a mic jack created for the given gpio.  This will be
used by the Tegra-based Chromebooks.
Signed-off-by: default avatarDylan Reid <dgreid@chromium.org>
Reviewed-by: default avatarStephen Warren <swarren@nvidia.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7d1311b9
...@@ -25,6 +25,7 @@ Required properties: ...@@ -25,6 +25,7 @@ Required properties:
Optional properties: Optional properties:
- nvidia,hp-det-gpios : The GPIO that detect headphones are plugged in - nvidia,hp-det-gpios : The GPIO that detect headphones are plugged in
- nvidia,mic-det-gpios : The GPIO that detect microphones are plugged in
Example: Example:
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
struct tegra_max98090 { struct tegra_max98090 {
struct tegra_asoc_utils_data util_data; struct tegra_asoc_utils_data util_data;
int gpio_hp_det; int gpio_hp_det;
int gpio_mic_det;
}; };
static int tegra_max98090_asoc_hw_params(struct snd_pcm_substream *substream, static int tegra_max98090_asoc_hw_params(struct snd_pcm_substream *substream,
...@@ -112,6 +113,22 @@ static struct snd_soc_jack_gpio tegra_max98090_hp_jack_gpio = { ...@@ -112,6 +113,22 @@ static struct snd_soc_jack_gpio tegra_max98090_hp_jack_gpio = {
.invert = 1, .invert = 1,
}; };
static struct snd_soc_jack tegra_max98090_mic_jack;
static struct snd_soc_jack_pin tegra_max98090_mic_jack_pins[] = {
{
.pin = "Mic Jack",
.mask = SND_JACK_MICROPHONE,
},
};
static struct snd_soc_jack_gpio tegra_max98090_mic_jack_gpio = {
.name = "Mic detection",
.report = SND_JACK_MICROPHONE,
.debounce_time = 150,
.invert = 1,
};
static const struct snd_soc_dapm_widget tegra_max98090_dapm_widgets[] = { static const struct snd_soc_dapm_widget tegra_max98090_dapm_widgets[] = {
SND_SOC_DAPM_HP("Headphones", NULL), SND_SOC_DAPM_HP("Headphones", NULL),
SND_SOC_DAPM_SPK("Speakers", NULL), SND_SOC_DAPM_SPK("Speakers", NULL),
...@@ -141,6 +158,19 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) ...@@ -141,6 +158,19 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd)
&tegra_max98090_hp_jack_gpio); &tegra_max98090_hp_jack_gpio);
} }
if (gpio_is_valid(machine->gpio_mic_det)) {
snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE,
&tegra_max98090_mic_jack);
snd_soc_jack_add_pins(&tegra_max98090_mic_jack,
ARRAY_SIZE(tegra_max98090_mic_jack_pins),
tegra_max98090_mic_jack_pins);
tegra_max98090_mic_jack_gpio.gpio = machine->gpio_mic_det;
snd_soc_jack_add_gpios(&tegra_max98090_mic_jack,
1,
&tegra_max98090_mic_jack_gpio);
}
return 0; return 0;
} }
...@@ -153,6 +183,11 @@ static int tegra_max98090_card_remove(struct snd_soc_card *card) ...@@ -153,6 +183,11 @@ static int tegra_max98090_card_remove(struct snd_soc_card *card)
&tegra_max98090_hp_jack_gpio); &tegra_max98090_hp_jack_gpio);
} }
if (gpio_is_valid(machine->gpio_mic_det)) {
snd_soc_jack_free_gpios(&tegra_max98090_mic_jack, 1,
&tegra_max98090_mic_jack_gpio);
}
return 0; return 0;
} }
...@@ -201,6 +236,11 @@ static int tegra_max98090_probe(struct platform_device *pdev) ...@@ -201,6 +236,11 @@ static int tegra_max98090_probe(struct platform_device *pdev)
if (machine->gpio_hp_det == -EPROBE_DEFER) if (machine->gpio_hp_det == -EPROBE_DEFER)
return -EPROBE_DEFER; return -EPROBE_DEFER;
machine->gpio_mic_det =
of_get_named_gpio(np, "nvidia,mic-det-gpios", 0);
if (machine->gpio_mic_det == -EPROBE_DEFER)
return -EPROBE_DEFER;
ret = snd_soc_of_parse_card_name(card, "nvidia,model"); ret = snd_soc_of_parse_card_name(card, "nvidia,model");
if (ret) if (ret)
goto err; goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment