All MIC1-4 bias registers are the same and the header already defines
register fields for them. Drop unused, duplicated defines for MIC2
bias enable register.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
sound/soc/codecs/wcd938x.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/sound/soc/codecs/wcd938x.h b/sound/soc/codecs/wcd938x.h
index 74b1498fec38..df07e92d9d97 100644
--- a/sound/soc/codecs/wcd938x.h
+++ b/sound/soc/codecs/wcd938x.h
@@ -75,9 +75,7 @@
#define WCD938X_MICB_PULL_UP 2
#define WCD938X_MICB_PULL_DOWN 3
#define WCD938X_ANA_MICB2 (0x3023)
-#define WCD938X_ANA_MICB2_ENABLE BIT(6)
#define WCD938X_ANA_MICB2_ENABLE_MASK GENMASK(7, 6)
-#define WCD938X_ANA_MICB2_VOUT_MASK GENMASK(5, 0)
#define WCD938X_ANA_MICB2_RAMP (0x3024)
#define WCD938X_RAMP_EN_MASK BIT(7)
#define WCD938X_RAMP_SHIFT_CTRL_MASK GENMASK(4, 2)
--
2.43.0
There is a define for MIC bias registers enable mask called
WCD938X_MICB_EN_MASK, which is already used to handle all four MIC1-4
biases in wcd938x_mbhc_micb_adjust_voltage().
Use the same define also in wcd938x_mbhc_micb_en_status() for MIC2 to
have unified, simpler approach.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
sound/soc/codecs/wcd938x.c | 2 +-
sound/soc/codecs/wcd938x.h | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index 6021aa5a5689..9e2070356b84 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -1982,7 +1982,7 @@ static bool wcd938x_mbhc_micb_en_status(struct snd_soc_component *component, int
if (micb_num == MIC_BIAS_2) {
val = snd_soc_component_read_field(component,
WCD938X_ANA_MICB2,
- WCD938X_ANA_MICB2_ENABLE_MASK);
+ WCD938X_MICB_EN_MASK);
if (val == WCD938X_MICB_ENABLE)
return true;
}
diff --git a/sound/soc/codecs/wcd938x.h b/sound/soc/codecs/wcd938x.h
index df07e92d9d97..0d332cb555ac 100644
--- a/sound/soc/codecs/wcd938x.h
+++ b/sound/soc/codecs/wcd938x.h
@@ -75,7 +75,6 @@
#define WCD938X_MICB_PULL_UP 2
#define WCD938X_MICB_PULL_DOWN 3
#define WCD938X_ANA_MICB2 (0x3023)
-#define WCD938X_ANA_MICB2_ENABLE_MASK GENMASK(7, 6)
#define WCD938X_ANA_MICB2_RAMP (0x3024)
#define WCD938X_RAMP_EN_MASK BIT(7)
#define WCD938X_RAMP_SHIFT_CTRL_MASK GENMASK(4, 2)
--
2.43.0
Correct white-space issues and drop unused
WCD939X_MBHC_IS_SECOND_RAMP_REQUIRED() define. No functional impact.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
sound/soc/codecs/wcd939x.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/sound/soc/codecs/wcd939x.c b/sound/soc/codecs/wcd939x.c
index 201592c728c3..770bc2f35ba7 100644
--- a/sound/soc/codecs/wcd939x.c
+++ b/sound/soc/codecs/wcd939x.c
@@ -85,7 +85,6 @@ enum {
#define WCD939X_MBHC_GET_X1(x) ((x) & 0x3FFF)
/* Z value compared in milliOhm */
-#define WCD939X_MBHC_IS_SECOND_RAMP_REQUIRED(z) false
#define WCD939X_ANA_MBHC_ZDET_CONST (1018 * 1024)
enum {
@@ -525,7 +524,7 @@ static int wcd939x_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
WCD939X_DIGITAL_CDC_COMP_CTL_0,
WCD939X_CDC_COMP_CTL_0_HPHL_COMP_EN,
true);
- /* 5msec compander delay as per HW requirement */
+ /* 5msec compander delay as per HW requirement */
if (!wcd939x->comp2_enable ||
snd_soc_component_read_field(component,
WCD939X_DIGITAL_CDC_COMP_CTL_0,
@@ -1869,7 +1868,6 @@ static void wcd939x_mbhc_program_btn_thr(struct snd_soc_component *component,
static bool wcd939x_mbhc_micb_en_status(struct snd_soc_component *component, int micb_num)
{
-
if (micb_num == MIC_BIAS_2) {
u8 val;
--
2.43.0
All four microphone bias registers have similar layout: enable 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: Krzysztof Kozlowski <[email protected]>
---
Not tested on hardware, but functionally code should be the same.
---
sound/soc/codecs/wcd939x.c | 36 +++++++++++++++++-------------------
sound/soc/codecs/wcd939x.h | 5 +----
2 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/sound/soc/codecs/wcd939x.c b/sound/soc/codecs/wcd939x.c
index c49894aad8a5..201592c728c3 100644
--- a/sound/soc/codecs/wcd939x.c
+++ b/sound/soc/codecs/wcd939x.c
@@ -1268,25 +1268,20 @@ static int wcd939x_micbias_control(struct snd_soc_component *component,
{
struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component);
int micb_index = micb_num - 1;
- u16 micb_field;
u16 micb_reg;
switch (micb_num) {
case MIC_BIAS_1:
micb_reg = WCD939X_ANA_MICB1;
- micb_field = WCD939X_MICB1_ENABLE;
break;
case MIC_BIAS_2:
micb_reg = WCD939X_ANA_MICB2;
- micb_field = WCD939X_MICB2_ENABLE;
break;
case MIC_BIAS_3:
micb_reg = WCD939X_ANA_MICB3;
- micb_field = WCD939X_MICB3_ENABLE;
break;
case MIC_BIAS_4:
micb_reg = WCD939X_ANA_MICB4;
- micb_field = WCD939X_MICB4_ENABLE;
break;
default:
dev_err(component->dev, "%s: Invalid micbias number: %d\n",
@@ -1300,7 +1295,8 @@ static int wcd939x_micbias_control(struct snd_soc_component *component,
if (wcd939x->pullup_ref[micb_index] == 1 &&
wcd939x->micb_ref[micb_index] == 0)
snd_soc_component_write_field(component, micb_reg,
- micb_field, MICB_BIAS_PULL_UP);
+ WCD939X_MICB_ENABLE,
+ MICB_BIAS_PULL_UP);
break;
case MICB_PULLUP_DISABLE:
if (wcd939x->pullup_ref[micb_index] > 0)
@@ -1308,7 +1304,8 @@ static int wcd939x_micbias_control(struct snd_soc_component *component,
if (wcd939x->pullup_ref[micb_index] == 0 &&
wcd939x->micb_ref[micb_index] == 0)
snd_soc_component_write_field(component, micb_reg,
- micb_field, MICB_BIAS_DISABLE);
+ WCD939X_MICB_ENABLE,
+ MICB_BIAS_DISABLE);
break;
case MICB_ENABLE:
wcd939x->micb_ref[micb_index]++;
@@ -1345,7 +1342,8 @@ static int wcd939x_micbias_control(struct snd_soc_component *component,
snd_soc_component_write_field(component,
WCD939X_MICB4_TEST_CTL_2,
WCD939X_TEST_CTL_2_IBIAS_LDO_DRIVER, true);
- snd_soc_component_write_field(component, micb_reg, micb_field,
+ snd_soc_component_write_field(component, micb_reg,
+ WCD939X_MICB_ENABLE,
MICB_BIAS_ENABLE);
if (micb_num == MIC_BIAS_2)
wcd_mbhc_event_notify(wcd939x->wcd_mbhc,
@@ -1362,7 +1360,8 @@ static int wcd939x_micbias_control(struct snd_soc_component *component,
if (wcd939x->micb_ref[micb_index] == 0 &&
wcd939x->pullup_ref[micb_index] > 0)
snd_soc_component_write_field(component, micb_reg,
- micb_field, MICB_BIAS_PULL_UP);
+ WCD939X_MICB_ENABLE,
+ MICB_BIAS_PULL_UP);
else if (wcd939x->micb_ref[micb_index] == 0 &&
wcd939x->pullup_ref[micb_index] == 0) {
if (micb_num == MIC_BIAS_2)
@@ -1370,7 +1369,8 @@ static int wcd939x_micbias_control(struct snd_soc_component *component,
WCD_EVENT_PRE_MICBIAS_2_OFF);
snd_soc_component_write_field(component, micb_reg,
- micb_field, MICB_BIAS_DISABLE);
+ WCD939X_MICB_ENABLE,
+ MICB_BIAS_DISABLE);
if (micb_num == MIC_BIAS_2)
wcd_mbhc_event_notify(wcd939x->wcd_mbhc,
WCD_EVENT_POST_MICBIAS_2_OFF);
@@ -1873,7 +1873,7 @@ static bool wcd939x_mbhc_micb_en_status(struct snd_soc_component *component, int
if (micb_num == MIC_BIAS_2) {
u8 val;
- val = FIELD_GET(WCD939X_MICB2_ENABLE,
+ val = FIELD_GET(WCD939X_MICB_ENABLE,
snd_soc_component_read(component, WCD939X_ANA_MICB2));
if (val == MICB_BIAS_ENABLE)
return true;
@@ -1935,7 +1935,7 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
int req_volt, int micb_num)
{
struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component);
- unsigned int micb_en_field, micb_vout_ctl_field;
+ unsigned int micb_vout_ctl_field;
unsigned int micb_reg, cur_vout_ctl, micb_en;
int req_vout_ctl;
int ret = 0;
@@ -1943,22 +1943,18 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
switch (micb_num) {
case MIC_BIAS_1:
micb_reg = WCD939X_ANA_MICB1;
- micb_en_field = WCD939X_MICB1_ENABLE;
micb_vout_ctl_field = WCD939X_MICB1_VOUT_CTL;
break;
case MIC_BIAS_2:
micb_reg = WCD939X_ANA_MICB2;
- micb_en_field = WCD939X_MICB2_ENABLE;
micb_vout_ctl_field = WCD939X_MICB2_VOUT_CTL;
break;
case MIC_BIAS_3:
micb_reg = WCD939X_ANA_MICB3;
- micb_en_field = WCD939X_MICB3_ENABLE;
micb_vout_ctl_field = WCD939X_MICB1_VOUT_CTL;
break;
case MIC_BIAS_4:
micb_reg = WCD939X_ANA_MICB4;
- micb_en_field = WCD939X_MICB4_ENABLE;
micb_vout_ctl_field = WCD939X_MICB2_VOUT_CTL;
break;
default:
@@ -1975,7 +1971,7 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
* micbias.
*/
micb_en = snd_soc_component_read_field(component, micb_reg,
- micb_en_field);
+ WCD939X_MICB_ENABLE);
cur_vout_ctl = snd_soc_component_read_field(component, micb_reg,
micb_vout_ctl_field);
@@ -1996,14 +1992,16 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
if (micb_en == MICB_BIAS_ENABLE)
snd_soc_component_write_field(component, micb_reg,
- micb_en_field, MICB_BIAS_PULL_DOWN);
+ WCD939X_MICB_ENABLE,
+ MICB_BIAS_PULL_DOWN);
snd_soc_component_write_field(component, micb_reg,
micb_vout_ctl_field, req_vout_ctl);
if (micb_en == MICB_BIAS_ENABLE) {
snd_soc_component_write_field(component, micb_reg,
- micb_en_field, MICB_BIAS_ENABLE);
+ WCD939X_MICB_ENABLE,
+ MICB_BIAS_ENABLE);
/*
* Add 2ms delay as per HW requirement after enabling
* micbias
diff --git a/sound/soc/codecs/wcd939x.h b/sound/soc/codecs/wcd939x.h
index 807cf3113d20..383a79316439 100644
--- a/sound/soc/codecs/wcd939x.h
+++ b/sound/soc/codecs/wcd939x.h
@@ -91,10 +91,9 @@
#define WCD939X_ANA_MBHC_BTN7 (0x3021)
#define WCD939X_MBHC_BTN7_VTH GENMASK(7, 2)
#define WCD939X_ANA_MICB1 (0x3022)
-#define WCD939X_MICB1_ENABLE GENMASK(7, 6)
+#define WCD939X_MICB_ENABLE GENMASK(7, 6)
#define WCD939X_MICB1_VOUT_CTL GENMASK(5, 0)
#define WCD939X_ANA_MICB2 (0x3023)
-#define WCD939X_MICB2_ENABLE GENMASK(7, 6)
#define WCD939X_MICB2_VOUT_CTL GENMASK(5, 0)
#define WCD939X_ANA_MICB2_RAMP (0x3024)
#define WCD939X_MICB2_RAMP_RAMP_ENABLE BIT(7)
@@ -103,10 +102,8 @@
#define WCD939X_MICB2_RAMP_SHIFT_CTL GENMASK(4, 2)
#define WCD939X_MICB2_RAMP_USB_MGDET_MICB2_RAMP GENMASK(1, 0)
#define WCD939X_ANA_MICB3 (0x3025)
-#define WCD939X_MICB3_ENABLE GENMASK(7, 6)
#define WCD939X_MICB3_VOUT_CTL GENMASK(5, 0)
#define WCD939X_ANA_MICB4 (0x3026)
-#define WCD939X_MICB4_ENABLE GENMASK(7, 6)
#define WCD939X_MICB4_VOUT_CTL GENMASK(5, 0)
#define WCD939X_BIAS_CTL (0x3028)
#define WCD939X_BIAS_VBG_FINE_ADJ (0x3029)
--
2.43.0