2020-08-04 08:10:45

by Rohit Kumar

[permalink] [raw]
Subject: [PATCH v5 00/12] 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.
This also fixes some concurrency issue.

This patch series is already tested by Srinivas on Dragon Board 410c.
Changes since v4:
- Updated compatible string for sc7180 lpass cpu as suggested by Rob
- Addressed comments by Rob in yaml Documentation.

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

Rohit kumar (8):
ASoC: qcom: lpass-cpu: Move ahbix clk to platform specific function
ASoC: qcom: lpass-platform: fix memory leak
ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers
ASoC: qcom: lpass-cpu: fix concurrency issue
dt-bindings: sound: lpass-cpu: Add sc7180 lpass cpu node
ASoC: qcom: lpass-cpu: Use platform_get_resource
ASoC: qcom: lpass-platform: Use platform_get_irq
dt-bindings: sound: lpass-cpu: Move to yaml format

.../devicetree/bindings/sound/qcom,lpass-cpu.txt | 79 --------
.../devicetree/bindings/sound/qcom,lpass-cpu.yaml | 179 +++++++++++++++++
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 | 204 ++++++++++---------
sound/soc/qcom/lpass-ipq806x.c | 67 +++++++
sound/soc/qcom/lpass-lpaif-reg.h | 157 ++++++++-------
sound/soc/qcom/lpass-platform.c | 155 +++++++++++----
sound/soc/qcom/lpass-sc7180.c | 216 +++++++++++++++++++++
sound/soc/qcom/lpass.h | 63 +++++-
12 files changed, 924 insertions(+), 299 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

--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


2020-08-04 08:10:55

by Rohit Kumar

[permalink] [raw]
Subject: [PATCH v5 12/12] dt-bindings: sound: lpass-cpu: Move to yaml format

Update lpass-cpu binding with yaml formats.

Signed-off-by: Rohit kumar <[email protected]>
---
.../devicetree/bindings/sound/qcom,lpass-cpu.txt | 130 ---------------
.../devicetree/bindings/sound/qcom,lpass-cpu.yaml | 179 +++++++++++++++++++++
2 files changed, 179 insertions(+), 130 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt
create mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml

