Browse Source

audio-lnx: Add latest snapshot for audio drivers.

Propagate the changes based on latest snapshot
for audio kernel source tree at below cutoff of
kernel msm-4.9 -
(040750bfa78 -
 "Revert "ARM: dts: msm: Add DT node for aop-qmp
  clock controller on SDM845 v2"")

CRs-Fixed: 2104096
Change-Id: I0927c40b3a188dbf892e7ec4c1c7810953724929
Signed-off-by: Laxminath Kasam <[email protected]>
Laxminath Kasam 7 years ago
parent
commit
8f7ccc2e6f

+ 8 - 2
asoc/codecs/msm-cdc-pinctrl.c

@@ -217,8 +217,14 @@ static int msm_cdc_pinctrl_remove(struct platform_device *pdev)
 
 	gpio_data = dev_get_drvdata(&pdev->dev);
 
-	if (gpio_data && gpio_data->pinctrl)
-		devm_pinctrl_put(gpio_data->pinctrl);
+	/* to free the requested gpio before exiting */
+	if (gpio_data) {
+		if (gpio_is_valid(gpio_data->gpio))
+			gpio_free(gpio_data->gpio);
+
+		if (gpio_data->pinctrl)
+			devm_pinctrl_put(gpio_data->pinctrl);
+	}
 
 	devm_kfree(&pdev->dev, gpio_data);
 

+ 4 - 0
asoc/codecs/wcd-spi.c

