Browse Source

asoc: wcd939x: Support xtalk for high voltage mics

Update zdet and xtalk to support high voltage microphones
with improved accuracy.

Change-Id: I4b0af5ade7f653de4a938162302ec21c4a09891f
Signed-off-by: Sam Rainey <[email protected]>
Sam Rainey 1 year ago
parent
commit
08bc673260

+ 100 - 62
asoc/codecs/wcd939x/internal.h

@@ -17,11 +17,14 @@
 #define SWR_SCP_CONTROL 0x44
 #define SWR_SCP_HOST_CLK_DIV2_CTL_BANK 0xE0
 #define WCD939X_MAX_MICBIAS 4
+#define R_COMMON_GND_BUFFER_SIZE 4
 #define MAX_XTALK_SCALE 31
 #define MIN_XTALK_ALPHA 0
 #define MIN_K_TIMES_100 -90
 #define MAX_K_TIMES_100 10000
 #define MAX_USBCSS_HS_IMPEDANCE_MOHMS 20000
+#define MIN_DIFF_SLOPE_FACTOR 9800
+#define MAX_DIFF_SLOPE_FACTOR 10000
 
 /* Convert from vout ctl to micbias voltage in mV */
 #define  WCD_VOUT_CTL_TO_MICB(v)  (1000 + v * 50)
@@ -162,80 +165,100 @@ struct wcd939x_micbias_setting {
 	u8 bias1_cfilt_sel;
 };
 
