Skip to contentSkip to conversation

ASoC: qcom: Add support for SC7180 lpass variant

PATCH Superseded Rohit kumar 4 participants 29 messages Jul 8, 2020 – Jul 22, 2020

Subsystems (5)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover ASoC: qcom: Add support for SC7180 lpass variant

This patch chain add audio support for SC7180 soc by doing the required modification in existing common lpass-cpu/lpass-platform driver. Below is a brief summary of patch series:

PATCH v3 0001 ... 0005: Update lpass-cpu, lpass-platform drivers to make it more generic and support newer soc registers configuration. This also updates existing lpass-apq8096.c and lpass-ipq806x.c.
PATCH v2 0005 ... 0007: Add documentation and platform driver for newer SC7180 SOC variant.

Changes since v2:
- Moved yaml conversion of Documentation to the end of patch series
- Used REG_FIELD_ID instead of REG_FIELD for DMACTL and I2SCTL registers.
Move reg_fields to struct lpass_variant as suggested by Srinivas.

Ajit Pandey (5):
ASoC: qcom: Add common array to initialize soc based core clocks
include: dt-bindings: sound: Add sc7180-lpass bindings header
ASoC: qcom: lpass-platform: Replace card->dev with component->dev
ASoC: qcom: lpass-sc7180: Add platform driver for lpass audio
dt-bindings: sound: lpass-cpu: Move to yaml format

Rohit kumar (3):
ASoC: qcom: lpass-cpu: Move ahbix clk to platform specific function
ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers
dt-bindings: sound: lpass-cpu: Add sc7180 lpass cpu node

 .../devicetree/bindings/sound/qcom,lpass-cpu.txt   |  79 --------
 .../devicetree/bindings/sound/qcom,lpass-cpu.yaml  | 154 +++++++++++++++
 include/dt-bindings/sound/sc7180-lpass.h           |  10 +
 sound/soc/qcom/Kconfig                             |   5 +
 sound/soc/qcom/Makefile                            |   2 +
 sound/soc/qcom/lpass-apq8016.c                     |  86 ++++++--
 sound/soc/qcom/lpass-cpu.c                         | 193 +++++++++---------
 sound/soc/qcom/lpass-ipq806x.c                     |  67 +++++++
 sound/soc/qcom/lpass-lpaif-reg.h                   | 157 ++++++++-------
 sound/soc/qcom/lpass-platform.c                    | 156 +++++++++++----
 sound/soc/qcom/lpass-sc7180.c                      | 216 +++++++++++++++++++++
 sound/soc/qcom/lpass.h                             |  63 +++++-
 12 files changed, 886 insertions(+), 302 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt
 create mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml
 create mode 100644 include/dt-bindings/sound/sc7180-lpass.h
 create mode 100644 sound/soc/qcom/lpass-sc7180.c
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
#1 lore raw

PATCH v3 1/8 ASoC: qcom: Add common array to initialize soc based core clocks

From: Ajit Pandey <[email protected]>

LPASS variants have their own soc specific clocks that needs to be enabled for MI2S audio support. Added a common variable in drvdata to initialize such clocks using bulk clk api. Such clock names is defined in variants specific data and needs to fetched during init.

---
 sound/soc/qcom/lpass-apq8016.c | 39 +++++++++++++++++++--------------------
 sound/soc/qcom/lpass.h         | 10 +++++++---
 2 files changed, 26 insertions(+), 23 deletions(-)
sound/soc/qcom/lpass-apq8016.c +19 -20
index b3610d0..8210e37 100644
@@ -161,32 +161,27 @@ static int apq8016_lpass_free_dma_channel(struct lpass_data *drvdata, int chan)
 static int apq8016_lpass_init(struct platform_device *pdev)
 {
 	struct lpass_data *drvdata = platform_get_drvdata(pdev);
+	struct lpass_variant *variant = drvdata->variant;
 	struct device *dev = &pdev->dev;
-	int ret;
+	int ret, i;
 
-	drvdata->pcnoc_mport_clk = devm_clk_get(dev, "pcnoc-mport-clk");
-	if (IS_ERR(drvdata->pcnoc_mport_clk)) {
-		dev_err(dev, "error getting pcnoc-mport-clk: %ld\n",
-			PTR_ERR(drvdata->pcnoc_mport_clk));
-		return PTR_ERR(drvdata->pcnoc_mport_clk);
-	}
 
-	ret = clk_prepare_enable(drvdata->pcnoc_mport_clk);
+	drvdata->clks = devm_kcalloc(dev, variant->num_clks,
+				     sizeof(*drvdata->clks), GFP_KERNEL);
+	drvdata->num_clks = variant->num_clks;
+
+	for (i = 0; i < drvdata->num_clks; i++)
+		drvdata->clks[i].id = variant->clk_name[i];
+
+	ret = devm_clk_bulk_get(dev, drvdata->num_clks, drvdata->clks);
 	if (ret) {
-		dev_err(dev, "Error enabling pcnoc-mport-clk: %d\n", ret);
+		dev_err(dev, "Failed to get clocks %d\n", ret);
 		return ret;
 	}
 
-	drvdata->pcnoc_sway_clk = devm_clk_get(dev, "pcnoc-sway-clk");
-	if (IS_ERR(drvdata->pcnoc_sway_clk)) {
-		dev_err(dev, "error getting pcnoc-sway-clk: %ld\n",
-			PTR_ERR(drvdata->pcnoc_sway_clk));
-		return PTR_ERR(drvdata->pcnoc_sway_clk);
-	}
-
-	ret = clk_prepare_enable(drvdata->pcnoc_sway_clk);
+	ret = clk_bulk_prepare_enable(drvdata->num_clks, drvdata->clks);
 	if (ret) {
-		dev_err(dev, "Error enabling pcnoc_sway_clk: %d\n", ret);
+		dev_err(dev, "apq8016 clk_enable failed\n");
 		return ret;
 	}
 
@@ -197,8 +192,7 @@ static int apq8016_lpass_exit(struct platform_device *pdev)
 {
 	struct lpass_data *drvdata = platform_get_drvdata(pdev);
 
-	clk_disable_unprepare(drvdata->pcnoc_mport_clk);
-	clk_disable_unprepare(drvdata->pcnoc_sway_clk);
+	clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
 
 	return 0;
 }
@@ -219,6 +213,11 @@ static struct lpass_variant apq8016_data = {
 	.wrdma_reg_stride	= 0x1000,
 	.wrdma_channel_start	= 5,
 	.wrdma_channels		= 2,
+	.clk_name		= (const char*[]) {
+				   "pcnoc-mport-clk",
+				   "pcnoc-sway-clk",
+				  },
+	.num_clks		= 2,
 	.dai_driver		= apq8016_lpass_cpu_dai_driver,
 	.num_dai		= ARRAY_SIZE(apq8016_lpass_cpu_dai_driver),
 	.dai_osr_clk_names	= (const char *[]) {
sound/soc/qcom/lpass.h +7 -3
index bd19ec5..450020e 100644
@@ -51,9 +51,9 @@ struct lpass_data {
 	/* used it for handling interrupt per dma channel */
 	struct snd_pcm_substream *substream[LPASS_MAX_DMA_CHANNELS];
 
-	/* 8016 specific */
-	struct clk *pcnoc_mport_clk;
-	struct clk *pcnoc_sway_clk;
+	/* SOC specific clock list */
+	struct clk_bulk_data *clks;
+	int num_clks;
 
 };
 
@@ -89,6 +89,10 @@ struct lpass_variant {
 	int num_dai;
 	const char * const *dai_osr_clk_names;
 	const char * const *dai_bit_clk_names;
+
+	/* SOC specific clocks configuration */
+	const char **clk_name;
+	int num_clks;
 };
 
 /* register the platform driver from the CPU DAI driver */
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
#5 lore raw

PATCH v3 3/8 ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers

In reply to Rohit kumar

I2SCTL and DMACTL registers has different bits alignment for newer LPASS variants of SC7180 soc. Use REG_FIELD_ID() to define the reg_fields in platform specific file and removed shifts and mask macros for such registers from header file.

---
 sound/soc/qcom/lpass-apq8016.c   |  24 ++++++
 sound/soc/qcom/lpass-cpu.c       | 163 +++++++++++++++++++++++----------------
 sound/soc/qcom/lpass-ipq806x.c   |  24 ++++++
 sound/soc/qcom/lpass-lpaif-reg.h | 157 +++++++++++++++++++------------------
 sound/soc/qcom/lpass-platform.c  | 151 +++++++++++++++++++++++++++---------
 sound/soc/qcom/lpass.h           |  53 +++++++++++++
 6 files changed, 398 insertions(+), 174 deletions(-)
sound/soc/qcom/lpass-apq8016.c +24 -0
index fe4c258..dd9e3dd 100644
@@ -240,6 +240,30 @@ static struct lpass_variant apq8016_data = {
 	.wrdma_reg_stride	= 0x1000,
 	.wrdma_channel_start	= 5,
 	.wrdma_channels		= 2,
+	.loopback		= REG_FIELD_ID(0x1000, 15, 15, 4, 0x1000),
+	.spken			= REG_FIELD_ID(0x1000, 14, 14, 4, 0x1000),
+	.spkmode		= REG_FIELD_ID(0x1000, 10, 13, 4, 0x1000),
+	.spkmono		= REG_FIELD_ID(0x1000, 9, 9, 4, 0x1000),
+	.micen			= REG_FIELD_ID(0x1000, 8, 8, 4, 0x1000),
+	.micmode		= REG_FIELD_ID(0x1000, 4, 7, 4, 0x1000),
+	.micmono		= REG_FIELD_ID(0x1000, 3, 3, 4, 0x1000),
+	.wssrc			= REG_FIELD_ID(0x1000, 2, 2, 4, 0x1000),
+	.bitwidth		= REG_FIELD_ID(0x1000, 0, 0, 4, 0x1000),
+
+	.rdma_dyncclk		= REG_FIELD_ID(0x8400, 12, 12, 2, 0x1000),
+	.rdma_bursten		= REG_FIELD_ID(0x8400, 11, 11, 2, 0x1000),
+	.rdma_wpscnt		= REG_FIELD_ID(0x8400, 8, 10, 2, 0x1000),
+	.rdma_intf		= REG_FIELD_ID(0x8400, 4, 7, 2, 0x1000),
+	.rdma_fifowm		= REG_FIELD_ID(0x8400, 1, 3, 2, 0x1000),
+	.rdma_enable		= REG_FIELD_ID(0x8400, 0, 0, 2, 0x1000),
+
+	.wrdma_dyncclk		= REG_FIELD_ID(0xB000, 12, 12, 2, 0x1000),
+	.wrdma_bursten		= REG_FIELD_ID(0xB000, 11, 11, 2, 0x1000),
+	.wrdma_wpscnt		= REG_FIELD_ID(0xB000, 8, 10, 2, 0x1000),
+	.wrdma_intf		= REG_FIELD_ID(0xB000, 4, 7, 2, 0x1000),
+	.wrdma_fifowm		= REG_FIELD_ID(0xB000, 1, 3, 2, 0x1000),
+	.wrdma_enable		= REG_FIELD_ID(0xB000, 0, 0, 2, 0x1000),
+
 	.clk_name		= (const char*[]) {
 				   "pcnoc-mport-clk",
 				   "pcnoc-sway-clk",
sound/soc/qcom/lpass-cpu.c +98 -65

270 lines not on this page · raw message

sound/soc/qcom/lpass-ipq806x.c +24 -0
index b7c0586..72f09b3 100644
@@ -123,6 +123,30 @@ static struct lpass_variant ipq806x_data = {
 	.wrdma_reg_stride	= 0x1000,
 	.wrdma_channel_start	= 5,
 	.wrdma_channels		= 4,
+	.loopback		= REG_FIELD_ID(0x0010, 15, 15, 5, 0x4),
+	.spken			= REG_FIELD_ID(0x0010, 14, 14, 5, 0x4),
+	.spkmode		= REG_FIELD_ID(0x0010, 10, 13, 5, 0x4),
+	.spkmono		= REG_FIELD_ID(0x0010, 9, 9, 5, 0x4),
+	.micen			= REG_FIELD_ID(0x0010, 8, 8, 5, 0x4),
+	.micmode		= REG_FIELD_ID(0x0010, 4, 7, 5, 0x4),
+	.micmono		= REG_FIELD_ID(0x0010, 3, 3, 5, 0x4),
+	.wssrc			= REG_FIELD_ID(0x0010, 2, 2, 5, 0x4),
+	.bitwidth		= REG_FIELD_ID(0x0010, 0, 0, 5, 0x4),
+
+	.rdma_dyncclk		= REG_FIELD_ID(0x6000, 12, 12, 4, 0x1000),
+	.rdma_bursten		= REG_FIELD_ID(0x6000, 11, 11, 4, 0x1000),
+	.rdma_wpscnt		= REG_FIELD_ID(0x6000, 8, 10, 4, 0x1000),
+	.rdma_intf		= REG_FIELD_ID(0x6000, 4, 7, 4, 0x1000),
+	.rdma_fifowm		= REG_FIELD_ID(0x6000, 1, 3, 4, 0x1000),
+	.rdma_enable		= REG_FIELD_ID(0x6000, 0, 0, 4, 0x1000),
+
+	.wrdma_dyncclk		= REG_FIELD_ID(0xB000, 12, 12, 4, 0x1000),
+	.wrdma_bursten		= REG_FIELD_ID(0xB000, 11, 11, 4, 0x1000),
+	.wrdma_wpscnt		= REG_FIELD_ID(0xB000, 8, 10, 4, 0x1000),
+	.wrdma_intf		= REG_FIELD_ID(0xB000, 4, 7, 4, 0x1000),
+	.wrdma_fifowm		= REG_FIELD_ID(0xB000, 1, 3, 4, 0x1000),
+	.wrdma_enable		= REG_FIELD_ID(0xB000, 0, 0, 4, 0x1000),
+
 	.dai_driver		= &ipq806x_lpass_cpu_dai_driver,
 	.num_dai		= 1,
 	.dai_osr_clk_names	= (const char *[]) {
sound/soc/qcom/lpass-lpaif-reg.h +84 -73

181 lines not on this page · raw message

sound/soc/qcom/lpass-platform.c +115 -36

262 lines not on this page · raw message

sound/soc/qcom/lpass.h +53 -0

71 lines not on this page · raw message

Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
#3 lore raw

PATCH v3 2/8 ASoC: qcom: lpass-cpu: Move ahbix clk to platform specific function

In reply to Rohit kumar

Ahbix clock is optional clock and not needed for all platforms. Move it to lpass-apq8016/ipq806x as it is not needed for sc7180.

---
 sound/soc/qcom/lpass-apq8016.c | 27 ++++++++++++++++++++++++++
 sound/soc/qcom/lpass-cpu.c     | 40 ++++++++++-----------------------------
 sound/soc/qcom/lpass-ipq806x.c | 43 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 80 insertions(+), 30 deletions(-)
sound/soc/qcom/lpass-apq8016.c +27 -0
index 8210e37..fe4c258 100644
@@ -185,7 +185,33 @@ static int apq8016_lpass_init(struct platform_device *pdev)
 		return ret;
 	}
 
+	drvdata->ahbix_clk = devm_clk_get(dev, "ahbix-clk");
+	if (IS_ERR(drvdata->ahbix_clk)) {
+		dev_err(dev, "error getting ahbix-clk: %ld\n",
+				PTR_ERR(drvdata->ahbix_clk));
+		ret = PTR_ERR(drvdata->ahbix_clk);
+		goto err_ahbix_clk;
+	}
+
+	ret = clk_set_rate(drvdata->ahbix_clk, LPASS_AHBIX_CLOCK_FREQUENCY);
+	if (ret) {
+		dev_err(dev, "error setting rate on ahbix_clk: %d\n", ret);
+		goto err_ahbix_clk;
+	}
+	dev_dbg(dev, "set ahbix_clk rate to %lu\n",
+			clk_get_rate(drvdata->ahbix_clk));
+
+	ret = clk_prepare_enable(drvdata->ahbix_clk);
+	if (ret) {
+		dev_err(dev, "error enabling ahbix_clk: %d\n", ret);
+		goto err_ahbix_clk;
+	}
+
 	return 0;
+
+err_ahbix_clk:
+	clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
+	return ret;
 }
 
 static int apq8016_lpass_exit(struct platform_device *pdev)
@@ -193,6 +219,7 @@ static int apq8016_lpass_exit(struct platform_device *pdev)
 	struct lpass_data *drvdata = platform_get_drvdata(pdev);
 
 	clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
+	clk_disable_unprepare(drvdata->ahbix_clk);
 
 	return 0;
 }
sound/soc/qcom/lpass-cpu.c +10 -30
index e00a4af..f0c7e93 100644
@@ -566,8 +566,13 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
 		return PTR_ERR(drvdata->lpaif_map);
 	}
 
-	if (variant->init)
-		variant->init(pdev);
+	if (variant->init) {
+		ret = variant->init(pdev);
+		if (ret) {
+			dev_err(dev, "error initializing variant: %d\n", ret);
+			return ret;
+		}
+	}
 
 	for (i = 0; i < variant->num_dai; i++) {
 		dai_id = variant->dai_driver[i].id;
@@ -594,46 +599,22 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
 		}
 	}
 
-	drvdata->ahbix_clk = devm_clk_get(dev, "ahbix-clk");
-	if (IS_ERR(drvdata->ahbix_clk)) {
-		dev_err(dev, "error getting ahbix-clk: %ld\n",
-			PTR_ERR(drvdata->ahbix_clk));
-		return PTR_ERR(drvdata->ahbix_clk);
-	}
-
-	ret = clk_set_rate(drvdata->ahbix_clk, LPASS_AHBIX_CLOCK_FREQUENCY);
-	if (ret) {
-		dev_err(dev, "error setting rate on ahbix_clk: %d\n", ret);
-		return ret;
-	}
-	dev_dbg(dev, "set ahbix_clk rate to %lu\n",
-		clk_get_rate(drvdata->ahbix_clk));
-
-	ret = clk_prepare_enable(drvdata->ahbix_clk);
-	if (ret) {
-		dev_err(dev, "error enabling ahbix_clk: %d\n", ret);
-		return ret;
-	}
-
 	ret = devm_snd_soc_register_component(dev,
 					      &lpass_cpu_comp_driver,
 					      variant->dai_driver,
 					      variant->num_dai);
 	if (ret) {
 		dev_err(dev, "error registering cpu driver: %d\n", ret);
-		goto err_clk;
+		goto err;
 	}
 
 	ret = asoc_qcom_lpass_platform_register(pdev);
 	if (ret) {
 		dev_err(dev, "error registering platform driver: %d\n", ret);
-		goto err_clk;
+		goto err;
 	}
 
-	return 0;
-
-err_clk:
-	clk_disable_unprepare(drvdata->ahbix_clk);
+err:
 	return ret;
 }
 EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_platform_probe);
