From fd25834b8484d50a66d83204f40147d75081e280 Mon Sep 17 00:00:00 2001 From: Sudheer Papothi Date: Thu, 5 Dec 2019 01:14:47 +0530 Subject: [PATCH 1/2] soc: soundwire: Check for clock source before clock switch Check for soundwire clock source before clock switch to avoid redundant clock switch for the same clock source. Change-Id: I8a7a116cc956f427af677b413928dace5a39a23d Signed-off-by: Sudheer Papothi --- soc/swr-mstr-ctrl.c | 13 +++++++++++-- soc/swr-mstr-ctrl.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c index c3ad05345eb3..3a33f8278086 100644 --- a/soc/swr-mstr-ctrl.c +++ b/soc/swr-mstr-ctrl.c @@ -3101,9 +3101,18 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data) * next activity on soundwire will request clock from new clock * source. */ + if (!data) { + dev_err(swrm->dev, "%s: data is NULL for id:%d\n", + __func__, id); + ret = -EINVAL; + break; + } mutex_lock(&swrm->mlock); - if (swrm->state == SWR_MSTR_UP) - swrm_device_suspend(&pdev->dev); + if (swrm->clk_src != *(int *)data) { + if (swrm->state == SWR_MSTR_UP) + swrm_device_suspend(&pdev->dev); + swrm->clk_src = *(int *)data; + } mutex_unlock(&swrm->mlock); break; case SWR_CLK_FREQ: diff --git a/soc/swr-mstr-ctrl.h b/soc/swr-mstr-ctrl.h index c2955f88d827..2e7cac4fb6a1 100644 --- a/soc/swr-mstr-ctrl.h +++ b/soc/swr-mstr-ctrl.h @@ -187,6 +187,7 @@ struct swr_mstr_ctrl { u32 swr_irq_wakeup_capable; int hw_core_clk_en; int aud_core_clk_en; + int clk_src; #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_swrm_dent; struct dentry *debugfs_peek; From 7e443c1cd682812f122ac4426c0640f1cfdf2b2b Mon Sep 17 00:00:00 2001 From: Laxminath Kasam Date: Fri, 22 Nov 2019 15:46:11 +0530 Subject: [PATCH 2/2] asoc: bengal: Avoid island config to afe for sva disable variant Check SVA disable variant and skip send afe island config. Change-Id: Ida6c32ec042f545291aaeb8e616478b991d923bd Signed-off-by: Laxminath Kasam --- asoc/bengal.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/asoc/bengal.c b/asoc/bengal.c index d60d61cd3323..bbf5413be861 100644 --- a/asoc/bengal.c +++ b/asoc/bengal.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #include @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -260,6 +261,7 @@ static u32 mi2s_ebit_clk[MI2S_MAX] = { }; static struct mi2s_conf mi2s_intf_conf[MI2S_MAX]; +static bool va_disable; /* Default configuration of TDM channels */ static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = { @@ -3824,6 +3826,8 @@ static int msm_snd_cdc_dma_startup(struct snd_pcm_substream *substream) case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0: case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1: case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2: + if (va_disable) + break; ret = bengal_send_island_va_config(dai_link->id); if (ret) pr_err("%s: send island va cfg failed, err: %d\n", @@ -6508,6 +6512,10 @@ static int msm_asoc_machine_probe(struct platform_device *pdev) const char *mbhc_audio_jack_type = NULL; int ret = 0; uint index = 0; + struct nvmem_cell *cell; + size_t len; + u32 *buf; + u32 adsp_var_idx = 0; if (!pdev->dev.of_node) { dev_err(&pdev->dev, @@ -6657,7 +6665,23 @@ static int msm_asoc_machine_probe(struct platform_device *pdev) __func__, ret); is_initial_boot = true; + /* get adsp variant idx */ + cell = nvmem_cell_get(&pdev->dev, "adsp_variant"); + if (IS_ERR_OR_NULL(cell)) { + dev_dbg(&pdev->dev, "%s: FAILED to get nvmem cell \n", __func__); + goto ret; + } + buf = nvmem_cell_read(cell, &len); + nvmem_cell_put(cell); + if (IS_ERR_OR_NULL(buf) || len <= 0 || len > sizeof(32)) { + dev_dbg(&pdev->dev, "%s: FAILED to read nvmem cell \n", __func__); + goto ret; + } + memcpy(&adsp_var_idx, buf, len); + kfree(buf); + va_disable = adsp_var_idx; +ret: return 0; err: devm_kfree(&pdev->dev, pdata);