diff --git a/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt b/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt
deleted file mode 100644
index c07202c..00000000
--- a/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt
+++ /dev/null
@@ -1,130 +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,sc7180-lpass-cpu"
-- 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"
- : required clocks for "qcom,lpass-cpu-sc7180"
- * "audio-core"
- * "mclk0"
- * "mi2s-bit-clk0"
- * "mi2s-bit-clk1"
- * "pcnoc-sway-clk"
- * "pcnoc-mport-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.
-
-Examples:
-1)
-
-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>;
- };
-};
-
-2)
-
-#include <dt-bindings/sound/sc7180-lpass.h>
-
-lpass_cpu: lpass {
- compatible = "qcom,sc7180-lpass-cpu";
-
- reg = <0 0x62F00000 0 0x29000>;
-
- iommus = <&apps_smmu 0x1020 0>;
-
- power-domains = <&lpass_hm LPASS_CORE_HM_GDSCR>;
- clocks = <&gcc GCC_LPASS_CFG_NOC_SWAY_CLK>,
- <&lpasscorecc LPASS_AUDIO_CORE_CORE_CLK>,
- <&lpasscorecc LPASS_AUDIO_CORE_EXT_MCLK0_CLK>,
- <&lpasscorecc LPASS_AUDIO_CORE_SYSNOC_MPORT_CORE_CLK>,
- <&lpasscorecc LPASS_AUDIO_CORE_LPAIF_PRI_IBIT_CLK>,
- <&lpasscorecc LPASS_AUDIO_CORE_LPAIF_SEC_IBIT_CLK>;
- clock-names = "pcnoc-sway-clk", "audio-core",
- "mclk0", "pcnoc-mport-clk",
- "mi2s-bit-clk0", "mi2s-bit-clk1";
- interrupts = <0 160 IRQ_TYPE_LEVEL_HIGH>;
- interrupt-names = "lpass-irq-lpaif";
-
-
- #sound-dai-cells = <1>;
-
- #address-cells = <1>;
- #size-cells = <0>;
-
- mi2s-primary@0 {
- reg = <MI2S_PRIMARY>;
- qcom,playback-sd-lines = <1>;
- qcom,capture-sd-lines = <0>;
- };
-
- mi2s-secondary@1 {
- reg = <MI2S_SECONDARY>;
- qcom,playback-sd-lines = <0>;
- };
-};
diff --git a/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml b/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml
new file mode 100644
index 00000000..5c1881d
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml
@@ -0,0 +1,179 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/qcom,lpass-cpu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Technologies Inc. LPASS CPU dai driver bindings
+
+maintainers:
+ - Srinivas Kandagatla <[email protected]>
+ - Rohit kumar <[email protected]>
+
+description: |
+ Qualcomm Technologies Inc. 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:
+ - qcom,lpass-cpu
+ - qcom,apq8016-lpass-cpu
+ - qcom,sc7180-lpass-cpu
+
+ reg:
+ maxItems: 1
+ description: LPAIF core registers
+
+ clocks:
+ minItems: 3
+ maxItems: 6
+
+ clock-names:
+ minItems: 3
+ maxItems: 6
+
+ interrupts:
+ maxItems: 1
+ description: LPAIF DMA buffer interrupt
+
+ qcom,adsp:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description: Phandle for the audio DSP node
+
+ iommus:
+ maxItems: 1
+ description: Phandle to apps_smmu node with sid mask
+
+ power-domains:
+ maxItems: 1
+
+ '#sound-dai-cells':
+ const: 1
+
+ '#address-cells':
+ const: 1
+
+ '#size-cells':
+ const: 0
+
+patternProperties:
+ "(^mi2s-[0-9a-f]$|mi2s)":
+ type: object
+ description: Required properties for each DAI
+
+ properties:
+ reg:
+ maxItems: 1
+ description: Must be one of the DAI ID
+
+ required:
+ - reg
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - interrupts
+ - '#sound-dai-cells'
+
+additionalProperties: false
+
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: qcom,lpass-cpu
+
+ then:
+ properties:
+ clock-names:
+ items:
+ - const: ahbix-clk
+ - const: mi2s-osr-clk
+ - const: mi2s-bit-clk
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: qcom,apq8016-lpass-cpu
+
+ then:
+ properties:
+ clock-names:
+ items:
+ - const: ahbix-clk
+ - const: mi2s-bit-clk0
+ - const: mi2s-bit-clk1
+ - const: mi2s-bit-clk2
+ - const: mi2s-bit-clk3
+ - const: pcnoc-mport-clk
+ - const: pcnoc-sway-clk
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: qcom,sc7180-lpass-cpu
+
+ then:
+ properties:
+ clock-names:
+ items:
+ - const: pcnoc-sway-clk
+ - const: audio-core
+ - const: mclk0
+ - const: pcnoc-mport-clk
+ - const: mi2s-bit-clk0
+ - const: mi2s-bit-clk1
+ required:
+ - iommus
+ - power-domains
+
+examples:
+ - |
+ #include <dt-bindings/sound/sc7180-lpass.h>
+
+ soc {
+ #address-cells = <2>;
+ #size-cells = <2>;
+ lpass@62f00000 {
+ compatible = "qcom,sc7180-lpass-cpu";
+
+ reg = <0 0x62f00000 0 0x29000>;
+
+ iommus = <&apps_smmu 0x1020 0>;
+ power-domains = <&lpass_hm 0>;
+
+ clocks = <&gcc 131>,
+ <&lpasscorecc 6>,
+ <&lpasscorecc 7>,
+ <&lpasscorecc 10>,
+ <&lpasscorecc 8>,
+ <&lpasscorecc 9>;
+
+ clock-names = "pcnoc-sway-clk", "audio-core",
+ "mclk0", "pcnoc-mport-clk",
+ "mi2s-bit-clk0", "mi2s-bit-clk1";
+
+ interrupts = <0 160 1>;
+
+ #sound-dai-cells = <1>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+ /* Optional to set different MI2S SD lines */
+ mi2s-primary@0 {
+ reg = <MI2S_PRIMARY>;
+ qcom,playback-sd-lines = <1>;
+ qcom,capture-sd-lines = <0>;
+ };
+ };
+ };
+
+...
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.

2020-08-04 08:12:08

by Rohit Kumar

[permalink] [raw]
Subject: [PATCH v5 08/12] include: dt-bindings: sound: Add sc7180-lpass bindings header

From: Ajit Pandey <[email protected]>

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

