[PATCH RFC 13/23] ASoC: qcom: lpass: support mapping I2S ports to multiple LPAIFs

From: Neil Armstrong

Date: Fri Nov 13 2026 - 18:57:09 EST


Now we have all the plumbing to support multiple MI2S ports
on multiple LPAIFs, add the optional descriptor and parse it
to probe the associated LPAIF when defined in the DT node.

When the descriptor is not provided, the behaviour is kept
as before and the 8 MI2S ports are mapped to the core
LPAIF.

Since an LPAIF address space can only be mapped by the MI2S
handling or the VA/RXTX/WSA handlers, if somehow the DT
declared some invalid setup (I2S port on WSA and WSA codec),
the probe would fail.

Signed-off-by: Neil Armstrong <neil.armstrong@xxxxxxxxxx>
---
sound/soc/qcom/lpass-cpu.c | 73 +++++++++++++++++++++++++++++++++++++----
sound/soc/qcom/lpass-platform.c | 27 ++++++++++++---
sound/soc/qcom/lpass.h | 23 ++++++++++++-
3 files changed, 110 insertions(+), 13 deletions(-)

diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c
index f8b9b2ec9055..411eecd9cbb9 100644
--- a/sound/soc/qcom/lpass-cpu.c
+++ b/sound/soc/qcom/lpass-cpu.c
@@ -1079,6 +1079,8 @@ static void of_lpass_cpu_parse_dai_data(struct device *dev,
data->mi2s_capture_sd_mode[port_id] =
of_lpass_cpu_parse_sd_lines(dev, node,
"qcom,capture-sd-lines");
+
+ set_bit(port_id, &data->lpaif_port_enable);
} else {
dev_err(dev, "invalid dai id: %d\n", id);
continue;
@@ -1121,12 +1123,33 @@ static int lpass_cpu_init_lpaif(struct platform_device *pdev, int idx,
struct regmap_config cfg = lpass_cpu_regmap_config;
struct device *dev = &pdev->dev;
void __iomem *base;
- int ret;
+ int ret, i;
+
+ /* Only probe an LPAIF if one of the port is described in DT */
+ if (v->mi2s_desc) {
+ const struct lpaif_mi2s_desc *desc = &v->mi2s_desc[idx];
+ bool enabled = false;
+
+ for (i = 0; i < desc->port_desc_count; ++i) {
+ unsigned int port_id = mi2s_port_id(desc->port_desc[i].id);
+
+ if (test_bit(port_id, &drvdata->lpaif_port_enable)) {
+ enabled = true;
+ break;
+ }
+ }
+
+ if (!enabled)
+ return 0;
+ }

base = devm_platform_ioremap_resource_byname(pdev, reg_name);
if (IS_ERR(base))
return PTR_ERR(base);

+ /* Keep the legacy regmap name for the core LPAIF */
+ if (idx)
+ cfg.name = reg_name;
cfg.max_register = LPAIF_WRDMAPER_REG(v, v->wrdma_channels +
v->wrdma_channel_start);

@@ -1247,11 +1270,25 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
drvdata->va_cdc_dma_lpm_buf = res->start;
}

- drvdata->num_lpaif = 1;
+ if (variant->mi2s_desc) {
+ if (variant->num_mi2s_desc > LPASS_MAX_LPAIF)
+ return -EINVAL;

- ret = lpass_cpu_init_lpaif(pdev, 0, "lpass-lpaif");
- if (ret)
- return ret;
+ drvdata->num_lpaif = variant->num_mi2s_desc;
+
+ for (i = 0; i < variant->num_mi2s_desc; i++) {
+ ret = lpass_cpu_init_lpaif(pdev, i,
+ variant->mi2s_desc[i].reg_name);
+ if (ret)
+ return ret;
+ }
+ } else {
+ drvdata->num_lpaif = 1;
+
+ ret = lpass_cpu_init_lpaif(pdev, 0, "lpass-lpaif");
+ if (ret)
+ return ret;
+ }

if (drvdata->hdmi_port_enable) {
drvdata->hdmiif = devm_platform_ioremap_resource_byname(pdev, "lpass-hdmiif");
@@ -1283,8 +1320,30 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)

port_id = mi2s_port_id(variant->dai_driver[i].id);

- drvdata->mi2s_lpaif[port_id] = &drvdata->lpaif[0];
- drvdata->mi2s_intf[port_id] = port_id;
+ if (variant->mi2s_desc) {
+ unsigned int lpaif_idx, lpaif_port;
+ const struct lpaif_mi2s_desc *desc;
+
+ for (lpaif_idx = 0; lpaif_idx < variant->num_mi2s_desc; ++lpaif_idx) {
+ desc = &variant->mi2s_desc[lpaif_idx];
+
+ for (lpaif_port = 0;
+ lpaif_port < desc->port_desc_count;
+ ++lpaif_port) {
+ if (desc->port_desc[lpaif_port].id !=
+ variant->dai_driver[i].id)
+ continue;
+
+ drvdata->mi2s_lpaif[port_id] =
+ &drvdata->lpaif[lpaif_idx];
+ drvdata->mi2s_intf[port_id] =
+ desc->port_desc[lpaif_port].intf;
+ }
+ }
+ } else {
+ drvdata->mi2s_lpaif[port_id] = &drvdata->lpaif[0];
+ drvdata->mi2s_intf[port_id] = port_id;
+ }

drvdata->mi2s_osr_clk[port_id] = devm_clk_get_optional(dev,
variant->dai_osr_clk_names[i]);
diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c
index 2400a6d16bb8..a953db262aa0 100644
--- a/sound/soc/qcom/lpass-platform.c
+++ b/sound/soc/qcom/lpass-platform.c
@@ -1375,6 +1375,8 @@ static int lpass_platform_pcmops_suspend(struct snd_soc_component *component)
}