-struct wcd939x_usbcss_hs_params {
-	/* Resistance of ground-side internal FET for SBU1 */
-	u32 r_gnd_sbu1_int_fet_mohms;
-	/* Resistance of ground-side internal FET for SBU2 */
-	u32 r_gnd_sbu2_int_fet_mohms;
-	/* Customer-characterized resistance for the ground-side external FET */
-	u32 r_gnd_ext_fet_customer_mohms;
-	/* SW-computed resistance for the ground-side external FET */
-	u32 r_gnd_ext_fet_mohms;
+struct aud_ch_params {
+	/* Resistance of audio-side internal FET */
+	u32 r_aud_int_fet_mohms;
+	/* Resistance of audio-side external FET */
+	u32 r_aud_ext_fet_mohms;
+	/* Total right audio-side resistance */
+	u32 r_aud_res_tot_mohms;
+	/* Sum of audio-side parasitics and the left/right side of the load */
+	u32 r_load_eff_mohms;
+	/* DT audio parasitics between HPH_L/R and HPHL/R_FB, in milliohms */
+	u32 r1;
+	/* DT audio-side parasitics between the WCD and external FET,
+	 * in milliohms
+	 */
+	u32 r3;
+	/* Calibrated and adjusted SE zdet measurement value */
+	u32 zval;
+};
+
+struct aud_params {
+	/* Left-side audio params */
+	struct aud_ch_params l;
+	/* Right-side audio params */
+	struct aud_ch_params r;
+	/* Surge switch resistance */
+	u32 r_surge_mohms;
+	/* Tap out linearizer constant for the audio path, multiplied by 100 from the original
+	 * constants to support decimal values up to the hundredth place
+	 */
+	s32 k_aud_times_100;
+	/* Fixed offset to be applied to audio taps */
+	s32 aud_tap_offset;
+};
+
+struct gnd_sbu_params {
+	/* Resistance of ground-side internal FET */
+	u32 r_gnd_int_fet_mohms;
 	/* Total ground-side parasitics between the WCD and external FET */
 	u32 r_gnd_par_route1_mohms;
 	/* Total ground-side parasitics between the external FET and connector */
 	u32 r_gnd_par_route2_mohms;
 	/* Total ground-side parasitics between the WCD and connector; sum of route1 and route2 */
 	u32 r_gnd_par_tot_mohms;
-	/* Total ground-side resistance for SBU1 */
-	u32 r_gnd_sbu1_res_tot_mohms;
-	/* Total ground-side resistance for SBU2 */
-	u32 r_gnd_sbu2_res_tot_mohms;
-	/* Customer-characterized positive parasitics introduced from the connector */
-	u32 r_conn_par_load_pos_mohms;
-	/* Resistance of left audio-side internal FET */
-	u32 r_aud_int_fet_l_mohms;
-	/* Resistance of right audio-side internal FET */
-	u32 r_aud_int_fet_r_mohms;
-	/* Resistance of left audio-side external FET */
-	u32 r_aud_ext_fet_l_mohms;
-	/* Resistance of right audio-side external FET */
-	u32 r_aud_ext_fet_r_mohms;
-	/* Total left audio-side resistance */
-	u32 r_aud_res_tot_l_mohms;
-	/* Total right audio-side resistance */
-	u32 r_aud_res_tot_r_mohms;
-	/* Surge switch resistance */
-	u32 r_surge_mohms;
-	/* Sum of left audio-side parasitics and the left side of the load */
-	u32 r_load_eff_l_mohms;
-	/* Sum of right audio-side parasitics and the right side of the load */
-	u32 r_load_eff_r_mohms;
-	/* Customer-characterized audio-side parasitics between the WCD and external FET,
-	 * in milliohms
-	 */
-	u32 r3;
-	/* Customer-characterized ground-side parasitics between the external FET and connector,
-	 * in milliohms
-	 */
+	/* Total ground-side resistance */
+	u32 r_gnd_res_tot_mohms;
+	/* DT ground-side parasitics between the external FET and connector, in milliohms */
 	u32 r4;
-	/* For digital crosstalk with remote sensed analog crosstalk mode, customer-characterized
-	 * ground path parasitic resistance between the WCD SBU pin and the external MOSFET,
-	 * in milliohms
+	/* For digital crosstalk with remote sensed analog crosstalk mode, DT ground path parasitic
+	 * resistance between the WCD SBU pin and the external MOSFET, in milliohms
 	 */
 	u32 r5;
-	/* For digital crosstalk with local sensed analog crosstalk mode, customer-characterized
-	 * ground path parasitic resistance between the WCD GSBU tap point and the external MOSFET,
-	 * in milliohms
+	/* For digital crosstalk with local sensed analog crosstalk mode, DT ground path parasitic
+	 * resistance between the WCD GSBU tap point and the external MOSFET, in milliohms
 	 */
 	u32 r6;
-	/* For digital crosstalk with local sensed analog crosstalk mode, customer-characterized
-	 * ground path parasitic resistance between the WCD GSBU tap point and the WCD SBU pin,
-	 * in milliohms
+	/* For digital crosstalk with local sensed analog crosstalk mode, DT ground path parasitic
+	 * resistance between the WCD GSBU tap point and the WCD SBU pin, in milliohms
 	 */
 	u32 r7;
-	/* Tap out linearizer constant for the audio path, multiplied by 100 from the original
-	 * constants to support decimal values up to the hundredth place
-	 */
-	s32 k_aud_times_100;
-	/* Tap out linearizer constant for the ground path, multiplied by 100 from the original
-	 * constants to support decimal values up to the hundredth place
-	 */
-	s32 k_gnd_times_100;
-	/* Fixed offset to be applied to audio taps */
-	s32 aud_tap_offset;
-	/* Fixed offset to be applied to ground taps */
-	s32 gnd_tap_offset;
+};
+
+struct r_common_gnd_buffer {
+	/* Data for elements in buffer */
+	u32 data[R_COMMON_GND_BUFFER_SIZE];
+	/* Index to write next element in buffer */
+	size_t write_index;
+};
+
+struct gnd_params {
+	/* SBU1-ground params */
+	struct gnd_sbu_params sbu1;
+	/* SBU2-ground params */
+	struct gnd_sbu_params sbu2;
+	/* FIFO circular buffer for storing previous values of r_common_gnd_mohms */
+	struct r_common_gnd_buffer r_cm_gnd_buffer;
+	/* DT resistance of the ground-side external FET, in milliohms */
+	u32 rdson_mohms;
+	/* DT resistance of the ground-side external FET, Vgs=3.6V, in milliohms */
+	u32 rdson_3p6v_mohms;
+	/* Difference between the ground external FET, Vgs=3.6V and Vgs=6V */
+	u32 gnd_ext_fet_delta_mohms;
+	/* Minimum value used for linearizer audio tap calculations */
+	u32 gnd_ext_fet_min_mohms;
+	/* SW-computed resistance for the ground-side external FET */
+	u32 r_gnd_ext_fet_mohms;
+	/* Total ground-side resistance, with the internal FET and the route1 parasitic removed */
+	u32 r_common_gnd_mohms;
+	/* Ground path offset for testing debug, in milliohms */
+	s32 r_common_gnd_offset;
+	/* Margin to check if the calculated r_common_gnd is in a reasonable range, in milliohms */
+	u32 r_common_gnd_margin;
+};
+
+struct xtalk_params {
 	/* Computed optimal d-xtalk left-side scale value */
 	u8 scale_l;
 	/* Computed optimal d-xtalk left-side alpha value */
@@ -244,7 +267,7 @@ struct wcd939x_usbcss_hs_params {
 	u8 scale_r;
 	/* Computed optimal d-xtalk right-side alpha value */
 	u8 alpha_r;
-	/* Customer-tuned configuration for d-xtalk:
+	/* DT configuration for d-xtalk:
 	 * 0 for digital crosstalk disabled,
 	 * 1 for digital crosstalk with local sensed a-xtalk enabled, and
 	 * 2 for digital crosstalk with remote sensed a-xtalk enabled.
@@ -252,6 +275,21 @@ struct wcd939x_usbcss_hs_params {
 	enum xtalk_mode xtalk_config;
 };
 
+struct wcd939x_usbcss_hs_params {
+	/* Audio-side USBCSS-HS impedance parameters */
+	struct aud_params aud;
+	/* Ground-side USBCSS-HS impedance parameters */
+	struct gnd_params gnd;
+	/* Xtalk-specific parameters */
+	struct xtalk_params xtalk;
+	/* Calibrated and adjusted differential zdet measurement value */
+	u32 zdiffval;
+	/* Multiplicative scale factor to adjust differential zdet measurement value, times 1000 */
+	u32 diff_slope_factor_times_1000;
+	/* Multiplicative scale factor to adjust single-ended zdet measurement value, times 1000 */
+	u32 se_slope_factor_times_1000;
+};
+
 struct wcd939x_pdata {
 	struct device_node *rst_np;
 	struct device_node *rx_slave;

File diff suppressed because it is too large
+ 455 - 377
asoc/codecs/wcd939x/wcd939x-mbhc.c


+ 3 - 2
asoc/codecs/wcd939x/wcd939x-mbhc.h

@@ -22,9 +22,10 @@ static inline u32 get_r_gnd_res_tot_mohms(u32 r_gnd_int_fet_mohms, u32 r_gnd_ext
 	return r_gnd_int_fet_mohms + r_gnd_ext_fet_mohms + r_gnd_par_tot_mohms;
 }
 
-static inline u32 get_r_aud_res_tot_mohms(u32 r_aud_int_fet_mohms, u32 r_aud_ext_fet_mohms)
+static inline u32 get_r_aud_res_tot_mohms(u32 r_aud_int_fet_mohms, u32 r_aud_ext_fet_mohms,
+					  u32 r_load_eff_mohms)
 {
-	return r_aud_int_fet_mohms + r_aud_ext_fet_mohms;
+	return r_aud_int_fet_mohms + r_aud_ext_fet_mohms + r_load_eff_mohms;
 }
 
 #if IS_ENABLED(CONFIG_SND_SOC_WCD939X)

+ 192 - 104
asoc/codecs/wcd939x/wcd939x.c

@@ -51,6 +51,7 @@
 #define HPH_IMPEDANCE_2VPK_MODE_OHMS 260
 #define XTALK_L_CH_NUM 0
 #define XTALK_R_CH_NUM 1
+#define GND_EXT_FET_MARGIN_MOHMS 200
 
 #define NUM_ATTEMPTS 5
 #define COMP_MAX_COEFF 25
@@ -1068,14 +1069,14 @@ static int wcd939x_config_xtalk(struct snd_soc_component *component,
 		/* Write scale and alpha based on channel */
 		if (xtalk_indx == XTALK_L_CH_NUM) {
 			snd_soc_component_update_bits(component, xtalk_sec1, 0xFF,
-						      pdata->usbcss_hs.alpha_l);
+						      pdata->usbcss_hs.xtalk.alpha_l);
 			snd_soc_component_update_bits(component, xtalk_sec0, 0x1F,
-						      pdata->usbcss_hs.scale_l);
+						      pdata->usbcss_hs.xtalk.scale_l);
 		} else if (xtalk_indx == XTALK_R_CH_NUM) {
 			snd_soc_component_update_bits(component, xtalk_sec1, 0xFF,
-						      pdata->usbcss_hs.alpha_r);
+						      pdata->usbcss_hs.xtalk.alpha_r);
 			snd_soc_component_update_bits(component, xtalk_sec0, 0x1F,
-						      pdata->usbcss_hs.scale_r);
+						      pdata->usbcss_hs.xtalk.scale_r);
 		} else {
 			snd_soc_component_update_bits(component, xtalk_sec1, 0xFF, MIN_XTALK_ALPHA);
 			snd_soc_component_update_bits(component, xtalk_sec0, 0x1F, MAX_XTALK_SCALE);
@@ -4768,41 +4769,69 @@ static void wcd939x_dt_parse_micbias_info(struct device *dev,
 	}
 }
 