Signed-off-by: Ajit Pandey <[email protected]>
Signed-off-by: Rohit kumar <[email protected]>
Acked-by: Rob Herring <[email protected]>
---
include/dt-bindings/sound/sc7180-lpass.h | 10 ++++++++++
1 file changed, 10 insertions(+)
create mode 100644 include/dt-bindings/sound/sc7180-lpass.h

diff --git a/include/dt-bindings/sound/sc7180-lpass.h b/include/dt-bindings/sound/sc7180-lpass.h
new file mode 100644
index 00000000..7d988f6
--- /dev/null
+++ b/include/dt-bindings/sound/sc7180-lpass.h
@@ -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 */
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.

2020-08-04 08:12:19

by Rohit Kumar

[permalink] [raw]
Subject: [PATCH v5 09/12] ASoC: qcom: lpass-sc7180: Add platform driver for lpass audio

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.

Signed-off-by: Ajit Pandey <[email protected]>
Signed-off-by: Rohit kumar <[email protected]>
Reviewed-by: Srinivas Kandagatla <[email protected]>
---
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

diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig
index 5d6b246..b47d2bdd 100644
--- a/sound/soc/qcom/Kconfig
+++ b/sound/soc/qcom/Kconfig
@@ -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
diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile
index 41b2c7a..7972c94 100644
--- a/sound/soc/qcom/Makefile
+++ b/sound/soc/qcom/Makefile
@@ -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
diff --git a/sound/soc/qcom/lpass-sc7180.c b/sound/soc/qcom/lpass-sc7180.c
new file mode 100644
index 00000000..b4c6a04
--- /dev/null
+++ b/sound/soc/qcom/lpass-sc7180.c
@@ -0,0 +1,216 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ *
+ * lpass-sc7180.c -- ALSA SoC platform-machine driver for QTi LPASS
+ */
+
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/sound/sc7180-lpass.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+
+#include "lpass-lpaif-reg.h"
+#include "lpass.h"
+
+static struct snd_soc_dai_driver sc7180_lpass_cpu_dai_driver[] = {
+ [MI2S_PRIMARY] = {
+ .id = MI2S_PRIMARY,
+ .name = "Primary MI2S",
+ .playback = {
+ .stream_name = "Primary Playback",
+ .formats = SNDRV_PCM_FMTBIT_S16,
+ .rates = SNDRV_PCM_RATE_48000,
+ .rate_min = 48000,
+ .rate_max = 48000,
+ .channels_min = 2,
+ .channels_max = 2,
+ },
+ .capture = {
+ .stream_name = "Primary Capture",
+ .formats = SNDRV_PCM_FMTBIT_S16,
+ .rates = SNDRV_PCM_RATE_48000,
+ .rate_min = 48000,
+ .rate_max = 48000,
+ .channels_min = 2,
+ .channels_max = 2,
+ },
+ .probe = &asoc_qcom_lpass_cpu_dai_probe,
+ .ops = &asoc_qcom_lpass_cpu_dai_ops,
+ },
+
+ [MI2S_SECONDARY] = {
+ .id = MI2S_SECONDARY,
+ .name = "Secondary MI2S",
+ .playback = {
+ .stream_name = "Secondary Playback",
+ .formats = SNDRV_PCM_FMTBIT_S16,
+ .rates = SNDRV_PCM_RATE_48000,
+ .rate_min = 48000,
+ .rate_max = 48000,
+ .channels_min = 2,
+ .channels_max = 2,
+ },
+ .probe = &asoc_qcom_lpass_cpu_dai_probe,
+ .ops = &asoc_qcom_lpass_cpu_dai_ops,
+ },
+};
+
+static int sc7180_lpass_alloc_dma_channel(struct lpass_data *drvdata,
+ int direction)
+{
+ struct lpass_variant *v = drvdata->variant;
+ int chan = 0;
+
+ if (direction == SNDRV_PCM_STREAM_PLAYBACK) {
+ chan = find_first_zero_bit(&drvdata->dma_ch_bit_map,
+ v->rdma_channels);
+
+ if (chan >= v->rdma_channels)
+ return -EBUSY;
+ } else {
+ chan = find_next_zero_bit(&drvdata->dma_ch_bit_map,
+ v->wrdma_channel_start +
+ v->wrdma_channels,
+ v->wrdma_channel_start);
+
+ if (chan >= v->wrdma_channel_start + v->wrdma_channels)
+ return -EBUSY;
+ }
+
+ set_bit(chan, &drvdata->dma_ch_bit_map);
+
+ return chan;
+}
+
+static int sc7180_lpass_free_dma_channel(struct lpass_data *drvdata, int chan)
+{
+ clear_bit(chan, &drvdata->dma_ch_bit_map);
+
+ return 0;
+}
+
+static int sc7180_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, i;
+
+ 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, "Failed to get clocks %d\n", ret);
+ return ret;
+ }
+
+ ret = clk_bulk_prepare_enable(drvdata->num_clks, drvdata->clks);
+ if (ret) {
+ dev_err(dev, "sc7180 clk_enable failed\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static int sc7180_lpass_exit(struct platform_device *pdev)
+{
+ struct lpass_data *drvdata = platform_get_drvdata(pdev);
+
+ clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
+
+ return 0;
+}
+
+static struct lpass_variant sc7180_data = {
+ .i2sctrl_reg_base = 0x1000,
+ .i2sctrl_reg_stride = 0x1000,
+ .i2s_ports = 3,
+ .irq_reg_base = 0x9000,
+ .irq_reg_stride = 0x1000,
+ .irq_ports = 3,
+ .rdma_reg_base = 0xC000,
+ .rdma_reg_stride = 0x1000,
+ .rdma_channels = 5,
+ .dmactl_audif_start = 1,
+ .wrdma_reg_base = 0x18000,
+ .wrdma_reg_stride = 0x1000,
+ .wrdma_channel_start = 5,
+ .wrdma_channels = 4,
+
+ .loopback = REG_FIELD_ID(0x1000, 17, 17, 3, 0x1000),
+ .spken = REG_FIELD_ID(0x1000, 16, 16, 3, 0x1000),
+ .spkmode = REG_FIELD_ID(0x1000, 11, 15, 3, 0x1000),
+ .spkmono = REG_FIELD_ID(0x1000, 10, 10, 3, 0x1000),
+ .micen = REG_FIELD_ID(0x1000, 9, 9, 3, 0x1000),
+ .micmode = REG_FIELD_ID(0x1000, 4, 8, 3, 0x1000),
+ .micmono = REG_FIELD_ID(0x1000, 3, 3, 3, 0x1000),
+ .wssrc = REG_FIELD_ID(0x1000, 2, 2, 3, 0x1000),
+ .bitwidth = REG_FIELD_ID(0x1000, 0, 0, 3, 0x1000),
+
+ .rdma_dyncclk = REG_FIELD_ID(0xC000, 21, 21, 5, 0x1000),
+ .rdma_bursten = REG_FIELD_ID(0xC000, 20, 20, 5, 0x1000),
+ .rdma_wpscnt = REG_FIELD_ID(0xC000, 16, 19, 5, 0x1000),
+ .rdma_intf = REG_FIELD_ID(0xC000, 12, 15, 5, 0x1000),
+ .rdma_fifowm = REG_FIELD_ID(0xC000, 1, 5, 5, 0x1000),
+ .rdma_enable = REG_FIELD_ID(0xC000, 0, 0, 5, 0x1000),
+
+ .wrdma_dyncclk = REG_FIELD_ID(0x18000, 22, 22, 4, 0x1000),
+ .wrdma_bursten = REG_FIELD_ID(0x18000, 21, 21, 4, 0x1000),
+ .wrdma_wpscnt = REG_FIELD_ID(0x18000, 17, 20, 4, 0x1000),
+ .wrdma_intf = REG_FIELD_ID(0x18000, 12, 16, 4, 0x1000),
+ .wrdma_fifowm = REG_FIELD_ID(0x18000, 1, 5, 4, 0x1000),
+ .wrdma_enable = REG_FIELD_ID(0x18000, 0, 0, 4, 0x1000),
+
+ .clk_name = (const char*[]) {
+ "pcnoc-sway-clk",
+ "audio-core",
+ "pcnoc-mport-clk",
+ },
+ .num_clks = 3,
+ .dai_driver = sc7180_lpass_cpu_dai_driver,
+ .num_dai = ARRAY_SIZE(sc7180_lpass_cpu_dai_driver),
+ .dai_osr_clk_names = (const char *[]) {
+ "mclk0",
+ "null",
+ },
+ .dai_bit_clk_names = (const char *[]) {
+ "mi2s-bit-clk0",
+ "mi2s-bit-clk1",
+ },
+ .init = sc7180_lpass_init,
+ .exit = sc7180_lpass_exit,
+ .alloc_dma_channel = sc7180_lpass_alloc_dma_channel,
+ .free_dma_channel = sc7180_lpass_free_dma_channel,
+};
+
+static const struct of_device_id sc7180_lpass_cpu_device_id[] = {
+ {.compatible = "qcom,sc7180-lpass-cpu", .data = &sc7180_data},
+ {}
+};
+
+static struct platform_driver sc7180_lpass_cpu_platform_driver = {
+ .driver = {
+ .name = "sc7180-lpass-cpu",
+ .of_match_table = of_match_ptr(sc7180_lpass_cpu_device_id),
+ },
+ .probe = asoc_qcom_lpass_cpu_platform_probe,
+ .remove = asoc_qcom_lpass_cpu_platform_probe,
+};
+
+module_platform_driver(sc7180_lpass_cpu_platform_driver);
+
+MODULE_DESCRIPTION("SC7180 LPASS CPU DRIVER");
+MODULE_LICENSE("GPL v2");
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.

2020-08-04 08:12:28

by Rohit Kumar

[permalink] [raw]
Subject: [PATCH v5 10/12] ASoC: qcom: lpass-cpu: Use platform_get_resource

platform_get_resource_byname() is used when there
is list of reg entries. As lpass-cpu node has only
one reg entry, use platform_get_resource() instead.

Signed-off-by: Rohit kumar <[email protected]>
Reviewed-by: Srinivas Kandagatla <[email protected]>
---
sound/soc/qcom/lpass-cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c
index 5d84f63..1ee6d8b 100644
--- a/sound/soc/qcom/lpass-cpu.c
+++ b/sound/soc/qcom/lpass-cpu.c
@@ -575,7 +575,7 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)

of_lpass_cpu_parse_dai_data(dev, drvdata);

- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpass-lpaif");
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

drvdata->lpaif = devm_ioremap_resource(dev, res);
if (IS_ERR((void const __force *)drvdata->lpaif)) {
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.

2020-08-04 08:12:37

by Rohit Kumar

[permalink] [raw]
Subject: [PATCH v5 11/12] ASoC: qcom: lpass-platform: Use platform_get_irq

platform_get_irq_byname() is used when there is list
of interrupts in the device node. As lpass-platform
has only one interrupt entry, use platform_get_irq()
instead.

Signed-off-by: Rohit kumar <[email protected]>
---
sound/soc/qcom/lpass-platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c
index 35aead1..df692ed 100644
--- a/sound/soc/qcom/lpass-platform.c
+++ b/sound/soc/qcom/lpass-platform.c
@@ -638,7 +638,7 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev)
struct lpass_variant *v = drvdata->variant;
int ret;

- drvdata->lpaif_irq = platform_get_irq_byname(pdev, "lpass-irq-lpaif");
+ drvdata->lpaif_irq = platform_get_irq(pdev, 0);
if (drvdata->lpaif_irq < 0)
return -ENODEV;

--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.

2020-08-06 17:08:16

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v5 12/12] dt-bindings: sound: lpass-cpu: Move to yaml format