@@ -1374,6 +1374,10 @@ static void wcd_spi_component_unbind(struct device *dev,
 {
 	struct spi_device *spi = to_spi_device(dev);
 	struct wcd_spi_priv *wcd_spi = spi_get_drvdata(spi);
+	struct wcd_spi_debug_data *dbg_data = &wcd_spi->debug_data;
+
+	debugfs_remove_recursive(dbg_data->dir);
+	dbg_data->dir = NULL;
 
 	wcd_spi->m_dev = NULL;
 	wcd_spi->m_ops = NULL;

+ 1 - 1
asoc/codecs/wcd9335.c

@@ -112,7 +112,7 @@
 /* Convert from vout ctl to micbias voltage in mV */
 #define WCD_VOUT_CTL_TO_MICB(v) (1000 + v * 50)
 
-#define TASHA_ZDET_NUM_MEASUREMENTS 150
+#define TASHA_ZDET_NUM_MEASUREMENTS 900
 #define TASHA_MBHC_GET_C1(c)  ((c & 0xC000) >> 14)
 #define TASHA_MBHC_GET_X1(x)  (x & 0x3FFF)
 /* z value compared in milliOhm */

+ 1 - 1
asoc/codecs/wcd934x/wcd934x-mbhc.c

@@ -44,7 +44,7 @@
 /* Z floating defined in ohms */
 #define TAVIL_ZDET_FLOATING_IMPEDANCE 0x0FFFFFFE
 
-#define TAVIL_ZDET_NUM_MEASUREMENTS   150
+#define TAVIL_ZDET_NUM_MEASUREMENTS   900
 #define TAVIL_MBHC_GET_C1(c)          ((c & 0xC000) >> 14)
 #define TAVIL_MBHC_GET_X1(x)          (x & 0x3FFF)
 /* Z value compared in milliOhm */

+ 36 - 4
asoc/codecs/wcd934x/wcd934x.c

@@ -128,6 +128,8 @@ static const struct snd_kcontrol_new name##_mux = \
 #define WCD934X_DIG_CORE_REG_MIN  WCD934X_CDC_ANC0_CLK_RESET_CTL
 #define WCD934X_DIG_CORE_REG_MAX  0xFFF
 
+#define WCD934X_CHILD_DEVICES_MAX	6
+
 #define WCD934X_MAX_MICBIAS 4
 #define DAPM_MICBIAS1_STANDALONE "MIC BIAS1 Standalone"
 #define DAPM_MICBIAS2_STANDALONE "MIC BIAS2 Standalone"
@@ -626,6 +628,11 @@ struct tavil_priv {
 	int power_active_ref;
 	int sidetone_coeff_array[IIR_MAX][BAND_MAX]
 		[WCD934X_CDC_SIDETONE_IIR_COEFF_MAX];
+
+	struct spi_device *spi;
+	struct platform_device *pdev_child_devices
+		[WCD934X_CHILD_DEVICES_MAX];
+	int child_count;
 };
 
 static const struct tavil_reg_mask_val tavil_spkr_default[] = {
@@ -5105,6 +5112,13 @@ static void tavil_restore_iir_coeff(struct tavil_priv *tavil, int iir_idx)
 	int band_idx = 0, coeff_idx = 0;
 	struct snd_soc_codec *codec = tavil->codec;
 
+	/*
+	 * snd_soc_write call crashes at rmmod if there is no machine
+	 * driver and hence no codec pointer available
+	 */
+	if (!codec)
+		return;
+
 	for (band_idx = 0; band_idx < BAND_MAX; band_idx++) {
 		snd_soc_write(codec,
 		(WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx),
@@ -9397,6 +9411,9 @@ static int tavil_soc_codec_remove(struct snd_soc_codec *codec)
 
 	control = dev_get_drvdata(codec->dev->parent);
 	devm_kfree(codec->dev, control->rx_chs);
+	/* slimslave deinit in wcd core looks for this value */
+	control->num_rx_port = 0;
+	control->num_tx_port = 0;
 	control->rx_chs = NULL;
 	control->tx_chs = NULL;
 	tavil_cleanup_irqs(tavil);
@@ -9736,6 +9753,7 @@ static void tavil_codec_add_spi_device(struct tavil_priv *tavil,
 		goto err_dt_parse;
 	}
 
+	tavil->spi = spi;
 	/* Put the reference to SPI master */
 	put_device(&master->dev);
 
@@ -9782,6 +9800,7 @@ static void tavil_add_child_devices(struct work_struct *work)
 	}
 
 	platdata = &tavil->swr.plat_data;
+	tavil->child_count = 0;
 
 	for_each_child_of_node(wcd9xxx->dev->of_node, node) {
 
@@ -9849,6 +9868,10 @@ static void tavil_add_child_devices(struct work_struct *work)
 				__func__);
 			tavil->swr.ctrl_data = swr_ctrl_data;
 		}
+		if (tavil->child_count < WCD934X_CHILD_DEVICES_MAX)
+			tavil->pdev_child_devices[tavil->child_count++] = pdev;
+		else
+			goto err_mem;
 	}
 
 	return;
@@ -10076,11 +10099,24 @@ err_resmgr:
 static int tavil_remove(struct platform_device *pdev)
 {
 	struct tavil_priv *tavil;
+	int count = 0;
 
 	tavil = platform_get_drvdata(pdev);
 	if (!tavil)
 		return -EINVAL;
 
+	/* do dsd deinit before codec->component->regmap becomes freed */
+	if (tavil->dsd_config) {
+		tavil_dsd_deinit(tavil->dsd_config);
+		tavil->dsd_config = NULL;
+	}
+
+	if (tavil->spi)
+		spi_unregister_device(tavil->spi);
+	for (count = 0; count < tavil->child_count &&
+				count < WCD934X_CHILD_DEVICES_MAX; count++)
+		platform_device_unregister(tavil->pdev_child_devices[count]);
+
 	mutex_destroy(&tavil->micb_lock);
 	mutex_destroy(&tavil->svs_mutex);
 	mutex_destroy(&tavil->codec_mutex);
@@ -10091,10 +10127,6 @@ static int tavil_remove(struct platform_device *pdev)
 	snd_soc_unregister_codec(&pdev->dev);
 	clk_put(tavil->wcd_ext_clk);
 	wcd_resmgr_remove(tavil->resmgr);
-	if (tavil->dsd_config) {
-		tavil_dsd_deinit(tavil->dsd_config);
-		tavil->dsd_config = NULL;
-	}
 	devm_kfree(&pdev->dev, tavil);
 	return 0;
 }

+ 1 - 0
asoc/codecs/wcd9xxx-core.c

@@ -592,6 +592,7 @@ static void wcd9xxx_device_exit(struct wcd9xxx *wcd9xxx)
 {
 	device_init_wakeup(wcd9xxx->dev, false);
 	wcd9xxx_irq_exit(&wcd9xxx->core_res);
+	mfd_remove_devices(wcd9xxx->dev);
 	wcd9xxx_bringdown(wcd9xxx->dev);
 	wcd9xxx_reset_low(wcd9xxx->dev);
 	wcd9xxx_core_res_deinit(&wcd9xxx->core_res);

+ 26 - 1
asoc/codecs/wcd9xxx-irq.c

@@ -52,6 +52,8 @@ static int phyirq_to_virq(
 	struct wcd9xxx_core_resource *wcd9xxx_res, int irq);
 static unsigned int wcd9xxx_irq_get_upstream_irq(
 	struct wcd9xxx_core_resource *wcd9xxx_res);
+static void wcd9xxx_irq_put_downstream_irq(
+	struct wcd9xxx_core_resource *wcd9xxx_res);
 static void wcd9xxx_irq_put_upstream_irq(
 	struct wcd9xxx_core_resource *wcd9xxx_res);
 static int wcd9xxx_map_irq(
@@ -632,6 +634,7 @@ void wcd9xxx_irq_exit(struct wcd9xxx_core_resource *wcd9xxx_res)
 		disable_irq_wake(wcd9xxx_res->irq);
 		free_irq(wcd9xxx_res->irq, wcd9xxx_res);
 		wcd9xxx_res->irq = 0;
+		wcd9xxx_irq_put_downstream_irq(wcd9xxx_res);
 		wcd9xxx_irq_put_upstream_irq(wcd9xxx_res);
 	}
 	mutex_destroy(&wcd9xxx_res->irq_lock);
@@ -754,6 +757,29 @@ static unsigned int wcd9xxx_irq_get_upstream_irq(
 	return data->irq;
 }
 
+static void wcd9xxx_irq_put_downstream_irq(
+			struct wcd9xxx_core_resource *wcd9xxx_res)
+{
+	int irq, virq, ret;
+
+	/*
+	 * IRQ migration hits error if the chip data and handles
+	 * are not made NULL. make associated data and handles
+	 * to NULL at irq_exit
+	 */
+	for (irq = 0; irq < wcd9xxx_res->num_irqs; irq++) {
+		virq = wcd9xxx_map_irq(wcd9xxx_res, irq);
+		pr_debug("%s: irq %d -> %d\n", __func__, irq, virq);
+		ret = irq_set_chip_data(virq, NULL);
+		if (ret) {
+			pr_err("%s: Failed to configure irq %d (%d)\n",
+				__func__, irq, ret);
+			return;
+		}
+		irq_set_chip_and_handler(virq, NULL, NULL);
+	}
+}
+
 static void wcd9xxx_irq_put_upstream_irq(
 			struct wcd9xxx_core_resource *wcd9xxx_res)
 {
@@ -821,7 +847,6 @@ static int wcd9xxx_irq_remove(struct platform_device *pdev)
 	wmb();
 	irq_domain_remove(data->domain);
 	kfree(data);
-	domain->host_data = NULL;
 
 	return 0;
 }

+ 20 - 0
asoc/msm-compress-q6-v2.c

@@ -1281,6 +1281,9 @@ static int msm_compr_configure_dsp_for_playback
 		.step = SOFT_VOLUME_STEP,
 		.rampingcurve = SOFT_VOLUME_CURVE_LINEAR,
 	};
+	struct snd_kcontrol *kctl;
+	struct snd_ctl_elem_value kctl_elem_value;
+	uint16_t target_asm_bit_width = 0;
 
 	pr_debug("%s: stream_id %d\n", __func__, ac->stream_id);
 	stream_index = STREAM_ARRAY_INDEX(ac->stream_id);
@@ -1289,6 +1292,23 @@ static int msm_compr_configure_dsp_for_playback
 		return -EINVAL;
 	}
 
+	kctl = snd_soc_card_get_kcontrol(soc_prtd->card,
+		DSP_BIT_WIDTH_MIXER_CTL);
+	if (kctl) {
+		kctl->get(kctl, &kctl_elem_value);
+		target_asm_bit_width = kctl_elem_value.value.integer.value[0];
+		if (target_asm_bit_width > 0) {
+			pr_debug("%s enforce ASM bitwidth to %d from %d\n",
+				__func__,
+				target_asm_bit_width,
+				bits_per_sample);
+			bits_per_sample = target_asm_bit_width;
+		}
+	} else {
+		pr_info("%s: failed to get mixer ctl for %s.\n",
+			__func__, DSP_BIT_WIDTH_MIXER_CTL);
+	}
+
 	if ((prtd->codec_param.codec.format == SNDRV_PCM_FORMAT_S24_LE) ||
 		(prtd->codec_param.codec.format == SNDRV_PCM_FORMAT_S24_3LE))
 		bits_per_sample = 24;

+ 0 - 1
asoc/msm-dai-q6-v2.c

@@ -3632,7 +3632,6 @@ static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
 		clear_bit(STATUS_PORT_STARTED,
 			  mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
 	}
-	kfree(mi2s_dai_data);
 	return 0;
 }
 

