瀏覽代碼

asoc: wcd937x: Change voltage for micbias depending on dt value

MICBIAS is always set to 1.8V. Change this voltage
depending on dt value for respective micbias.

Change-Id: I8eb1e71ae0256423bfd0bcc8ba2cd6bcc4a5ee61
Signed-off-by: Vatsal Bucha <[email protected]>
Vatsal Bucha 6 年之前
父節點
當前提交
1793ff07cb
共有 1 個文件被更改,包括 37 次插入1 次删除
  1. 37 1
      asoc/codecs/wcd937x/wcd937x.c

+ 37 - 1
asoc/codecs/wcd937x/wcd937x.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/module.h>
@@ -2082,6 +2082,36 @@ int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,
 }
 EXPORT_SYMBOL(wcd937x_info_create_codec_entry);
 
+static int wcd937x_set_micbias_data(struct wcd937x_priv *wcd937x,
+			      struct wcd937x_pdata *pdata)
+{
+	int vout_ctl_1 = 0, vout_ctl_2 = 0, vout_ctl_3 = 0;
+	int rc = 0;
+
+	if (!pdata) {
+		dev_err(wcd937x->dev, "%s: NULL pdata\n", __func__);
+		return -ENODEV;
+	}
+
+	/* set micbias voltage */
+	vout_ctl_1 = wcd937x_get_micb_vout_ctl_val(pdata->micbias.micb1_mv);
+	vout_ctl_2 = wcd937x_get_micb_vout_ctl_val(pdata->micbias.micb2_mv);
+	vout_ctl_3 = wcd937x_get_micb_vout_ctl_val(pdata->micbias.micb3_mv);
+	if (vout_ctl_1 < 0 || vout_ctl_2 < 0 || vout_ctl_3 < 0) {
+		rc = -EINVAL;
+		goto done;
+	}
+	regmap_update_bits(wcd937x->regmap, WCD937X_ANA_MICB1, 0x3F,
+			   vout_ctl_1);
+	regmap_update_bits(wcd937x->regmap, WCD937X_ANA_MICB2, 0x3F,
+			   vout_ctl_2);
+	regmap_update_bits(wcd937x->regmap, WCD937X_ANA_MICB3, 0x3F,
+			   vout_ctl_3);
+
+done:
+	return rc;
+}
+
 static int wcd937x_soc_codec_probe(struct snd_soc_component *component)
 {
 	struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component);
@@ -2574,6 +2604,12 @@ static int wcd937x_bind(struct device *dev)
 	}
 	wcd937x->tx_swr_dev->slave_irq = wcd937x->virq;
 
+	ret = wcd937x_set_micbias_data(wcd937x, pdata);
+	if (ret < 0) {
+		dev_err(dev, "%s: bad micbias pdata\n", __func__);
+		goto err_irq;
+	}
+
 	mutex_init(&wcd937x->micb_lock);
 	ret = snd_soc_register_component(dev, &soc_codec_dev_wcd937x,
 				     NULL, 0);