On Tue, Aug 04, 2020 at 01:37:33PM +0530, Rohit kumar wrote:
> Update lpass-cpu binding with yaml formats.
>
> Signed-off-by: Rohit kumar <[email protected]>
> ---
> .../devicetree/bindings/sound/qcom,lpass-cpu.txt | 130 ---------------
> .../devicetree/bindings/sound/qcom,lpass-cpu.yaml | 179 +++++++++++++++++++++
> 2 files changed, 179 insertions(+), 130 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt
> create mode 100644 Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml
>
> diff --git a/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt b/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt
> deleted file mode 100644
> index c07202c..00000000
> --- a/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.txt
> +++ /dev/null
> @@ -1,130 +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,sc7180-lpass-cpu"
> -- 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"
> - : required clocks for "qcom,lpass-cpu-sc7180"
> - * "audio-core"
> - * "mclk0"
> - * "mi2s-bit-clk0"
> - * "mi2s-bit-clk1"
> - * "pcnoc-sway-clk"
> - * "pcnoc-mport-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.
> -
> -Examples:
> -1)
> -
> -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>;
> - };
> -};
> -
> -2)
> -
> -#include <dt-bindings/sound/sc7180-lpass.h>
> -
> -lpass_cpu: lpass {
> - compatible = "qcom,sc7180-lpass-cpu";
> -
> - reg = <0 0x62F00000 0 0x29000>;
> -
> - iommus = <&apps_smmu 0x1020 0>;
> -
> - power-domains = <&lpass_hm LPASS_CORE_HM_GDSCR>;
> - clocks = <&gcc GCC_LPASS_CFG_NOC_SWAY_CLK>,
> - <&lpasscorecc LPASS_AUDIO_CORE_CORE_CLK>,
> - <&lpasscorecc LPASS_AUDIO_CORE_EXT_MCLK0_CLK>,
> - <&lpasscorecc LPASS_AUDIO_CORE_SYSNOC_MPORT_CORE_CLK>,
> - <&lpasscorecc LPASS_AUDIO_CORE_LPAIF_PRI_IBIT_CLK>,
> - <&lpasscorecc LPASS_AUDIO_CORE_LPAIF_SEC_IBIT_CLK>;
> - clock-names = "pcnoc-sway-clk", "audio-core",
> - "mclk0", "pcnoc-mport-clk",
> - "mi2s-bit-clk0", "mi2s-bit-clk1";
> - interrupts = <0 160 IRQ_TYPE_LEVEL_HIGH>;
> - interrupt-names = "lpass-irq-lpaif";
> -
> -
> - #sound-dai-cells = <1>;
> -
> - #address-cells = <1>;
> - #size-cells = <0>;
> -
> - mi2s-primary@0 {
> - reg = <MI2S_PRIMARY>;
> - qcom,playback-sd-lines = <1>;
> - qcom,capture-sd-lines = <0>;
> - };
> -
> - mi2s-secondary@1 {
> - reg = <MI2S_SECONDARY>;
> - qcom,playback-sd-lines = <0>;
> - };
> -};
> diff --git a/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml b/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml
> new file mode 100644
> index 00000000..5c1881d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml
> @@ -0,0 +1,179 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/sound/qcom,lpass-cpu.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Qualcomm Technologies Inc. LPASS CPU dai driver bindings
> +
> +maintainers:
> + - Srinivas Kandagatla <[email protected]>
> + - Rohit kumar <[email protected]>
> +
> +description: |
> + Qualcomm Technologies Inc. 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:
> + - qcom,lpass-cpu
> + - qcom,apq8016-lpass-cpu
> + - qcom,sc7180-lpass-cpu
> +
> + reg:
> + maxItems: 1
> + description: LPAIF core registers
> +
> + clocks:
> + minItems: 3
> + maxItems: 6
> +
> + clock-names:
> + minItems: 3
> + maxItems: 6
> +
> + interrupts:
> + maxItems: 1
> + description: LPAIF DMA buffer interrupt
> +
> + qcom,adsp:
> + $ref: /schemas/types.yaml#/definitions/phandle
> + description: Phandle for the audio DSP node
> +
> + iommus:
> + maxItems: 1
> + description: Phandle to apps_smmu node with sid mask
> +
> + power-domains:
> + maxItems: 1
> +
> + '#sound-dai-cells':
> + const: 1
> +
> + '#address-cells':
> + const: 1
> +
> + '#size-cells':
> + const: 0
> +
> +patternProperties:
> + "(^mi2s-[0-9a-f]$|mi2s)":