+ 41 - 0
asoc/msm-qti-pp-config.c

@@ -392,6 +392,7 @@ static int msm_afe_tert_mi2s_lb_vol_ctrl;
 static int msm_afe_quat_mi2s_lb_vol_ctrl;
 static int msm_afe_slimbus_7_lb_vol_ctrl;
 static int msm_afe_slimbus_8_lb_vol_ctrl;
+static int msm_asm_bit_width;
 static const DECLARE_TLV_DB_LINEAR(fm_rx_vol_gain, 0, INT_RX_VOL_MAX_STEPS);
 static const DECLARE_TLV_DB_LINEAR(afe_lb_vol_gain, 0, INT_RX_VOL_MAX_STEPS);
 
@@ -412,6 +413,38 @@ static int msm_qti_pp_set_fm_vol_mixer(struct snd_kcontrol *kcontrol,
 	return 0;
 }
 
+static int msm_asm_bit_width_get(struct snd_kcontrol *kcontrol,
+			struct snd_ctl_elem_value *ucontrol)
+{
+	pr_debug("%s get ASM bitwidth = %d\n",
+		__func__, msm_asm_bit_width);
+
+	ucontrol->value.integer.value[0] = msm_asm_bit_width;
+
+	return 0;
+}
+
+static int msm_asm_bit_width_put(struct snd_kcontrol *kcontrol,
+			struct snd_ctl_elem_value *ucontrol)
+{
+	switch (ucontrol->value.integer.value[0]) {
+	case 16:
+		msm_asm_bit_width = 16;
+		break;
+	case 24:
+		msm_asm_bit_width = 24;
+		break;
+	case 32:
+		msm_asm_bit_width = 32;
+		break;
+	default:
+		msm_asm_bit_width = 0;
+		break;
+	}
+
+	return 0;
+}
+
 static int msm_qti_pp_get_pri_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
 				       struct snd_ctl_elem_value *ucontrol)
 {
@@ -1132,6 +1165,11 @@ static const struct snd_kcontrol_new int_fm_vol_mixer_controls[] = {
 	msm_qti_pp_set_quat_mi2s_fm_vol_mixer, fm_rx_vol_gain),
 };
 