+static void fill_r_common_gnd_buffer(struct wcd939x_usbcss_hs_params *usbcss_hs, u32 val)
+{
+	size_t i;
+
+	for (i = 0; i < R_COMMON_GND_BUFFER_SIZE; i++)
+		usbcss_hs->gnd.r_cm_gnd_buffer.data[i] = val;
+}
+
 static void init_usbcss_hs_params(struct wcd939x_usbcss_hs_params *usbcss_hs)
 {
-	usbcss_hs->r_gnd_sbu1_int_fet_mohms = 145;
-	usbcss_hs->r_gnd_sbu2_int_fet_mohms = 185;
-	usbcss_hs->r_gnd_ext_fet_customer_mohms = 0;
-	usbcss_hs->r_gnd_ext_fet_mohms = 0;  /* to be computed during MBHC zdet */
-	usbcss_hs->r_gnd_par_route1_mohms = 5;
-	usbcss_hs->r_gnd_par_route2_mohms = 330;
-	usbcss_hs->r_gnd_par_tot_mohms = 0;
-	usbcss_hs->r_gnd_sbu1_res_tot_mohms = 0;
-	usbcss_hs->r_gnd_sbu2_res_tot_mohms = 0;
-	usbcss_hs->r_conn_par_load_pos_mohms = 7550;
-	usbcss_hs->r_aud_int_fet_l_mohms = 303;
-	usbcss_hs->r_aud_int_fet_r_mohms = 275;
-	usbcss_hs->r_aud_ext_fet_l_mohms = 0; /* to be computed during MBHC zdet */
-	usbcss_hs->r_aud_ext_fet_r_mohms = 0; /* to be computed during MBHC zdet */
-	usbcss_hs->r_aud_res_tot_l_mohms = 0;
-	usbcss_hs->r_aud_res_tot_r_mohms = 0;
-	usbcss_hs->r_surge_mohms = 272;
-	usbcss_hs->r_load_eff_l_mohms = 0; /* to be computed during MBHC zdet */
-	usbcss_hs->r_load_eff_r_mohms = 0; /* to be computed during MBHC zdet */
-	usbcss_hs->r3 = 1;
-	usbcss_hs->r4 = 330;
-	usbcss_hs->r5 = 5;
-	usbcss_hs->r6 = 1;
-	usbcss_hs->r7 = 5;
-	usbcss_hs->k_aud_times_100 = 13;
-	usbcss_hs->k_gnd_times_100 = 13;
-	usbcss_hs->aud_tap_offset = 0;
-	usbcss_hs->gnd_tap_offset = 0;
-	usbcss_hs->scale_l = MAX_XTALK_SCALE;
-	usbcss_hs->alpha_l = MIN_XTALK_ALPHA;
-	usbcss_hs->scale_r = MAX_XTALK_SCALE;
-	usbcss_hs->alpha_r = MIN_XTALK_ALPHA;
-	usbcss_hs->xtalk_config = XTALK_NONE;
+	fill_r_common_gnd_buffer(usbcss_hs, 0);
+	usbcss_hs->gnd.sbu1.r_gnd_int_fet_mohms = 183;
+	usbcss_hs->gnd.sbu2.r_gnd_int_fet_mohms = 127;
+	usbcss_hs->gnd.r_cm_gnd_buffer.write_index = 0;
+	usbcss_hs->gnd.rdson_mohms = 500;
+	usbcss_hs->gnd.rdson_3p6v_mohms = 545;
+	usbcss_hs->gnd.r_gnd_ext_fet_mohms = 0;  /* to be computed during MBHC zdet */
+	usbcss_hs->gnd.r_common_gnd_mohms = 0;
+	usbcss_hs->gnd.r_common_gnd_offset = 0;
+	usbcss_hs->gnd.r_common_gnd_margin = 500;
+	usbcss_hs->gnd.gnd_ext_fet_delta_mohms = 45;
+	usbcss_hs->gnd.gnd_ext_fet_min_mohms = 0;
+	usbcss_hs->gnd.sbu1.r_gnd_par_route1_mohms = 5;
+	usbcss_hs->gnd.sbu2.r_gnd_par_route1_mohms = 5;
+	usbcss_hs->gnd.sbu1.r_gnd_par_route2_mohms = 330;
+	usbcss_hs->gnd.sbu2.r_gnd_par_route2_mohms = 330;
+	usbcss_hs->gnd.sbu1.r_gnd_par_tot_mohms = 0;
+	usbcss_hs->gnd.sbu2.r_gnd_par_tot_mohms = 0;
+	usbcss_hs->gnd.sbu1.r_gnd_res_tot_mohms = 0;
+	usbcss_hs->gnd.sbu2.r_gnd_res_tot_mohms = 0;
+	usbcss_hs->aud.l.r_aud_int_fet_mohms = 290;
+	usbcss_hs->aud.r.r_aud_int_fet_mohms = 290;
+	usbcss_hs->aud.l.r_aud_ext_fet_mohms = 0; /* to be computed during MBHC zdet */
+	usbcss_hs->aud.r.r_aud_ext_fet_mohms = 0; /* to be computed during MBHC zdet */
+	usbcss_hs->aud.l.r_aud_res_tot_mohms = 0;
+	usbcss_hs->aud.r.r_aud_res_tot_mohms = 0;
+	usbcss_hs->aud.r_surge_mohms = 229;
+	usbcss_hs->aud.l.r_load_eff_mohms = 0; /* to be computed during MBHC zdet */
+	usbcss_hs->aud.r.r_load_eff_mohms = 0; /* to be computed during MBHC zdet */
+	usbcss_hs->aud.l.zval = 0; /* to be computed during MBHC zdet */
+	usbcss_hs->aud.r.zval = 0; /* to be computed during MBHC zdet */
+	usbcss_hs->zdiffval = 0; /* to be computed during MBHC zdet */
+	usbcss_hs->diff_slope_factor_times_1000 = 9898;
+	usbcss_hs->se_slope_factor_times_1000 = 9906;
+	usbcss_hs->aud.l.r1 = 310;
+	usbcss_hs->aud.r.r1 = 310;
+	usbcss_hs->aud.l.r3 = 1;
+	usbcss_hs->aud.r.r3 = 1;
+	usbcss_hs->gnd.sbu1.r4 = 530;
+	usbcss_hs->gnd.sbu2.r4 = 530;
+	usbcss_hs->gnd.sbu1.r5 = 5;
+	usbcss_hs->gnd.sbu2.r5 = 5;
+	usbcss_hs->gnd.sbu1.r6 = 1;
+	usbcss_hs->gnd.sbu2.r6 = 1;
+	usbcss_hs->gnd.sbu1.r7 = 5;
+	usbcss_hs->gnd.sbu2.r7 = 5;
+	usbcss_hs->aud.k_aud_times_100 = 13;
+	usbcss_hs->aud.aud_tap_offset = 0;
+	usbcss_hs->xtalk.scale_l = MAX_XTALK_SCALE;
+	usbcss_hs->xtalk.alpha_l = MIN_XTALK_ALPHA;
+	usbcss_hs->xtalk.scale_r = MAX_XTALK_SCALE;
+	usbcss_hs->xtalk.alpha_r = MIN_XTALK_ALPHA;
+	usbcss_hs->xtalk.xtalk_config = XTALK_NONE;
 }
 
 static void parse_xtalk_param(struct device *dev, u32 default_val, u32 *prop_val_p,
@@ -4827,7 +4856,7 @@ static void parse_xtalk_param(struct device *dev, u32 default_val, u32 *prop_val
 static void wcd939x_dt_parse_usbcss_hs_info(struct device *dev,
 					    struct wcd939x_usbcss_hs_params *usbcss_hs)
 {
-	u32 prop_val = 0;
+	u32 prop_val = 0, r_common_gnd_mohms = 0;
 	s32 prop_val_signed = 0;
 	int rc = 0;
 
@@ -4839,7 +4868,7 @@ static void wcd939x_dt_parse_usbcss_hs_info(struct device *dev,
 		rc = wcd939x_read_of_property_u32(dev, "qcom,usbcss-hs-xtalk-config", &prop_val);
 		if ((!rc) && (prop_val == XTALK_NONE || prop_val == XTALK_DIGITAL
 			      || prop_val == XTALK_ANALOG)) {
-			usbcss_hs->xtalk_config = (enum xtalk_mode) prop_val;
+			usbcss_hs->xtalk.xtalk_config = (enum xtalk_mode) prop_val;
 		} else
 			dev_dbg(dev, "%s: %s OOB. Default value of %s used.\n",
 				__func__, "qcom,usbcss-hs-xtalk-config", "XTALK_NONE");
@@ -4850,83 +4879,142 @@ static void wcd939x_dt_parse_usbcss_hs_info(struct device *dev,
 	/* k values for linearizer */
 	if (of_find_property(dev->of_node, "qcom,usbcss-hs-lin-k-aud", NULL)) {
 		rc = wcd939x_read_of_property_s32(dev, "qcom,usbcss-hs-lin-k-aud",
-						  &prop_val);
-		if ((!rc) && (prop_val <= MAX_K_TIMES_100) && (prop_val >= MIN_K_TIMES_100))
-			usbcss_hs->k_aud_times_100 = prop_val;
-		dev_dbg(dev, "%s: %s OOB. Default value of %d will be used.\n",
-			__func__, "qcom,usbcss-hs-lin-k-aud",
-			usbcss_hs->k_aud_times_100);
+						  &prop_val_signed);
+		if ((!rc) && (prop_val_signed <= MAX_K_TIMES_100) &&
+		    (prop_val_signed >= MIN_K_TIMES_100))
+			usbcss_hs->aud.k_aud_times_100 = prop_val_signed;
+		else
+			dev_dbg(dev, "%s: %s OOB. Default value of %d will be used.\n",
+				__func__, "qcom,usbcss-hs-lin-k-aud",
+				usbcss_hs->aud.k_aud_times_100);
 	} else {
 		dev_dbg(dev, "%s: %s property not found. Default value of %d will be used.\n",
 			__func__, "qcom,usbcss-hs-lin-k-aud",
-			usbcss_hs->k_aud_times_100);
+			usbcss_hs->aud.k_aud_times_100);
 	}
-	if (of_find_property(dev->of_node, "qcom,usbcss-hs-lin-k-gnd", NULL)) {
-		rc = wcd939x_read_of_property_s32(dev, "qcom,usbcss-hs-lin-k-gnd",
-						  &prop_val_signed);
-		if ((!rc) && (prop_val_signed <= MAX_K_TIMES_100) &&
-		    (prop_val_signed >= MIN_K_TIMES_100))
-			usbcss_hs->k_gnd_times_100 = prop_val_signed;
-		dev_dbg(dev, "%s: %s OOB. Default value of %d will be used.\n",
-			__func__, "qcom,usbcss-hs-lin-k-gnd",
-			usbcss_hs->k_gnd_times_100);
+
+	/* Differential slope factor */
+	if (of_find_property(dev->of_node, "qcom,usbcss-hs-diff-slope", NULL)) {
+		rc = wcd939x_read_of_property_u32(dev, "qcom,usbcss-hs-diff-slope", &prop_val);
+		if ((!rc) && (prop_val <= MAX_DIFF_SLOPE_FACTOR) &&
+		    (prop_val >= MIN_DIFF_SLOPE_FACTOR))
+			usbcss_hs->diff_slope_factor_times_1000 = prop_val;
+		else
+			dev_dbg(dev, "%s: %s OOB. Default value of %d will be used.\n",
+				__func__, "qcom,usbcss-hs-diff-slope",
+				usbcss_hs->diff_slope_factor_times_1000);
 	} else {
 		dev_dbg(dev, "%s: %s property not found. Default value of %d will be used.\n",
-			__func__, "qcom,usbcss-hs-lin-k-gnd",
-			usbcss_hs->k_gnd_times_100);
-	}
-
-	/* r_gnd_ext_fet_customer_mohms */
-	parse_xtalk_param(dev, usbcss_hs->r_gnd_ext_fet_customer_mohms, &prop_val,
-			  "qcom,usbcss-hs-rdson");
-	usbcss_hs->r_gnd_ext_fet_customer_mohms = prop_val;
-	/* r_conn_par_load_pos_mohm */
-	parse_xtalk_param(dev, usbcss_hs->r_conn_par_load_pos_mohms, &prop_val,
-			  "qcom,usbcss-hs-r2");
-	usbcss_hs->r_conn_par_load_pos_mohms = prop_val;
+			__func__, "qcom,usbcss-hs-diff-slope",
+			usbcss_hs->diff_slope_factor_times_1000);
+	}
+
+	/* R_ds(on) */
+	parse_xtalk_param(dev, usbcss_hs->gnd.rdson_mohms, &prop_val, "qcom,usbcss-hs-rdson-6v");
+	usbcss_hs->gnd.rdson_mohms = prop_val;
+	/* R_ds(on) Vgs=3.6V */
+	parse_xtalk_param(dev, usbcss_hs->gnd.rdson_3p6v_mohms, &prop_val,
+			  "qcom,usbcss-hs-rdson-3p6v");
+	usbcss_hs->gnd.rdson_3p6v_mohms = prop_val;
+	usbcss_hs->gnd.gnd_ext_fet_delta_mohms = (s32) (usbcss_hs->gnd.rdson_3p6v_mohms -
+							usbcss_hs->gnd.rdson_mohms);
+	/* r_common_gnd_margin */
+	parse_xtalk_param(dev, usbcss_hs->gnd.r_common_gnd_margin, &prop_val,
+			  "qcom,usbcss-hs-rcom-margin");
+	usbcss_hs->gnd.r_common_gnd_margin = prop_val;
+	/* r1 */
+	parse_xtalk_param(dev, usbcss_hs->aud.l.r1, &prop_val,
+			  "qcom,usbcss-hs-r1-l");
+	usbcss_hs->aud.l.r1 = prop_val;
+	parse_xtalk_param(dev, usbcss_hs->aud.r.r1, &prop_val,
+			  "qcom,usbcss-hs-r1-r");
+	usbcss_hs->aud.r.r1 = prop_val;
 	/* r3 */
-	parse_xtalk_param(dev, usbcss_hs->r3, &prop_val,
-			  "qcom,usbcss-hs-r3");
-	usbcss_hs->r3 = prop_val;
+	parse_xtalk_param(dev, usbcss_hs->aud.l.r3, &prop_val,
+			  "qcom,usbcss-hs-r3-l");
+	usbcss_hs->aud.l.r3 = prop_val;
+	parse_xtalk_param(dev, usbcss_hs->aud.r.r3, &prop_val,
+			  "qcom,usbcss-hs-r3-r");
+	usbcss_hs->aud.r.r3 = prop_val;
 	/* r4 */
-	parse_xtalk_param(dev, usbcss_hs->r4, &prop_val,
-			  "qcom,usbcss-hs-r4");
-	usbcss_hs->r4 = prop_val;
+	parse_xtalk_param(dev, usbcss_hs->gnd.sbu1.r4, &prop_val,
+			  "qcom,usbcss-hs-r4-sbu1");
+	usbcss_hs->gnd.sbu1.r4 = prop_val;
+	parse_xtalk_param(dev, usbcss_hs->gnd.sbu2.r4, &prop_val,
+			  "qcom,usbcss-hs-r4-sbu2");
+	usbcss_hs->gnd.sbu2.r4 = prop_val;
 	/* r_gnd_par_route1_mohms and r_gnd_par_route2_mohms */
-	if (usbcss_hs->xtalk_config == XTALK_ANALOG) {
-		parse_xtalk_param(dev, usbcss_hs->r5, &prop_val,
-				  "qcom,usbcss-hs-r5");
-		usbcss_hs->r5 = prop_val;
-		usbcss_hs->r_gnd_par_route1_mohms = usbcss_hs->r5 + usbcss_hs->r4;
-		usbcss_hs->r_gnd_par_route2_mohms = 125;
-	} else if (usbcss_hs->xtalk_config == XTALK_DIGITAL) {
-		parse_xtalk_param(dev, usbcss_hs->r6, &prop_val,
-				  "qcom,usbcss-hs-r6");
-		usbcss_hs->r6 = prop_val;
-		usbcss_hs->r_gnd_par_route2_mohms = usbcss_hs->r6 + usbcss_hs->r4;
-		parse_xtalk_param(dev, usbcss_hs->r_gnd_par_route1_mohms, &prop_val,
-				  "qcom,usbcss-hs-r7");
-		usbcss_hs->r7 = prop_val;
-		usbcss_hs->r_gnd_par_route1_mohms = prop_val;
+	if (usbcss_hs->xtalk.xtalk_config == XTALK_ANALOG) {
+		parse_xtalk_param(dev, usbcss_hs->gnd.sbu1.r5, &prop_val,
+				  "qcom,usbcss-hs-r5-sbu1");
+		usbcss_hs->gnd.sbu1.r5 = prop_val;
+		parse_xtalk_param(dev, usbcss_hs->gnd.sbu2.r5, &prop_val,
+				  "qcom,usbcss-hs-r5-sbu2");
+		usbcss_hs->gnd.sbu2.r5 = prop_val;
+		usbcss_hs->gnd.sbu1.r_gnd_par_route1_mohms = usbcss_hs->gnd.sbu1.r5 +
+							     usbcss_hs->gnd.sbu1.r4;
+		usbcss_hs->gnd.sbu2.r_gnd_par_route1_mohms = usbcss_hs->gnd.sbu2.r5 +
+							     usbcss_hs->gnd.sbu2.r4;
+		usbcss_hs->gnd.sbu1.r_gnd_par_route2_mohms = 125;
+		usbcss_hs->gnd.sbu2.r_gnd_par_route2_mohms = 125;
+	} else if (usbcss_hs->xtalk.xtalk_config == XTALK_DIGITAL) {
+		parse_xtalk_param(dev, usbcss_hs->gnd.sbu1.r6, &prop_val,
+				  "qcom,usbcss-hs-r6-sbu1");
+		usbcss_hs->gnd.sbu1.r6 = prop_val;
+		parse_xtalk_param(dev, usbcss_hs->gnd.sbu2.r6, &prop_val,
+				  "qcom,usbcss-hs-r6-sbu2");
+		usbcss_hs->gnd.sbu2.r6 = prop_val;
+		usbcss_hs->gnd.sbu1.r_gnd_par_route2_mohms = usbcss_hs->gnd.sbu1.r6 +
+							     usbcss_hs->gnd.sbu1.r4;
+		usbcss_hs->gnd.sbu2.r_gnd_par_route2_mohms = usbcss_hs->gnd.sbu2.r6 +
+							     usbcss_hs->gnd.sbu2.r4;
+		parse_xtalk_param(dev, usbcss_hs->gnd.sbu1.r7, &prop_val,
+				  "qcom,usbcss-hs-r7-sbu1");
+		usbcss_hs->gnd.sbu1.r7 = prop_val;
+		usbcss_hs->gnd.sbu1.r_gnd_par_route1_mohms = prop_val;
+		parse_xtalk_param(dev, usbcss_hs->gnd.sbu2.r7, &prop_val,
+				  "qcom,usbcss-hs-r7-sbu2");
+		usbcss_hs->gnd.sbu2.r7 = prop_val;
+		usbcss_hs->gnd.sbu2.r_gnd_par_route1_mohms = prop_val;
 	}
 
 	/* Compute total resistances */
-	usbcss_hs->r_gnd_par_tot_mohms = usbcss_hs->r_gnd_par_route1_mohms +
-					 usbcss_hs->r_gnd_par_route2_mohms;
-	usbcss_hs->r_gnd_sbu1_res_tot_mohms = get_r_gnd_res_tot_mohms(
-								usbcss_hs->r_gnd_sbu1_int_fet_mohms,
-								usbcss_hs->r_gnd_ext_fet_mohms,
-								usbcss_hs->r_gnd_par_tot_mohms);
-	usbcss_hs->r_gnd_sbu2_res_tot_mohms = get_r_gnd_res_tot_mohms(
-								usbcss_hs->r_gnd_sbu2_int_fet_mohms,
-								usbcss_hs->r_gnd_ext_fet_mohms,
-								usbcss_hs->r_gnd_par_tot_mohms);
-	usbcss_hs->r_aud_res_tot_l_mohms = get_r_aud_res_tot_mohms(
-								usbcss_hs->r_aud_int_fet_l_mohms,
-								usbcss_hs->r_aud_ext_fet_l_mohms);
-	usbcss_hs->r_aud_res_tot_r_mohms = get_r_aud_res_tot_mohms(
-								usbcss_hs->r_aud_int_fet_r_mohms,
-								usbcss_hs->r_aud_ext_fet_r_mohms);
+	usbcss_hs->gnd.sbu1.r_gnd_par_tot_mohms = usbcss_hs->gnd.sbu1.r_gnd_par_route1_mohms +
+						  usbcss_hs->gnd.sbu1.r_gnd_par_route2_mohms;
+	usbcss_hs->gnd.sbu2.r_gnd_par_tot_mohms = usbcss_hs->gnd.sbu2.r_gnd_par_route1_mohms +
+						  usbcss_hs->gnd.sbu2.r_gnd_par_route2_mohms;
+	usbcss_hs->gnd.sbu1.r_gnd_res_tot_mohms = get_r_gnd_res_tot_mohms(
+							usbcss_hs->gnd.sbu1.r_gnd_int_fet_mohms,
+							usbcss_hs->gnd.r_gnd_ext_fet_mohms,
+							usbcss_hs->gnd.sbu1.r_gnd_par_tot_mohms);
+	usbcss_hs->gnd.sbu2.r_gnd_res_tot_mohms = get_r_gnd_res_tot_mohms(
+							usbcss_hs->gnd.sbu2.r_gnd_int_fet_mohms,
+							usbcss_hs->gnd.r_gnd_ext_fet_mohms,
+							usbcss_hs->gnd.sbu2.r_gnd_par_tot_mohms);
+	usbcss_hs->aud.l.r_aud_res_tot_mohms = get_r_aud_res_tot_mohms(
+							usbcss_hs->aud.l.r_aud_int_fet_mohms,
+							usbcss_hs->aud.l.r_aud_ext_fet_mohms,
+							usbcss_hs->aud.l.r3);
+	usbcss_hs->aud.r.r_aud_res_tot_mohms = get_r_aud_res_tot_mohms(
+							usbcss_hs->aud.r.r_aud_int_fet_mohms,
+							usbcss_hs->aud.r.r_aud_ext_fet_mohms,
+							usbcss_hs->aud.r.r3);
+
+	/* Fill r_common_gnd buffer */
+	r_common_gnd_mohms = usbcss_hs->gnd.rdson_mohms +
+			     (usbcss_hs->gnd.sbu1.r_gnd_par_route2_mohms +
+			      usbcss_hs->gnd.sbu2.r_gnd_par_route2_mohms) / 2;
+	fill_r_common_gnd_buffer(usbcss_hs, r_common_gnd_mohms);
+
+	/* Determine min val used for linearizer audio tap calculations */
+	if (usbcss_hs->gnd.rdson_3p6v_mohms < GND_EXT_FET_MARGIN_MOHMS)
+		usbcss_hs->gnd.gnd_ext_fet_min_mohms = 0;
+	else if ((usbcss_hs->gnd.rdson_3p6v_mohms - GND_EXT_FET_MARGIN_MOHMS)
+		 < GND_EXT_FET_MARGIN_MOHMS)
+		usbcss_hs->gnd.gnd_ext_fet_min_mohms = usbcss_hs->gnd.rdson_3p6v_mohms -
+						       GND_EXT_FET_MARGIN_MOHMS;
+	else
+		usbcss_hs->gnd.gnd_ext_fet_min_mohms = GND_EXT_FET_MARGIN_MOHMS;
 
 	/* Set linearizer calibration codes to be sourced from SW */
 	wcd_usbss_linearizer_rdac_cal_code_select(LINEARIZER_SOURCE_SW);

Some files were not shown because too many files changed in this diff