Ver Fonte

Merge "asoc: codec: Add support for 2S battery configuration in the WSA884x driver"

qctecmdr há 2 anos atrás
pai
commit
bca378d01d

+ 23 - 0
asoc/codecs/wsa884x/wsa884x-reg-masks.h

@@ -187,6 +187,29 @@
 #define WSA884X_CLSH_CTL_0_DLY_EN_MASK                                   0x04
 #define WSA884X_CLSH_CTL_0_INPUT_EN_MASK                                 0x02
 #define WSA884X_CLSH_CTL_0_CLSH_EN_MASK                                  0x01
+/* WSA884X_CLSH_CTL_1 Fields: */
+#define WSA884X_CLSH_CTL_1_SLR_MAX_MASK                                  0xf0
+#define WSA884X_CLSH_CTL_1_VERF_OVRD_EN_MASK                             0x08
+#define WSA884X_CLSH_CTL_1_DECAY_RATE_MASK                               0x07
+/* WSA884X_CLSH_V_HD_PA Fields: */
+#define WSA884X_CLSH_V_HD_PA_V_HD_PA_MASK                                0x1f
+/* WSA884X_UVLO_PROG Fields: */
+#define WSA884X_UVLO_PROG_UVLO1_HYST_MASK                                0xf0
+#define WSA884X_UVLO_PROG_UVLO1_VTH_MASK                                 0x0f
+/* WSA884X_DAC_VCM_CTRL_REG2 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG2_DAC_VCM_SHIFT_MASK                     0xff
+/* WSA884X_DAC_VCM_CTRL_REG3 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG3_DAC_VCM_SHIFT_MASK                     0xff
+/* WSA884X_DAC_VCM_CTRL_REG4 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG4_DAC_VCM_SHIFT_MASK                     0xff
+/* WSA884X_DAC_VCM_CTRL_REG5 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG5_DAC_VCM_SHIFT_MASK                     0xff
+/* WSA884X_DAC_VCM_CTRL_REG6 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG6_DAC_VCM_SHIFT_MASK                     0xff
+/* WSA884X_DAC_VCM_CTRL_REG7 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG7_SPARE_BITS_7_2_MASK                    0xfc
+#define WSA884X_DAC_VCM_CTRL_REG7_DAC_VCM_SHIFT_FINAL_OVERRIDE_MASK      0x02
+#define WSA884X_DAC_VCM_CTRL_REG7_DAC_VCM_SHIFT_ZONE_OVERRIDE_MASK       0x01
 /* WSA884X_STB_CTRL1 Fields: */
 #define WSA884X_STB_CTRL1_SLOPE_COMP_CURRENT_MASK                        0xf8
 #define WSA884X_STB_CTRL1_VOUT_FS_MASK                                   0x07

+ 24 - 0
asoc/codecs/wsa884x/wsa884x-reg-shifts.h

@@ -177,6 +177,30 @@
 #define WSA884X_CLSH_CTL_0_DLY_EN_SHIFT                                   0x02
 #define WSA884X_CLSH_CTL_0_INPUT_EN_SHIFT                                 0x01
 #define WSA884X_CLSH_CTL_0_CLSH_EN_SHIFT                                  0x00
+/* WSA884X_CLSH_CTL_1 Fields: */
+#define WSA884X_CLSH_CTL_1_SLR_MAX_SHIFT                                  0x04
+#define WSA884X_CLSH_CTL_1_VERF_OVRD_EN_SHIFT                             0x03
+#define WSA884X_CLSH_CTL_1_DECAY_RATE_SHIFT                               0x00
+/* WSA884X_CLSH_V_HD_PA Fields: */
+#define WSA884X_CLSH_V_HD_PA_V_HD_PA_SHIFT                                0x00
+/* WSA884X_UVLO_PROG Fields: */
+#define WSA884X_UVLO_PROG_UVLO1_HYST_SHIFT                                0x04
+#define WSA884X_UVLO_PROG_UVLO1_VTH_SHIFT                                 0x00
+/* WSA884X_DAC_VCM_CTRL_REG2 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG2_DAC_VCM_SHIFT_SHIFT                     0x00
+/* WSA884X_DAC_VCM_CTRL_REG3 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG3_DAC_VCM_SHIFT_SHIFT                     0x00
+/* WSA884X_DAC_VCM_CTRL_REG4 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG4_DAC_VCM_SHIFT_SHIFT                     0x00
+/* WSA884X_DAC_VCM_CTRL_REG5 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG5_DAC_VCM_SHIFT_SHIFT                     0x00
+/* WSA884X_DAC_VCM_CTRL_REG6 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG6_DAC_VCM_SHIFT_SHIFT                     0x00
+/* WSA884X_DAC_VCM_CTRL_REG7 Fields: */
+#define WSA884X_DAC_VCM_CTRL_REG7_SPARE_BITS_7_2_SHIFT                    0x02
+#define WSA884X_DAC_VCM_CTRL_REG7_DAC_VCM_SHIFT_FINAL_OVERRIDE_SHIFT      0x01
+#define WSA884X_DAC_VCM_CTRL_REG7_DAC_VCM_SHIFT_ZONE_OVERRIDE_SHIFT       0x00
+
 /* WSA884X_STB_CTRL1 Fields: */
 #define WSA884X_STB_CTRL1_SLOPE_COMP_CURRENT_SHIFT                        0x03
 #define WSA884X_STB_CTRL1_VOUT_FS_SHIFT                                   0x00