I believe this will work:

"^mi2s(-[0-9a-f])?$"

> + type: object
> + description: Required properties for each DAI
> +
> + properties:
> + reg:
> + maxItems: 1
> + description: Must be one of the DAI ID
> +
> + required:
> + - reg

additionalProperties: false

> +
> +required:
> + - compatible
> + - reg
> + - clocks
> + - clock-names
> + - interrupts
> + - '#sound-dai-cells'
> +
> +additionalProperties: false
> +
> +allOf:
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: qcom,lpass-cpu
> +
> + then:
> + properties:
> + clock-names:
> + items:
> + - const: ahbix-clk
> + - const: mi2s-osr-clk
> + - const: mi2s-bit-clk
> +
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: qcom,apq8016-lpass-cpu
> +
> + then:
> + properties:
> + clock-names:
> + items:
> + - const: ahbix-clk
> + - const: mi2s-bit-clk0
> + - const: mi2s-bit-clk1
> + - const: mi2s-bit-clk2
> + - const: mi2s-bit-clk3
> + - const: pcnoc-mport-clk
> + - const: pcnoc-sway-clk
> +
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: qcom,sc7180-lpass-cpu
> +
> + then:
> + properties:
> + clock-names:
> + items:
> + - const: pcnoc-sway-clk
> + - const: audio-core
> + - const: mclk0
> + - const: pcnoc-mport-clk
> + - const: mi2s-bit-clk0
> + - const: mi2s-bit-clk1
> + required:
> + - iommus
> + - power-domains
> +
> +examples:
> + - |
> + #include <dt-bindings/sound/sc7180-lpass.h>
> +
> + soc {
> + #address-cells = <2>;
> + #size-cells = <2>;
> + lpass@62f00000 {
> + compatible = "qcom,sc7180-lpass-cpu";
> +
> + reg = <0 0x62f00000 0 0x29000>;
> +
> + iommus = <&apps_smmu 0x1020 0>;
> + power-domains = <&lpass_hm 0>;
> +
> + clocks = <&gcc 131>,
> + <&lpasscorecc 6>,
> + <&lpasscorecc 7>,
> + <&lpasscorecc 10>,
> + <&lpasscorecc 8>,
> + <&lpasscorecc 9>;
> +
> + clock-names = "pcnoc-sway-clk", "audio-core",
> + "mclk0", "pcnoc-mport-clk",
> + "mi2s-bit-clk0", "mi2s-bit-clk1";
> +
> + interrupts = <0 160 1>;
> +
> + #sound-dai-cells = <1>;
> +
> + #address-cells = <1>;
> + #size-cells = <0>;
> + /* Optional to set different MI2S SD lines */
> + mi2s-primary@0 {
> + reg = <MI2S_PRIMARY>;
> + qcom,playback-sd-lines = <1>;
> + qcom,capture-sd-lines = <0>;

These 2 aren't documented.

Rob

2020-08-06 17:44:10

by Rohit Kumar

[permalink] [raw]
Subject: Re: [PATCH v5 00/12] ASoC: qcom: Add support for SC7180 lpass variant

Hello Mark,

Other than patch 12, there is no comment on other patches from anyone as
of now.

[PATCH v5 12/12] dt-bindings: sound: lpass-cpu: Move to yaml format

I will plan to post patch12 only with comments addressed if other
changes does not have any comment. Please let me know your inputs.

Thanks,
Rohit
On 8/4/2020 1:37 PM, Rohit kumar wrote:
> This patch chain add audio support for SC7180 soc by doing the required
> modification in existing common lpass-cpu/lpass-platform driver.
> This also fixes some concurrency issue.
>
> This patch series is already tested by Srinivas on Dragon Board 410c.
> Changes since v4:
> - Updated compatible string for sc7180 lpass cpu as suggested by Rob
> - Addressed comments by Rob in yaml Documentation.
>
> Ajit Pandey (4):
> ASoC: qcom: Add common array to initialize soc based core clocks
> ASoC: qcom: lpass-platform: Replace card->dev with component->dev
> include: dt-bindings: sound: Add sc7180-lpass bindings header
> ASoC: qcom: lpass-sc7180: Add platform driver for lpass audio
>
> Rohit kumar (8):
> ASoC: qcom: lpass-cpu: Move ahbix clk to platform specific function
> ASoC: qcom: lpass-platform: fix memory leak
> ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers
> ASoC: qcom: lpass-cpu: fix concurrency issue
> dt-bindings: sound: lpass-cpu: Add sc7180 lpass cpu node
> ASoC: qcom: lpass-cpu: Use platform_get_resource
> ASoC: qcom: lpass-platform: Use platform_get_irq
> dt-bindings: sound: lpass-cpu: Move to yaml format
>
> .../devicetree/bindings/sound/qcom,lpass-cpu.txt | 79 --------
> .../devicetree/bindings/sound/qcom,lpass-cpu.yaml | 179 +++++++++++++++++
> 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 | 204 ++++++++++---------
> sound/soc/qcom/lpass-ipq806x.c | 67 +++++++
> sound/soc/qcom/lpass-lpaif-reg.h | 157 ++++++++-------
> sound/soc/qcom/lpass-platform.c | 155 +++++++++++----
> sound/soc/qcom/lpass-sc7180.c | 216 +++++++++++++++++++++
> sound/soc/qcom/lpass.h | 63 +++++-
> 12 files changed, 924 insertions(+), 299 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
>
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the Linux Foundation.