Skip to content

Commit e269998

Browse files
Srinivas-Kandagatlabroonie
authored andcommitted
ASoC: codecs: msm8916-wcd-analog: get micbias voltage from dt
This patch adds bindings in DT to provide required micbias voltage which could be specific to board. With this new binding, now the mic bias voltage is left at hardware default value if the device tree does not specify any mic bias voltage value. Correct micbias value is required for mbhc buttons to work. Signed-off-by: Srinivas Kandagatla <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 6329b1b commit e269998

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Required properties
3333
- vdd-micbias-supply: phandle of VDD_MICBIAS supply's regulator DT node.
3434

3535
Optional Properties:
36+
- qcom,micbias-lvl: Voltage (mV) for Mic Bias
3637
- qcom,micbias1-ext-cap: boolean, present if micbias1 has external capacitor
3738
connected.
3839
- qcom,micbias2-ext-cap: boolean, present if micbias2 has external capacitor

sound/soc/codecs/msm8916-wcd-analog.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@
9393
#define MICB_1_EN_TX3_GND_SEL_TX_GND 0
9494

9595
#define CDC_A_MICB_1_VAL (0xf141)
96+
#define MICB_MIN_VAL 1600
97+
#define MICB_STEP_SIZE 50
98+
#define MICB_VOLTAGE_REGVAL(v) ((v - MICB_MIN_VAL)/MICB_STEP_SIZE)
9699
#define MICB_1_VAL_MICB_OUT_VAL_MASK GENMASK(7, 3)
97100
#define MICB_1_VAL_MICB_OUT_VAL_V2P70V ((0x16) << 3)
101+
#define MICB_1_VAL_MICB_OUT_VAL_V1P80V ((0x4) << 3)
98102
#define CDC_A_MICB_1_CTL (0xf142)
99103

100104
#define MICB_1_CTL_CFILT_REF_SEL_MASK BIT(1)
@@ -225,6 +229,7 @@ struct pm8916_wcd_analog_priv {
225229
struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)];
226230
unsigned int micbias1_cap_mode;
227231
unsigned int micbias2_cap_mode;
232+
unsigned int micbias_mv;
228233
};
229234

230235
static const char *const adc2_mux_text[] = { "ZERO", "INP2", "INP3" };
@@ -265,18 +270,25 @@ static const struct snd_kcontrol_new pm8916_wcd_analog_snd_controls[] = {
265270

266271
static void pm8916_wcd_analog_micbias_enable(struct snd_soc_codec *codec)
267272
{
273+
struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec);
274+
268275
snd_soc_update_bits(codec, CDC_A_MICB_1_CTL,
269276
MICB_1_CTL_EXT_PRECHARG_EN_MASK |
270277
MICB_1_CTL_INT_PRECHARG_BYP_MASK,
271278
MICB_1_CTL_INT_PRECHARG_BYP_EXT_PRECHRG_SEL
272279
| MICB_1_CTL_EXT_PRECHARG_EN_ENABLE);
273280

274-
snd_soc_write(codec, CDC_A_MICB_1_VAL, MICB_1_VAL_MICB_OUT_VAL_V2P70V);
275-
/*
276-
* Special headset needs MICBIAS as 2.7V so wait for
277-
* 50 msec for the MICBIAS to reach 2.7 volts.
278-
*/
279-
msleep(50);
281+
if (wcd->micbias_mv) {
282+
snd_soc_write(codec, CDC_A_MICB_1_VAL,
283+
MICB_VOLTAGE_REGVAL(wcd->micbias_mv));
284+
/*
285+
* Special headset needs MICBIAS as 2.7V so wait for
286+
* 50 msec for the MICBIAS to reach 2.7 volts.
287+
*/
288+
if (wcd->micbias_mv >= 2700)
289+
msleep(50);
290+
}
291+
280292
snd_soc_update_bits(codec, CDC_A_MICB_1_CTL,
281293
MICB_1_CTL_EXT_PRECHARG_EN_MASK |
282294
MICB_1_CTL_INT_PRECHARG_BYP_MASK, 0);
@@ -795,6 +807,9 @@ static int pm8916_wcd_analog_parse_dt(struct device *dev,
795807
else
796808
priv->micbias2_cap_mode = MICB_1_EN_NO_EXT_BYP_CAP;
797809

810+
of_property_read_u32(dev->of_node, "qcom,micbias-lvl",
811+
&priv->micbias_mv);
812+
798813
return 0;
799814
}
800815

0 commit comments

Comments
 (0)