+static const struct snd_kcontrol_new dsp_bit_width_controls[] = {
+	SOC_SINGLE_EXT(DSP_BIT_WIDTH_MIXER_CTL, SND_SOC_NOPM, 0, 0x20,
+	0, msm_asm_bit_width_get, msm_asm_bit_width_put),
+};
+
 static const struct snd_kcontrol_new pri_mi2s_lb_vol_mixer_controls[] = {
 	SOC_SINGLE_EXT_TLV("PRI MI2S LOOPBACK Volume", SND_SOC_NOPM, 0,
 	INT_RX_VOL_GAIN, 0, msm_qti_pp_get_pri_mi2s_lb_vol_mixer,
@@ -1403,5 +1441,8 @@ void msm_qti_pp_add_controls(struct snd_soc_platform *platform)
 
 	snd_soc_add_platform_controls(platform, msm_multichannel_ec_controls,
 			ARRAY_SIZE(msm_multichannel_ec_controls));
+
+	snd_soc_add_platform_controls(platform, dsp_bit_width_controls,
+			ARRAY_SIZE(dsp_bit_width_controls));
 }
 #endif /* CONFIG_QTI_PP */

+ 1 - 0
asoc/msm-qti-pp-config.h

@@ -14,6 +14,7 @@
 #define _MSM_QTI_PP_H_
 
 #include <sound/soc.h>
+#define DSP_BIT_WIDTH_MIXER_CTL "ASM Bit Width"
 int msm_adsp_inform_mixer_ctl(struct snd_soc_pcm_runtime *rtd,
 			uint32_t *payload);
 int msm_adsp_init_mixer_ctl_pp_event_queue(struct snd_soc_pcm_runtime *rtd);

+ 1 - 5
asoc/sdm660-common.c

@@ -3186,8 +3186,6 @@ err:
 		gpio_free(pdata->hph_en0_gpio);
 		pdata->hph_en0_gpio = 0;
 	}
