[PATCH RFC 16/23] ASoC: qcom: lpass: enable the right codec_mem clock when usin LPM memory
From: Neil Armstrong
Date: Fri Nov 13 2026 - 14:26:44 EST
The LPM memory zone needs different codec_mem clock to be
enabled depending on the DMA buffer offset, add an helper
returning the right clock and add support for the MI2S
ports using a non-core LPAIF.
Signed-off-by: Neil Armstrong <neil.armstrong@xxxxxxxxxx>
---
sound/soc/qcom/lpass-cdc-dma.c | 27 ++++++++++++---------------
sound/soc/qcom/lpass-cpu.c | 21 +++++++++++++++++++++
sound/soc/qcom/lpass.h | 20 ++++++++++++++++++++
3 files changed, 53 insertions(+), 15 deletions(-)
diff --git a/sound/soc/qcom/lpass-cdc-dma.c b/sound/soc/qcom/lpass-cdc-dma.c
index 903055e3188d..c20e0976563b 100644
--- a/sound/soc/qcom/lpass-cdc-dma.c
+++ b/sound/soc/qcom/lpass-cdc-dma.c
@@ -199,12 +199,14 @@ static int lpass_cdc_dma_daiops_startup(struct snd_pcm_substream *substream,
{
struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
struct snd_soc_pcm_runtime *soc_runtime = snd_soc_substream_to_rtd(substream);
+ struct clk *mem_clk;
switch (dai->id) {
case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
- clk_set_rate(drvdata->codec_mem0, CODEC_MEM_HZ_NORMAL);
- clk_prepare_enable(drvdata->codec_mem0);
+ mem_clk = lpass_cdc_dma_mem_clk(drvdata, drvdata->rxtx_lpm_offset);
+ clk_set_rate(mem_clk, CODEC_MEM_HZ_NORMAL);
+ clk_prepare_enable(mem_clk);
break;
case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX0:
clk_set_rate(drvdata->va_mem0, CODEC_MEM_HZ_NORMAL);
@@ -212,14 +214,9 @@ static int lpass_cdc_dma_daiops_startup(struct snd_pcm_substream *substream,
break;
case LPASS_CDC_DMA_WSA_RX0 ... LPASS_CDC_DMA_WSA_RX9:
case LPASS_CDC_DMA_WSA_TX0 ... LPASS_CDC_DMA_WSA_TX8:
- clk_set_rate(drvdata->codec_mem0, CODEC_MEM_HZ_NORMAL); //??
- clk_set_rate(drvdata->codec_mem1, CODEC_MEM_HZ_NORMAL); //??
- clk_set_rate(drvdata->codec_mem2, CODEC_MEM_HZ_NORMAL); //??
- clk_set_rate(drvdata->codec_mem3, CODEC_MEM_HZ_NORMAL); //??
- clk_prepare_enable(drvdata->codec_mem0); //??
- clk_prepare_enable(drvdata->codec_mem1); //??
- clk_prepare_enable(drvdata->codec_mem2); //??
- clk_prepare_enable(drvdata->codec_mem3); //??
+ mem_clk = lpass_cdc_dma_mem_clk(drvdata, drvdata->wsa_lpm_offset);
+ clk_set_rate(mem_clk, CODEC_MEM_HZ_NORMAL);
+ clk_prepare_enable(mem_clk);
break;
default:
dev_err(soc_runtime->dev, "%s: invalid interface: %d\n", __func__, dai->id);
@@ -233,21 +230,21 @@ static void lpass_cdc_dma_daiops_shutdown(struct snd_pcm_substream *substream,
{
struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
struct snd_soc_pcm_runtime *soc_runtime = snd_soc_substream_to_rtd(substream);
+ struct clk *mem_clk;
switch (dai->id) {
case LPASS_CDC_DMA_RX0 ... LPASS_CDC_DMA_RX9:
case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX8:
- clk_disable_unprepare(drvdata->codec_mem0);
+ mem_clk = lpass_cdc_dma_mem_clk(drvdata, drvdata->rxtx_lpm_offset);
+ clk_disable_unprepare(mem_clk);
break;
case LPASS_CDC_DMA_VA_TX0 ... LPASS_CDC_DMA_VA_TX0:
clk_disable_unprepare(drvdata->va_mem0);
break;
case LPASS_CDC_DMA_WSA_RX0 ... LPASS_CDC_DMA_WSA_RX9:
case LPASS_CDC_DMA_WSA_TX0 ... LPASS_CDC_DMA_WSA_TX8:
- clk_disable_unprepare(drvdata->codec_mem3);
- clk_disable_unprepare(drvdata->codec_mem2);
- clk_disable_unprepare(drvdata->codec_mem1);
- clk_disable_unprepare(drvdata->codec_mem0);
+ mem_clk = lpass_cdc_dma_mem_clk(drvdata, drvdata->wsa_lpm_offset);
+ clk_disable_unprepare(mem_clk);
break;
default:
dev_err(soc_runtime->dev, "%s: invalid interface: %d\n", __func__, dai->id);
diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c
index 4bbcd59ebd60..302c31b23090 100644
--- a/sound/soc/qcom/lpass-cpu.c
+++ b/sound/soc/qcom/lpass-cpu.c
@@ -89,6 +89,17 @@ static int lpass_cpu_daiops_startup(struct snd_pcm_substream *substream,
unsigned int port_id = mi2s_port_id(dai->driver->id);
int ret;
+ if (is_lpm_mi2s_port(drvdata, dai->driver->id)) {
+ struct clk *mem_clk = drvdata->va_mem0;
+
+ if (drvdata->mi2s_lpm[port_id] == LPASS_RXTX_CDC_LPM)
+ mem_clk = lpass_cdc_dma_mem_clk(drvdata,
+ drvdata->mi2s_lpm_offset[port_id]);
+
+ clk_set_rate(mem_clk, LPASS_CODEC_MEM_HZ_NORMAL);
+ clk_prepare_enable(mem_clk);
+ }
+
ret = clk_prepare_enable(drvdata->mi2s_osr_clk[port_id]);
if (ret) {
dev_err(dai->dev, "error in enabling mi2s osr clk: %d\n", ret);
@@ -133,6 +144,16 @@ static void lpass_cpu_daiops_shutdown(struct snd_pcm_substream *substream,
}
clk_unprepare(drvdata->mi2s_bit_clk[port_id]);
+
+ if (is_lpm_mi2s_port(drvdata, dai->driver->id)) {
+ struct clk *mem_clk = drvdata->va_mem0;
+
+ if (drvdata->mi2s_lpm[port_id] == LPASS_RXTX_CDC_LPM)
+ mem_clk = lpass_cdc_dma_mem_clk(drvdata,
+ drvdata->mi2s_lpm_offset[port_id]);
+
+ clk_disable_unprepare(mem_clk);
+ }
}
static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
diff --git a/sound/soc/qcom/lpass.h b/sound/soc/qcom/lpass.h
index 8f361f2808ca..699b9a07eb5a 100644
--- a/sound/soc/qcom/lpass.h
+++ b/sound/soc/qcom/lpass.h
@@ -30,6 +30,8 @@
#define LPASS_CDC_DMA_INTF_FOUR_CHANNEL (0x0F)
#define LPASS_CDC_DMA_INTF_SIX_CHANNEL (0x3F)
#define LPASS_CDC_DMA_INTF_EIGHT_CHANNEL (0xFF)
+#define LPASS_CDC_DMA_LPM_MEM_BLK_SIZE (2 * 8 * 1024)
+#define LPASS_CODEC_MEM_HZ_NORMAL 153600000
#define LPASS_ACTIVE_PDS (4)
#define LPASS_PROXY_PDS (8)
@@ -291,6 +293,24 @@ static inline bool is_lpm_mi2s_port(struct lpass_data *drvdata, unsigned int dai
return false;
}
+static inline struct clk *lpass_cdc_dma_mem_clk(struct lpass_data *drvdata, u32 offset)
+{
+ unsigned int id = offset / LPASS_CDC_DMA_LPM_MEM_BLK_SIZE;
+
+ switch (id) {
+ case 0:
+ return drvdata->codec_mem0;
+ case 1:
+ return drvdata->codec_mem1;
+ case 2:
+ return drvdata->codec_mem2;
+ case 3:
+ return drvdata->codec_mem3;
+ default:
+ return NULL;
+ }
+}
+
/* Vairant data per each SOC */
struct lpass_variant {
u32 irq_reg_base;
--
2.34.1