for (i = 0; i < drvdata->num_lpaif; i++) {
+ if (!drvdata->lpaif[i].drvdata)
+ continue;
map = drvdata->lpaif[i].map;
regcache_cache_only(map, true);
regcache_mark_dirty(map);
@@ -1398,6 +1400,8 @@ static int lpass_platform_pcmops_resume(struct snd_soc_component *component)
}

for (i = 0; i < drvdata->num_lpaif; i++) {
+ if (!drvdata->lpaif[i].drvdata)
+ continue;
map = drvdata->lpaif[i].map;
regcache_cache_only(map, false);
ret = regcache_sync(map);
@@ -1468,6 +1472,10 @@ static int lpass_platform_init_lpaif(struct platform_device *pdev, int idx,
const struct lpass_variant *v = drvdata->variant;
int ret;

+ /* Only continue if already initialized by lpass-cpu */
+ if (!lpaif->drvdata)
+ return 0;
+
lpaif->irq = platform_get_irq_byname(pdev, irq_name);
if (lpaif->irq < 0)
return -ENODEV;
@@ -1499,12 +1507,21 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev)
{
struct lpass_data *drvdata = platform_get_drvdata(pdev);
const struct lpass_variant *v = drvdata->variant;
- int ret;
+ int i, ret;

- ret = lpass_platform_init_lpaif(pdev, 0, "lpass-irq-lpaif",
- IRQF_TRIGGER_RISING);
- if (ret)
- return ret;
+ if (v->mi2s_desc) {
+ for (i = 0; i < v->num_mi2s_desc; i++) {
+ ret = lpass_platform_init_lpaif(pdev, i,
+ v->mi2s_desc[i].irq_name, 0);
+ if (ret)
+ return ret;
+ }
+ } else {
+ ret = lpass_platform_init_lpaif(pdev, 0, "lpass-irq-lpaif",
+ IRQF_TRIGGER_RISING);
+ if (ret)
+ return ret;
+ }

if (drvdata->codec_dma_enable) {
ret = regmap_write(drvdata->rxtx_lpaif_map,
diff --git a/sound/soc/qcom/lpass.h b/sound/soc/qcom/lpass.h
index 4407996fb145..70d64bf3f073 100644
--- a/sound/soc/qcom/lpass.h
+++ b/sound/soc/qcom/lpass.h
@@ -20,7 +20,7 @@
#define LPASS_AHBIX_CLOCK_FREQUENCY 131072000
#define LPASS_MAX_PORTS (LPASS_MAX_PORT)
#define LPASS_MAX_MI2S_PORTS (8)
-#define LPASS_MAX_LPAIF (1)
+#define LPASS_MAX_LPAIF (7)
#define LPASS_MAX_DMA_CHANNELS (8)
#define LPASS_MAX_HDMI_DMA_CHANNELS (4)
#define LPASS_MAX_CDC_DMA_CHANNELS (8)
@@ -148,6 +148,19 @@ struct lpass_lpaif {
struct snd_pcm_substream *substream[LPASS_MAX_DMA_CHANNELS];
};

+struct mi2s_port_desc {
+ unsigned int intf; /* LPAIF Interface */
+ unsigned int id; /* DAI ID */
+};
+
+/* Extended LPAIF MI2S layout */
+struct lpaif_mi2s_desc {
+ const char *reg_name;
+ const char *irq_name;
+ struct mi2s_port_desc *port_desc;
+ unsigned int port_desc_count;
+};
+
/* Both the CPU DAI and platform drivers will access this data */
struct lpass_data {

@@ -184,6 +197,7 @@ struct lpass_data {
/* LPAIF instance and interface index of each MI2S port */
struct lpass_lpaif *mi2s_lpaif[LPASS_MAX_MI2S_PORTS];
unsigned int mi2s_intf[LPASS_MAX_MI2S_PORTS];
+ unsigned long lpaif_port_enable;

/* low-power audio interface (LPAIF) registers */
void __iomem *hdmiif;
@@ -498,6 +512,13 @@ struct lpass_variant {
const char * const *dai_osr_clk_names;
const char * const *dai_bit_clk_names;

+ /*
+ * Optional LPAIF MI2S instances layout when all the MI2S
+ * ports are not available on the core LPAIF.
+ */
+ const struct lpaif_mi2s_desc *mi2s_desc;
+ int num_mi2s_desc;
+
/* SOC specific clocks configuration */
const char **clk_name;
int num_clks;

--
2.34.1