Browse Source

Merge "asoc: wcd939x: Add conditional check before calling wcd usb api"

qctecmdr 1 year ago
parent
commit
db5e3d22a0
2 changed files with 26 additions and 6 deletions
  1. 10 4
      asoc/codecs/wcd939x/wcd939x-mbhc.c
  2. 16 2
      asoc/codecs/wcd939x/wcd939x.c

+ 10 - 4
asoc/codecs/wcd939x/wcd939x-mbhc.c

@@ -776,9 +776,12 @@ static void update_ext_fet_res(struct wcd939x_pdata *pdata, u32 r_aud_ext_fet_mo
 
 static void get_linearizer_taps(struct wcd939x_pdata *pdata, u32 *aud_tap)
 {
-	u32 r_gnd_res_tot_mohms = 0, r_gnd_int_fet_mohms = 0, r_gnd_par_tot_mohms = 0;
+	u32 r_gnd_int_fet_mohms = 0, r_gnd_par_tot_mohms = 0;
 	u32 v_aud1 = 0, v_aud2 = 0, aud_denom = 0;
 	u32 r_load_eff_mohms = 0, r3 = 0, r_aud_ext_fet_mohms = 0, r_aud_int_fet_mohms = 0;
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
+	u32 r_gnd_res_tot_mohms = 0;
+#endif
 
 	if (!pdata)
 		goto err_data;
@@ -1300,7 +1303,9 @@ static ssize_t usbcss_sysfs_store(struct kobject *kobj, struct kobj_attribute *a
 
 	if (update_linearizer) {
 		get_linearizer_taps(pdata, &aud_tap);
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
 		wcd_usbss_set_linearizer_sw_tap(aud_tap, LINEARIZER_DEFAULT_TAP);
+#endif
 		dev_err(wcd939x->dev, "%s: Updated linearizer thru sysfs\n",
 			__func__);
 		dev_dbg(wcd939x->dev, "%s: Linearizer aud_tap is 0x%x\n",
@@ -1433,12 +1438,13 @@ static void wcd939x_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl,
 	struct wcd939x_mbhc_zdet_param zdet_param = {4, 0, 6, 0x18, 0x60, 0x78};
 	struct wcd939x_mbhc_zdet_param *zdet_param_ptr = &zdet_param;
 	s16 d1[] = {0, 30, 30, 6};
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
 	uint32_t cached_regs[4][2] = {{WCD_USBSS_EXT_LIN_EN, 0}, {WCD_USBSS_EXT_SW_CTRL_1, 0},
 				      {WCD_USBSS_MG1_BIAS, 0}, {WCD_USBSS_MG2_BIAS, 0}};
 	uint32_t l_3_6V_regs[4][2] = {{WCD_USBSS_EXT_LIN_EN, 0x00}, {WCD_USBSS_EXT_SW_CTRL_1, 0x00},
 				      {WCD_USBSS_MG1_BIAS, 0x0E}, {WCD_USBSS_MG2_BIAS, 0x0E}};
 	uint32_t diff_regs[2][2] = {{WCD_USBSS_EXT_LIN_EN, 0x00}, {WCD_USBSS_EXT_SW_CTRL_1, 0x00}};
-
+#endif
 	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
 
 	/* Turn on RX supplies */
@@ -1806,7 +1812,7 @@ mono_stereo_detection:
 		mbhc->hph_type = WCD_MBHC_HPH_MONO;
 	}
 	goto zdet_complete;
-
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
 default_vals:
 	pdata->usbcss_hs.xtalk.scale_l = MAX_XTALK_SCALE;
 	pdata->usbcss_hs.xtalk.scale_r = MAX_XTALK_SCALE;
@@ -1819,7 +1825,7 @@ default_vals:
 	dev_dbg(component->dev,
 		"%s: Right-channel: Xtalk scale is 0x%x and alpha is 0x%x\n", __func__,
 		pdata->usbcss_hs.xtalk.scale_r, pdata->usbcss_hs.xtalk.alpha_r);
-
+#endif
 zdet_complete:
 	/* Configure linearizer */
 #if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)

+ 16 - 2
asoc/codecs/wcd939x/wcd939x.c

@@ -893,6 +893,7 @@ static int  wcd939x_config_power_mode(struct snd_soc_component *component,
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
 static int wcd939x_get_usbss_hph_power_mode(int hph_mode)
 {
 	switch (hph_mode) {
@@ -904,6 +905,7 @@ static int wcd939x_get_usbss_hph_power_mode(int hph_mode)
 		return 0x2;
 	}
 }
+#endif
 
 static int wcd939x_enable_hph_pcm_index(struct snd_soc_component *component,
 				int event, int hph)
@@ -1431,10 +1433,12 @@ static int wcd939x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
 			snd_soc_component_update_bits(component,
 					REG_FIELD_VALUE(HPH, PWR_LEVEL, 0x00));
 		}
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
 		/* update USBSS power mode for AATC */
 		if (wcd939x->mbhc->wcd_mbhc.mbhc_cfg->enable_usbc_analog)
 			wcd_usbss_audio_config(NULL, WCD_USBSS_CONFIG_TYPE_POWER_MODE,
 				wcd939x_get_usbss_hph_power_mode(hph_mode));
+#endif
 		snd_soc_component_update_bits(component,
 			REG_FIELD_VALUE(VNEG_CTRL_4, ILIM_SEL, 0xD));
 		snd_soc_component_update_bits(component,
@@ -1529,9 +1533,11 @@ static int wcd939x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
 					REG_FIELD_VALUE(HPH, HPHR_REF_ENABLE, 0x00));
 		snd_soc_component_update_bits(component,
 					REG_FIELD_VALUE(PDM_WD_CTL1, PDM_WD_EN, 0x00));
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
 		if (wcd939x->mbhc->wcd_mbhc.mbhc_cfg->enable_usbc_analog &&
 			!(snd_soc_component_read(component, WCD939X_HPH) & 0XC0))
 			wcd_usbss_audio_config(NULL, WCD_USBSS_CONFIG_TYPE_POWER_MODE, 1);
+#endif
 		wcd_cls_h_fsm(component, &wcd939x->clsh_info,
 			     WCD_CLSH_EVENT_POST_PA,
 			     WCD_CLSH_STATE_HPHR,
@@ -1584,10 +1590,12 @@ static int wcd939x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
 			snd_soc_component_update_bits(component,
 				REG_FIELD_VALUE(HPH, PWR_LEVEL, 0x00));
 		}
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
 		/* update USBSS power mode for AATC */
 		if (wcd939x->mbhc->wcd_mbhc.mbhc_cfg->enable_usbc_analog)
 			wcd_usbss_audio_config(NULL, WCD_USBSS_CONFIG_TYPE_POWER_MODE,
 				wcd939x_get_usbss_hph_power_mode(hph_mode));
+#endif
 		snd_soc_component_update_bits(component,
 			REG_FIELD_VALUE(VNEG_CTRL_4, ILIM_SEL, 0xD));
 		snd_soc_component_update_bits(component,
@@ -1680,9 +1688,11 @@ static int wcd939x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
 					REG_FIELD_VALUE(HPH, HPHL_REF_ENABLE, 0x00));
 		snd_soc_component_update_bits(component,
 					REG_FIELD_VALUE(PDM_WD_CTL0, PDM_WD_EN, 0x00));
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
 		if (wcd939x->mbhc->wcd_mbhc.mbhc_cfg->enable_usbc_analog &&
 			!(snd_soc_component_read(component, WCD939X_HPH) & 0XC0))
 			wcd_usbss_audio_config(NULL, WCD_USBSS_CONFIG_TYPE_POWER_MODE, 1);
+#endif
 		wcd_cls_h_fsm(component, &wcd939x->clsh_info,
 			     WCD_CLSH_EVENT_POST_PA,
 			     WCD_CLSH_STATE_HPHL,
@@ -5050,8 +5060,10 @@ static void wcd939x_dt_parse_usbcss_hs_info(struct device *dev,
 	else
 		usbcss_hs->gnd.gnd_ext_fet_min_mohms = GND_EXT_FET_MARGIN_MOHMS;
 
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
 	/* Set linearizer calibration codes to be sourced from SW */
 	wcd_usbss_linearizer_rdac_cal_code_select(LINEARIZER_SOURCE_SW);
+#endif
 }
 
 static int wcd939x_reset_low(struct device *dev)
@@ -5201,11 +5213,13 @@ static void wcd939x_update_regmap_cache(struct wcd939x_priv *wcd939x)
 
 static int wcd939x_bind(struct device *dev)
 {
-	int ret = 0, i = 0, val = 0;
+	int ret = 0, i = 0;
 	struct wcd939x_pdata *pdata = dev_get_platdata(dev);
 	struct wcd939x_priv *wcd939x = dev_get_drvdata(dev);
 	u8 id1 = 0, status1 = 0;
-
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
+	int val = 0;
+#endif
 	/*
 	 * Add 5msec delay to provide sufficient time for
 	 * soundwire auto enumeration of slave devices as