[PATCH] ASoC: qcom: SC7280: Add support for external DMIC bias supply

From: Srinivasa Rao Mandadapu
Date: Thu Jul 28 2022 - 03:11:05 EST


Update SC7280 machine driver for enabling external mic bias supply,
Which is required for villager rev boards.

Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@xxxxxxxxxxx>
---
sound/soc/qcom/sc7280.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/sound/soc/qcom/sc7280.c b/sound/soc/qcom/sc7280.c
index da7469a..6404e94 100644
--- a/sound/soc/qcom/sc7280.c
+++ b/sound/soc/qcom/sc7280.c
@@ -33,6 +33,7 @@ struct sc7280_snd_data {
struct snd_soc_jack hdmi_jack;
bool jack_setup;
bool stream_prepared[LPASS_MAX_PORTS];
+ struct regulator *vdd_supply;
};

static void sc7280_jack_free(struct snd_jack *jack)
@@ -345,6 +346,24 @@ static int sc7280_snd_startup(struct snd_pcm_substream *substream)
return ret;
}

+static int sc7280_dmic_micbias(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+{
+ struct snd_soc_card *card = w->dapm->card;
+ struct sc7280_snd_data *data = snd_soc_card_get_drvdata(card);
+ int ret = 0;
+
+ switch (event) {
+ case SND_SOC_DAPM_PRE_PMU:
+ ret = regulator_enable(data->vdd_supply);
+ break;
+ case SND_SOC_DAPM_POST_PMD:
+ ret = regulator_disable(data->vdd_supply);
+ break;
+ }
+ return ret;
+}
+
static const struct snd_soc_ops sc7280_ops = {
.startup = sc7280_snd_startup,
.hw_params = sc7280_snd_hw_params,
@@ -356,6 +375,7 @@ static const struct snd_soc_ops sc7280_ops = {
static const struct snd_soc_dapm_widget sc7280_snd_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
+ SND_SOC_DAPM_MIC("PMIC BIAS", sc7280_dmic_micbias),
};

static int sc7280_snd_platform_probe(struct platform_device *pdev)
@@ -389,6 +409,10 @@ static int sc7280_snd_platform_probe(struct platform_device *pdev)
link->ops = &sc7280_ops;
}

+ data->vdd_supply = devm_regulator_get(dev, "vdd-dmic-bias");
+ if (IS_ERR(data->vdd_supply)
+ return PTR_ERR(data->vdd_supply);
+
return devm_snd_soc_register_card(dev, card);
}

--
2.7.4