@@ -645,7 +626,6 @@ int asoc_qcom_lpass_cpu_platform_remove(struct platform_device *pdev)
 	if (drvdata->variant->exit)
 		drvdata->variant->exit(pdev);
 
-	clk_disable_unprepare(drvdata->ahbix_clk);
 
 	return 0;
 }
sound/soc/qcom/lpass-ipq806x.c +43 -0

55 lines not on this page · raw message

Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
#13 lore raw

PATCH v3 5/8 ASoC: qcom: lpass-platform: Replace card->dev with component->dev

In reply to Rohit kumar

From: Ajit Pandey <[email protected]>

We are allocating dma memory for component->dev but trying to mmap such memory for substream->pcm->card->dev. Replace device argument in mmap with component->dev to fix this.

---
 sound/soc/qcom/lpass-platform.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
sound/soc/qcom/lpass-platform.c +2 -3
index 445ca193..f9424cc 100644
@@ -472,9 +472,8 @@ static int lpass_platform_pcmops_mmap(struct snd_soc_component *component,
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 
-	return dma_mmap_coherent(substream->pcm->card->dev, vma,
-			runtime->dma_area, runtime->dma_addr,
-			runtime->dma_bytes);
+	return dma_mmap_coherent(component->dev, vma, runtime->dma_area,
+				 runtime->dma_addr, runtime->dma_bytes);
 }
 
 static irqreturn_t lpass_dma_interrupt_handler(
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
#10 lore raw

PATCH v3 4/8 include: dt-bindings: sound: Add sc7180-lpass bindings header

In reply to Rohit kumar

From: Ajit Pandey <[email protected]>

Add header defining dai-id and mclk id for SC7180 lpass soc.

---
 include/dt-bindings/sound/sc7180-lpass.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 include/dt-bindings/sound/sc7180-lpass.h
include/dt-bindings/sound/sc7180-lpass.h new file +10 -0
new file mode 100644
index 00000000..7d988f6
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __DT_SC7180_LPASS_H
+#define __DT_SC7180_LPASS_H
+
+#define MI2S_PRIMARY	0
+#define MI2S_SECONDARY	1
+
+#define LPASS_MCLK0	0
+
+#endif /* __DT_APQ8016_LPASS_H */
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
#24 lore raw

PATCH v3 7/8 ASoC: qcom: lpass-sc7180: Add platform driver for lpass audio

In reply to Rohit kumar

From: Ajit Pandey <[email protected]>

Add platform driver for configuring sc7180 lpass core I2S and DMA configuration to support playback & capture to external codecs connected over primary & secondary MI2S interfaces.

---
 sound/soc/qcom/Kconfig        |   5 +
 sound/soc/qcom/Makefile       |   2 +
 sound/soc/qcom/lpass-sc7180.c | 216 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 223 insertions(+)
 create mode 100644 sound/soc/qcom/lpass-sc7180.c
sound/soc/qcom/Kconfig +5 -0
index 0ea4cde..87bec7f 100644
@@ -24,6 +24,11 @@ config SND_SOC_LPASS_APQ8016
 	select SND_SOC_LPASS_CPU
 	select SND_SOC_LPASS_PLATFORM
 
+config SND_SOC_LPASS_SC7180
+	tristate
+	select SND_SOC_LPASS_CPU
+	select SND_SOC_LPASS_PLATFORM
+
 config SND_SOC_STORM
 	tristate "ASoC I2S support for Storm boards"
 	depends on SND_SOC_QCOM
sound/soc/qcom/Makefile +2 -0
index 41b2c7a..7972c94 100644
@@ -4,11 +4,13 @@ snd-soc-lpass-cpu-objs := lpass-cpu.o
 snd-soc-lpass-platform-objs := lpass-platform.o
 snd-soc-lpass-ipq806x-objs := lpass-ipq806x.o
 snd-soc-lpass-apq8016-objs := lpass-apq8016.o
+snd-soc-lpass-sc7180-objs := lpass-sc7180.o
 
 obj-$(CONFIG_SND_SOC_LPASS_CPU) += snd-soc-lpass-cpu.o
 obj-$(CONFIG_SND_SOC_LPASS_PLATFORM) += snd-soc-lpass-platform.o
 obj-$(CONFIG_SND_SOC_LPASS_IPQ806X) += snd-soc-lpass-ipq806x.o
 obj-$(CONFIG_SND_SOC_LPASS_APQ8016) += snd-soc-lpass-apq8016.o
+obj-$(CONFIG_SND_SOC_LPASS_SC7180) += snd-soc-lpass-sc7180.o
 
 # Machine
 snd-soc-storm-objs := storm.o
sound/soc/qcom/lpass-sc7180.c new file +216 -0

216 lines not on this page · raw message

Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
#17 lore raw

PATCH v3 6/8 dt-bindings: sound: lpass-cpu: Add sc7180 lpass cpu node

In reply to Rohit kumar

Add dt-bindings to support "qcom,lpass-cpu-sc7180" node.

---
 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt +2 -1
index 32c2cdb..04e34cc 100644
@@ -4,7 +4,8 @@ This node models the Qualcomm Technologies Low-Power Audio SubSystem (LPASS).
 
 Required properties:
 
-- compatible		: "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu"
+- compatible		: "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" or
+			  "qcom,lpass-cpu-sc7180"
 - clocks		: Must contain an entry for each entry in clock-names.
 - clock-names		: A list which must include the following entries:
 				* "ahbix-clk"
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
#26 lore raw

PATCH v3 8/8 dt-bindings: sound: lpass-cpu: Move to yaml format

In reply to Rohit kumar

From: Ajit Pandey <[email protected]>

Update lpass-cpu binding with yaml formats.

---
 .../devicetree/bindings/sound/qcom,lpass-cpu.txt   |  80 -----------
 .../devicetree/bindings/sound/qcom,lpass-cpu.yaml  | 154 +++++++++++++++++++++
 2 files changed, 154 insertions(+), 80 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt
 create mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt deleted +0 -80
deleted file mode 100644
index 04e34cc..00000000
@@ -1,80 +0,0 @@
-* Qualcomm Technologies LPASS CPU DAI
-
-This node models the Qualcomm Technologies Low-Power Audio SubSystem (LPASS).
-
-Required properties:
-
-- compatible		: "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" or
-			  "qcom,lpass-cpu-sc7180"
-- clocks		: Must contain an entry for each entry in clock-names.
-- clock-names		: A list which must include the following entries:
-				* "ahbix-clk"
-				* "mi2s-osr-clk"
-				* "mi2s-bit-clk"
-			: required clocks for "qcom,lpass-cpu-apq8016"
-				* "ahbix-clk"
-				* "mi2s-bit-clk0"
-				* "mi2s-bit-clk1"
-				* "mi2s-bit-clk2"
-				* "mi2s-bit-clk3"
-				* "pcnoc-mport-clk"
-				* "pcnoc-sway-clk"
-
-- interrupts		: Must contain an entry for each entry in
-			  interrupt-names.
-- interrupt-names	: A list which must include the following entries:
-				* "lpass-irq-lpaif"
-- pinctrl-N		: One property must exist for each entry in
-			  pinctrl-names.  See ../pinctrl/pinctrl-bindings.txt
-			  for details of the property values.
-- pinctrl-names		: Must contain a "default" entry.
-- reg			: Must contain an address for each entry in reg-names.
-- reg-names		: A list which must include the following entries:
-				* "lpass-lpaif"
-- #address-cells	: Must be 1
-- #size-cells		: Must be 0
-
-
-
-Optional properties:
-
-- qcom,adsp		: Phandle for the audio DSP node
-
-By default, the driver uses up to 4 MI2S SD lines, for a total of 8 channels.
-The SD lines to use can be configured by adding subnodes for each of the DAIs.
-
-Required properties for each DAI (represented by a subnode):
-- reg			: Must be one of the DAI IDs
-			  (usually part of dt-bindings header)
-- qcom,playback-sd-lines: List of serial data lines to use for playback
-			  Each SD line should be represented by a number from 0-3.
-- qcom,capture-sd-lines	: List of serial data lines to use for capture
-			  Each SD line should be represented by a number from 0-3.
-
-Note that adding a subnode changes the default to "no lines configured",
-so both playback and capture lines should be configured when a subnode is added.
-
-Example:
-
-lpass@28100000 {
-	compatible = "qcom,lpass-cpu";
-	clocks = <&lcc AHBIX_CLK>, <&lcc MI2S_OSR_CLK>, <&lcc MI2S_BIT_CLK>;
-	clock-names = "ahbix-clk", "mi2s-osr-clk", "mi2s-bit-clk";
-	interrupts = <0 85 1>;
-	interrupt-names = "lpass-irq-lpaif";
-	pinctrl-names = "default", "idle";
-	pinctrl-0 = <&mi2s_default>;
-	pinctrl-1 = <&mi2s_idle>;
-	reg = <0x28100000 0x10000>;
-	reg-names = "lpass-lpaif";
-	qcom,adsp = <&adsp>;
-
-	#address-cells = <1>;
-	#size-cells = <0>;
-
-	/* Optional to set different MI2S SD lines */
-	dai@3 {
-		reg = <MI2S_QUATERNARY>;
-		qcom,playback-sd-lines = <0 1>;
-	};
-};
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +154 -0

154 lines not on this page · raw message

Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
maintainer
#14 lore raw

Re: [PATCH v3 5/8] ASoC: qcom: lpass-platform: Replace card->dev with component->dev

In reply to Rohit kumar
Quoted 5 lines · Rohit kumar

From: Ajit Pandey <[email protected]>

We are allocating dma memory for component->dev but trying to mmap such memory for substream->pcm->card->dev. Replace device argument in mmap with component->dev to fix this.

This is a bug fix and should've been at the start of the series (or sent separately) so that it can be applied without the rest of the series.

#15 lore raw

Re: [PATCH v3 5/8] ASoC: qcom: lpass-platform: Replace card->dev with component->dev

Quoted 8 lines · Mark Brown
Quoted 5 lines · Rohit kumar

From: Ajit Pandey <[email protected]>

We are allocating dma memory for component->dev but trying to mmap such memory for substream->pcm->card->dev. Replace device argument in mmap with component->dev to fix this.

This is a bug fix and should've been at the start of the series (or sent separately) so that it can be applied without the rest of the series.

Thanks Mark for the suggestion. I will send it separately.

For other patches in series, I will wait for comments before posting next

patchset.

Thanks,

Rohit

Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the Linux Foundation.
Reviewed-by on v3 2/8
#4 lore raw

Re: [PATCH v3 2/8] ASoC: qcom: lpass-cpu: Move ahbix clk to platform specific function

In reply to Rohit kumar
Quoted 10 lines · Rohit kumar

Ahbix clock is optional clock and not needed for all platforms. Move it to lpass-apq8016/ipq806x as it is not needed for sc7180.

---
  sound/soc/qcom/lpass-apq8016.c | 27 ++++++++++++++++++++++++++
  sound/soc/qcom/lpass-cpu.c     | 40 ++++++++++-----------------------------
  sound/soc/qcom/lpass-ipq806x.c | 43 ++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 80 insertions(+), 30 deletions(-)

LGTM,

Reviewed-by on v3 1/8
#2 lore raw

Re: [PATCH v3 1/8] ASoC: qcom: Add common array to initialize soc based core clocks

In reply to Rohit kumar
Quoted 7 lines · Rohit kumar

From: Ajit Pandey <[email protected]>

LPASS variants have their own soc specific clocks that needs to be enabled for MI2S audio support. Added a common variable in drvdata to initialize such clocks using bulk clk api. Such clock names is defined in variants specific data and needs to fetched during init.

Quoted 6 lines
---
  sound/soc/qcom/lpass-apq8016.c | 39 +++++++++++++++++++--------------------
  sound/soc/qcom/lpass.h         | 10 +++++++---
  2 files changed, 26 insertions(+), 23 deletions(-)

LGTM,

#6 lore raw

Re: [PATCH v3 3/8] ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers

In reply to Rohit kumar
Quoted 6 lines · Rohit kumar

I2SCTL and DMACTL registers has different bits alignment for newer LPASS variants of SC7180 soc. Use REG_FIELD_ID() to define the reg_fields in platform specific file and removed shifts and mask macros for such registers from header file.

Thanks Rohit for doing this, this looks much better now! I have few minor comments..

Quoted 9 lines
---
  sound/soc/qcom/lpass-apq8016.c   |  24 ++++++
  sound/soc/qcom/lpass-cpu.c       | 163 +++++++++++++++++++++++----------------
  sound/soc/qcom/lpass-ipq806x.c   |  24 ++++++
  sound/soc/qcom/lpass-lpaif-reg.h | 157 +++++++++++++++++++------------------
  sound/soc/qcom/lpass-platform.c  | 151 +++++++++++++++++++++++++++---------
  sound/soc/qcom/lpass.h           |  53 +++++++++++++
  6 files changed, 398 insertions(+), 174 deletions(-)

index f0c7e93..f358d12 100644

Quoted 14 lines
sound/soc/qcom/lpass-cpu.c +0 -0
@@ -29,6 +29,32 @@
  #define LPASS_CPU_I2S_SD0_1_2_MASK	GENMASK(2, 0)
  #define LPASS_CPU_I2S_SD0_1_2_3_MASK	GENMASK(3, 0)
 
 
 
  static int lpass_cpu_daiops_set_sysclk(struct snd_soc_dai *dai, int clk_id,
  		unsigned int freq, int dir)
  {
@@ -79,12 +105,13 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
  		struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
  {

sound/soc/qcom/lpass-cpu.c static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, · line 114

Quoted 10 lines
sound/soc/qcom/lpass-cpu.c +3 -2
  	struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
+	struct lpaif_i2sctl *i2sctl = drvdata->i2sctl;
+	unsigned int id = dai->driver->id;
  	snd_pcm_format_t format = params_format(params);
  	unsigned int channels = params_channels(params);
  	unsigned int rate = params_rate(params);
  	unsigned int mode;
-	unsigned int regval;
-	int bitwidth, ret;
+	int bitwidth, ret, regval;

Why is this change?

Quoted 110 lines
sound/soc/qcom/lpass-cpu.c +39 -22
  	bitwidth = snd_pcm_format_width(format);
  	if (bitwidth < 0) {
@@ -92,28 +119,45 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
  		return bitwidth;
  	}
 
-	regval = LPAIF_I2SCTL_LOOPBACK_DISABLE |
-			LPAIF_I2SCTL_WSSRC_INTERNAL;
+	ret = regmap_fields_write(i2sctl->loopback, id,
+				 LPAIF_I2SCTL_LOOPBACK_DISABLE);
+	if (ret) {
+		dev_err(dai->dev, "error updating loopback field: %d\n", ret);
+		return ret;
+	}
+
+	ret = regmap_fields_write(i2sctl->wssrc, id,
+				 LPAIF_I2SCTL_WSSRC_INTERNAL);
+	if (ret) {
+		dev_err(dai->dev, "error updating wssrc field: %d\n", ret);
+		return ret;
+	}
 
  	switch (bitwidth) {
  	case 16:
-		regval |= LPAIF_I2SCTL_BITWIDTH_16;
+		regval = LPAIF_I2SCTL_BITWIDTH_16;
  		break;
  	case 24:
-		regval |= LPAIF_I2SCTL_BITWIDTH_24;
+		regval = LPAIF_I2SCTL_BITWIDTH_24;
  		break;
  	case 32:
-		regval |= LPAIF_I2SCTL_BITWIDTH_32;
+		regval = LPAIF_I2SCTL_BITWIDTH_32;
  		break;
  	default:
  		dev_err(dai->dev, "invalid bitwidth given: %d\n", bitwidth);
  		return -EINVAL;
  	}
 
+	ret = regmap_fields_write(i2sctl->bitwidth, id, regval);
+	if (ret) {
+		dev_err(dai->dev, "error updating bitwidth field: %d\n", ret);
+		return ret;
+	}
+
  	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		mode = drvdata->mi2s_playback_sd_mode[dai->driver->id];
+		mode = drvdata->mi2s_playback_sd_mode[id];
  	else
-		mode = drvdata->mi2s_capture_sd_mode[dai->driver->id];
+		mode = drvdata->mi2s_capture_sd_mode[id];
 
  	if (!mode) {
  		dev_err(dai->dev, "no line is assigned\n");
@@ -175,30 +219,34 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
  	}
 
  	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		regval |= LPAIF_I2SCTL_SPKMODE(mode);
+		ret = regmap_fields_write(i2sctl->spkmode, id,
+					 LPAIF_I2SCTL_SPKMODE(mode));
 
  		if (channels >= 2)
-			regval |= LPAIF_I2SCTL_SPKMONO_STEREO;
+			ret = regmap_fields_write(i2sctl->spkmono, id,
+						 LPAIF_I2SCTL_SPKMONO_STEREO);
  		else
-			regval |= LPAIF_I2SCTL_SPKMONO_MONO;
+			ret = regmap_fields_write(i2sctl->spkmono, id,
+						 LPAIF_I2SCTL_SPKMONO_MONO);
  	} else {
-		regval |= LPAIF_I2SCTL_MICMODE(mode);
+		ret = regmap_fields_write(i2sctl->micmode, id,
+					 LPAIF_I2SCTL_MICMODE(mode));
 
  		if (channels >= 2)
-			regval |= LPAIF_I2SCTL_MICMONO_STEREO;
+			ret = regmap_fields_write(i2sctl->micmono, id,
+						 LPAIF_I2SCTL_MICMONO_STEREO);
  		else
-			regval |= LPAIF_I2SCTL_MICMONO_MONO;
+			ret = regmap_fields_write(i2sctl->micmono, id,
+						 LPAIF_I2SCTL_MICMONO_MONO);
  	}
 
-	ret = regmap_write(drvdata->lpaif_map,
-			   LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
-			   regval);
  	if (ret) {
-		dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);
+		dev_err(dai->dev, "error writing to i2sctl channels mode: %d\n",
+			ret);
  		return ret;
  	}
 
-	ret = clk_set_rate(drvdata->mi2s_bit_clk[dai->driver->id],
+	ret = clk_set_rate(drvdata->mi2s_bit_clk[id],
  			   rate * bitwidth * 2);
  	if (ret) {
  		dev_err(dai->dev, "error setting mi2s bitclk to %u: %d\n",
@@ -209,41 +257,24 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
  	return 0;
  }
 
-static int lpass_cpu_daiops_hw_free(struct snd_pcm_substream *substream,
-		struct snd_soc_dai *dai)
-{
-	struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);

sound/soc/qcom/lpass-cpu.c static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, · line 225

Quoted 10 lines
sound/soc/qcom/lpass-cpu.c +0 -10
-	int ret;
-
-	ret = regmap_write(drvdata->lpaif_map,
-			   LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
-			   0);
-	if (ret)
-		dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);
-
-	return ret;
-}

Any particular reason why this function remove

Quoted 32 lines
sound/soc/qcom/lpass-cpu.c +8 -11
-
  static int lpass_cpu_daiops_prepare(struct snd_pcm_substream *substream,
  		struct snd_soc_dai *dai)
  {
  	struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
+	struct lpaif_i2sctl *i2sctl = drvdata->i2sctl;
+	unsigned int id = dai->driver->id;
  	int ret;
-	unsigned int val, mask;
 
  	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		val = LPAIF_I2SCTL_SPKEN_ENABLE;
-		mask = LPAIF_I2SCTL_SPKEN_MASK;
-	} else  {
-		val = LPAIF_I2SCTL_MICEN_ENABLE;
-		mask = LPAIF_I2SCTL_MICEN_MASK;
+		ret = regmap_fields_write(i2sctl->spken, id,
+					 LPAIF_I2SCTL_SPKEN_ENABLE);
+	} else {
+		ret = regmap_fields_write(i2sctl->micen, id,
+					 LPAIF_I2SCTL_MICEN_ENABLE);
  	}
 
-	ret = regmap_update_bits(drvdata->lpaif_map,
-			LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
-			mask, val);
  	if (ret)
-		dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);
+		dev_err(dai->dev, "error writing to i2sctl enable: %d\n", ret);
 
  	return ret;
  }