+ 21 - 1
asoc/codecs/wsa884x/wsa884x.c

@@ -132,6 +132,19 @@ static const struct wsa_reg_mask_val reg_init[] = {
 	{REG_FIELD_VALUE(ZX_CTRL1, ZX_DET_SW_SEL, 0x03)},
 };
 
+static const struct wsa_reg_mask_val reg_init_2S[] = {
+	{REG_FIELD_VALUE(CLSH_CTL_1, SLR_MAX, 0x02)},
+	{REG_FIELD_VALUE(CLSH_V_HD_PA, V_HD_PA, 0x13)},
+	{REG_FIELD_VALUE(UVLO_PROG, UVLO1_VTH, 0x03)},
+	{REG_FIELD_VALUE(UVLO_PROG, UVLO1_HYST, 0x03)},
+	{REG_FIELD_VALUE(DAC_VCM_CTRL_REG2, DAC_VCM_SHIFT, 0x06)},
+	{REG_FIELD_VALUE(DAC_VCM_CTRL_REG3, DAC_VCM_SHIFT, 0x14)},
+	{REG_FIELD_VALUE(DAC_VCM_CTRL_REG4, DAC_VCM_SHIFT, 0x19)},
+	{REG_FIELD_VALUE(DAC_VCM_CTRL_REG5, DAC_VCM_SHIFT, 0x1B)},
+	{REG_FIELD_VALUE(DAC_VCM_CTRL_REG6, DAC_VCM_SHIFT, 0x1C)},
+	{REG_FIELD_VALUE(DAC_VCM_CTRL_REG7, DAC_VCM_SHIFT_FINAL_OVERRIDE, 0x01)},
+};
+
 static int wsa884x_handle_post_irq(void *data);
 static int wsa884x_get_temperature(struct snd_soc_component *component,
 				   int *temp);
@@ -1505,6 +1518,13 @@ static void wsa884x_codec_init(struct snd_soc_component *component)
 		snd_soc_component_update_bits(component, reg_init[i].reg,
 					reg_init[i].mask, reg_init[i].val);
 
+	/* Register updates for 2S battery configuration */
+	if (wsa884x->bat_cfg == CONFIG_2S) {
+		for (i = 0; i < ARRAY_SIZE(reg_init_2S); i++)
+			snd_soc_component_update_bits(component, reg_init_2S[i].reg,
+						reg_init_2S[i].mask, reg_init_2S[i].val);
+	}
+
 	wsa_noise_gate_write(component, wsa884x->noise_gate_mode);
 
 }
@@ -2246,7 +2266,7 @@ static int wsa884x_swr_probe(struct swr_device *pdev)
 	wsa884x_set_gain_parameters(component);
 	wsa884x_set_pbr_parameters(component);
 	/* Must write WO registers in a single write */
-	wo0_val = (0xC | (wsa884x->pa_aux_gain << 0x02) | !wsa884x->dev_mode);
+	wo0_val = (0xC0 | (wsa884x->pa_aux_gain << 0x02) | !wsa884x->dev_mode);
 	snd_soc_component_write(component, WSA884X_ANA_WO_CTL_0, wo0_val);
 	snd_soc_component_write(component, WSA884X_ANA_WO_CTL_1, 0x0);
 	if (wsa884x->rload == WSA_4_OHMS || wsa884x->rload == WSA_6_OHMS)