Bladeren bron

Merge 575a0b0dd19b41a533c4455fdb8b0825b19bd5ea on remote branch

Change-Id: I23b5e04bffc73e9063775a517fe8f321514e93b9
Linux Build Service Account 2 jaren geleden
bovenliggende
commit
245ccf4818

+ 1 - 0
asoc/codecs/Kbuild

@@ -178,6 +178,7 @@ ifdef CONFIG_SND_SOC_SWR_DMIC
 endif
 
 ifdef CONFIG_SND_SOC_WSA881X_ANALOG
+	INCS += -include $(KERNEL_SRC)/drivers/base/regmap/internal.h
 	WSA881X_ANALOG_OBJS += wsa881x-analog.o
 	WSA881X_ANALOG_OBJS += wsa881x-tables-analog.o
 	WSA881X_ANALOG_OBJS += wsa881x-regmap-analog.o

+ 2 - 0
asoc/codecs/lpass-cdc/lpass-cdc-wsa-macro.c

@@ -1664,6 +1664,8 @@ static int lpass_cdc_wsa_macro_enable_main_path(struct snd_soc_dapm_widget *w,
 			snd_soc_component_update_bits(component,
 						reg, 0x20, 0x20);
 			lpass_cdc_wsa_pa_on(wsa_dev, adie_lb);
+			snd_soc_component_update_bits(component,
+						reg, 0x10, 0x00);
 		}
 		break;
 	default:

+ 2 - 0
asoc/codecs/lpass-cdc/lpass-cdc-wsa2-macro.c

@@ -1670,6 +1670,8 @@ static int lpass_cdc_wsa2_macro_enable_main_path(struct snd_soc_dapm_widget *w,
 			snd_soc_component_update_bits(component,
 						reg, 0x20, 0x20);
 			lpass_cdc_wsa_pa_on(wsa2_dev, adie_lb);
+			snd_soc_component_update_bits(component,
+						reg, 0x10, 0x00);
 		}
 		break;
 	default:

+ 1 - 1
asoc/codecs/swr-haptics.c

