From bb40dd89d8d49484e826f391bfda0e284e641eb5 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Wed, 12 Aug 2020 09:42:46 +0530 Subject: [PATCH 1/4] soc: swr-mstr: Fix headset detect issue due to master.num_dev not updated Headset is not detected sometimes due to master.num_dev not being updated when we call GET_ENUM_SLAVE_STATUS as get_logical address may not have been called. Also enable slave irq only when swr wokeup from clk stop and not when master is already up. This will prevent valid irq to be discarded as spurious irq. Change-Id: I00284e9340668c853d0bd604fe66801118982780 Signed-off-by: Vatsal Bucha --- soc/swr-mstr-ctrl.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c index ad4db4f7ea02..ff2ed2e08422 100644 --- a/soc/swr-mstr-ctrl.c +++ b/soc/swr-mstr-ctrl.c @@ -2157,20 +2157,21 @@ handle_irq: case SWRM_INTERRUPT_STATUS_CLK_STOP_FINISHED_V2: break; case SWRM_INTERRUPT_STATUS_EXT_CLK_STOP_WAKEUP: - if (swrm->state == SWR_MSTR_UP) + if (swrm->state == SWR_MSTR_UP) { dev_dbg(swrm->dev, "%s:SWR Master is already up\n", __func__); - else + } else { dev_err_ratelimited(swrm->dev, "%s: SWR wokeup during clock stop\n", __func__); - /* It might be possible the slave device gets reset - * and slave interrupt gets missed. So re-enable - * Host IRQ and process slave pending - * interrupts, if any. - */ - swrm_enable_slave_irq(swrm); + /* It might be possible the slave device gets + * reset and slave interrupt gets missed. So + * re-enable Host IRQ and process slave pending + * interrupts, if any. + */ + swrm_enable_slave_irq(swrm); + } break; default: dev_err_ratelimited(swrm->dev, @@ -2661,6 +2662,8 @@ static int swrm_probe(struct platform_device *pdev) SWRM_NUM_AUTO_ENUM_SLAVES); ret = -EINVAL; goto err_pdata_fail; + } else { + swrm->master.num_dev = swrm->num_dev; } } From 86fd2a41dbd5d2033c12c0d84a92e26943dd844a Mon Sep 17 00:00:00 2001 From: Vignesh Kulothungan Date: Tue, 13 Oct 2020 17:10:09 -0700 Subject: [PATCH 2/4] soc: add check condition before enabling irq Enable interrupt request only when the interrupt is in disabled state. Change-Id: I67795bf0ee344661e02b0fec3181cd7980d56652 Signed-off-by: Vignesh Kulothungan --- soc/swr-mstr-ctrl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c index 422a1db5828c..58e311510984 100644 --- a/soc/swr-mstr-ctrl.c +++ b/soc/swr-mstr-ctrl.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. */ #include @@ -3128,6 +3128,7 @@ static int swrm_runtime_suspend(struct device *dev) struct swr_master *mstr = &swrm->master; struct swr_device *swr_dev; int current_state = 0; + struct irq_data *irq_data = NULL; trace_printk("%s: pm_runtime: suspend state: %d\n", __func__, swrm->state); @@ -3236,7 +3237,9 @@ static int swrm_runtime_suspend(struct device *dev) if (swrm->clk_stop_mode0_supp) { if (swrm->wake_irq > 0) { - enable_irq(swrm->wake_irq); + irq_data = irq_get_irq_data(swrm->wake_irq); + if (irq_data && irqd_irq_disabled(irq_data)) + enable_irq(swrm->wake_irq); } else if (swrm->ipc_wakeup) { msm_aud_evt_blocking_notifier_call_chain( SWR_WAKE_IRQ_REGISTER, (void *)swrm); From 4b9587900376cf7f1f08dad09f253de1c8d44d86 Mon Sep 17 00:00:00 2001 From: Soumya Managoli Date: Tue, 19 Oct 2021 14:17:05 +0530 Subject: [PATCH 3/4] ASoC: wcd937x: Update EAR PA CnP FSM sequence EAR PA short switch is not released after PA is turned on and off. Address this hardware issue by updating the EAR PA CnP FSM while EAR power down sequence. Change-Id: If4269c30c13572db1b252f223368d444b9250901 Signed-off-by: Soumya Managoli --- asoc/codecs/wcd937x/wcd937x.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c index 34d913feab86..31bd85457092 100644 --- a/asoc/codecs/wcd937x/wcd937x.c +++ b/asoc/codecs/wcd937x/wcd937x.c @@ -1009,6 +1009,22 @@ static int wcd937x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, snd_soc_component_update_bits(component, WCD937X_DIGITAL_PDM_WD_CTL0, 0x17, 0x00); + usleep_range(10000, 10010); + /* disable EAR CnP FSM */ + snd_soc_component_update_bits(component, + WCD937X_EAR_EAR_EN_REG, + 0x02, 0x00); + /* toggle EAR PA to let PA control registers take effect */ + snd_soc_component_update_bits(component, + WCD937X_ANA_EAR, + 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD937X_ANA_EAR, + 0x80, 0x00); + /* enable EAR CnP FSM */ + snd_soc_component_update_bits(component, + WCD937X_EAR_EAR_EN_REG, + 0x02, 0x02); break; }; return ret; From 5144dbbcd1163977398a05af1de084a50bf7c549 Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Tue, 25 Aug 2020 17:14:49 +0800 Subject: [PATCH 4/4] soc: swr-mstr: update component and interrupt enable sequence Enable component after enabling interrupt to avoid missing some intterupt during master init. Change-Id: I0f60c5431a815c58f878d3b9275a046e47939111 Signed-off-by: Meng Wang --- soc/swr-mstr-ctrl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c index 422a1db5828c..dae0dff9696a 100644 --- a/soc/swr-mstr-ctrl.c +++ b/soc/swr-mstr-ctrl.c @@ -2489,9 +2489,6 @@ static int swrm_master_init(struct swr_mstr_ctrl *swrm) reg[len] = SWRM_COMP_CFG_ADDR; value[len++] = 0x02; - reg[len] = SWRM_COMP_CFG_ADDR; - value[len++] = 0x03; - reg[len] = SWRM_INTERRUPT_CLEAR; value[len++] = 0xFFFFFFFF; @@ -2503,6 +2500,9 @@ static int swrm_master_init(struct swr_mstr_ctrl *swrm) reg[len] = SWR_MSTR_RX_SWRM_CPU_INTERRUPT_EN; value[len++] = swrm->intr_mask; + reg[len] = SWRM_COMP_CFG_ADDR; + value[len++] = 0x03; + swr_master_bulk_write(swrm, reg, value, len); if (!swrm_check_link_status(swrm, 0x1)) {