Commit fe243a54 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown

ASoC: codecs: wcd939x: Unify define used for MIC bias VOUT registers

All four microphone bias registers have similar layout: VOUT control
mask is exactly the same.  Use one define, just like older driver
wcd938x is doing, to make the code a bit simpler.
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://msgid.link/r/20240523125049.43713-1-krzysztof.kozlowski@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4ac0f06c
...@@ -1933,7 +1933,6 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component, ...@@ -1933,7 +1933,6 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
int req_volt, int micb_num) int req_volt, int micb_num)
{ {
struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component);
unsigned int micb_vout_ctl_field;
unsigned int micb_reg, cur_vout_ctl, micb_en; unsigned int micb_reg, cur_vout_ctl, micb_en;
int req_vout_ctl; int req_vout_ctl;
int ret = 0; int ret = 0;
...@@ -1941,19 +1940,15 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component, ...@@ -1941,19 +1940,15 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
switch (micb_num) { switch (micb_num) {
case MIC_BIAS_1: case MIC_BIAS_1:
micb_reg = WCD939X_ANA_MICB1; micb_reg = WCD939X_ANA_MICB1;
micb_vout_ctl_field = WCD939X_MICB1_VOUT_CTL;
break; break;
case MIC_BIAS_2: case MIC_BIAS_2:
micb_reg = WCD939X_ANA_MICB2; micb_reg = WCD939X_ANA_MICB2;
micb_vout_ctl_field = WCD939X_MICB2_VOUT_CTL;
break; break;
case MIC_BIAS_3: case MIC_BIAS_3:
micb_reg = WCD939X_ANA_MICB3; micb_reg = WCD939X_ANA_MICB3;
micb_vout_ctl_field = WCD939X_MICB1_VOUT_CTL;
break; break;
case MIC_BIAS_4: case MIC_BIAS_4:
micb_reg = WCD939X_ANA_MICB4; micb_reg = WCD939X_ANA_MICB4;
micb_vout_ctl_field = WCD939X_MICB2_VOUT_CTL;
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -1971,7 +1966,7 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component, ...@@ -1971,7 +1966,7 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
micb_en = snd_soc_component_read_field(component, micb_reg, micb_en = snd_soc_component_read_field(component, micb_reg,
WCD939X_MICB_ENABLE); WCD939X_MICB_ENABLE);
cur_vout_ctl = snd_soc_component_read_field(component, micb_reg, cur_vout_ctl = snd_soc_component_read_field(component, micb_reg,
micb_vout_ctl_field); WCD939X_MICB_VOUT_CTL);
req_vout_ctl = wcd939x_get_micb_vout_ctl_val(req_volt); req_vout_ctl = wcd939x_get_micb_vout_ctl_val(req_volt);
if (req_vout_ctl < 0) { if (req_vout_ctl < 0) {
...@@ -1994,7 +1989,7 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component, ...@@ -1994,7 +1989,7 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
MICB_BIAS_PULL_DOWN); MICB_BIAS_PULL_DOWN);
snd_soc_component_write_field(component, micb_reg, snd_soc_component_write_field(component, micb_reg,
micb_vout_ctl_field, req_vout_ctl); WCD939X_MICB_VOUT_CTL, req_vout_ctl);
if (micb_en == MICB_BIAS_ENABLE) { if (micb_en == MICB_BIAS_ENABLE) {
snd_soc_component_write_field(component, micb_reg, snd_soc_component_write_field(component, micb_reg,
...@@ -2912,13 +2907,13 @@ static int wcd939x_set_micbias_data(struct wcd939x_priv *wcd939x) ...@@ -2912,13 +2907,13 @@ static int wcd939x_set_micbias_data(struct wcd939x_priv *wcd939x)
return -EINVAL; return -EINVAL;
regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB1, regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB1,
WCD939X_MICB1_VOUT_CTL, vout_ctl_1); WCD939X_MICB_VOUT_CTL, vout_ctl_1);
regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB2, regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB2,
WCD939X_MICB2_VOUT_CTL, vout_ctl_2); WCD939X_MICB_VOUT_CTL, vout_ctl_2);
regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB3, regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB3,
WCD939X_MICB3_VOUT_CTL, vout_ctl_3); WCD939X_MICB_VOUT_CTL, vout_ctl_3);
regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB4, regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB4,
WCD939X_MICB4_VOUT_CTL, vout_ctl_4); WCD939X_MICB_VOUT_CTL, vout_ctl_4);
return 0; return 0;
} }
......
...@@ -92,9 +92,8 @@ ...@@ -92,9 +92,8 @@
#define WCD939X_MBHC_BTN7_VTH GENMASK(7, 2) #define WCD939X_MBHC_BTN7_VTH GENMASK(7, 2)
#define WCD939X_ANA_MICB1 (0x3022) #define WCD939X_ANA_MICB1 (0x3022)
#define WCD939X_MICB_ENABLE GENMASK(7, 6) #define WCD939X_MICB_ENABLE GENMASK(7, 6)
#define WCD939X_MICB1_VOUT_CTL GENMASK(5, 0) #define WCD939X_MICB_VOUT_CTL GENMASK(5, 0)
#define WCD939X_ANA_MICB2 (0x3023) #define WCD939X_ANA_MICB2 (0x3023)
#define WCD939X_MICB2_VOUT_CTL GENMASK(5, 0)
#define WCD939X_ANA_MICB2_RAMP (0x3024) #define WCD939X_ANA_MICB2_RAMP (0x3024)
#define WCD939X_MICB2_RAMP_RAMP_ENABLE BIT(7) #define WCD939X_MICB2_RAMP_RAMP_ENABLE BIT(7)
#define WCD939X_MICB2_RAMP_MB2_IN2P_SHORT_ENABLE BIT(6) #define WCD939X_MICB2_RAMP_MB2_IN2P_SHORT_ENABLE BIT(6)
...@@ -102,9 +101,7 @@ ...@@ -102,9 +101,7 @@
#define WCD939X_MICB2_RAMP_SHIFT_CTL GENMASK(4, 2) #define WCD939X_MICB2_RAMP_SHIFT_CTL GENMASK(4, 2)
#define WCD939X_MICB2_RAMP_USB_MGDET_MICB2_RAMP GENMASK(1, 0) #define WCD939X_MICB2_RAMP_USB_MGDET_MICB2_RAMP GENMASK(1, 0)
#define WCD939X_ANA_MICB3 (0x3025) #define WCD939X_ANA_MICB3 (0x3025)
#define WCD939X_MICB3_VOUT_CTL GENMASK(5, 0)
#define WCD939X_ANA_MICB4 (0x3026) #define WCD939X_ANA_MICB4 (0x3026)
#define WCD939X_MICB4_VOUT_CTL GENMASK(5, 0)
#define WCD939X_BIAS_CTL (0x3028) #define WCD939X_BIAS_CTL (0x3028)
#define WCD939X_BIAS_VBG_FINE_ADJ (0x3029) #define WCD939X_BIAS_VBG_FINE_ADJ (0x3029)
#define WCD939X_LDOL_VDDCX_ADJUST (0x3040) #define WCD939X_LDOL_VDDCX_ADJUST (0x3040)
......
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