...

Quoted 33 lines
sound/soc/qcom/lpass-cpu.c +12 -1
@@ -304,7 +326,6 @@ const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops = {
  	.startup	= lpass_cpu_daiops_startup,
  	.shutdown	= lpass_cpu_daiops_shutdown,
  	.hw_params	= lpass_cpu_daiops_hw_params,
-	.hw_free	= lpass_cpu_daiops_hw_free,
  	.prepare	= lpass_cpu_daiops_prepare,
  	.trigger	= lpass_cpu_daiops_trigger,
  };
@@ -599,6 +620,18 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
  		}
  	}
 
+	/* Allocation for i2sctl regmap fields */
+	drvdata->i2sctl = devm_kzalloc(&pdev->dev, sizeof(struct lpaif_i2sctl),
+					GFP_KERNEL);
+
+	/* Initialize bitfields for dai I2SCTL register */
+	ret = lpass_cpu_init_i2sctl_bitfields(dev, drvdata->i2sctl,
+						drvdata->lpaif_map);
+	if (ret) {
+		dev_err(dev, "error init i2sctl field: %d\n", ret);
+		return ret;
+	}
+
  	ret = devm_snd_soc_register_component(dev,
  					      &lpass_cpu_comp_driver,
  					      variant->dai_driver,
sound/soc/qcom/lpass-lpaif-reg.h +0 -0
index 72a3e2f..5258e60 100644
@@ -12,15 +12,12 @@

...

Quoted 9 lines
  #endif /* __LPASS_LPAIF_REG_H__ */
sound/soc/qcom/lpass-platform.c +0 -0
index 34f7fd1..445ca193 100644
@@ -50,6 +50,53 @@ static const struct snd_pcm_hardware lpass_platform_pcm_hardware = {
  	.fifo_size		=	0,
  };
 

...

sound/soc/qcom/lpass-platform.c static int lpass_platform_pcmops_open(struct snd_soc_component *component, · line 111

Quoted 12 lines

static int lpass_platform_pcmops_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{

sound/soc/qcom/lpass-platform.c +2 -2
@@ -59,9 +106,9 @@ static int lpass_platform_pcmops_open(struct snd_soc_component *component,
  	struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
  	struct lpass_variant *v = drvdata->variant;
  	int ret, dma_ch, dir = substream->stream;
-	struct lpass_pcm_data *data;
+	struct lpass_pcm_data *data = NULL;
 
-	data = devm_kzalloc(soc_runtime->dev, sizeof(*data), GFP_KERNEL);
+	data = kzalloc(sizeof(*data), GFP_KERNEL);

Does this change belong in this patch?

Quoted 30 lines
sound/soc/qcom/lpass-platform.c +2 -2
  	if (!data)
  		return -ENOMEM;
 
@@ -111,13 +158,13 @@ static int lpass_platform_pcmops_close(struct snd_soc_component *component,
  	struct snd_pcm_runtime *runtime = substream->runtime;
  	struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
  	struct lpass_variant *v = drvdata->variant;
-	struct lpass_pcm_data *data;
+	struct lpass_pcm_data *data = runtime->private_data;
 
-	data = runtime->private_data;
  	drvdata->substream[data->dma_ch] = NULL;
  	if (v->free_dma_channel)
  		v->free_dma_channel(drvdata, data->dma_ch);
 
+	kfree(data);
  	return 0;
  }
 

return devm_snd_soc_register_component(&pdev->dev,
&lpass_component_driver, NULL, 0);

sound/soc/qcom/lpass.h +0 -0
index 450020e..4294ec2 100644
@@ -17,6 +17,28 @@
  #define LPASS_MAX_MI2S_PORTS			(8)
  #define LPASS_MAX_DMA_CHANNELS			(8)
 

...

Quoted 15 lines

/* Both the CPU DAI and platform drivers will access this data */ struct lpass_data {

sound/soc/qcom/lpass.h +4 -0
@@ -55,6 +77,10 @@ struct lpass_data {
  	struct clk_bulk_data *clks;
  	int num_clks;
 
+	/* Regmap fields of I2SCTL & DMACTL registers bitfields */
+	struct lpaif_i2sctl *i2sctl;
+	struct lpaif_dmactl *rd_dmactl;
+	struct lpaif_dmactl *wr_dmactl;
  };
 
  /* Vairant data per each SOC */

sound/soc/qcom/lpass.h struct lpass_variant { · line 100

Quoted 3 lines
sound/soc/qcom/lpass.h +0 -0
@@ -72,6 +98,33 @@ struct lpass_variant {
  	u32	wrdma_reg_stride;
  	u32	wrdma_channels;
 

Above two along with rddma members can be removed, these become redundant after adding regmap field!

Quoted 31 lines
sound/soc/qcom/lpass.h +27 -0
+	/* I2SCTL Register fields */
+	struct reg_field loopback;
+	struct reg_field spken;
+	struct reg_field spkmode;
+	struct reg_field spkmono;
+	struct reg_field micen;
+	struct reg_field micmode;
+	struct reg_field micmono;
+	struct reg_field wssrc;
+	struct reg_field bitwidth;
+
+	/* RD_DMA Register fields */
+	struct reg_field rdma_bursten;
+	struct reg_field rdma_wpscnt;
+	struct reg_field rdma_intf;
+	struct reg_field rdma_fifowm;
+	struct reg_field rdma_enable;
+	struct reg_field rdma_dyncclk;
+
+	/* RD_DMA Register fields */
+	struct reg_field wrdma_bursten;
+	struct reg_field wrdma_wpscnt;
+	struct reg_field wrdma_intf;
+	struct reg_field wrdma_fifowm;
+	struct reg_field wrdma_enable;
+	struct reg_field wrdma_dyncclk;
+
  	/**
  	 * on SOCs like APQ8016 the channel control bits start
  	 * at different offset to ipq806x
Reviewed-by on v3 5/8
#16 lore raw

Re: [PATCH v3 5/8] ASoC: qcom: lpass-platform: Replace card->dev with component->dev

In reply to Rohit kumar
Quoted 7 lines · Rohit kumar

From: Ajit Pandey <[email protected]>

We are allocating dma memory for component->dev but trying to mmap such memory for substream->pcm->card->dev. Replace device argument in mmap with component->dev to fix this.

Quoted 21 lines
---
  sound/soc/qcom/lpass-platform.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
sound/soc/qcom/lpass-platform.c +2 -3
index 445ca193..f9424cc 100644
@@ -472,9 +472,8 @@ static int lpass_platform_pcmops_mmap(struct snd_soc_component *component,
  {
  	struct snd_pcm_runtime *runtime = substream->runtime;
 
-	return dma_mmap_coherent(substream->pcm->card->dev, vma,
-			runtime->dma_area, runtime->dma_addr,
-			runtime->dma_bytes);
+	return dma_mmap_coherent(component->dev, vma, runtime->dma_area,
+				 runtime->dma_addr, runtime->dma_bytes);
  }
 
  static irqreturn_t lpass_dma_interrupt_handler(
#18 lore raw

Re: [PATCH v3 6/8] dt-bindings: sound: lpass-cpu: Add sc7180 lpass cpu node

In reply to Rohit kumar
Quoted 12 lines · Rohit kumar

Add dt-bindings to support "qcom,lpass-cpu-sc7180" node.

---
  Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt +0 -0
index 32c2cdb..04e34cc 100644

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt This node models the Qualcomm Technologies Low-Power Audio SubSystem (LPASS). · line 11

Quoted 9 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt +2 -1
@@ -4,7 +4,8 @@ This node models the Qualcomm Technologies Low-Power Audio SubSystem (LPASS).
 
  Required properties:
 
-- compatible		: "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu"
+- compatible		: "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" or
+			  "qcom,lpass-cpu-sc7180"
  - clocks		: Must contain an entry for each entry in clock-names.
  - clock-names		: A list which must include the following entries:
  				* "ahbix-clk"

Can you also list the clocks that are mandatory for this SoC.

--srini

Quoted 1 line
Reviewed-by on v3 7/8
#25 lore raw

Re: [PATCH v3 7/8] ASoC: qcom: lpass-sc7180: Add platform driver for lpass audio

In reply to Rohit kumar
Quoted 9 lines · Rohit kumar

From: Ajit Pandey <[email protected]>

Add platform driver for configuring sc7180 lpass core I2S and DMA configuration to support playback & capture to external codecs connected over primary & secondary MI2S interfaces.

---

LGTM,

Quoted 8 lines
  sound/soc/qcom/Kconfig        |   5 +
  sound/soc/qcom/Makefile       |   2 +
  sound/soc/qcom/lpass-sc7180.c | 216 ++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 223 insertions(+)

create mode 100644 sound/soc/qcom/lpass-sc7180.c

sound/soc/qcom/Kconfig +0 -0
index 0ea4cde..87bec7f 100644
#7 lore raw

Re: [PATCH v3 3/8] ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers

In reply to Srinivas Kandagatla

Thanks Srini for reviewing.

Quoted 45 lines · Srinivas Kandagatla
Quoted 6 lines · Rohit kumar

I2SCTL and DMACTL registers has different bits alignment for newer LPASS variants of SC7180 soc. Use REG_FIELD_ID() to define the reg_fields in platform specific file and removed shifts and mask macros for such registers from header file.

Thanks Rohit for doing this, this looks much better now! I have few minor comments..

Quoted 10 lines

---
  sound/soc/qcom/lpass-apq8016.c   |  24 ++++++ sound/soc/qcom/lpass-cpu.c       | 163
+++++++++++++++++++++++----------------
  sound/soc/qcom/lpass-ipq806x.c   |  24 ++++++ sound/soc/qcom/lpass-lpaif-reg.h | 157
+++++++++++++++++++------------------
  sound/soc/qcom/lpass-platform.c  | 151
+++++++++++++++++++++++++++---------
  sound/soc/qcom/lpass.h           |  53 +++++++++++++

Quoted 2 lines
  6 files changed, 398 insertions(+), 174 deletions(-)

index f0c7e93..f358d12 100644

Quoted 18 lines
sound/soc/qcom/lpass-cpu.c +0 -0
@@ -29,6 +29,32 @@
   #define LPASS_CPU_I2S_SD0_1_2_MASK    GENMASK(2, 0)
   #define LPASS_CPU_I2S_SD0_1_2_3_MASK    GENMASK(3, 0)
 
 
   static int lpass_cpu_daiops_set_sysclk(struct snd_soc_dai *dai, int clk_id,
           unsigned int freq, int dir)

  {

sound/soc/qcom/lpass-cpu.c +2 -0
@@ -79,12 +105,13 @@ static int lpass_cpu_daiops_hw_params(struct 
 snd_pcm_substream *substream,
           struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
   {
       struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
+    struct lpaif_i2sctl *i2sctl = drvdata->i2sctl;
+    unsigned int id = dai->driver->id;
       snd_pcm_format_t format = params_format(params);
Quoted 8 lines

sound/soc/qcom/lpass-cpu.c static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, · line 114

Quoted 6 lines
sound/soc/qcom/lpass-cpu.c +1 -2
       unsigned int channels = params_channels(params);
       unsigned int rate = params_rate(params);
       unsigned int mode;
-    unsigned int regval;
-    int bitwidth, ret;
+    int bitwidth, ret, regval;

Why is this change?

Sorry, It came as part of previous patchset. regval was removed in patchv2  and

bitwidth variable was used to configure both clk and i2sctl register, which was not proper.

Added regval again. I will repost this patch without this change.

Quoted 108 lines
Quoted 108 lines
sound/soc/qcom/lpass-cpu.c +0 -0
         bitwidth = snd_pcm_format_width(format);
       if (bitwidth < 0) {
@@ -92,28 +119,45 @@ static int lpass_cpu_daiops_hw_params(struct 
 snd_pcm_substream *substream,
           return bitwidth;
       }

  -    regval = LPAIF_I2SCTL_LOOPBACK_DISABLE |
-            LPAIF_I2SCTL_WSSRC_INTERNAL;
+    ret = regmap_fields_write(i2sctl->loopback, id,
+                 LPAIF_I2SCTL_LOOPBACK_DISABLE);
+    if (ret) {
+        dev_err(dai->dev, "error updating loopback field: %d\n", ret); +        return ret;
+    }
+
+    ret = regmap_fields_write(i2sctl->wssrc, id,
+                 LPAIF_I2SCTL_WSSRC_INTERNAL);
+    if (ret) {
+        dev_err(dai->dev, "error updating wssrc field: %d\n", ret); +        return ret;
+    }
        switch (bitwidth) {
      case 16:
-        regval |= LPAIF_I2SCTL_BITWIDTH_16;
+        regval = LPAIF_I2SCTL_BITWIDTH_16;
          break;
      case 24:
-        regval |= LPAIF_I2SCTL_BITWIDTH_24;
+        regval = LPAIF_I2SCTL_BITWIDTH_24;
          break;
      case 32:
-        regval |= LPAIF_I2SCTL_BITWIDTH_32;
+        regval = LPAIF_I2SCTL_BITWIDTH_32;
          break;
      default:
          dev_err(dai->dev, "invalid bitwidth given: %d\n", bitwidth); return -EINVAL;
      }
  +    ret = regmap_fields_write(i2sctl->bitwidth, id, regval); +    if (ret) {
+        dev_err(dai->dev, "error updating bitwidth field: %d\n", ret); +        return ret;
+    }
+
      if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-        mode = drvdata->mi2s_playback_sd_mode[dai->driver->id]; +        mode = drvdata->mi2s_playback_sd_mode[id];
      else
-        mode = drvdata->mi2s_capture_sd_mode[dai->driver->id]; +        mode = drvdata->mi2s_capture_sd_mode[id];
        if (!mode) {
          dev_err(dai->dev, "no line is assigned\n");

sound/soc/qcom/lpass-cpu.c +4 -2
@@ -175,30 +219,34 @@ static int lpass_cpu_daiops_hw_params(struct 
 snd_pcm_substream *substream,
       }
         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-        regval |= LPAIF_I2SCTL_SPKMODE(mode);
+        ret = regmap_fields_write(i2sctl->spkmode, id,
+                     LPAIF_I2SCTL_SPKMODE(mode));
             if (channels >= 2)
-            regval |= LPAIF_I2SCTL_SPKMONO_STEREO;
+            ret = regmap_fields_write(i2sctl->spkmono, id,
+                         LPAIF_I2SCTL_SPKMONO_STEREO);

          else
-            regval |= LPAIF_I2SCTL_SPKMONO_MONO;
+            ret = regmap_fields_write(i2sctl->spkmono, id, +                         LPAIF_I2SCTL_SPKMONO_MONO);
      } else {
-        regval |= LPAIF_I2SCTL_MICMODE(mode);
+        ret = regmap_fields_write(i2sctl->micmode, id,
+                     LPAIF_I2SCTL_MICMODE(mode));
            if (channels >= 2)
-            regval |= LPAIF_I2SCTL_MICMONO_STEREO;
+            ret = regmap_fields_write(i2sctl->micmono, id, +                         LPAIF_I2SCTL_MICMONO_STEREO); else
-            regval |= LPAIF_I2SCTL_MICMONO_MONO;
+            ret = regmap_fields_write(i2sctl->micmono, id, +                         LPAIF_I2SCTL_MICMONO_MONO);
      }
  -    ret = regmap_write(drvdata->lpaif_map,
-               LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id), -               regval);
      if (ret) {
-        dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret); +        dev_err(dai->dev, "error writing to i2sctl channels mode:
%d\n",
+            ret);
          return ret;
      }
  -    ret = clk_set_rate(drvdata->mi2s_bit_clk[dai->driver->id], +    ret = clk_set_rate(drvdata->mi2s_bit_clk[id],
                 rate * bitwidth * 2);
      if (ret) {
          dev_err(dai->dev, "error setting mi2s bitclk to %u: %d\n",

sound/soc/qcom/lpass-cpu.c +0 -7
@@ -209,41 +257,24 @@ static int lpass_cpu_daiops_hw_params(struct 
 snd_pcm_substream *substream,
       return 0;
   }
   -static int lpass_cpu_daiops_hw_free(struct snd_pcm_substream *substream,
-        struct snd_soc_dai *dai)
-{
-    struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
-    int ret;
-
-    ret = regmap_write(drvdata->lpaif_map,
-               LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
Quoted 8 lines

sound/soc/qcom/lpass-cpu.c static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, · line 225

Quoted 6 lines
sound/soc/qcom/lpass-cpu.c +0 -6
-               0);
-    if (ret)
-        dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);
-
-    return ret;
-}

Any particular reason why this function remove

This was causing issue in playback/capture concurrency. It sets I2SCTL register value to 0

when usecase ends. However, playback/capture specific bits are already cleared during trigger() stop

function. So, this is not needed.

Quoted 76 lines
Quoted 29 lines
sound/soc/qcom/lpass-cpu.c +8 -10
-
   static int lpass_cpu_daiops_prepare(struct snd_pcm_substream *substream,
           struct snd_soc_dai *dai)
   {
       struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
+    struct lpaif_i2sctl *i2sctl = drvdata->i2sctl;
+    unsigned int id = dai->driver->id;
       int ret;
-    unsigned int val, mask;
         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-        val = LPAIF_I2SCTL_SPKEN_ENABLE;
-        mask = LPAIF_I2SCTL_SPKEN_MASK;
-    } else  {
-        val = LPAIF_I2SCTL_MICEN_ENABLE;
-        mask = LPAIF_I2SCTL_MICEN_MASK;
+        ret = regmap_fields_write(i2sctl->spken, id,
+                     LPAIF_I2SCTL_SPKEN_ENABLE);
+    } else {
+        ret = regmap_fields_write(i2sctl->micen, id,
+                     LPAIF_I2SCTL_MICEN_ENABLE);
       }
   -    ret = regmap_update_bits(drvdata->lpaif_map,
-            LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
-            mask, val);
       if (ret)
-        dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);
+        dev_err(dai->dev, "error writing to i2sctl enable: %d\n", ret);
         return ret;
   }

...

Quoted 35 lines
sound/soc/qcom/lpass-cpu.c +0 -1
@@ -304,7 +326,6 @@ const struct snd_soc_dai_ops 
 asoc_qcom_lpass_cpu_dai_ops = {
       .startup    = lpass_cpu_daiops_startup,
       .shutdown    = lpass_cpu_daiops_shutdown,
       .hw_params    = lpass_cpu_daiops_hw_params,
-    .hw_free    = lpass_cpu_daiops_hw_free,
       .prepare    = lpass_cpu_daiops_prepare,
       .trigger    = lpass_cpu_daiops_trigger,

  };

sound/soc/qcom/lpass-cpu.c +0 -0
@@ -599,6 +620,18 @@ int asoc_qcom_lpass_cpu_platform_probe(struct 
 platform_device *pdev)
           }
       }

  +    /* Allocation for i2sctl regmap fields */
+    drvdata->i2sctl = devm_kzalloc(&pdev->dev, sizeof(struct lpaif_i2sctl),
+                    GFP_KERNEL);

sound/soc/qcom/lpass-cpu.c +9 -0
+
+    /* Initialize bitfields for dai I2SCTL register */
+    ret = lpass_cpu_init_i2sctl_bitfields(dev, drvdata->i2sctl,
+                        drvdata->lpaif_map);
+    if (ret) {
+        dev_err(dev, "error init i2sctl field: %d\n", ret);
+        return ret;
+    }
+

      ret = devm_snd_soc_register_component(dev, &lpass_cpu_comp_driver, variant->dai_driver,

sound/soc/qcom/lpass-lpaif-reg.h +0 -0
index 72a3e2f..5258e60 100644
@@ -12,15 +12,12 @@

...

Quoted 9 lines

  #endif /* __LPASS_LPAIF_REG_H__ */

sound/soc/qcom/lpass-platform.c +0 -0
index 34f7fd1..445ca193 100644
@@ -50,6 +50,53 @@ static const struct snd_pcm_hardware 
 lpass_platform_pcm_hardware = {
       .fifo_size        =    0,
   };

...

Quoted 14 lines

sound/soc/qcom/lpass-platform.c static int lpass_platform_pcmops_open(struct · line 112

Quoted 12 lines

  static int lpass_platform_pcmops_open(struct snd_soc_component *component, struct snd_pcm_substream *substream)
  {

sound/soc/qcom/lpass-platform.c +2 -1
@@ -59,9 +106,9 @@ static int lpass_platform_pcmops_open(struct 
 snd_soc_component *component,
       struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
       struct lpass_variant *v = drvdata->variant;
       int ret, dma_ch, dir = substream->stream;
-    struct lpass_pcm_data *data;
+    struct lpass_pcm_data *data = NULL;
   -    data = devm_kzalloc(soc_runtime->dev, sizeof(*data), GFP_KERNEL);
+    data = kzalloc(sizeof(*data), GFP_KERNEL);

Does this change belong in this patch?

As part of this change, I fixed memory leak too by adding kfree() in close()

However, this was causing issue as memory was allocated using devm_kzalloc().

Should I move it to different patch?

Quoted 27 lines
Quoted 25 lines
sound/soc/qcom/lpass-platform.c +0 -0
       if (!data)
           return -ENOMEM;

  @@ -111,13 +158,13 @@ static int lpass_platform_pcmops_close(struct snd_soc_component *component, struct snd_pcm_runtime *runtime = substream->runtime;
      struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
      struct lpass_variant *v = drvdata->variant;
-    struct lpass_pcm_data *data;
+    struct lpass_pcm_data *data = runtime->private_data;
  -    data = runtime->private_data;
      drvdata->substream[data->dma_ch] = NULL;
      if (v->free_dma_channel)
          v->free_dma_channel(drvdata, data->dma_ch);
  +    kfree(data);
      return 0;
  }
          return devm_snd_soc_register_component(&pdev->dev, &lpass_component_driver, NULL, 0);

sound/soc/qcom/lpass.h +0 -0
index 450020e..4294ec2 100644
@@ -17,6 +17,28 @@
   #define LPASS_MAX_MI2S_PORTS            (8)
   #define LPASS_MAX_DMA_CHANNELS            (8)

...

Quoted 17 lines
Quoted 12 lines

  /* Both the CPU DAI and platform drivers will access this data */ struct lpass_data {
  @@ -55,6 +77,10 @@ struct lpass_data {
      struct clk_bulk_data *clks;
      int num_clks;
  +    /* Regmap fields of I2SCTL & DMACTL registers bitfields */ +    struct lpaif_i2sctl *i2sctl;
+    struct lpaif_dmactl *rd_dmactl;
+    struct lpaif_dmactl *wr_dmactl;
  };
    /* Vairant data per each SOC */

sound/soc/qcom/lpass.h struct lpass_variant { · line 99

Quoted 2 lines
sound/soc/qcom/lpass.h +0 -0
@@ -72,6 +98,33 @@ struct lpass_variant {
       u32    wrdma_reg_stride;
       u32    wrdma_channels;

Above two along with rddma members can be removed, these become redundant after adding regmap field!

wrdma_channels is used in alloc_dma_channel() to get the channel id.

Also, both are used for other DMA registers such as LPAIF_RDMABASE_REG,

LPAIF_RDMABUFF_REG, LPAIF_RDMACURR_REG, etc.

Quoted 24 lines
Quoted 24 lines
sound/soc/qcom/lpass.h +23 -0
+    /* I2SCTL Register fields */
+    struct reg_field loopback;
+    struct reg_field spken;
+    struct reg_field spkmode;
+    struct reg_field spkmono;
+    struct reg_field micen;
+    struct reg_field micmode;
+    struct reg_field micmono;
+    struct reg_field wssrc;
+    struct reg_field bitwidth;
+
+    /* RD_DMA Register fields */
+    struct reg_field rdma_bursten;
+    struct reg_field rdma_wpscnt;
+    struct reg_field rdma_intf;
+    struct reg_field rdma_fifowm;
+    struct reg_field rdma_enable;
+    struct reg_field rdma_dyncclk;
+
+    /* RD_DMA Register fields */
+    struct reg_field wrdma_bursten;
+    struct reg_field wrdma_wpscnt;
+    struct reg_field wrdma_intf;
Quoted 8 lines

sound/soc/qcom/lpass.h struct lpass_variant {

Quoted 8 lines
sound/soc/qcom/lpass.h +4 -0
+    struct reg_field wrdma_fifowm;
+    struct reg_field wrdma_enable;
+    struct reg_field wrdma_dyncclk;
+
       /**
        * on SOCs like APQ8016 the channel control bits start
        * at different offset to ipq806x
 

Thanks,

Rohit

Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the Linux Foundation.
#19 lore raw

Re: [PATCH v3 6/8] dt-bindings: sound: lpass-cpu: Add sc7180 lpass cpu node

In reply to Srinivas Kandagatla
Quoted 26 lines · Srinivas Kandagatla
Quoted 12 lines · Rohit kumar

Add dt-bindings to support "qcom,lpass-cpu-sc7180" node.

---
  Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt +0 -0
index 32c2cdb..04e34cc 100644
@@ -4,7 +4,8 @@ This node models the Qualcomm Technologies Low-Power 
Quoted 8 lines

Audio SubSystem (LPASS).
    Required properties:
  -- compatible        : "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" +- compatible        : "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" or +              "qcom,lpass-cpu-sc7180"
  - clocks        : Must contain an entry for each entry in clock-names.
  - clock-names        : A list which must include the following entries:
                  * "ahbix-clk"

Can you also list the clocks that are mandatory for this SoC.

Quoted 2 lines

--srini

Will it be fine if I update it in patch 8 only where we have moved to yaml format?

Thanks,

Rohit

Quoted 2 lines
Quoted 2 lines
Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the Linux Foundation.
#8 lore raw

Re: [PATCH v3 3/8] ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers

In reply to Rohit Kumar
Quoted 55 lines · Rohit Kumar

Thanks Srini for reviewing.

Quoted 43 lines · Srinivas Kandagatla
Quoted 6 lines · Rohit kumar

I2SCTL and DMACTL registers has different bits alignment for newer LPASS variants of SC7180 soc. Use REG_FIELD_ID() to define the reg_fields in platform specific file and removed shifts and mask macros for such registers from header file.

Thanks Rohit for doing this, this looks much better now! I have few minor comments..

Quoted 10 lines

---
  sound/soc/qcom/lpass-apq8016.c   |  24 ++++++ sound/soc/qcom/lpass-cpu.c       | 163
+++++++++++++++++++++++----------------
  sound/soc/qcom/lpass-ipq806x.c   |  24 ++++++ sound/soc/qcom/lpass-lpaif-reg.h | 157
+++++++++++++++++++------------------
  sound/soc/qcom/lpass-platform.c  | 151
+++++++++++++++++++++++++++---------
  sound/soc/qcom/lpass.h           |  53 +++++++++++++

Quoted 2 lines
  6 files changed, 398 insertions(+), 174 deletions(-)

index f0c7e93..f358d12 100644

Quoted 16 lines
sound/soc/qcom/lpass-cpu.c +0 -7
@@ -29,6 +29,32 @@
   #define LPASS_CPU_I2S_SD0_1_2_MASK    GENMASK(2, 0)
   #define LPASS_CPU_I2S_SD0_1_2_3_MASK    GENMASK(3, 0)
 
 
   }
   -static int lpass_cpu_daiops_hw_free(struct snd_pcm_substream *substream,
-        struct snd_soc_dai *dai)
-{
-    struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
-    int ret;
-
-    ret = regmap_write(drvdata->lpaif_map,
-               LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
Quoted 8 lines

sound/soc/qcom/lpass-cpu.c static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, · line 225

Quoted 6 lines

-               0);
-    if (ret)
-        dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);

sound/soc/qcom/lpass-cpu.c +0 -3
-
-    return ret;
-}

Any particular reason why this function remove

Quoted 5 lines

This was causing issue in playback/capture concurrency. It sets I2SCTL register value to 0

when usecase ends. However, playback/capture specific bits are already cleared during trigger() stop

function. So, this is not needed.

This should be sent as separate fix with fixes tag!

Quoted 35 lines
Quoted 19 lines
Quoted 8 lines
sound/soc/qcom/lpass-lpaif-reg.h +0 -0
index 72a3e2f..5258e60 100644
@@ -12,15 +12,12 @@

...

Quoted 9 lines

  #endif /* __LPASS_LPAIF_REG_H__ */

sound/soc/qcom/lpass-platform.c +0 -0
index 34f7fd1..445ca193 100644
@@ -50,6 +50,53 @@ static const struct snd_pcm_hardware 
 lpass_platform_pcm_hardware = {
       .fifo_size        =    0,
   };

...

Quoted 14 lines

sound/soc/qcom/lpass-platform.c static int lpass_platform_pcmops_open(struct · line 112

Quoted 12 lines

  static int lpass_platform_pcmops_open(struct snd_soc_component *component, struct snd_pcm_substream *substream)
  {

sound/soc/qcom/lpass-platform.c +2 -1
@@ -59,9 +106,9 @@ static int lpass_platform_pcmops_open(struct 
 snd_soc_component *component,
       struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
       struct lpass_variant *v = drvdata->variant;
       int ret, dma_ch, dir = substream->stream;
-    struct lpass_pcm_data *data;
+    struct lpass_pcm_data *data = NULL;
   -    data = devm_kzalloc(soc_runtime->dev, sizeof(*data), GFP_KERNEL);
+    data = kzalloc(sizeof(*data), GFP_KERNEL);

Does this change belong in this patch?

Quoted 5 lines

As part of this change, I fixed memory leak too by adding kfree() in close()

However, this was causing issue as memory was allocated using devm_kzalloc().

Should I move it to different patch?

That would be the right thing to do, can also add fixes tag!

Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
sound/soc/qcom/lpass-platform.c +0 -0
       if (!data)
           return -ENOMEM;

  @@ -111,13 +158,13 @@ static int lpass_platform_pcmops_close(struct snd_soc_component *component, struct snd_pcm_runtime *runtime = substream->runtime;
      struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
      struct lpass_variant *v = drvdata->variant;

Quoted 8 lines
Quoted 2 lines

Above two along with rddma members can be removed, these become redundant after adding regmap field!

wrdma_channels is used in alloc_dma_channel() to get the channel id.

Also, both are used for other DMA registers such as LPAIF_RDMABASE_REG,

LPAIF_RDMABUFF_REG, LPAIF_RDMACURR_REG, etc.

Ah I see we are still using this in lpass_cpu_regmap_writeable! ignore my previous comments about removing them!

--srini

#12 lore raw

Re: [PATCH v3 4/8] include: dt-bindings: sound: Add sc7180-lpass bindings header

In reply to Mark Brown
Quoted 9 lines · Mark Brown
Quoted 6 lines · Rohit kumar

From: Ajit Pandey <[email protected]>

Add header defining dai-id and mclk id for SC7180 lpass soc.

---

This one is missing a signoff as well, and I can't seem to see any reference to this header in the bindings document patches?

Thanks Mark for reviewing. I will add it documentation in next patchset.

Thanks,

Rohit

Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the Linux Foundation.
#20 lore raw

Re: [PATCH v3 6/8] dt-bindings: sound: lpass-cpu: Add sc7180 lpass cpu node

In reply to Rohit Kumar
Quoted 28 lines · Rohit Kumar
Quoted 26 lines · Srinivas Kandagatla
Quoted 12 lines · Rohit kumar

Add dt-bindings to support "qcom,lpass-cpu-sc7180" node.

---
  Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt +0 -0
index 32c2cdb..04e34cc 100644
@@ -4,7 +4,8 @@ This node models the Qualcomm Technologies Low-Power 
Quoted 8 lines

Audio SubSystem (LPASS).
    Required properties:
  -- compatible        : "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" +- compatible        : "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" or +              "qcom,lpass-cpu-sc7180"
  - clocks        : Must contain an entry for each entry in clock-names.
  - clock-names        : A list which must include the following entries:
                  * "ahbix-clk"

Can you also list the clocks that are mandatory for this SoC.

Quoted 4 lines
Quoted 2 lines

--srini

Will it be fine if I update it in patch 8 only where we have moved to yaml format?

May be reverse the order, Convert to Yaml first and then add sc7180!

--srini

Quoted 6 lines

Thanks,

Rohit

Quoted 2 lines
Quoted 2 lines
#21 lore raw

Re: [PATCH v3 6/8] dt-bindings: sound: lpass-cpu: Add sc7180 lpass cpu node

Quoted 31 lines · Srinivas Kandagatla
Quoted 28 lines · Rohit Kumar
Quoted 26 lines · Srinivas Kandagatla
Quoted 12 lines · Rohit kumar

Add dt-bindings to support "qcom,lpass-cpu-sc7180" node.

---
  Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt +0 -0
index 32c2cdb..04e34cc 100644
@@ -4,7 +4,8 @@ This node models the Qualcomm Technologies 
Quoted 8 lines

Low-Power Audio SubSystem (LPASS).
    Required properties:
  -- compatible        : "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" +- compatible        : "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" or +              "qcom,lpass-cpu-sc7180"
  - clocks        : Must contain an entry for each entry in clock-names.
  - clock-names        : A list which must include the following entries:
                  * "ahbix-clk"

Can you also list the clocks that are mandatory for this SoC.

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

--srini

Will it be fine if I update it in patch 8 only where we have moved to yaml format?

May be reverse the order, Convert to Yaml first and then add sc7180!

Actually Mark suggested to keep yaml change at the end of patch series as there

are pending yaml patch reviews and it might take time. If we keep yaml change before sc7180

change, then it will get blocked until yaml review. For now, I can update in exisiting

documentation. Please suggest.

Thanks

Quoted 8 lines

--srini

Quoted 6 lines

Thanks,

Rohit

Quoted 2 lines
Quoted 2 lines
Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the Linux Foundation.
#22 lore raw

Re: [PATCH v3 6/8] dt-bindings: sound: lpass-cpu: Add sc7180 lpass cpu node

Quoted 39 lines · Rohit Kumar
Quoted 31 lines · Srinivas Kandagatla
Quoted 28 lines · Rohit Kumar
Quoted 26 lines · Srinivas Kandagatla
Quoted 12 lines · Rohit kumar

Add dt-bindings to support "qcom,lpass-cpu-sc7180" node.

---
  Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt +0 -0
index 32c2cdb..04e34cc 100644
@@ -4,7 +4,8 @@ This node models the Qualcomm Technologies 
Quoted 8 lines

Low-Power Audio SubSystem (LPASS).
    Required properties:
  -- compatible        : "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" +- compatible        : "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" or +              "qcom,lpass-cpu-sc7180"
  - clocks        : Must contain an entry for each entry in clock-names.
  - clock-names        : A list which must include the following entries:
                  * "ahbix-clk"

Can you also list the clocks that are mandatory for this SoC.

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

--srini

Will it be fine if I update it in patch 8 only where we have moved to yaml format?

May be reverse the order, Convert to Yaml first and then add sc7180!

Quoted 7 lines

Actually Mark suggested to keep yaml change at the end of patch series as there

are pending yaml patch reviews and it might take time. If we keep yaml change before sc7180

change, then it will get blocked until yaml review. For now, I can update in exisiting

documentation. Please suggest.

Then these clocks need to be documented in this patch itself!

--srini

Quoted 11 lines

Thanks

Quoted 8 lines

--srini

Quoted 6 lines

Thanks,

Rohit

Quoted 2 lines
Quoted 2 lines
#9 lore raw

Re: [PATCH v3 3/8] ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers

In reply to Srinivas Kandagatla
Quoted 58 lines · Srinivas Kandagatla
Quoted 55 lines · Rohit Kumar

Thanks Srini for reviewing.

Quoted 51 lines · Srinivas Kandagatla
Quoted 6 lines · Rohit kumar

I2SCTL and DMACTL registers has different bits alignment for newer LPASS variants of SC7180 soc. Use REG_FIELD_ID() to define the reg_fields in platform specific file and removed shifts and mask macros for such registers from header file.

Thanks Rohit for doing this, this looks much better now! I have few minor comments..

Quoted 10 lines

---
  sound/soc/qcom/lpass-apq8016.c   |  24 ++++++ sound/soc/qcom/lpass-cpu.c       | 163
+++++++++++++++++++++++----------------
  sound/soc/qcom/lpass-ipq806x.c   |  24 ++++++ sound/soc/qcom/lpass-lpaif-reg.h | 157
+++++++++++++++++++------------------
  sound/soc/qcom/lpass-platform.c  | 151
+++++++++++++++++++++++++++---------
  sound/soc/qcom/lpass.h           |  53 +++++++++++++

Quoted 2 lines
  6 files changed, 398 insertions(+), 174 deletions(-)

index f0c7e93..f358d12 100644

Quoted 12 lines
sound/soc/qcom/lpass-cpu.c +0 -3
@@ -29,6 +29,32 @@
   #define LPASS_CPU_I2S_SD0_1_2_MASK    GENMASK(2, 0)
   #define LPASS_CPU_I2S_SD0_1_2_3_MASK    GENMASK(3, 0)
 
 
   }
   -static int lpass_cpu_daiops_hw_free(struct snd_pcm_substream *substream,
-        struct snd_soc_dai *dai)
-{
-    struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);

sound/soc/qcom/lpass-cpu.c static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, · line 225

Quoted 10 lines
sound/soc/qcom/lpass-cpu.c +0 -10
-    int ret;
-
-    ret = regmap_write(drvdata->lpaif_map,
-               LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
-               0);
-    if (ret)
-        dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);
-
-    return ret;
-}

Any particular reason why this function remove

Quoted 7 lines
Quoted 5 lines

This was causing issue in playback/capture concurrency. It sets I2SCTL register value to 0

when usecase ends. However, playback/capture specific bits are already cleared during trigger() stop

function. So, this is not needed.

This should be sent as separate fix with fixes tag!

Ok. Will create separate patch with fixes tag and post.

Quoted 36 lines
Quoted 36 lines
Quoted 34 lines
Quoted 9 lines
sound/soc/qcom/lpass-lpaif-reg.h +0 -0
index 72a3e2f..5258e60 100644
@@ -12,15 +12,12 @@

...

Quoted 9 lines

  #endif /* __LPASS_LPAIF_REG_H__ */

sound/soc/qcom/lpass-platform.c +0 -0
index 34f7fd1..445ca193 100644
@@ -50,6 +50,53 @@ static const struct snd_pcm_hardware 
 lpass_platform_pcm_hardware = {
       .fifo_size        =    0,
   };

...

sound/soc/qcom/lpass-platform.c static int lpass_platform_pcmops_open(struct · line 112

Quoted 12 lines

  static int lpass_platform_pcmops_open(struct snd_soc_component *component, struct snd_pcm_substream *substream)
  {

sound/soc/qcom/lpass-platform.c +2 -1
@@ -59,9 +106,9 @@ static int lpass_platform_pcmops_open(struct 
 snd_soc_component *component,
       struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
       struct lpass_variant *v = drvdata->variant;
       int ret, dma_ch, dir = substream->stream;
-    struct lpass_pcm_data *data;
+    struct lpass_pcm_data *data = NULL;
   -    data = devm_kzalloc(soc_runtime->dev, sizeof(*data), GFP_KERNEL);
+    data = kzalloc(sizeof(*data), GFP_KERNEL);

Does this change belong in this patch?

Quoted 7 lines
Quoted 5 lines

As part of this change, I fixed memory leak too by adding kfree() in close()

However, this was causing issue as memory was allocated using devm_kzalloc().

Should I move it to different patch?

That would be the right thing to do, can also add fixes tag!

Sure, Will do that in next spin.

Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
Quoted 10 lines
sound/soc/qcom/lpass-platform.c +0 -0
       if (!data)
           return -ENOMEM;

  @@ -111,13 +158,13 @@ static int lpass_platform_pcmops_close(struct snd_soc_component *component, struct snd_pcm_runtime *runtime = substream->runtime;
      struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
      struct lpass_variant *v = drvdata->variant;

Quoted 8 lines
Quoted 2 lines

Above two along with rddma members can be removed, these become redundant after adding regmap field!

wrdma_channels is used in alloc_dma_channel() to get the channel id.

Also, both are used for other DMA registers such as LPAIF_RDMABASE_REG,

LPAIF_RDMABUFF_REG, LPAIF_RDMACURR_REG, etc.

Ah I see we are still using this in lpass_cpu_regmap_writeable! ignore my previous comments about removing them!

--srini

Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the Linux Foundation.
maintainer
#23 lore raw

Re: [PATCH v3 6/8] dt-bindings: sound: lpass-cpu: Add sc7180 lpass cpu node

In reply to Rohit Kumar
Quoted 6 lines · Rohit Kumar
Quoted 1 line · Srinivas Kandagatla

May be reverse the order, Convert to Yaml first and then add sc7180!

Actually Mark suggested to keep yaml change at the end of patch series as there

Right, there's a huge backlog on YAML reviews so they lead to all the other work getting held up waiting for them.

maintainer
#27 lore raw

Re: [PATCH v3 8/8] dt-bindings: sound: lpass-cpu: Move to yaml format

In reply to Rohit kumar
Quoted 123 lines · Rohit kumar

From: Ajit Pandey <[email protected]>

Update lpass-cpu binding with yaml formats.

---
 .../devicetree/bindings/sound/qcom,lpass-cpu.txt   |  80 -----------
 .../devicetree/bindings/sound/qcom,lpass-cpu.yaml  | 154 +++++++++++++++++++++
 2 files changed, 154 insertions(+), 80 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt
 create mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt deleted +0 -80
deleted file mode 100644
index 04e34cc..00000000
@@ -1,80 +0,0 @@
-* Qualcomm Technologies LPASS CPU DAI
-
-This node models the Qualcomm Technologies Low-Power Audio SubSystem (LPASS).
-
-Required properties:
-
-- compatible		: "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" or
-			  "qcom,lpass-cpu-sc7180"
-- clocks		: Must contain an entry for each entry in clock-names.
-- clock-names		: A list which must include the following entries:
-				* "ahbix-clk"
-				* "mi2s-osr-clk"
-				* "mi2s-bit-clk"
-			: required clocks for "qcom,lpass-cpu-apq8016"
-				* "ahbix-clk"
-				* "mi2s-bit-clk0"
-				* "mi2s-bit-clk1"
-				* "mi2s-bit-clk2"
-				* "mi2s-bit-clk3"
-				* "pcnoc-mport-clk"
-				* "pcnoc-sway-clk"
-
-- interrupts		: Must contain an entry for each entry in
-			  interrupt-names.
-- interrupt-names	: A list which must include the following entries:
-				* "lpass-irq-lpaif"
-- pinctrl-N		: One property must exist for each entry in
-			  pinctrl-names.  See ../pinctrl/pinctrl-bindings.txt
-			  for details of the property values.
-- pinctrl-names		: Must contain a "default" entry.
-- reg			: Must contain an address for each entry in reg-names.
-- reg-names		: A list which must include the following entries:
-				* "lpass-lpaif"
-- #address-cells	: Must be 1
-- #size-cells		: Must be 0
-
-
-
-Optional properties:
-
-- qcom,adsp		: Phandle for the audio DSP node
-
-By default, the driver uses up to 4 MI2S SD lines, for a total of 8 channels.
-The SD lines to use can be configured by adding subnodes for each of the DAIs.
-
-Required properties for each DAI (represented by a subnode):
-- reg			: Must be one of the DAI IDs
-			  (usually part of dt-bindings header)
-- qcom,playback-sd-lines: List of serial data lines to use for playback
-			  Each SD line should be represented by a number from 0-3.
-- qcom,capture-sd-lines	: List of serial data lines to use for capture
-			  Each SD line should be represented by a number from 0-3.
-
-Note that adding a subnode changes the default to "no lines configured",
-so both playback and capture lines should be configured when a subnode is added.
-
-Example:
-
-lpass@28100000 {
-	compatible = "qcom,lpass-cpu";
-	clocks = <&lcc AHBIX_CLK>, <&lcc MI2S_OSR_CLK>, <&lcc MI2S_BIT_CLK>;
-	clock-names = "ahbix-clk", "mi2s-osr-clk", "mi2s-bit-clk";
-	interrupts = <0 85 1>;
-	interrupt-names = "lpass-irq-lpaif";
-	pinctrl-names = "default", "idle";
-	pinctrl-0 = <&mi2s_default>;
-	pinctrl-1 = <&mi2s_idle>;
-	reg = <0x28100000 0x10000>;
-	reg-names = "lpass-lpaif";
-	qcom,adsp = <&adsp>;
-
-	#address-cells = <1>;
-	#size-cells = <0>;
-
-	/* Optional to set different MI2S SD lines */
-	dai@3 {
-		reg = <MI2S_QUATERNARY>;
-		qcom,playback-sd-lines = <0 1>;
-	};
-};
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +18 -0
new file mode 100644
index 00000000..9c350bc
@@ -0,0 +1,154 @@
+# SPDX-License-Identifier: GPL-2.0-only
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/qcom,lpass-cpu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm LPASS CPU dai driver bindings
+
+maintainers:
+  - Srinivas Kandagatla <[email protected]>
+  - Rohit kumar <[email protected]>
+
+description:
+  Qualcomm SOC Low-Power Audio SubSystem (LPASS) that consist of MI2S interface
+  for audio data transfer on external codecs. LPASS cpu driver is a module to
+  configure Low-Power Audio Interface(LPAIF) core registers across different
+  IP versions.
+

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 28

Quoted 10 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +10 -0
+properties:
+  compatible:
+    enum:
+      - qcom,lpass-cpu
+      - qcom,apq8016-lpass-cpu
+      - qcom,lpass-cpu-sc7180
+
+  reg:
+    items:
+      - description: LPAIF core registers

Just: 'maxItems: 1' for a single entry.

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 32

Quoted 4 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +4 -0
+
+  reg-names:
+    items:
+      - const: lpass-lpaif

Not all that useful with only 1.

Quoted 18 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +18 -0
+
+  clocks:
+    items:
+      - description: AHBIX core clock
+      - description: oscillator clock for MI2S external interfaces
+      - description: Bit clock for single MI2S dai
+      - description: Bit clock for MI2S_PRIMARY dai interface
+      - description: Bit clock for MI2S_SECONDARY dai interface
+      - description: Bit clock for MI2S_TERTIARY dai interface
+      - description: Bit clock for MI2S_QUATERNARY dai interface
+      - description: NOC MPORT clock of LPASS core
+      - description: NOC SWAY clock of LPASS core
+
+  clock-names:
+    items:
+      - const: ahbix-clk
+      - const: mi2s-osr-clk
+      - const: mi2s-bit-clk

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 60

Quoted 10 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +10 -0
+      - const: mi2s-bit-clk0
+      - const: mi2s-bit-clk1
+      - const: mi2s-bit-clk2
+      - const: mi2s-bit-clk3
+      - const: pcnoc-mport-clk
+      - const: pcnoc-sway-clk
+
+  interrupts:
+    items:
+      - description: LPAIF DMA buffer interrupt

maxItems: 1

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 68

Quoted 8 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +8 -0
+
+  interrupt-names:
+    items:
+      - const: lpass-irq-lpaif
+
+  qcom,adsp:
+    maxItems: 1
+    description: Phandle for the audio DSP node

Needs a type $ref. And if just a phandle, 'maxItems: 1' is not appropriate.

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 76

Quoted 8 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +8 -0
+
+  iommus:
+    maxItems: 1
+    description: Phandle to apps_smmu node with sid mask
+
+  power-domains:
+    maxItems: 1
+    description: Phandle for power domain node

Drop. That's every 'power-domains' property.

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 81

Quoted 5 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +5 -0
+
+  '#sound-dai-cells':
+    const: 1
+
+  child-node:

I'm sure I said this on some review recently, but you are defining a child node named 'child-node'. You need this under patternProperties with the actual child node name.

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 87

Quoted 6 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +6 -0
+    description: Required properties for each DAI
+    type: object
+    properties:
+      reg:
+        description: Must be one of the DAI ID
+                     (Usually part of dtbindings header)

Ideally, you'd define the range of values here.

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 90

Quoted 3 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +3 -0
+      qcom,playback-sd-lines:
+        description: List of serial data lines to use for playback
+                     Each SD line should be represented by a number from 0-3.

Needs a type $ref and 0-3 should be expressed as a schema.

'make dt_binding_check' should complain about this. You did run that, right?

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 93

Quoted 3 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +3 -0
+      qcom,capture-sd-lines :
+        description: List of serial data lines to use for capture
+                     Each SD line should be represented by a number from 0-3.

ditto

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 95

Quoted 2 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +2 -0
+    required:
+      -reg

space ^

Quoted 4 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +4 -0
+    # Note that adding a subnode changes the default to "no lines configured",
+    # so both playback and capture lines should be configured when a subnode
+    # is added.
+

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 109

Quoted 10 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +10 -0
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+  - interrupts
+  - interrupt-names
+  - sound-dai-cells

Not a valid property.

Quoted 7 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +7 -0
+
+optional:
+  - qcom,adsp
+
+if:
+  properties:
+    compatible:

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 126

Quoted 10 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +10 -0
+      contains:
+        const: qcom,lpass-cpu-sc7180
+
+then:
+  required:
+    - iommus
+    - power-domains
+
+examples:
+  lpass@28100000 {

This is not valid. 'examples' should be a list.

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 130

Quoted 4 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +4 -0
+	compatible = "qcom,lpass-cpu";
+	clocks = <&lcc AHBIX_CLK>,
+		 <&lcc MI2S_OSR_CLK>,
+		 <&lcc MI2S_BIT_CLK>;

The example will not build because the includes are missing.

Quoted 28 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +24 -0
+
+	clock-names = "ahbix-clk",
+		      "mi2s-osr-clk",
+		      "mi2s-bit-clk";
+
+	interrupts = <0 85 1>;
+        interrupt-names = "lpass-irq-lpaif";
+
+	iommus = <&apps_smmu 0x1020 0>;
+	power-domains = <&lpass_hm LPASS_CORE_HM_GDSCR>;
+
+	reg = <0x28100000 0x10000>;
+	reg-names = "lpass-lpaif";
+	#sound-dai-cells = <1>;
+	qcom,adsp = <&adsp>;
+
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	/* Optional to set different MI2S SD lines */
+	mi2s-quaternary@3 {
+		reg = <MI2S_QUATERNARY>;
+		qcom,playback-sd-lines = <0 1>;
+  };
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
#28 lore raw

Re: [PATCH v3 8/8] dt-bindings: sound: lpass-cpu: Move to yaml format

Thanks Rob for the review. Posted v4 with fixes.

Quoted 127 lines · Rob Herring
Quoted 126 lines · Rohit kumar

From: Ajit Pandey <[email protected]>

Update lpass-cpu binding with yaml formats.

---
  .../devicetree/bindings/sound/qcom,lpass-cpu.txt   |  80 -----------
  .../devicetree/bindings/sound/qcom,lpass-cpu.yaml  | 154 +++++++++++++++++++++
  2 files changed, 154 insertions(+), 80 deletions(-)

delete mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt create mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt deleted +0 -80
deleted file mode 100644
index 04e34cc..00000000
@@ -1,80 +0,0 @@
-* Qualcomm Technologies LPASS CPU DAI
-
-This node models the Qualcomm Technologies Low-Power Audio SubSystem (LPASS).
-
-Required properties:
-
-- compatible		: "qcom,lpass-cpu" or "qcom,apq8016-lpass-cpu" or
-			  "qcom,lpass-cpu-sc7180"
-- clocks		: Must contain an entry for each entry in clock-names.
-- clock-names		: A list which must include the following entries:
-				* "ahbix-clk"
-				* "mi2s-osr-clk"
-				* "mi2s-bit-clk"
-			: required clocks for "qcom,lpass-cpu-apq8016"
-				* "ahbix-clk"
-				* "mi2s-bit-clk0"
-				* "mi2s-bit-clk1"
-				* "mi2s-bit-clk2"
-				* "mi2s-bit-clk3"
-				* "pcnoc-mport-clk"
-				* "pcnoc-sway-clk"
-
-- interrupts		: Must contain an entry for each entry in
-			  interrupt-names.
-- interrupt-names	: A list which must include the following entries:
-				* "lpass-irq-lpaif"
-- pinctrl-N		: One property must exist for each entry in
-			  pinctrl-names.  See ../pinctrl/pinctrl-bindings.txt
-			  for details of the property values.
-- pinctrl-names		: Must contain a "default" entry.
-- reg			: Must contain an address for each entry in reg-names.
-- reg-names		: A list which must include the following entries:
-				* "lpass-lpaif"
-- #address-cells	: Must be 1
-- #size-cells		: Must be 0
-
-
-
-Optional properties:
-
-- qcom,adsp		: Phandle for the audio DSP node
-
-By default, the driver uses up to 4 MI2S SD lines, for a total of 8 channels.
-The SD lines to use can be configured by adding subnodes for each of the DAIs.
-
-Required properties for each DAI (represented by a subnode):
-- reg			: Must be one of the DAI IDs
-			  (usually part of dt-bindings header)
-- qcom,playback-sd-lines: List of serial data lines to use for playback
-			  Each SD line should be represented by a number from 0-3.
-- qcom,capture-sd-lines	: List of serial data lines to use for capture
-			  Each SD line should be represented by a number from 0-3.
-
-Note that adding a subnode changes the default to "no lines configured",
-so both playback and capture lines should be configured when a subnode is added.
-
-Example:
-
-lpass@28100000 {
-	compatible = "qcom,lpass-cpu";
-	clocks = <&lcc AHBIX_CLK>, <&lcc MI2S_OSR_CLK>, <&lcc MI2S_BIT_CLK>;
-	clock-names = "ahbix-clk", "mi2s-osr-clk", "mi2s-bit-clk";
-	interrupts = <0 85 1>;
-	interrupt-names = "lpass-irq-lpaif";
-	pinctrl-names = "default", "idle";
-	pinctrl-0 = <&mi2s_default>;
-	pinctrl-1 = <&mi2s_idle>;
-	reg = <0x28100000 0x10000>;
-	reg-names = "lpass-lpaif";
-	qcom,adsp = <&adsp>;
-
-	#address-cells = <1>;
-	#size-cells = <0>;
-
-	/* Optional to set different MI2S SD lines */
-	dai@3 {
-		reg = <MI2S_QUATERNARY>;
-		qcom,playback-sd-lines = <0 1>;
-	};
-};
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +21 -0
new file mode 100644
index 00000000..9c350bc
@@ -0,0 +1,154 @@
+# SPDX-License-Identifier: GPL-2.0-only
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/qcom,lpass-cpu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm LPASS CPU dai driver bindings
+
+maintainers:
+  - Srinivas Kandagatla <[email protected]>
+  - Rohit kumar <[email protected]>
+
+description:
+  Qualcomm SOC Low-Power Audio SubSystem (LPASS) that consist of MI2S interface
+  for audio data transfer on external codecs. LPASS cpu driver is a module to
+  configure Low-Power Audio Interface(LPAIF) core registers across different
+  IP versions.
+
+properties:
+  compatible:
+    enum:
Quoted 8 lines

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 28

Quoted 7 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +7 -0
+      - qcom,lpass-cpu
+      - qcom,apq8016-lpass-cpu
+      - qcom,lpass-cpu-sc7180
+
+  reg:
+    items:
+      - description: LPAIF core registers

Just: 'maxItems: 1' for a single entry.

pl

Quoted 6 lines

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 32

Quoted 5 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +4 -0
+
+  reg-names:
+    items:
+      - const: lpass-lpaif

Not all that useful with only 1.

ok .. Removed in v4.

Quoted 22 lines
Quoted 22 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +21 -0
+
+  clocks:
+    items:
+      - description: AHBIX core clock
+      - description: oscillator clock for MI2S external interfaces
+      - description: Bit clock for single MI2S dai
+      - description: Bit clock for MI2S_PRIMARY dai interface
+      - description: Bit clock for MI2S_SECONDARY dai interface
+      - description: Bit clock for MI2S_TERTIARY dai interface
+      - description: Bit clock for MI2S_QUATERNARY dai interface
+      - description: NOC MPORT clock of LPASS core
+      - description: NOC SWAY clock of LPASS core
+
+  clock-names:
+    items:
+      - const: ahbix-clk
+      - const: mi2s-osr-clk
+      - const: mi2s-bit-clk
+      - const: mi2s-bit-clk0
+      - const: mi2s-bit-clk1
+      - const: mi2s-bit-clk2
Quoted 8 lines

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 60

Quoted 7 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +7 -0
+      - const: mi2s-bit-clk3
+      - const: pcnoc-mport-clk
+      - const: pcnoc-sway-clk
+
+  interrupts:
+    items:
+      - description: LPAIF DMA buffer interrupt

maxItems: 1

ok

Quoted 12 lines

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 68

Quoted 9 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +8 -0
+
+  interrupt-names:
+    items:
+      - const: lpass-irq-lpaif
+
+  qcom,adsp:
+    maxItems: 1
+    description: Phandle for the audio DSP node

Needs a type $ref. And if just a phandle, 'maxItems: 1' is not appropriate.

Quoted 9 lines

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 76

Quoted 8 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +8 -0
+
+  iommus:
+    maxItems: 1
+    description: Phandle to apps_smmu node with sid mask
+
+  power-domains:
+    maxItems: 1
+    description: Phandle for power domain node

Drop. That's every 'power-domains' property.

ok

Quoted 8 lines

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 81

Quoted 5 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +5 -0
+
+  '#sound-dai-cells':
+    const: 1
+
+  child-node:

I'm sure I said this on some review recently, but you are defining a child node named 'child-node'. You need this under patternProperties with the actual child node name.

Done in v4.

Quoted 9 lines

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 87

Quoted 7 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +6 -0
+    description: Required properties for each DAI
+    type: object
+    properties:
+      reg:
+        description: Must be one of the DAI ID
+                     (Usually part of dtbindings header)

Ideally, you'd define the range of values here.

Quoted 7 lines

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 90

Quoted 3 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +3 -0
+      qcom,playback-sd-lines:
+        description: List of serial data lines to use for playback
+                     Each SD line should be represented by a number from 0-3.

Needs a type $ref and 0-3 should be expressed as a schema.

'make dt_binding_check' should complain about this. You did run that, right?

Actually I reposted the Ajit's patch. Fixed all issues in v4.

Quoted 69 lines

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 93

Quoted 3 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +3 -0
+      qcom,capture-sd-lines :
+        description: List of serial data lines to use for capture
+                     Each SD line should be represented by a number from 0-3.

ditto

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 95

Quoted 2 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +2 -0
+    required:
+      -reg

space ^

Quoted 4 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +4 -0
+    # Note that adding a subnode changes the default to "no lines configured",
+    # so both playback and capture lines should be configured when a subnode
+    # is added.
+

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 109

Quoted 10 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +10 -0
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+  - interrupts
+  - interrupt-names
+  - sound-dai-cells

Not a valid property.

Quoted 7 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +7 -0
+
+optional:
+  - qcom,adsp
+
+if:
+  properties:
+    compatible:

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 126

Quoted 10 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +10 -0
+      contains:
+        const: qcom,lpass-cpu-sc7180
+
+then:
+  required:
+    - iommus
+    - power-domains
+
+examples:
+  lpass@28100000 {

This is not valid. 'examples' should be a list.

Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml line 130

Quoted 4 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +4 -0
+	compatible = "qcom,lpass-cpu";
+	clocks = <&lcc AHBIX_CLK>,
+		 <&lcc MI2S_OSR_CLK>,
+		 <&lcc MI2S_BIT_CLK>;

The example will not build because the includes are missing.

Quoted 19 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +19 -0
+
+	clock-names = "ahbix-clk",
+		      "mi2s-osr-clk",
+		      "mi2s-bit-clk";
+
+	interrupts = <0 85 1>;
+        interrupt-names = "lpass-irq-lpaif";
+
+	iommus = <&apps_smmu 0x1020 0>;
+	power-domains = <&lpass_hm LPASS_CORE_HM_GDSCR>;
+
+	reg = <0x28100000 0x10000>;
+	reg-names = "lpass-lpaif";
+	#sound-dai-cells = <1>;
+	qcom,adsp = <&adsp>;
+
+	#address-cells = <1>;
+	#size-cells = <0>;
+
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml new file +5 -0
+	/* Optional to set different MI2S SD lines */
+	mi2s-quaternary@3 {
+		reg = <MI2S_QUATERNARY>;
+		qcom,playback-sd-lines = <0 1>;
+  };
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.

Thanks,

Rohit

Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the Linux Foundation.