Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4811ba8f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: msm8939: fix no audio after SSR"

parents 0e1f4aac b8fae01a
Loading
Loading
Loading
Loading
+68 −40
Original line number Diff line number Diff line
@@ -769,11 +769,64 @@ static int msm8939_wcd93xx_codec_up(struct snd_soc_codec *codec)
	return err;
}

static int msm8939_gpio_set_mux_ctl(void)
{
	void __iomem *vaddr = NULL;
	int val = 0;

	vaddr = ioremap(LPASS_CSR_GP_IO_MUX_MIC_CTL , 4);
	if (!vaddr) {
		pr_err("%s ioremap failure for addr %x\n",
				__func__,
				LPASS_CSR_GP_IO_MUX_MIC_CTL);
		return -ENOMEM;
	}
	val = ioread32(vaddr);
	val = val | 0x5000dff;
	iowrite32(val, vaddr);
	pr_debug("%s:val_mic_mux gpio %x\n", __func__, val);
	iounmap(vaddr);
	vaddr = ioremap(LPASS_CSR_GP_IO_MUX_SPKR_CTL , 4);
	if (!vaddr) {
		pr_err("%s ioremap failure for addr %x\n",
				__func__,
				LPASS_CSR_GP_IO_MUX_SPKR_CTL);
		return -ENOMEM;
	}
	val = ioread32(vaddr);
	val = val | 0x000800BF;
	iowrite32(val, vaddr);
	pr_debug("%s:val_spkr_mux gpio %x\n", __func__, val);
	iounmap(vaddr);

	vaddr = ioremap(0x103f004, 4);
	if (!vaddr)
		pr_err("%s ioremap failure for addr\n",
					__func__);
	val = ioread32(vaddr);
	pr_debug("%s:val1 %x\n", __func__, val);
	iounmap(vaddr);
	vaddr = ioremap(0x103f000, 4);
	if (!vaddr)
		pr_err("%s ioremap failure for addr2\n",
					__func__);
	val = ioread32(vaddr);
	pr_debug("%s:val2 %x\n", __func__, val);
	iounmap(vaddr);
	return 0;
}

static int msm8939_codec_event_cb(struct snd_soc_codec *codec,
		enum wcd9xxx_codec_event codec_event)
{
	int ret = 0;
	switch (codec_event) {
	case WCD9XXX_CODEC_EVENT_CODEC_UP:
		ret = msm8939_gpio_set_mux_ctl();
		if (ret < 0) {
			pr_err("%s: failed to set MUX ctl\n", __func__);
			return ret;
		}
		return msm8939_wcd93xx_codec_up(codec);
	default:
		pr_err("%s: UnSupported codec event %d\n",
@@ -931,8 +984,6 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
	struct snd_soc_dai *codec_dai = rtd->codec_dai;
	struct snd_soc_card *card = codec->card;
	struct msm8939_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
	void __iomem *vaddr = NULL;
	int val = 0;
	int ret = 0;

	/*
@@ -980,45 +1031,12 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
			__func__, ret);
		return ret;
	}
	vaddr = ioremap(LPASS_CSR_GP_IO_MUX_MIC_CTL , 4);
	if (!vaddr) {
		pr_err("%s ioremap failure for addr %x\n",
				__func__,
				LPASS_CSR_GP_IO_MUX_MIC_CTL);
		return -ENOMEM;
	}
	val = ioread32(vaddr);
	val = val | 0x5000dff;
	iowrite32(val, vaddr);
	pr_debug("%s:val_mic_mux gpio %x\n", __func__, val);
	iounmap(vaddr);
	vaddr = ioremap(LPASS_CSR_GP_IO_MUX_SPKR_CTL , 4);
	if (!vaddr) {
		pr_err("%s ioremap failure for addr %x\n",
				__func__,
				LPASS_CSR_GP_IO_MUX_SPKR_CTL);
		return -ENOMEM;
	ret = msm8939_gpio_set_mux_ctl();
	if (ret) {
		pr_err("%s: Failed to set MUX CTL %d\n",
			__func__, ret);
		return ret;
	}
	val = ioread32(vaddr);
	val = val | 0x000800BF;
	iowrite32(val, vaddr);
	pr_debug("%s:val_spkr_mux gpio %x\n", __func__, val);
	iounmap(vaddr);

	vaddr = ioremap(0x103f004 , 4);
	if (!vaddr)
		pr_err("%s ioremap failure for addr\n",
					__func__);
	val = ioread32(vaddr);
	pr_debug("%s:val1 %x\n", __func__, val);
	iounmap(vaddr);
	vaddr = ioremap(0x103f000 , 4);
	if (!vaddr)
		pr_err("%s ioremap failure for addr2\n",
					__func__);
	val = ioread32(vaddr);
	pr_debug("%s:val2 %x\n", __func__, val);
	iounmap(vaddr);

	wcd9xxx_mbhc_cfg.calibration = def_codec_mbhc_cal();
	if (wcd9xxx_mbhc_cfg.calibration) {
@@ -1033,6 +1051,16 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
	} else {
		ret = -ENOMEM;
	}
	adsp_state_notifier =
	    subsys_notif_register_notifier("modem",
					   &adsp_state_notifier_block);
	if (!adsp_state_notifier) {
		pr_err("%s: Failed to register adsp state notifier\n",
		       __func__);
		ret = -EFAULT;
	}
	tapan_event_register(msm8939_codec_event_cb, rtd->codec);

	return ret;
}