-	if (pdata->snd_card_val != INT_SND_CARD)
-		msm_ext_cdc_deinit(pdata);
 	devm_kfree(&pdev->dev, pdata);
 	return ret;
 }
@@ -3199,10 +3197,8 @@ static int msm_asoc_machine_remove(struct platform_device *pdev)
 
 	if (pdata->snd_card_val == INT_SND_CARD)
 		mutex_destroy(&pdata->cdc_int_mclk0_mutex);
-	else
-		msm_ext_cdc_deinit(pdata);
-	msm_free_auxdev_mem(pdev);
 
+	msm_free_auxdev_mem(pdev);
 	gpio_free(pdata->us_euro_gpio);
 	gpio_free(pdata->hph_en1_gpio);
 	gpio_free(pdata->hph_en0_gpio);

+ 0 - 9
asoc/sdm660-common.h

@@ -78,14 +78,6 @@ enum {
 	EXT_SND_CARD_TAVIL,
 };
 
-struct msm_snd_interrupt {
-	void __iomem *mpm_wakeup;
-	void __iomem *intr1_cfg_apps;
-	void __iomem *lpi_gpio_intr_cfg;
-	void __iomem *lpi_gpio_cfg;
-	void __iomem *lpi_gpio_inout;
-};
-
 struct msm_asoc_mach_data {
 	int us_euro_gpio; /* used by gpio driver API */
 	int hph_en1_gpio;
@@ -112,7 +104,6 @@ struct msm_asoc_mach_data {
 	struct mutex cdc_int_mclk0_mutex;
 	struct delayed_work disable_int_mclk0_work;
 	struct afe_clk_set digital_cdc_core_clk;
-	struct msm_snd_interrupt msm_snd_intr_lpi;
 };
 
 int msm_common_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,

+ 0 - 68
asoc/sdm660-external.c

@@ -35,22 +35,6 @@
 #define CODEC_EXT_CLK_RATE          9600000
 #define ADSP_STATE_READY_TIMEOUT_MS 3000
 
-#define TLMM_CENTER_MPM_WAKEUP_INT_EN_0 0x03596000
-#define LPI_GPIO_22_WAKEUP_VAL 0x00000002
-
-#define TLMM_LPI_DIR_CONN_INTR1_CFG_APPS 0x0359D004
-#define LPI_GPIO_22_INTR1_CFG_VAL 0x01
-#define LPI_GPIO_22_INTR1_CFG_MASK 0x03
-
-#define TLMM_LPI_GPIO_INTR_CFG1  0x0359B004
-#define LPI_GPIO_INTR_CFG1_VAL 0x00000113
-
-#define TLMM_LPI_GPIO22_CFG  0x15078040
-#define LPI_GPIO22_CFG_VAL 0x0000009
-
-#define TLMM_LPI_GPIO22_INOUT  0x179D1318
-#define LPI_GPIO22_INOUT_VAL 0x0020000
-
 #define WSA8810_NAME_1 "wsa881x.20170211"
 #define WSA8810_NAME_2 "wsa881x.20170212"
 
@@ -1209,28 +1193,6 @@ static void msm_afe_clear_config(void)
 	afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
 }
 
-static void msm_snd_interrupt_config(struct msm_asoc_mach_data *pdata)
-{
-	int val;
-
-	val = ioread32(pdata->msm_snd_intr_lpi.mpm_wakeup);
-	val |= LPI_GPIO_22_WAKEUP_VAL;
-	iowrite32(val, pdata->msm_snd_intr_lpi.mpm_wakeup);
-
-	val = ioread32(pdata->msm_snd_intr_lpi.intr1_cfg_apps);
-	val &= ~(LPI_GPIO_22_INTR1_CFG_MASK);
-	val |= LPI_GPIO_22_INTR1_CFG_VAL;
-	iowrite32(val, pdata->msm_snd_intr_lpi.intr1_cfg_apps);
-
-	iowrite32(LPI_GPIO_INTR_CFG1_VAL,
-			pdata->msm_snd_intr_lpi.lpi_gpio_intr_cfg);
-	iowrite32(LPI_GPIO22_CFG_VAL,
-			pdata->msm_snd_intr_lpi.lpi_gpio_cfg);
-	val = ioread32(pdata->msm_snd_intr_lpi.lpi_gpio_inout);
-	val |= LPI_GPIO22_INOUT_VAL;
-	iowrite32(val, pdata->msm_snd_intr_lpi.lpi_gpio_inout);
-}
-
 static int msm_adsp_power_up_config(struct snd_soc_codec *codec)
 {
 	int ret = 0;
@@ -1262,7 +1224,6 @@ static int msm_adsp_power_up_config(struct snd_soc_codec *codec)
 		ret = -ETIMEDOUT;
 		goto err_fail;
 	}