@@ -332,7 +332,7 @@ static int hap_enable_swr_dac_port(struct snd_soc_dapm_widget *w,
 		break;
 	case SND_SOC_DAPM_PRE_PMD:
 		/* stop SWR play */
-		val = 0;
+		val = SWR_PLAY_SRC_VAL_SWR;
 		rc = regmap_write(swr_hap->regmap, SWR_PLAY_REG, val);
 		if (rc) {
 			dev_err_ratelimited(swr_hap->dev, "%s: Enable SWR_PLAY failed, rc=%d\n",

+ 2 - 2
asoc/codecs/wcd-irq.c

@@ -42,7 +42,7 @@ int wcd_request_irq(struct wcd_irq_info *irq_info, int irq, const char *name,
 	if (irq < 0)
 		return irq;
 
-	return request_threaded_irq(irq, NULL, handler,
+	return devm_request_threaded_irq(irq_info->dev, irq, NULL, handler,
 				    IRQF_ONESHOT | IRQF_TRIGGER_RISING,
 				    name, data);
 }
@@ -65,7 +65,7 @@ void wcd_free_irq(struct wcd_irq_info *irq_info, int irq, void *data)
 	if (irq < 0)
 		return;
 
-	free_irq(irq, data);
+	devm_free_irq(irq_info->dev, irq, data);
 }
 EXPORT_SYMBOL(wcd_free_irq);
 

+ 1 - 1
asoc/codecs/wcd939x/internal.h

@@ -100,6 +100,7 @@ struct wcd939x_priv {
 	bool ldoh;
 	bool bcs_dis;
 	bool dapm_bias_off;
+	bool in_2Vpk_mode;
 	struct irq_domain *virq;
 	struct wcd_irq_info irq_info;
 	u32 rx_clk_cnt;
@@ -194,7 +195,6 @@ enum {
 	WCD939X_IRQ_EAR_PDM_WD_INT,
 
 	/* INTR_CTRL_INT_MASK_2 */
-	WCD939X_IRQ_LDORT_SCD_INT,
 	WCD939X_IRQ_MBHC_MOISTURE_INT,
 	WCD939X_IRQ_HPHL_SURGE_DET_INT,
 	WCD939X_IRQ_HPHR_SURGE_DET_INT,

+ 78 - 109
asoc/codecs/wcd939x/wcd939x.c

@@ -20,6 +20,7 @@
 #include <asoc/wcdcal-hwdep.h>
 #include <asoc/msm-cdc-pinctrl.h>
 #include <asoc/msm-cdc-supply.h>
+#include <asoc/wcd-mbhc-v2-api.h>
 #include <bindings/audio-codec-port-types.h>
 #include <linux/qti-regmap-debugfs.h>
 #include "wcd939x-registers.h"
@@ -28,6 +29,9 @@
 #include "asoc/bolero-slave-internal.h"
 #include "wcd939x-reg-masks.h"
 #include "wcd939x-reg-shifts.h"
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
+#include <linux/soc/qcom/wcd939x-i2c.h>
+#endif
 
 
 #define NUM_SWRS_DT_PARAMS 5
@@ -43,6 +47,8 @@
 #define ADC_MODE_VAL_ULP1     0x09
 #define ADC_MODE_VAL_ULP2     0x0B
 
+#define HPH_IMPEDANCE_2VPK_MODE_OHMS 300
+
 #define NUM_ATTEMPTS 5
 #define COMP_MAX_COEFF 25
 #define HPH_MODE_MAX 4
@@ -74,65 +80,6 @@ value << FIELD_SHIFT(register_name, field_name)
 #define WCD939X_XTALK_OFFSET \
 		(WCD939X_HPHR_RX_PATH_SEC0 - WCD939X_HPHL_RX_PATH_SEC0)
 
-static struct comp_coeff_val
-		comp_coeff_table [HPH_MODE_MAX][COMP_MAX_COEFF] = {
-	{
-		{0x40, 0x00},
-		{0x4C, 0x00},
-		{0x5A, 0x00},
-		{0x6B, 0x00},
-		{0x7F, 0x00},
-		{0x97, 0x00},
-		{0xB3, 0x00},
-		{0xD5, 0x00},
-		{0xFD, 0x00},
-		{0x2D, 0x01},
-		{0x66, 0x01},
-		{0xA7, 0x01},
-		{0xF8, 0x01},
-		{0x57, 0x02},
-		{0xC7, 0x02},
-		{0x4B, 0x03},
-		{0xE9, 0x03},
-		{0xA3, 0x04},
-		{0x7D, 0x05},
-		{0x90, 0x06},
-		{0xD1, 0x07},
-		{0x49, 0x09},
-		{0x00, 0x0B},
-		{0x01, 0x0D},
-		{0x59, 0x0F},
-	},
-	{
-	/*HPH_HIFI, HPH_LOHIFI, HPH_LP*/
-		{0x40, 0x00},
-		{0x4C, 0x00},
-		{0x5A, 0x00},
-		{0x6B, 0x00},
-		{0x80, 0x00},
-		{0x98, 0x00},
-		{0xB4, 0x00},
-		{0xD5, 0x00},
-		{0xFE, 0x00},
-		{0x2E, 0x01},
-		{0x66, 0x01},
-		{0xA9, 0x01},
-		{0xF8, 0x01},
-		{0x56, 0x02},
-		{0xC4, 0x02},
-		{0x4F, 0x03},
-		{0xF0, 0x03},
-		{0xAE, 0x04},
-		{0x8B, 0x05},
-		{0x8E, 0x06},
-		{0xBC, 0x07},
-		{0x56, 0x09},
-		{0x0F, 0x0B},
-		{0x13, 0x0D},
-		{0x6F, 0x0F},
-	},
-};
-
 enum {
 	CODEC_TX = 0,
 	CODEC_RX,
@@ -197,7 +144,6 @@ static const struct regmap_irq wcd939x_irqs[WCD939X_NUM_IRQS] = {
 	REGMAP_IRQ_REG(WCD939X_IRQ_HPHL_PDM_WD_INT, 1, 0x20),
 	REGMAP_IRQ_REG(WCD939X_IRQ_HPHR_PDM_WD_INT, 1, 0x40),
 	REGMAP_IRQ_REG(WCD939X_IRQ_EAR_PDM_WD_INT, 1, 0x80),
-	REGMAP_IRQ_REG(WCD939X_IRQ_LDORT_SCD_INT, 2, 0x01),
 	REGMAP_IRQ_REG(WCD939X_IRQ_MBHC_MOISTURE_INT, 2, 0x02),
 	REGMAP_IRQ_REG(WCD939X_IRQ_HPHL_SURGE_DET_INT, 2, 0x04),
 	REGMAP_IRQ_REG(WCD939X_IRQ_HPHR_SURGE_DET_INT, 2, 0x08),
@@ -232,25 +178,6 @@ static int wcd939x_handle_post_irq(void *data)
 
 	return IRQ_HANDLED;
 }
-int wcd939x_load_compander_coeff(struct snd_soc_component *component,
-					u16 lsb_reg, u16 msb_reg,
-					struct comp_coeff_val *comp_coeff_table,
-					u16 arr_size)
-{
-	int i = 0;
-
-	/* Load Compander Coeff */
-	for (i = 0; i < arr_size; i++) {
-		snd_soc_component_write(component, lsb_reg,
-			comp_coeff_table[i].lsb);
-		snd_soc_component_write(component, msb_reg,
-			comp_coeff_table[i].msb);
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(wcd939x_load_compander_coeff);
-
 
 static int wcd939x_hph_compander_get(struct snd_kcontrol *kcontrol,
 				struct snd_ctl_elem_value *ucontrol)
@@ -474,10 +401,23 @@ static int wcd939x_init_reg(struct snd_soc_component *component)
 	snd_soc_component_update_bits(component,
 					REG_FIELD_VALUE(TEST_BLK_EN2, TXFE2_MBHC_CLKRST_EN, 0x00));
 
-	snd_soc_component_update_bits(component,
+	if (of_find_property(component->card->dev->of_node, "qcom,wcd-disable-legacy-surge", NULL)) {
+		snd_soc_component_update_bits(component,
+			REG_FIELD_VALUE(HPHLR_SURGE_EN, EN_SURGE_PROTECTION_HPHL, 0x00));
+		snd_soc_component_update_bits(component,
+			REG_FIELD_VALUE(HPHLR_SURGE_EN, EN_SURGE_PROTECTION_HPHR, 0x00));
+	}
+	else {
+		snd_soc_component_update_bits(component,
 			REG_FIELD_VALUE(HPHLR_SURGE_EN, EN_SURGE_PROTECTION_HPHL, 0x01));
-	snd_soc_component_update_bits(component,
+		snd_soc_component_update_bits(component,
 			REG_FIELD_VALUE(HPHLR_SURGE_EN, EN_SURGE_PROTECTION_HPHR, 0x01));
+	}
+
+	snd_soc_component_update_bits(component,
+		REG_FIELD_VALUE(HPH_OCP_CTL, OCP_FSM_EN, 0x01));
+	snd_soc_component_update_bits(component,
+		REG_FIELD_VALUE(HPH_OCP_CTL, SCD_OP_EN, 0x01));
 
 	snd_soc_component_write(component, WCD939X_CFG0, 0x05);
 
@@ -955,11 +895,9 @@ static int wcd939x_enable_hph_pcm_index(struct snd_soc_component *component,
 static int wcd939x_config_compander(struct snd_soc_component *component,
 				int event, int compander_indx)
 {
-	u16 comp_coeff_lsb_reg = 0, comp_coeff_msb_reg = 0;
-	u16 comp_ctl7_reg = 0, comp_ctl0_reg  = 0;
+	u16 comp_ctl7_reg = 0, comp_ctl0_reg = 0;
 	u16 comp_en_mask_val = 0;
 	struct wcd939x_priv *wcd939x;
-	int hph_mode;
 
 
 	if (compander_indx >= WCD939X_HPH_MAX || compander_indx < 0) {
@@ -977,26 +915,20 @@ static int wcd939x_config_compander(struct snd_soc_component *component,
 	if (!wcd939x->compander_enabled[compander_indx])
 		return 0;
 
-	hph_mode = wcd939x->hph_mode;
-	dev_dbg(component->dev, "%s compander_index = %d hph mode = %d\n",
-				__func__, compander_indx, wcd939x->hph_mode);
+	dev_dbg(component->dev, "%s compander_index = %d\n", __func__, compander_indx);
 
-	if (compander_indx == WCD939X_HPHL) {
-		comp_coeff_lsb_reg = WCD939X_HPHL_COMP_WR_LSB;
-		comp_coeff_msb_reg = WCD939X_HPHL_COMP_WR_MSB;
+	if (compander_indx == WCD939X_HPHL)
 		comp_en_mask_val = 1 << 1;
-	} else if (compander_indx == WCD939X_HPHR) {
-		comp_coeff_lsb_reg = WCD939X_HPHR_COMP_WR_LSB;
-		comp_coeff_msb_reg = WCD939X_HPHR_COMP_WR_MSB;
+	else if (compander_indx == WCD939X_HPHR)
 		comp_en_mask_val = 1 << 0;
-	} else {
+	else
 		return 0;
-	}
+
 
 	comp_ctl0_reg  = WCD939X_CTL0 + (compander_indx * WCD939X_COMP_OFFSET);
 	comp_ctl7_reg = WCD939X_CTL7 + (compander_indx * WCD939X_COMP_OFFSET);
 
-	if (SND_SOC_DAPM_EVENT_ON(event)){
+	if (SND_SOC_DAPM_EVENT_ON(event)) {
 
 		snd_soc_component_update_bits(component,
 			comp_ctl7_reg, 0x1E, 0x00);
@@ -1011,26 +943,15 @@ static int wcd939x_config_compander(struct snd_soc_component *component,
 		snd_soc_component_update_bits(component,
 			comp_ctl0_reg , 0x02, 0x00);
 
-		/* Compander coeff values are same for below modes */
-		if (wcd939x->hph_mode == CLS_H_HIFI || wcd939x->hph_mode == CLS_H_LOHIFI
-				|| wcd939x->hph_mode == CLS_H_LP)
-			hph_mode = 1;
-		else if (wcd939x->hph_mode == CLS_H_ULP)
-			hph_mode = 0;
-
-		wcd939x_load_compander_coeff(component, comp_coeff_lsb_reg,
-				comp_coeff_msb_reg, comp_coeff_table[hph_mode],
-				COMP_MAX_COEFF);
-
 		/* Enable compander*/
 		snd_soc_component_update_bits(component,
 				WCD939X_CDC_COMP_CTL_0, comp_en_mask_val, comp_en_mask_val);
 
-	} if (SND_SOC_DAPM_EVENT_OFF(event)) {
+	} else if (SND_SOC_DAPM_EVENT_OFF(event)) {
 			snd_soc_component_update_bits(component,
 				WCD939X_CDC_COMP_CTL_0, comp_en_mask_val, 0x00);
 			snd_soc_component_update_bits(component,
-			comp_ctl0_reg , 0x01, 0x00);
+				comp_ctl0_reg , 0x01, 0x00);
 	}
 
 	return 0;
@@ -1127,6 +1048,28 @@ static int wcd939x_rx_mux(struct snd_soc_dapm_widget *w,
 	return 0;
 }
 
+static void wcd939x_config_2Vpk_mode(struct snd_soc_component *component,
+			struct wcd939x_priv *wcd939x)
+{
+	uint32_t zl = 0, zr = 0;
+	int rc = wcd_mbhc_get_impedance(&wcd939x->mbhc->wcd_mbhc, &zl, &zr);
+
+	if (rc) {
+		dev_err_ratelimited(component->dev, "%s: Unable to get impedance for 2Vpk mode", __func__);
+		return;
+	}
+
+	snd_soc_component_update_bits(component,
+		REG_FIELD_VALUE(PA_GAIN_CTL_L, RX_SUPPLY_LEVEL, 0x01));
+
+	if (zl < HPH_IMPEDANCE_2VPK_MODE_OHMS)
+		snd_soc_component_update_bits(component,
+			REG_FIELD_VALUE(PA_GAIN_CTL_L, EN_HPHPA_2VPK, 0x00));
+	else
+		snd_soc_component_update_bits(component,
+			REG_FIELD_VALUE(PA_GAIN_CTL_L, EN_HPHPA_2VPK, 0x01));
+}
+
 static int wcd939x_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
 					struct snd_kcontrol *kcontrol,
 					int event)
@@ -1142,6 +1085,9 @@ static int wcd939x_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
 		if (!wcd939x->hph_pcm_enabled)
 			snd_soc_component_update_bits(component,
 				REG_FIELD_VALUE(RDAC_CLK_CTL1, OPAMP_CHOP_CLK_EN, 0x00));
+		if (wcd939x->in_2Vpk_mode)
+			wcd939x_config_2Vpk_mode(component, wcd939x);
+
 		snd_soc_component_update_bits(component,
 				REG_FIELD_VALUE(CDC_HPH_GAIN_CTL, HPHL_RX_EN, 0x01));
 		break;
@@ -1196,6 +1142,9 @@ static int wcd939x_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
 		if (!wcd939x->hph_pcm_enabled)
 			snd_soc_component_update_bits(component,
 				REG_FIELD_VALUE(RDAC_CLK_CTL1, OPAMP_CHOP_CLK_EN, 0x00));
+		if (wcd939x->in_2Vpk_mode)
+			wcd939x_config_2Vpk_mode(component, wcd939x);
+
 		snd_soc_component_update_bits(component,
 				REG_FIELD_VALUE(CDC_HPH_GAIN_CTL, HPHR_RX_EN, 0x01));
 		break;
@@ -3073,6 +3022,22 @@ static int wcd939x_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
 		mode_val = CLS_H_ULP;
 	}
 	wcd939x->hph_mode = mode_val;
+
+	switch (mode_val) {
+	case CLS_H_HIFI:
+	case CLS_H_LOHIFI:
+		mode_val = 0x4;
+		break;
+	default:
+		/* set default mode to ULP */
+		mode_val = 0x2;
+		break;
+	}
+
+#if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
+	wcd_usbss_audio_config(NULL, WCD_USBSS_CONFIG_TYPE_POWER_MODE, mode_val);
+#endif
+
 	return 0;
 }
 
@@ -4351,6 +4316,10 @@ static int wcd939x_soc_codec_probe(struct snd_soc_component *component)
 	/*Harmonium contains only one variant i.e wcd9395*/
 	wcd939x->variant = WCD9395;
 
+	/* Check device tree to see if 2Vpk flag is enabled, this value should not be changed */
+	wcd939x->in_2Vpk_mode = of_find_property(wcd939x->dev->of_node,
+					"qcom,hph-2p15v-mode", NULL) != NULL;
+
 	wcd939x->fw_data = devm_kzalloc(component->dev,
 					sizeof(*(wcd939x->fw_data)),
 					GFP_KERNEL);

+ 1 - 2
asoc/codecs/wsa881x-analog.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2015-2016, 2018-2020, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/clk.h>
@@ -26,7 +26,6 @@
 #include <linux/i2c.h>
 #include <linux/kernel.h>
 #include <linux/gpio.h>
-#include <soc/internal.h>
 #include <linux/regmap.h>
 #include <asoc/msm-cdc-pinctrl.h>
 #include "wsa881x-analog.h"

+ 10 - 28
asoc/codecs/wsa884x/wsa884x.c

@@ -208,16 +208,13 @@ static int wsa884x_handle_post_irq(void *data)
 	u32 sts1 = 0, sts2 = 0;
 	int retry = WSA884X_IRQ_RETRY;
 
-	struct snd_soc_component *component = NULL;
-
 	if (!wsa884x)
 		return IRQ_NONE;
 
-	component = wsa884x->component;
 	if (!wsa884x->pa_mute) {
 		do {
 			wsa884x->pa_mute = 0;
-			snd_soc_component_update_bits(component,
+			regmap_update_bits(wsa884x->regmap,
 				REG_FIELD_VALUE(PA_FSM_EN, GLOBAL_PA_EN, 0x01));
 			usleep_range(1000, 1100);
 
@@ -231,7 +228,7 @@ static int wsa884x_handle_post_irq(void *data)
 			if (wsa884x->swr_slave->slave_irq_pending) {
 				pr_debug("%s: IRQ retries left: %0d\n",
 					__func__, retry);
-				snd_soc_component_update_bits(component,
+				regmap_update_bits(wsa884x->regmap,
 					REG_FIELD_VALUE(PA_FSM_EN, GLOBAL_PA_EN, 0x00));
 				wsa884x->pa_mute = 1;
 				if (retry--)
@@ -1122,6 +1119,9 @@ static bool wsa884x_validate_dt_configuration_params(struct snd_soc_component *c
 	bool is_invalid_flag = true;
 
 	bat_cfg_reg = snd_soc_component_read(component, WSA884X_VPHX_SYS_EN_STATUS);
+
+	dev_info(component->dev, "VPHX EN Status: %d", bat_cfg_reg);
+
 	if ((ibat_cfg_dts == EXT_1S) || (ibat_cfg_dts == EXT_2S) || (ibat_cfg_dts == EXT_3S))
 		ibat_cfg_dts = EXT_ABOVE_3S;
 	if ((WSA_4_OHMS <= irload && irload < WSA_MAX_OHMS) &&
@@ -2331,26 +2331,19 @@ static int wsa884x_swr_probe(struct swr_device *pdev)
 	return 0;
 
 err_mem:
+	snd_soc_unregister_component(&pdev->dev);
 	if (wsa884x->dai_driver) {
 		kfree(wsa884x->dai_driver->name);
 		kfree(wsa884x->dai_driver->playback.stream_name);
-		kfree(wsa884x->dai_driver);
+		devm_kfree(&pdev->dev, wsa884x->dai_driver);
+		wsa884x->dai_driver = NULL;
 	}
 	if (wsa884x->driver) {
 		kfree(wsa884x->driver->name);
-		kfree(wsa884x->driver);
+		devm_kfree(&pdev->dev, wsa884x->driver);
+		wsa884x->driver = NULL;
 	}
 err_irq:
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_SAF2WAR, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_WAR2SAF, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_DISABLE, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_OCP, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_CLIP, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_PDM_WD, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_CLK_WD, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_INTR_PIN, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_UVLO, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_PA_ON_ERR, NULL);
 	wcd_irq_exit(&wsa884x->irq_info, wsa884x->virq);
 dev_err:
 	if (pin_state_current == false)
@@ -2375,17 +2368,6 @@ static int wsa884x_swr_remove(struct swr_device *pdev)
 		return -EINVAL;
 	}
 
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_SAF2WAR, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_WAR2SAF, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_DISABLE, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_OCP, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_CLIP, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_PDM_WD, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_CLK_WD, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_INTR_PIN, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_UVLO, NULL);
-	wcd_free_irq(&wsa884x->irq_info, WSA884X_IRQ_INT_PA_ON_ERR, NULL);
-
 	if (wsa884x->register_notifier)
 		wsa884x->register_notifier(wsa884x->handle,
 				&wsa884x->parent_nblock, false);

+ 4 - 1
asoc/msm-audio-defs.h

@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2019-2022, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 #ifndef _MSM_AUDIO_DEFS_H
 #define _MSM_AUDIO_DEFS_H
@@ -115,4 +115,7 @@
 
 #define LPASS_BE_PCM_DUMMY_TX_0 "PCM_DUMMY-TX-0"
 
+#define LPASS_BE_BTFM_PROXY_RX_0 "BTFM_PROXY-RX-0"
+#define LPASS_BE_BTFM_PROXY_TX_0 "BTFM_PROXY-TX-0"
+
 #endif /*_MSM_AUDIO_DEFS_H*/

+ 59 - 4
asoc/msm_common.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/gpio.h>
@@ -19,6 +19,7 @@
 #include <sound/info.h>
 #include <dsp/audio_prm.h>
 #include <dsp/digital-cdc-rsc-mgr.h>
+#include <linux/sched/walt.h>
 
 #include "msm_common.h"
 
@@ -974,24 +975,78 @@ static void msm_audio_update_qos_request(u32 latency)
 	}
 }
 
+static int msm_get_and_print_cpu_map_taken(cpumask_t* expected_cpu_map) {
+	int ret = 0;
+	int cpu = 0;
+	cpumask_t current_cpu_map = walt_get_cpus_taken();
+
+	if (memcmp(&current_cpu_map, &CPU_MASK_NONE, sizeof(cpumask_t)) == 0) {
+		pr_debug("%s: current cpu map is none.\n", __func__);
+	} else {
+		for_each_cpu(cpu, &current_cpu_map) {
+			pr_debug("%s: current cpu core taken %d.\n", __func__, cpu);
+		}
+	}
+	if (memcmp(&current_cpu_map, expected_cpu_map, sizeof(cpumask_t)) == 0)
+		ret = 1;
+
+	return ret;
+}
+
 static int msm_qos_ctl_put(struct snd_kcontrol *kcontrol,
 		struct snd_ctl_elem_value *ucontrol)
 {
+	cpumask_t expected_cpu_map = CPU_MASK_NONE;
 	qos_vote_status = ucontrol->value.enumerated.item[0];
+
+	pr_debug("%s: qos_vote_status = %d, qos_client_active_cnt = %d.\n",
+				__func__, qos_vote_status, qos_client_active_cnt);
 	if (qos_vote_status) {
 		if (dev_pm_qos_request_active(&latency_pm_qos_req))
 			dev_pm_qos_remove_request(&latency_pm_qos_req);
 
 		qos_client_active_cnt++;
-		if (qos_client_active_cnt == 1)
+		if (qos_client_active_cnt == 1) {
 			msm_audio_update_qos_request(MSM_LL_QOS_VALUE);
+
+			expected_cpu_map = audio_cpu_map;
+			if (msm_get_and_print_cpu_map_taken(&expected_cpu_map)) {
+				pr_debug("%s: already expected, don't need to set it.\n",
+							__func__);
+				return 0;
+			}
+
+			walt_set_cpus_taken(&audio_cpu_map);
+			pr_debug("%s: set cpus taken to walt for audio RT tasks.\n",
+						__func__);
+
+			if (msm_get_and_print_cpu_map_taken(&expected_cpu_map)) {
+				pr_debug("%s: set cpus taken as expected successfully.\n",
+					__func__);
+			}
+		}
 	} else {
 		if (qos_client_active_cnt > 0)
 			qos_client_active_cnt--;
-		if (qos_client_active_cnt == 0)
+		if (qos_client_active_cnt == 0) {
 			msm_audio_update_qos_request(PM_QOS_CPU_LATENCY_DEFAULT_VALUE);
-	}
 
+			if (msm_get_and_print_cpu_map_taken(&expected_cpu_map)) {
+				pr_debug("%s: already expected, don't need to unset it.\n",
+							__func__);
+				return 0;
+			}
+
+			walt_unset_cpus_taken(&audio_cpu_map);
+			pr_debug("%s: unset cpus taken to walt for audio RT tasks.\n",
+						__func__);
+
+			if (msm_get_and_print_cpu_map_taken(&expected_cpu_map)) {
+				pr_debug("%s: unset cpus taken as expected successfully.\n",
+							__func__);
+			}
+		}
+	}
 	return 0;
 }
 

+ 13 - 1
asoc/msm_dailink.h

@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <sound/soc.h>
@@ -33,6 +33,18 @@ SND_SOC_DAILINK_DEFS(slimbus_7_tx,
 			"btfm_bt_sco_slim_tx")),
 	DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy")));
 
+SND_SOC_DAILINK_DEFS(btfm_0_rx,
+	DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")),
+	DAILINK_COMP_ARRAY(COMP_CODEC("btfmcodec_dev",
+			"btfm_bt_sco_a2dp_slim_rx")),
+	DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy")));
+
+SND_SOC_DAILINK_DEFS(btfm_0_tx,
+	DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")),
+	DAILINK_COMP_ARRAY(COMP_CODEC("btfmcodec_dev",
+			"btfm_bt_sco_slim_tx")),
+	DAILINK_COMP_ARRAY(COMP_PLATFORM("snd-soc-dummy")));
+
 SND_SOC_DAILINK_DEFS(display_port,
 	DAILINK_COMP_ARRAY(COMP_CPU("snd-soc-dummy-dai")),
 	DAILINK_COMP_ARRAY(COMP_CODEC(

+ 33 - 1
asoc/pineapple.c

@@ -390,6 +390,7 @@ static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
 	SND_SOC_DAPM_MIC("Digital Mic7", NULL),
 };
 
+#ifndef CONFIG_AUDIO_BTFM_PROXY
 static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
 {
 	unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
@@ -405,6 +406,7 @@ static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
 	msm_common_dai_link_init(rtd);
     return ret;
 }
+#endif
 
 static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod,
 				const char *name,
@@ -510,6 +512,7 @@ static struct snd_soc_dai_link msm_common_be_dai_links[] = {
 	},
 };
 
+#ifndef CONFIG_AUDIO_BTFM_PROXY
 static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
 	{
 		.name = LPASS_BE_SLIMBUS_7_RX,
@@ -535,7 +538,32 @@ static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
 		SND_SOC_DAILINK_REG(slimbus_7_tx),
 	},
 };
-
+#else
+static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
+        {
+                .name = LPASS_BE_BTFM_PROXY_RX_0,
+                .stream_name = LPASS_BE_BTFM_PROXY_RX_0,
+                .playback_only = 1,
+                .trigger = {SND_SOC_DPCM_TRIGGER_POST,
+                        SND_SOC_DPCM_TRIGGER_POST},
+                .ops = &msm_common_be_ops,
+                /* dai link has playback support */
+                .ignore_pmdown_time = 1,
+                .ignore_suspend = 1,
+                SND_SOC_DAILINK_REG(btfm_0_rx),
+        },
+        {
+                .name = LPASS_BE_BTFM_PROXY_TX_0,
+                .stream_name = LPASS_BE_BTFM_PROXY_TX_0,
+                .capture_only = 1,
+                .trigger = {SND_SOC_DPCM_TRIGGER_POST,
+                        SND_SOC_DPCM_TRIGGER_POST},
+                .ops = &msm_common_be_ops,
+                .ignore_suspend = 1,
+                SND_SOC_DAILINK_REG(btfm_0_tx),
+        },
+};
+#endif
 static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
 	/* DISP PORT BACK END DAI Link */
 	{
@@ -2125,7 +2153,11 @@ static void __exit msm_asoc_machine_exit(void)
 }
 module_exit(msm_asoc_machine_exit);
 
+#ifndef CONFIG_AUDIO_BTFM_PROXY
 MODULE_SOFTDEP("pre: bt_fm_slim");
+#else
+MODULE_SOFTDEP("pre: btfmcodec");
+#endif
 MODULE_DESCRIPTION("ALSA SoC msm");
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("platform:" DRV_NAME);

+ 20 - 8
dsp/msm_audio_ion.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/init.h>
@@ -102,6 +102,7 @@ static void msm_audio_ion_add_allocation(
 	mutex_unlock(&(msm_audio_ion_data->list_mutex));
 }
 
+/* This function is called with ion_data list mutex lock */
 static int msm_audio_ion_map_kernel(struct dma_buf *dma_buf,
 	struct msm_audio_ion_private *ion_data, struct iosys_map *iosys_vmap)
 {
@@ -139,6 +140,7 @@ exit:
 	return rc;
 }
 
+/* This function is called with ion_data list mutex lock */
 static int msm_audio_dma_buf_map(struct dma_buf *dma_buf,
 				 dma_addr_t *addr, size_t *len, bool is_iova,
 				 struct msm_audio_ion_private *ion_data)
@@ -231,7 +233,6 @@ static int msm_audio_dma_buf_unmap(struct dma_buf *dma_buf, struct msm_audio_ion
 	 * should be explicitly acquired to avoid race condition
 	 * on adding elements to the list.
 	 */
-	mutex_lock(&(ion_data->list_mutex));
 	list_for_each_safe(ptr, next,
 			    &(ion_data->alloc_list)) {
 
@@ -256,7 +257,6 @@ static int msm_audio_dma_buf_unmap(struct dma_buf *dma_buf, struct msm_audio_ion
 			break;
 		}
 	}
-	mutex_unlock(&(ion_data->list_mutex));
 
 	if (!found) {
 		dev_err(cb_dev,
@@ -301,7 +301,6 @@ static int msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf, struct msm_audio_
 	 * TBD: remove the below section once new API
 	 * for unmapping kernel virtual address is available.
 	 */
-	mutex_lock(&(ion_data->list_mutex));
 	list_for_each_entry(alloc_data, &(ion_data->alloc_list),
 			    list) {
 		if (alloc_data->dma_buf == dma_buf) {
@@ -309,7 +308,6 @@ static int msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf, struct msm_audio_
 			break;
 		}
 	}
-	mutex_unlock(&(ion_data->list_mutex));
 
 	if (!iosys_vmap) {
 		dev_err(cb_dev,
@@ -332,7 +330,8 @@ err:
 	return rc;
 }
 
-static int msm_audio_ion_map_buf(struct dma_buf *dma_buf, dma_addr_t *paddr,
+/* This function is called with ion_data list mutex lock */
+static int msm_audio_ion_buf_map(struct dma_buf *dma_buf, dma_addr_t *paddr,
 				 size_t *plen, struct iosys_map *iosys_vmap,
 				 struct msm_audio_ion_private *ion_data)
 {
@@ -357,7 +356,9 @@ static int msm_audio_ion_map_buf(struct dma_buf *dma_buf, dma_addr_t *paddr,
 		pr_err("%s: ION memory mapping for AUDIO failed, err:%d\n",
 			__func__, rc);
 		rc = -ENOMEM;
+		mutex_lock(&(ion_data->list_mutex));
 		msm_audio_dma_buf_unmap(dma_buf, ion_data);
+		mutex_unlock(&(ion_data->list_mutex));
 		goto err;
 	}
 
@@ -400,6 +401,11 @@ void msm_audio_delete_fd_entry(void *handle)
 	struct msm_audio_fd_data *msm_audio_fd_data = NULL;
 	struct list_head *ptr, *next;
 
+	if (!handle) {
+		pr_err("%s Invalid handle\n", __func__);
+		return;
+	}
+
 	mutex_lock(&(msm_audio_ion_fd_list.list_mutex));
 	list_for_each_safe(ptr, next,
 			&msm_audio_ion_fd_list.fd_list) {
@@ -471,6 +477,7 @@ void msm_audio_get_handle(int fd, void **handle)
 
 	pr_debug("%s fd %d\n", __func__, fd);
 	mutex_lock(&(msm_audio_ion_fd_list.list_mutex));
+	*handle = NULL;
 	list_for_each_entry(msm_audio_fd_data,
 			&msm_audio_ion_fd_list.fd_list, list) {
 		if (msm_audio_fd_data->fd == fd) {
@@ -531,7 +538,7 @@ static int msm_audio_ion_import(struct dma_buf **dma_buf, int fd,
 		}
 	}
 	if (ion_data->smmu_enabled) {
-		rc = msm_audio_ion_map_buf(*dma_buf, paddr, plen, iosys_vmap, ion_data);
+		rc = msm_audio_ion_buf_map(*dma_buf, paddr, plen, iosys_vmap, ion_data);
 		if (rc) {
 			pr_err("%s: failed to map ION buf, rc = %d\n", __func__, rc);
 			goto err;
@@ -558,6 +565,7 @@ err:
  *
  * Returns 0 on success or error on failure
  */
+/* This funtion is called with ion_data list mutex lock */
 static int msm_audio_ion_free(struct dma_buf *dma_buf, struct msm_audio_ion_private *ion_data)
 {
 	int ret = 0;
@@ -567,14 +575,18 @@ static int msm_audio_ion_free(struct dma_buf *dma_buf, struct msm_audio_ion_priv
 		return -EINVAL;
 	}
 
+	mutex_lock(&(ion_data->list_mutex));
 	if (ion_data->smmu_enabled) {
 		ret = msm_audio_ion_unmap_kernel(dma_buf, ion_data);
-		if (ret)
+		if (ret) {
+			mutex_unlock(&(ion_data->list_mutex));
 			return ret;
+		}
 	}
 
 	msm_audio_dma_buf_unmap(dma_buf, ion_data);
 
+	mutex_unlock(&(ion_data->list_mutex));
 	return 0;
 }
 

+ 0 - 300
include/soc/internal.h

@@ -1,300 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Register map access API internal header
- *
- * Copyright 2011 Wolfson Microelectronics plc
- *
- * Author: Mark Brown <[email protected]>
- */
-
-#ifndef _REGMAP_INTERNAL_H
-#define _REGMAP_INTERNAL_H
-
-#include <linux/device.h>
-#include <linux/regmap.h>
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/wait.h>
-
-struct regmap;
-struct regcache_ops;
-
-struct regmap_debugfs_off_cache {
-	struct list_head list;
-	off_t min;
-	off_t max;
-	unsigned int base_reg;
-	unsigned int max_reg;
-};
-
-struct regmap_format {
-	size_t buf_size;
-	size_t reg_bytes;
-	size_t pad_bytes;
-	size_t val_bytes;
-	void (*format_write)(struct regmap *map,
-			     unsigned int reg, unsigned int val);
-	void (*format_reg)(void *buf, unsigned int reg, unsigned int shift);
-	void (*format_val)(void *buf, unsigned int val, unsigned int shift);
-	unsigned int (*parse_val)(const void *buf);
-	void (*parse_inplace)(void *buf);
-};
-
-struct regmap_async {
-	struct list_head list;
-	struct regmap *map;
-	void *work_buf;
-};
-
-struct regmap {
-	union {
-		struct mutex mutex;
-		struct {
-			spinlock_t spinlock;
-			unsigned long spinlock_flags;
-		};
-	};
-	regmap_lock lock;
-	regmap_unlock unlock;
-	void *lock_arg; /* This is passed to lock/unlock functions */
-	gfp_t alloc_flags;
-
-	struct device *dev; /* Device we do I/O on */
-	void *work_buf;     /* Scratch buffer used to format I/O */
-	struct regmap_format format;  /* Buffer format */
-	const struct regmap_bus *bus;
-	void *bus_context;
-	const char *name;
-
-	bool async;
-	spinlock_t async_lock;
-	wait_queue_head_t async_waitq;
-	struct list_head async_list;
-	struct list_head async_free;
-	int async_ret;
-
-#ifdef CONFIG_DEBUG_FS
-	bool debugfs_disable;
-	struct dentry *debugfs;
-	const char *debugfs_name;
-
-	unsigned int debugfs_reg_len;
-	unsigned int debugfs_val_len;
-	unsigned int debugfs_tot_len;
-
-	struct list_head debugfs_off_cache;
-	struct mutex cache_lock;
-#endif
-
-	unsigned int max_register;
-	bool (*writeable_reg)(struct device *dev, unsigned int reg);
-	bool (*readable_reg)(struct device *dev, unsigned int reg);
-	bool (*volatile_reg)(struct device *dev, unsigned int reg);
-	bool (*precious_reg)(struct device *dev, unsigned int reg);
-	bool (*writeable_noinc_reg)(struct device *dev, unsigned int reg);
-	bool (*readable_noinc_reg)(struct device *dev, unsigned int reg);
-	const struct regmap_access_table *wr_table;
-	const struct regmap_access_table *rd_table;
-	const struct regmap_access_table *volatile_table;
-	const struct regmap_access_table *precious_table;
-	const struct regmap_access_table *wr_noinc_table;
-	const struct regmap_access_table *rd_noinc_table;
-
-	int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
-	int (*reg_write)(void *context, unsigned int reg, unsigned int val);
-	int (*reg_update_bits)(void *context, unsigned int reg,
-			       unsigned int mask, unsigned int val);
-
-	bool defer_caching;
-
-	unsigned long read_flag_mask;
-	unsigned long write_flag_mask;
-
-	/* number of bits to (left) shift the reg value when formatting*/
-	int reg_shift;
-	int reg_stride;
-	int reg_stride_order;
-
-	/* regcache specific members */
-	const struct regcache_ops *cache_ops;
-	enum regcache_type cache_type;
-
-	/* number of bytes in reg_defaults_raw */
-	unsigned int cache_size_raw;
-	/* number of bytes per word in reg_defaults_raw */
-	unsigned int cache_word_size;
-	/* number of entries in reg_defaults */
-	unsigned int num_reg_defaults;
-	/* number of entries in reg_defaults_raw */
-	unsigned int num_reg_defaults_raw;
-
-	/* if set, only the cache is modified not the HW */
-	bool cache_only;
-	/* if set, only the HW is modified not the cache */
-	bool cache_bypass;
-	/* if set, remember to free reg_defaults_raw */
-	bool cache_free;
-
-	struct reg_default *reg_defaults;
-	const void *reg_defaults_raw;
-	void *cache;
-	/* if set, the cache contains newer data than the HW */
-	bool cache_dirty;
-	/* if set, the HW registers are known to match map->reg_defaults */
-	bool no_sync_defaults;
-
-	struct reg_sequence *patch;
-	int patch_regs;
-
-	/* if set, converts bulk read to single read */
-	bool use_single_read;
-	/* if set, converts bulk write to single write */
-	bool use_single_write;
-	/* if set, the device supports multi write mode */
-	bool can_multi_write;
-
-	/* if set, raw reads/writes are limited to this size */
-	size_t max_raw_read;
-	size_t max_raw_write;
-
-	struct rb_root range_tree;
-	void *selector_work_buf;	/* Scratch buffer used for selector */
-
-	struct hwspinlock *hwlock;
-
-	/* if set, the regmap core can sleep */
-	bool can_sleep;
-};
-
-struct regcache_ops {
-	const char *name;
-	enum regcache_type type;
-	int (*init)(struct regmap *map);
-	int (*exit)(struct regmap *map);
-#ifdef CONFIG_DEBUG_FS
-	void (*debugfs_init)(struct regmap *map);
-#endif
-	int (*read)(struct regmap *map, unsigned int reg, unsigned int *value);
-	int (*write)(struct regmap *map, unsigned int reg, unsigned int value);
-	int (*sync)(struct regmap *map, unsigned int min, unsigned int max);
-	int (*drop)(struct regmap *map, unsigned int min, unsigned int max);
-};
-
-bool regmap_cached(struct regmap *map, unsigned int reg);
-bool regmap_writeable(struct regmap *map, unsigned int reg);
-bool regmap_readable(struct regmap *map, unsigned int reg);
-bool regmap_volatile(struct regmap *map, unsigned int reg);
-bool regmap_precious(struct regmap *map, unsigned int reg);
-bool regmap_writeable_noinc(struct regmap *map, unsigned int reg);
-bool regmap_readable_noinc(struct regmap *map, unsigned int reg);
-
-int _regmap_write(struct regmap *map, unsigned int reg,
-		  unsigned int val);
-
-struct regmap_range_node {
-	struct rb_node node;
-	const char *name;
-	struct regmap *map;
-
-	unsigned int range_min;
-	unsigned int range_max;
-
-	unsigned int selector_reg;
-	unsigned int selector_mask;
-	int selector_shift;
-
-	unsigned int window_start;
-	unsigned int window_len;
-};
-
-struct regmap_field {
-	struct regmap *regmap;
-	unsigned int mask;
-	/* lsb */
-	unsigned int shift;
-	unsigned int reg;
-
-	unsigned int id_size;
-	unsigned int id_offset;
-};
-
-#ifdef CONFIG_DEBUG_FS
-extern void regmap_debugfs_initcall(void);
-extern void regmap_debugfs_init(struct regmap *map);
-extern void regmap_debugfs_exit(struct regmap *map);
-
-static inline void regmap_debugfs_disable(struct regmap *map)
-{
-	map->debugfs_disable = true;
-}
-
-#else
-static inline void regmap_debugfs_initcall(void) { }
-static inline void regmap_debugfs_init(struct regmap *map) { }
-static inline void regmap_debugfs_exit(struct regmap *map) { }
-static inline void regmap_debugfs_disable(struct regmap *map) { }
-#endif
-
-/* regcache core declarations */
-int regcache_init(struct regmap *map, const struct regmap_config *config);
-void regcache_exit(struct regmap *map);
-int regcache_read(struct regmap *map,
-		       unsigned int reg, unsigned int *value);
-int regcache_write(struct regmap *map,
-			unsigned int reg, unsigned int value);
-int regcache_sync(struct regmap *map);
-int regcache_sync_block(struct regmap *map, void *block,
-			unsigned long *cache_present,
-			unsigned int block_base, unsigned int start,
-			unsigned int end);
-
-static inline const void *regcache_get_val_addr(struct regmap *map,
-						const void *base,
-						unsigned int idx)
-{
-	return base + (map->cache_word_size * idx);
-}
-
-unsigned int regcache_get_val(struct regmap *map, const void *base,
-			      unsigned int idx);
-bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
-		      unsigned int val);
-int regcache_lookup_reg(struct regmap *map, unsigned int reg);
-
-int _regmap_raw_write(struct regmap *map, unsigned int reg,
-		      const void *val, size_t val_len, bool noinc);
-
-void regmap_async_complete_cb(struct regmap_async *async, int ret);
-
-enum regmap_endian regmap_get_val_endian(struct device *dev,
-					 const struct regmap_bus *bus,
-					 const struct regmap_config *config);
-
-extern struct regcache_ops regcache_rbtree_ops;
-extern struct regcache_ops regcache_lzo_ops;
-extern struct regcache_ops regcache_flat_ops;
-
-static inline const char *regmap_name(const struct regmap *map)
-{
-	if (map->dev)
-		return dev_name(map->dev);
-
-	return map->name;
-}
-
-static inline unsigned int regmap_get_offset(const struct regmap *map,
-					     unsigned int index)
-{
-	if (map->reg_stride_order >= 0)
-		return index << map->reg_stride_order;
-	else
-		return index * map->reg_stride;
-}
-
-static inline unsigned int regcache_get_index_by_order(const struct regmap *map,
-						       unsigned int reg)
-{
-	return reg >> map->reg_stride_order;
-}
-
-#endif

+ 3 - 1
ipc/audio-pkt.c

@@ -1,5 +1,5 @@
 /* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -406,6 +406,8 @@ ssize_t audio_pkt_write(struct file *file, const char __user *buf,
 	ret = gpr_send_pkt(ap_priv->adev,(struct gpr_pkt *) kbuf);
 	if (ret < 0) {
 		AUDIO_PKT_ERR("APR Send Packet Failed ret -%d\n", ret);
+		if (ret == -ECONNRESET)
+			ret = -ENETRESET;
 	}
 	mutex_unlock(&audpkt_dev->lock);
 

+ 1 - 0
soc/Kbuild

@@ -155,6 +155,7 @@ ifdef CONFIG_SOUNDWIRE_MSTR_CTRL
 endif
 
 ifdef CONFIG_SOUNDWIRE
+	INCS += -include $(KERNEL_SRC)/drivers/base/regmap/internal.h
 	SWR_OBJS += regmap-swr.o
 	SWR_OBJS += soundwire.o
 endif

+ 29 - 4
soc/pinctrl-lpi.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/gpio.h>
@@ -150,9 +150,18 @@ int lpi_pinctrl_runtime_suspend(struct device *dev);
 static int lpi_gpio_read(struct lpi_gpio_pad *pad, unsigned int addr)
 {
 	int ret = 0;
-	struct lpi_gpio_state *state = dev_get_drvdata(lpi_dev);
+	struct lpi_gpio_state *state = NULL;
 	static DEFINE_RATELIMIT_STATE(rtl, 1 * HZ, 1);
 
+	if (!lpi_dev) {
+		if (__ratelimit(&rtl))
+			pr_err_ratelimited("%s: lpi_dev is NULL, return\n",
+							__func__);
+		return -EINVAL;
+	}
+
+	state = dev_get_drvdata(lpi_dev);
+
 	if (!lpi_dev_up) {
 		if (__ratelimit(&rtl))
 			pr_err_ratelimited("%s: ADSP is down due to SSR, return\n",
@@ -183,10 +192,19 @@ err:
 static int lpi_gpio_write(struct lpi_gpio_pad *pad, unsigned int addr,
 			  unsigned int val)
 {
-	struct lpi_gpio_state *state = dev_get_drvdata(lpi_dev);
+	struct lpi_gpio_state *state = NULL;
 	int ret = 0;
 	static DEFINE_RATELIMIT_STATE(rtl, 1 * HZ, 1);
 
+	if (!lpi_dev) {
+		if (__ratelimit(&rtl))
+			pr_err_ratelimited("%s: lpi_dev is NULL, return\n",
+							__func__);
+		return -EINVAL;
+	}
+
+	state = dev_get_drvdata(lpi_dev);
+
 	if (!lpi_dev_up) {
 		return 0;
 	}
@@ -549,9 +567,16 @@ static void lpi_pinctrl_ssr_disable(struct device *dev, void *data)
 
 static int lpi_pinctrl_ssr_enable(struct device *dev, void *data)
 {
-	struct lpi_gpio_state *state = dev_get_drvdata(lpi_dev);
+	struct lpi_gpio_state *state = NULL;
 	dev_dbg(dev, "%s: enter\n", __func__);
 
+	if (!lpi_dev) {
+		dev_err(dev, "%s: lpi_dev is NULL, return\n", __func__);
+		return -EINVAL;
+	}
+
+	state = dev_get_drvdata(lpi_dev);
+
 	if (!initial_boot) {
 		trace_printk("%s: enter\n", __func__);
 		if (!lpi_dev_up) {

+ 1 - 2
soc/regmap-swr.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/device.h>
@@ -11,7 +11,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <soc/soundwire.h>
-#include <soc/internal.h>
 
 
 static int regmap_swr_gather_write(void *context,