-	msm_snd_interrupt_config(pdata);
 
 	ret = msm_afe_set_config(codec);
 	if (ret)
@@ -1883,36 +1844,7 @@ int msm_ext_cdc_init(struct platform_device *pdev,
 			ret);
 		ret = 0;
 	}
-	pdata->msm_snd_intr_lpi.mpm_wakeup =
-			ioremap(TLMM_CENTER_MPM_WAKEUP_INT_EN_0, 4);
-	pdata->msm_snd_intr_lpi.intr1_cfg_apps =
-			ioremap(TLMM_LPI_DIR_CONN_INTR1_CFG_APPS, 4);
-	pdata->msm_snd_intr_lpi.lpi_gpio_intr_cfg =
-			ioremap(TLMM_LPI_GPIO_INTR_CFG1, 4);
-	pdata->msm_snd_intr_lpi.lpi_gpio_cfg =
-			ioremap(TLMM_LPI_GPIO22_CFG, 4);
-	pdata->msm_snd_intr_lpi.lpi_gpio_inout =
-			ioremap(TLMM_LPI_GPIO22_INOUT, 4);
 err:
 	return ret;
 }
 EXPORT_SYMBOL(msm_ext_cdc_init);
-
-/**
- * msm_ext_cdc_deinit - external codec machine specific deinit.
- */
-void msm_ext_cdc_deinit(struct msm_asoc_mach_data *pdata)
-{
-	if (pdata->msm_snd_intr_lpi.mpm_wakeup)
-		iounmap(pdata->msm_snd_intr_lpi.mpm_wakeup);
-	if (pdata->msm_snd_intr_lpi.intr1_cfg_apps)
-		iounmap(pdata->msm_snd_intr_lpi.intr1_cfg_apps);
-	if (pdata->msm_snd_intr_lpi.lpi_gpio_intr_cfg)
-		iounmap(pdata->msm_snd_intr_lpi.lpi_gpio_intr_cfg);
-	if (pdata->msm_snd_intr_lpi.lpi_gpio_cfg)
-		iounmap(pdata->msm_snd_intr_lpi.lpi_gpio_cfg);
-	if (pdata->msm_snd_intr_lpi.lpi_gpio_inout)
-		iounmap(pdata->msm_snd_intr_lpi.lpi_gpio_inout);
-
-}
-EXPORT_SYMBOL(msm_ext_cdc_deinit);

+ 0 - 4
asoc/sdm660-external.h

@@ -36,7 +36,6 @@ int msm_snd_card_tasha_late_probe(struct snd_soc_card *card);
 int msm_ext_cdc_init(struct platform_device *, struct msm_asoc_mach_data *,
 		     struct snd_soc_card **, struct wcd_mbhc_config *);
 void msm_ext_register_audio_notifier(struct platform_device *pdev);
-void msm_ext_cdc_deinit(struct msm_asoc_mach_data *pdata);
 #else
 inline int msm_ext_cdc_init(struct platform_device *pdev,
 			    struct msm_asoc_mach_data *pdata,
@@ -49,8 +48,5 @@ inline int msm_ext_cdc_init(struct platform_device *pdev,
 inline void msm_ext_register_audio_notifier(struct platform_device *pdev)
 {
 }
-inline void msm_ext_cdc_deinit(void)
-{
-}
 #endif
 #endif

+ 1 - 0
asoc/sdm845.c

@@ -7149,6 +7149,7 @@ static int msm_asoc_machine_remove(struct platform_device *pdev)
 
 	msm_release_pinctrl(pdev);
 	snd_soc_unregister_card(card);
+	audio_notifier_deregister("sdm845");
 	return 0;
 }
 

+ 1 - 1
dsp/audio_notifier.c

@@ -510,7 +510,7 @@ int audio_notifier_deregister(char *client_name)
 	int ret = 0;
 	int ret2;
 	struct list_head *ptr, *next;
-	struct client_data *client_data;
+	struct client_data *client_data = NULL;
 
 	if (client_name == NULL) {
 		pr_err("%s: client_name is NULL\n", __func__);

+ 2 - 0
dsp/codecs/audio_utils_aio.c

@@ -1067,6 +1067,8 @@ static int audio_aio_async_write(struct q6audio_aio *audio,
 	struct audio_client *ac;
 	struct audio_aio_write_param param;
 
+	memset(&param, 0, sizeof(param));
+
 	if (!audio || !buf_node) {
 		pr_err("%s NULL pointer audio=[0x%pK], buf_node=[0x%pK]\n",
 			__func__, audio, buf_node);

+ 1 - 1
dsp/q6adm.c

@@ -2438,7 +2438,7 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology,
 			flags = ADM_LEGACY_DEVICE_SESSION;
 	}
 
-	if ((topology == VPM_TX_SM_ECNS_COPP_TOPOLOGY) ||
+	if ((topology == VPM_TX_SM_ECNS_V2_COPP_TOPOLOGY) ||
 	    (topology == VPM_TX_DM_FLUENCE_COPP_TOPOLOGY) ||
 	    (topology == VPM_TX_DM_RFECNS_COPP_TOPOLOGY))
 		rate = 16000;

+ 1 - 1
dsp/q6core.c

@@ -373,7 +373,7 @@ int q6core_get_service_version(uint32_t service_id,
 
 	svc_size = q6core_get_avcs_service_size(service_id);
 	if (svc_size != size) {
-		pr_err("%s: Expected size: %ld, Provided size: %ld",
+		pr_err("%s: Expected size: %zu, Provided size: %zu\n",
 		       __func__, svc_size, size);
 		return -EINVAL;
 	}

+ 1 - 1
dsp/q6voice.c

@@ -8038,7 +8038,7 @@ uint32_t voice_get_topology(uint32_t topology_idx)
 	if (topology_idx == CVP_VOC_RX_TOPOLOGY_CAL) {
 		topology = VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT;
 	} else if (topology_idx == CVP_VOC_TX_TOPOLOGY_CAL) {
-		topology = VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS;
+		topology = VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS_V2;
 	} else {
 		pr_err("%s: cal index %x is invalid!\n",
 			__func__, topology_idx);

+ 1 - 1
include/dsp/apr_audio-v2.h

@@ -3666,7 +3666,7 @@ struct afe_lpass_core_shared_clk_config_command {
 #define DEFAULT_POPP_TOPOLOGY				0x00010BE4
 #define COMPRESSED_PASSTHROUGH_DEFAULT_TOPOLOGY         0x0001076B
 #define COMPRESSED_PASSTHROUGH_NONE_TOPOLOGY            0x00010774
-#define VPM_TX_SM_ECNS_COPP_TOPOLOGY			0x00010F71
+#define VPM_TX_SM_ECNS_V2_COPP_TOPOLOGY			0x00010F89
 #define VPM_TX_DM_FLUENCE_COPP_TOPOLOGY			0x00010F72
 #define VPM_TX_QMIC_FLUENCE_COPP_TOPOLOGY		0x00010F75
 #define VPM_TX_DM_RFECNS_COPP_TOPOLOGY			0x00010F86

+ 1 - 1
include/dsp/q6voice.h

@@ -1218,7 +1218,7 @@ struct vss_istream_cmd_set_packet_exchange_mode_t {
 #define VSS_IVOCPROC_CMD_DEREGISTER_DYNAMIC_CALIBRATION_DATA    0x0001307C
 
 #define VSS_IVOCPROC_TOPOLOGY_ID_NONE			0x00010F70
-#define VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS		0x00010F71
+#define VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS_V2		0x00010F89
 #define VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE		0x00010F72
 
 #define VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT		0x00010F77

+ 1 - 0
ipc/apr.c

@@ -820,6 +820,7 @@ static void dispatch_event(unsigned long code, uint16_t proc)
 	uint16_t clnt;
 	int i, j;
 
+	memset(&data, 0, sizeof(data));
 	data.opcode = RESET_EVENTS;
 	data.reset_event = code;
 

+ 1 - 1
ipc/apr_tal_glink.c

@@ -239,7 +239,7 @@ int apr_tal_rx_intents_config(struct apr_svc_ch_dev *apr_ch,
 			      int num_of_intents, uint32_t size)
 {
 	int i;
-	int rc;
+	int rc = 0;
 
 	if (!apr_ch || !num_of_intents || !size) {
 		pr_err("%s: Invalid parameter\n", __func__);

+ 7 - 4
soc/soundwire.c

@@ -79,11 +79,16 @@ void swr_remove_device(struct swr_device *swr_dev)
 {
 	struct swr_device *swr_dev_loop, *safe;
 
+	/*
+	 * master still has reference to all nodes and deletes
+	 * at platform_unregister, so need to init the deleted
+	 * entry
+	 */
 	list_for_each_entry_safe(swr_dev_loop, safe,
 				 &swr_dev->master->devices,
 				 dev_list) {
 		if (swr_dev == swr_dev_loop)
-			list_del(&swr_dev_loop->dev_list);
+			list_del_init(&swr_dev_loop->dev_list);
 	}
 }
 EXPORT_SYMBOL(swr_remove_device);
@@ -789,9 +794,7 @@ static void swr_unregister_device(struct swr_device *swr)
 
 static void swr_master_release(struct device *dev)
 {
-	struct swr_master *master = to_swr_master(dev);
-
-	kfree(master);
+	/* kfree of master done at swrm_remove of device */
 }
 
 #define swr_master_attr_gr NULL

+ 18 - 6
soc/swr-wcd-ctrl.c

@@ -396,11 +396,17 @@ static int swrm_clk_request(struct swr_mstr_ctrl *swrm, bool enable)
 		return -EINVAL;
 
 	if (enable) {
-		swrm->clk(swrm->handle, true);
-		swrm->state = SWR_MSTR_UP;
-	} else {
+		swrm->clk_ref_count++;
+		if (swrm->clk_ref_count == 1) {
+			swrm->clk(swrm->handle, true);
+			swrm->state = SWR_MSTR_UP;
+		}
+	} else if (--swrm->clk_ref_count == 0) {
 		swrm->clk(swrm->handle, false);
 		swrm->state = SWR_MSTR_DOWN;
+	} else if (swrm->clk_ref_count < 0) {
+		pr_err("%s: swrm clk count mismatch\n", __func__);
+		swrm->clk_ref_count = 0;
 	}
 	return 0;
 }
@@ -1170,7 +1176,10 @@ static irqreturn_t swr_mstr_interrupt(int irq, void *dev)
 	u8 devnum = 0;
 	int ret = IRQ_HANDLED;
 
-	pm_runtime_get_sync(&swrm->pdev->dev);
+	mutex_lock(&swrm->reslock);
+	swrm_clk_request(swrm, true);
+	mutex_unlock(&swrm->reslock);
+
 	intr_sts = swrm->read(swrm->handle, SWRM_INTERRUPT_STATUS);
 	intr_sts &= SWRM_INTERRUPT_STATUS_RMSK;
 	for (i = 0; i < SWRM_INTERRUPT_MAX; i++) {
@@ -1258,8 +1267,10 @@ static irqreturn_t swr_mstr_interrupt(int irq, void *dev)
 			break;
 		}
 	}
-	pm_runtime_mark_last_busy(&swrm->pdev->dev);
-	pm_runtime_put_autosuspend(&swrm->pdev->dev);
+
+	mutex_lock(&swrm->reslock);
+	swrm_clk_request(swrm, false);
+	mutex_unlock(&swrm->reslock);
 	return ret;
 }
 
@@ -1447,6 +1458,7 @@ static int swrm_probe(struct platform_device *pdev)
 	swrm->wcmd_id = 0;
 	swrm->slave_status = 0;
 	swrm->num_rx_chs = 0;
+	swrm->clk_ref_count = 0;
 	swrm->state = SWR_MSTR_RESUME;
 	init_completion(&swrm->reset);
 	init_completion(&swrm->broadcast);

+ 1 - 0
soc/swr-wcd-ctrl.h

@@ -78,6 +78,7 @@ struct swr_mstr_ctrl {
 	struct device *dev;
 	struct resource *supplies;
 	struct clk *mclk;
+	int clk_ref_count;
 	struct completion reset;
 	struct completion broadcast;
 	struct mutex mlock;