* [PATCH v2 0/5] add sof support on imx95
@ 2024-11-13 19:52 Laurentiu Mihalcea
2024-11-13 19:52 ` [PATCH v2 1/5] ASoC: dt-bindings: add common binding for NXP CPUs Laurentiu Mihalcea
` (4 more replies)
0 siblings, 5 replies; 20+ messages in thread
From: Laurentiu Mihalcea @ 2024-11-13 19:52 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, Frank Li
Cc: linux-arm-kernel, devicetree, linux-sound, imx, linux-kernel
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Add sof support on imx95. This series also includes some changes to
the audio-graph-card2 binding required for the support.
---
Changes in v2:
- Added new binding for 95's CM7 core with SOF. fsl,dsp.yaml is no longer used.
- "hp-det-gpios" and "widgets" properties now reference the definitions from audio-graph.yaml
- Removed extra empty spaces from DTS as suggested by Frank
- Ordered 'edma2', 'sai3', 'wm8962' DT nodes alphabetically. The order of the nodes
placed inside / is kept the same for readability
- Ordered driver header files includes alphabetically as suggested by Frank
- Removed "reg-names" and changed the maximum size of the "reg" property to 1 to align
with the other NXP CPUs sharing the same programming model (i.e: audio processing with SOF).
The region described in the DTS is the SRAM and the mailbox region is now hardcoded in the
driver as an offset to the start of the SRAM region.
- Added new binding with properties required by all NXP CPUs sharing the same programming
model (i.e: audio processing with SOF).
- Various driver adjustments made to accomodate the DT changes + some bug fixing related
to the mboxes not being requested/free'd on resume/suspend.
- Fixed value passed to "dma-channel-mask". A set bit means the channel is masked, not the
other way around.
- Link to v1: https://lore.kernel.org/lkml/20241023162114.3354-1-laurentiumihalcea111@gmail.com/
---
Laurentiu Mihalcea (5):
ASoC: dt-bindings: add common binding for NXP CPUs
ASoC: dt-bindings: add binding for imx95's CM7 core
ASoC: dt-bindings: audio-graph-card2: add widgets and hp-det-gpios
support
ASoC: SOF: imx: add driver for imx95
arm64: dts: imx: add imx95 dts for sof
.../bindings/sound/audio-graph-card2.yaml | 4 +
.../bindings/sound/fsl,imx95-cm7-sof.yaml | 44 ++
.../bindings/sound/fsl,sof-cpu.yaml | 35 ++
arch/arm64/boot/dts/freescale/Makefile | 1 +
.../dts/freescale/imx95-19x19-evk-sof.dts | 74 ++++
sound/soc/sof/imx/Kconfig | 8 +
sound/soc/sof/imx/Makefile | 2 +
sound/soc/sof/imx/imx95.c | 401 ++++++++++++++++++
8 files changed, 569 insertions(+)
create mode 100644 Documentation/devicetree/bindings/sound/fsl,imx95-cm7-sof.yaml
create mode 100644 Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml
create mode 100644 arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts
create mode 100644 sound/soc/sof/imx/imx95.c
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 1/5] ASoC: dt-bindings: add common binding for NXP CPUs
2024-11-13 19:52 [PATCH v2 0/5] add sof support on imx95 Laurentiu Mihalcea
@ 2024-11-13 19:52 ` Laurentiu Mihalcea
2024-11-13 20:03 ` Frank Li
2024-11-13 19:52 ` [PATCH v2 2/5] ASoC: dt-bindings: add binding for imx95's CM7 core Laurentiu Mihalcea
` (3 subsequent siblings)
4 siblings, 1 reply; 20+ messages in thread
From: Laurentiu Mihalcea @ 2024-11-13 19:52 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, Frank Li
Cc: linux-arm-kernel, devicetree, linux-sound, imx, linux-kernel
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Add common binding for NXP CPUs sharing the same programming
model (i.e: audio processing with SOF).
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
.../bindings/sound/fsl,sof-cpu.yaml | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml
diff --git a/Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml b/Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml
new file mode 100644
index 000000000000..6d63fcd71154
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/fsl,sof-cpu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP audio CPU common properties
+
+maintainers:
+ - Daniel Baluta <daniel.baluta@nxp.com>
+
+properties:
+ reg:
+ maxItems: 1
+
+ mboxes:
+ maxItems: 4
+
+ mbox-names:
+ items:
+ - const: txdb0
+ - const: txdb1
+ - const: rxdb0
+ - const: rxdb1
+
+ memory-region:
+ maxItems: 1
+
+required:
+ - reg
+ - mboxes
+ - mbox-names
+ - memory-region
+
+additionalProperties: true
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 2/5] ASoC: dt-bindings: add binding for imx95's CM7 core
2024-11-13 19:52 [PATCH v2 0/5] add sof support on imx95 Laurentiu Mihalcea
2024-11-13 19:52 ` [PATCH v2 1/5] ASoC: dt-bindings: add common binding for NXP CPUs Laurentiu Mihalcea
@ 2024-11-13 19:52 ` Laurentiu Mihalcea
2024-11-13 20:07 ` Frank Li
2024-11-13 19:52 ` [PATCH v2 3/5] ASoC: dt-bindings: audio-graph-card2: add widgets and hp-det-gpios support Laurentiu Mihalcea
` (2 subsequent siblings)
4 siblings, 1 reply; 20+ messages in thread
From: Laurentiu Mihalcea @ 2024-11-13 19:52 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, Frank Li
Cc: linux-arm-kernel, devicetree, linux-sound, imx, linux-kernel
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Add binding for imx95's CM7 core.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
.../bindings/sound/fsl,imx95-cm7-sof.yaml | 44 +++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100644 Documentation/devicetree/bindings/sound/fsl,imx95-cm7-sof.yaml
diff --git a/Documentation/devicetree/bindings/sound/fsl,imx95-cm7-sof.yaml b/Documentation/devicetree/bindings/sound/fsl,imx95-cm7-sof.yaml
new file mode 100644
index 000000000000..f11e03bbcaba
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/fsl,imx95-cm7-sof.yaml
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/fsl,imx95-cm7-sof.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP imx95 CM7 core
+
+maintainers:
+ - Daniel Baluta <daniel.baluta@nxp.com>
+
+description: NXP imx95 CM7 core used for audio processing
+
+allOf:
+ - $ref: fsl,sof-cpu.yaml#
+
+properties:
+ compatible:
+ const: fsl,imx95-cm7-sof
+
+ port:
+ description: SAI3 port
+ $ref: audio-graph-port.yaml#
+ unevaluatedProperties: false
+
+required:
+ - compatible
+ - port
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ cm7-cpu@80000000 {
+ compatible = "fsl,imx95-cm7-sof";
+ reg = <0x80000000 0x6100000>;
+ mboxes = <&mu7 2 0>, <&mu7 2 1>, <&mu7 3 0>, <&mu7 3 1>;
+ mbox-names = "txdb0", "txdb1", "rxdb0", "rxdb1";
+ memory-region = <&adma_res>;
+ cpu: port {
+ /* SAI3-WM8962 link */
+ cpu_ep: endpoint { remote-endpoint = <&wm8962_ep>; };
+ };
+ };
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 3/5] ASoC: dt-bindings: audio-graph-card2: add widgets and hp-det-gpios support
2024-11-13 19:52 [PATCH v2 0/5] add sof support on imx95 Laurentiu Mihalcea
2024-11-13 19:52 ` [PATCH v2 1/5] ASoC: dt-bindings: add common binding for NXP CPUs Laurentiu Mihalcea
2024-11-13 19:52 ` [PATCH v2 2/5] ASoC: dt-bindings: add binding for imx95's CM7 core Laurentiu Mihalcea
@ 2024-11-13 19:52 ` Laurentiu Mihalcea
2024-11-13 20:11 ` Frank Li
2024-11-13 19:52 ` [PATCH v2 4/5] ASoC: SOF: imx: add driver for imx95 Laurentiu Mihalcea
2024-11-13 19:52 ` [PATCH v2 5/5] arm64: dts: imx: add imx95 dts for sof Laurentiu Mihalcea
4 siblings, 1 reply; 20+ messages in thread
From: Laurentiu Mihalcea @ 2024-11-13 19:52 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, Frank Li
Cc: linux-arm-kernel, devicetree, linux-sound, imx, linux-kernel
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Introduce the 'widgets' property, allowing the creation of widgets from
4 template widgets: Microphone, Line, Headphone, and Speaker. Also
introduce the 'hp-det-gpios' property, which allows using headphone
detection using the specified GPIO.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
.../devicetree/bindings/sound/audio-graph-card2.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml b/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
index f943f90d8b15..94588353f852 100644
--- a/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
+++ b/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
@@ -37,6 +37,10 @@ properties:
codec2codec:
type: object
description: Codec to Codec node
+ hp-det-gpios:
+ $ref: audio-graph.yaml#/properties/hp-det-gpios
+ widgets:
+ $ref: audio-graph.yaml#/properties/widgets
required:
- compatible
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 4/5] ASoC: SOF: imx: add driver for imx95
2024-11-13 19:52 [PATCH v2 0/5] add sof support on imx95 Laurentiu Mihalcea
` (2 preceding siblings ...)
2024-11-13 19:52 ` [PATCH v2 3/5] ASoC: dt-bindings: audio-graph-card2: add widgets and hp-det-gpios support Laurentiu Mihalcea
@ 2024-11-13 19:52 ` Laurentiu Mihalcea
2024-11-13 20:17 ` Frank Li
2024-11-13 19:52 ` [PATCH v2 5/5] arm64: dts: imx: add imx95 dts for sof Laurentiu Mihalcea
4 siblings, 1 reply; 20+ messages in thread
From: Laurentiu Mihalcea @ 2024-11-13 19:52 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, Frank Li
Cc: linux-arm-kernel, devicetree, linux-sound, imx, linux-kernel
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Add SOF driver for imx95.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
sound/soc/sof/imx/Kconfig | 8 +
sound/soc/sof/imx/Makefile | 2 +
sound/soc/sof/imx/imx95.c | 401 +++++++++++++++++++++++++++++++++++++
3 files changed, 411 insertions(+)
create mode 100644 sound/soc/sof/imx/imx95.c
diff --git a/sound/soc/sof/imx/Kconfig b/sound/soc/sof/imx/Kconfig
index 4751b04d5e6f..51a70a193533 100644
--- a/sound/soc/sof/imx/Kconfig
+++ b/sound/soc/sof/imx/Kconfig
@@ -50,4 +50,12 @@ config SND_SOC_SOF_IMX8ULP
Say Y if you have such a device.
If unsure select "N".
+config SND_SOC_SOF_IMX95
+ tristate "SOF support for i.MX95"
+ depends on IMX_DSP
+ help
+ This adds support for Sound Open Firmware for NXP i.MX95 platforms.
+ Say Y if you have such a device.
+ If unsure select "N".
+
endif ## SND_SOC_SOF_IMX_TOPLEVEL
diff --git a/sound/soc/sof/imx/Makefile b/sound/soc/sof/imx/Makefile
index be0bf0736dfa..715ac3798668 100644
--- a/sound/soc/sof/imx/Makefile
+++ b/sound/soc/sof/imx/Makefile
@@ -2,10 +2,12 @@
snd-sof-imx8-y := imx8.o
snd-sof-imx8m-y := imx8m.o
snd-sof-imx8ulp-y := imx8ulp.o
+snd-sof-imx95-y := imx95.o
snd-sof-imx-common-y := imx-common.o
obj-$(CONFIG_SND_SOC_SOF_IMX8) += snd-sof-imx8.o
obj-$(CONFIG_SND_SOC_SOF_IMX8M) += snd-sof-imx8m.o
obj-$(CONFIG_SND_SOC_SOF_IMX8ULP) += snd-sof-imx8ulp.o
+obj-$(CONFIG_SND_SOC_SOF_IMX95) += snd-sof-imx95.o
obj-$(CONFIG_SND_SOC_SOF_IMX_COMMON) += imx-common.o
diff --git a/sound/soc/sof/imx/imx95.c b/sound/soc/sof/imx/imx95.c
new file mode 100644
index 000000000000..5a0e44f5bd48
--- /dev/null
+++ b/sound/soc/sof/imx/imx95.c
@@ -0,0 +1,401 @@
+// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
+/*
+ * Copyright 2024 NXP
+ */
+
+#include <linux/arm-smccc.h>
+#include <linux/clk.h>
+#include <linux/firmware/imx/dsp.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/of_reserved_mem.h>
+#include <sound/sof.h>
+
+#include "../sof-of-dev.h"
+#include "../ops.h"
+
+#define IMX_SIP_SRC 0xC2000005
+#define IMX_SIP_SRC_M_RESET_ADDR_SET 0x03
+
+#define IMX95_CPU_VEC_FLAGS_BOOT BIT(29)
+
+#define IMX_SIP_LMM 0xC200000F
+#define IMX_SIP_LMM_BOOT 0x0
+#define IMX_SIP_LMM_SHUTDOWN 0x1
+
+#define IMX95_M7_LM_ID 0x1
+
+#define MBOX_DSPBOX_OFFSET 0x1000
+#define MBOX_WINDOW_OFFSET 0x6000000
+
+struct imx95_priv {
+ struct platform_device *ipc_dev;
+ struct imx_dsp_ipc *ipc_handle;
+ resource_size_t bootaddr;
+};
+
+static void imx95_ipc_handle_reply(struct imx_dsp_ipc *ipc)
+{
+ unsigned long flags;
+ struct snd_sof_dev *sdev = imx_dsp_get_data(ipc);
+
+ spin_lock_irqsave(&sdev->ipc_lock, flags);
+ snd_sof_ipc_process_reply(sdev, 0);
+ spin_unlock_irqrestore(&sdev->ipc_lock, flags);
+}
+
+static void imx95_ipc_handle_request(struct imx_dsp_ipc *ipc)
+{
+ snd_sof_ipc_msgs_rx(imx_dsp_get_data(ipc));
+}
+
+static struct imx_dsp_ops ipc_ops = {
+ .handle_reply = imx95_ipc_handle_reply,
+ .handle_request = imx95_ipc_handle_request,
+};
+
+static int imx95_disable_enable_core(bool enable)
+{
+ struct arm_smccc_res res;
+
+ if (enable)
+ arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_BOOT, IMX95_M7_LM_ID,
+ 0, 0, 0, 0, 0, &res);
+ else
+ arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_SHUTDOWN, IMX95_M7_LM_ID,
+ 0, 0, 0, 0, 0, &res);
+
+ return res.a0;
+}
+
+static int imx95_run(struct snd_sof_dev *sdev)
+{
+ return imx95_disable_enable_core(true);
+}
+
+static int imx95_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
+{
+ struct imx95_priv *priv = sdev->pdata->hw_pdata;
+
+ sof_mailbox_write(sdev, sdev->host_box.offset,
+ msg->msg_data, msg->msg_size);
+
+ imx_dsp_ring_doorbell(priv->ipc_handle, 0);
+
+ return 0;
+}
+
+static int imx95_get_mailbox_offset(struct snd_sof_dev *sdev)
+{
+ return MBOX_DSPBOX_OFFSET + MBOX_WINDOW_OFFSET;
+}
+
+static int imx95_get_bar_index(struct snd_sof_dev *sdev, u32 type)
+{
+ switch (type) {
+ case SOF_FW_BLK_TYPE_SRAM:
+ return type;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int imx95_get_window_offset(struct snd_sof_dev *sdev, u32 id)
+{
+ return MBOX_WINDOW_OFFSET;
+}
+
+static int imx95_set_power_state(struct snd_sof_dev *sdev,
+ const struct sof_dsp_power_state *target_state)
+{
+ sdev->dsp_power_state = *target_state;
+
+ return 0;
+}
+
+static int imx95_suspend_resume(struct snd_sof_dev *sdev, bool suspend)
+{
+ struct imx95_priv *priv;
+ int ret, i;
+
+ priv = sdev->pdata->hw_pdata;
+
+ if (suspend) {
+ ret = imx95_disable_enable_core(false);
+ if (ret) {
+ dev_err(sdev->dev, "failed to stop core\n");
+ return ret;
+ }
+ }
+
+ for (i = 0; i < DSP_MU_CHAN_NUM; i++) {
+ if (suspend)
+ imx_dsp_free_channel(priv->ipc_handle, i);
+ else
+ imx_dsp_request_channel(priv->ipc_handle, i);
+ }
+
+ return 0;
+}
+
+static int imx95_runtime_resume(struct snd_sof_dev *sdev)
+{
+ int ret;
+ const struct sof_dsp_power_state target_state = {
+ .state = SOF_DSP_PM_D0,
+ };
+
+ ret = imx95_suspend_resume(sdev, false);
+ if (ret < 0) {
+ dev_err(sdev->dev, "failed to runtime resume: %d\n", ret);
+ return ret;
+ }
+
+ return snd_sof_dsp_set_power_state(sdev, &target_state);
+}
+
+static int imx95_resume(struct snd_sof_dev *sdev)
+{
+ int ret;
+ const struct sof_dsp_power_state target_state = {
+ .state = SOF_DSP_PM_D0,
+ };
+
+ ret = imx95_suspend_resume(sdev, false);
+ if (ret < 0) {
+ dev_err(sdev->dev, "failed to resume: %d\n", ret);
+ return ret;
+ }
+
+ if (pm_runtime_suspended(sdev->dev)) {
+ pm_runtime_disable(sdev->dev);
+ pm_runtime_set_active(sdev->dev);
+ pm_runtime_mark_last_busy(sdev->dev);
+ pm_runtime_enable(sdev->dev);
+ pm_runtime_idle(sdev->dev);
+ }
+
+ return snd_sof_dsp_set_power_state(sdev, &target_state);
+}
+
+static int imx95_runtime_suspend(struct snd_sof_dev *sdev)
+{
+ int ret;
+ const struct sof_dsp_power_state target_state = {
+ .state = SOF_DSP_PM_D3,
+ };
+
+ ret = imx95_suspend_resume(sdev, true);
+ if (ret < 0) {
+ dev_err(sdev->dev, "failed to runtime suspend: %d\n", ret);
+ return ret;
+ }
+
+ return snd_sof_dsp_set_power_state(sdev, &target_state);
+}
+
+static int imx95_suspend(struct snd_sof_dev *sdev, unsigned int target_state)
+{
+ int ret;
+ const struct sof_dsp_power_state target_power_state = {
+ .state = target_state,
+ };
+
+ if (!pm_runtime_suspended(sdev->dev)) {
+ ret = imx95_suspend_resume(sdev, true);
+ if (ret < 0) {
+ dev_err(sdev->dev, "failed to suspend: %d\n", ret);
+ return ret;
+ }
+ }
+
+ return snd_sof_dsp_set_power_state(sdev, &target_power_state);
+}
+
+static struct snd_soc_dai_driver imx95_dai[] = {
+ {
+ .name = "sai3",
+ .playback = {
+ .channels_min = 1,
+ .channels_max = 32,
+ },
+ .capture = {
+ .channels_min = 1,
+ .channels_max = 32,
+ },
+ },
+};
+
+static int imx95_probe(struct snd_sof_dev *sdev)
+{
+ struct platform_device *pdev;
+ struct imx95_priv *priv;
+ struct resource *res;
+ struct arm_smccc_res smc_ret;
+ int ret;
+
+ pdev = container_of(sdev->dev, struct platform_device, dev);
+
+ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return dev_err_probe(&pdev->dev, -ENOMEM, "failed to alloc priv\n");
+
+ sdev->pdata->hw_pdata = priv;
+
+ /* map SRAM */
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return dev_err_probe(&pdev->dev, -ENODEV,
+ "failed to fetch SRAM region\n");
+
+ sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap(&pdev->dev, res->start,
+ resource_size(res));
+ if (IS_ERR(sdev->bar[SOF_FW_BLK_TYPE_SRAM]))
+ return dev_err_probe(&pdev->dev,
+ PTR_ERR(sdev->bar[SOF_FW_BLK_TYPE_SRAM]),
+ "failed to map SRAM region\n");
+
+ sdev->mmio_bar = SOF_FW_BLK_TYPE_SRAM;
+ sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM;
+ sdev->dsp_box.offset = MBOX_DSPBOX_OFFSET + MBOX_WINDOW_OFFSET;
+ priv->bootaddr = res->start;
+
+ ret = of_reserved_mem_device_init(sdev->dev);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "failed to bind DMA region\n");
+
+ priv->ipc_dev = platform_device_register_data(&pdev->dev, "imx-dsp",
+ PLATFORM_DEVID_NONE,
+ pdev, sizeof(*pdev));
+ if (IS_ERR(priv->ipc_dev))
+ return dev_err_probe(&pdev->dev, PTR_ERR(priv->ipc_dev),
+ "failed to create IPC device\n");
+
+ priv->ipc_handle = dev_get_drvdata(&priv->ipc_dev->dev);
+ if (!priv->ipc_handle) {
+ ret = -EPROBE_DEFER;
+ dev_err(&pdev->dev, "failed to fetch ipc handle\n");
+ goto err_unregister_ipc_dev;
+ }
+
+ priv->ipc_handle->ops = &ipc_ops;
+ imx_dsp_set_data(priv->ipc_handle, sdev);
+
+ /* set core boot reset address */
+ arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M_RESET_ADDR_SET, priv->bootaddr,
+ IMX95_CPU_VEC_FLAGS_BOOT, 0, 0, 0, 0, &smc_ret);
+ if ((int)smc_ret.a0 < 0) {
+ ret = smc_ret.a0;
+ dev_err(&pdev->dev, "failed to set boot address: %d", ret);
+ goto err_unregister_ipc_dev;
+ }
+
+ return 0;
+
+err_unregister_ipc_dev:
+ platform_device_unregister(priv->ipc_dev);
+
+ return ret;
+}
+
+static void imx95_remove(struct snd_sof_dev *sdev)
+{
+ struct imx95_priv *priv;
+
+ priv = sdev->pdata->hw_pdata;
+
+ if (imx95_disable_enable_core(false))
+ dev_err(sdev->dev, "failed to stop core\n");
+
+ platform_device_unregister(priv->ipc_dev);
+}
+
+static const struct snd_sof_dsp_ops sof_imx95_ops = {
+ .probe = imx95_probe,
+ .remove = imx95_remove,
+
+ /* mandatory "DSP" ops */
+ .run = imx95_run,
+ .block_read = sof_block_read,
+ .block_write = sof_block_write,
+ .send_msg = imx95_send_msg,
+ .load_firmware = snd_sof_load_firmware_memcpy,
+ .ipc_msg_data = sof_ipc_msg_data,
+
+ .mailbox_read = sof_mailbox_read,
+ .mailbox_write = sof_mailbox_write,
+
+ .get_mailbox_offset = imx95_get_mailbox_offset,
+ .get_bar_index = imx95_get_bar_index,
+ .get_window_offset = imx95_get_window_offset,
+
+ .pcm_open = sof_stream_pcm_open,
+ .pcm_close = sof_stream_pcm_close,
+ .set_stream_data_offset = sof_set_stream_data_offset,
+
+ .runtime_suspend = imx95_runtime_suspend,
+ .runtime_resume = imx95_runtime_resume,
+
+ .resume = imx95_resume,
+ .suspend = imx95_suspend,
+
+ .set_power_state = imx95_set_power_state,
+
+ .drv = imx95_dai,
+ .num_drv = ARRAY_SIZE(imx95_dai),
+
+ .hw_info = SNDRV_PCM_INFO_MMAP |
+ SNDRV_PCM_INFO_MMAP_VALID |
+ SNDRV_PCM_INFO_INTERLEAVED |
+ SNDRV_PCM_INFO_PAUSE |
+ SNDRV_PCM_INFO_BATCH |
+ SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
+};
+
+static struct snd_sof_of_mach sof_imx95_machs[] = {
+ {
+ .compatible = "fsl,imx95-19x19-evk",
+ .sof_tplg_filename = "sof-imx95-wm8962.tplg",
+ .drv_name = "asoc-audio-graph-card2",
+ },
+ {
+ },
+};
+
+static struct sof_dev_desc sof_of_imx95_desc = {
+ .of_machines = sof_imx95_machs,
+ .ipc_supported_mask = BIT(SOF_IPC_TYPE_3),
+ .ipc_default = SOF_IPC_TYPE_3,
+ .default_fw_path = {
+ [SOF_IPC_TYPE_3] = "imx/sof",
+ },
+ .default_tplg_path = {
+ [SOF_IPC_TYPE_3] = "imx/sof-tplg",
+ },
+ .default_fw_filename = {
+ [SOF_IPC_TYPE_3] = "sof-imx95.ri",
+ },
+ .ops = &sof_imx95_ops,
+};
+
+static const struct of_device_id sof_of_imx95_ids[] = {
+ { .compatible = "fsl,imx95-cm7-sof", .data = &sof_of_imx95_desc },
+ { },
+};
+MODULE_DEVICE_TABLE(of, sof_of_imx95_ids);
+
+static struct platform_driver snd_sof_of_imx95_driver = {
+ .probe = sof_of_probe,
+ .remove = sof_of_remove,
+ .driver = {
+ .name = "sof-audio-of-imx95",
+ .pm = &sof_of_pm,
+ .of_match_table = sof_of_imx95_ids,
+ },
+};
+module_platform_driver(snd_sof_of_imx95_driver);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("SOF support for i.MX95 platforms");
+MODULE_AUTHOR("Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>");
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 5/5] arm64: dts: imx: add imx95 dts for sof
2024-11-13 19:52 [PATCH v2 0/5] add sof support on imx95 Laurentiu Mihalcea
` (3 preceding siblings ...)
2024-11-13 19:52 ` [PATCH v2 4/5] ASoC: SOF: imx: add driver for imx95 Laurentiu Mihalcea
@ 2024-11-13 19:52 ` Laurentiu Mihalcea
2024-11-13 20:21 ` Frank Li
4 siblings, 1 reply; 20+ messages in thread
From: Laurentiu Mihalcea @ 2024-11-13 19:52 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, Frank Li
Cc: linux-arm-kernel, devicetree, linux-sound, imx, linux-kernel
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Add imx95 DTS for SOF usage.
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
arch/arm64/boot/dts/freescale/Makefile | 1 +
.../dts/freescale/imx95-19x19-evk-sof.dts | 74 +++++++++++++++++++
2 files changed, 75 insertions(+)
create mode 100644 arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts
diff --git a/arch/arm64/boot/dts/freescale/Makefile b/arch/arm64/boot/dts/freescale/Makefile
index 42e6482a31cb..0a313133d013 100644
--- a/arch/arm64/boot/dts/freescale/Makefile
+++ b/arch/arm64/boot/dts/freescale/Makefile
@@ -269,6 +269,7 @@ dtb-$(CONFIG_ARCH_MXC) += imx93-tqma9352-mba93xxca.dtb
dtb-$(CONFIG_ARCH_MXC) += imx93-tqma9352-mba93xxla.dtb
dtb-$(CONFIG_ARCH_MXC) += imx93-var-som-symphony.dtb
dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-evk.dtb
+dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-evk-sof.dtb
imx8mm-kontron-dl-dtbs := imx8mm-kontron-bl.dtb imx8mm-kontron-dl.dtbo
diff --git a/arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts b/arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts
new file mode 100644
index 000000000000..3fa4c252e355
--- /dev/null
+++ b/arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2024 NXP
+ */
+
+/dts-v1/;
+
+#include "imx95-19x19-evk.dts"
+
+/ {
+ reserved-memory {
+ adma_res: memory@86100000 {
+ compatible = "shared-dma-pool";
+ reg = <0x0 0x86100000 0x0 0x100000>;
+ no-map;
+ };
+ };
+
+ sound-wm8962 {
+ status = "disabled";
+ };
+
+ sof-sound-wm8962 {
+ compatible = "audio-graph-card2";
+ links = <&cpu>;
+ label = "wm8962-audio";
+ hp-det-gpios = <&gpio2 11 GPIO_ACTIVE_HIGH>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_hp>;
+ widgets =
+ "Headphone", "Headphones",
+ "Microphone", "Headset Mic";
+ routing =
+ "Headphones", "HPOUTL",
+ "Headphones", "HPOUTR",
+ "Headset Mic", "MICBIAS",
+ "IN3R", "Headset Mic",
+ "IN1R", "Headset Mic";
+ };
+
+ sof_cpu: cm7-cpu@80000000 {
+ compatible = "fsl,imx95-cm7-sof";
+ reg = <0x0 0x80000000 0x0 0x6100000>;
+ memory-region = <&adma_res>;
+ mboxes = <&mu7 2 0>, <&mu7 2 1>, <&mu7 3 0>, <&mu7 3 1>;
+ mbox-names = "txdb0", "txdb1", "rxdb0", "rxdb1";
+ cpu: port {
+ cpu_ep: endpoint { remote-endpoint = <&codec_ep>; };
+ };
+ };
+};
+
+&edma2 {
+ dma-channel-mask = <0xc0000000>, <0x0>;
+};
+
+&sai3 {
+ status = "disabled";
+};
+
+&wm8962 {
+ assigned-clocks = <&scmi_clk IMX95_CLK_AUDIOPLL1_VCO>,
+ <&scmi_clk IMX95_CLK_AUDIOPLL2_VCO>,
+ <&scmi_clk IMX95_CLK_AUDIOPLL1>,
+ <&scmi_clk IMX95_CLK_AUDIOPLL2>,
+ <&scmi_clk IMX95_CLK_SAI3>;
+ assigned-clock-parents = <0>, <0>, <0>, <0>, <&scmi_clk IMX95_CLK_AUDIOPLL1>;
+ assigned-clock-rates = <3932160000>, <3612672000>,
+ <393216000>, <361267200>,
+ <12288000>;
+ port {
+ codec_ep: endpoint { remote-endpoint = <&cpu_ep>; };
+ };
+};
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH v2 1/5] ASoC: dt-bindings: add common binding for NXP CPUs
2024-11-13 19:52 ` [PATCH v2 1/5] ASoC: dt-bindings: add common binding for NXP CPUs Laurentiu Mihalcea
@ 2024-11-13 20:03 ` Frank Li
2024-11-15 17:33 ` Rob Herring
0 siblings, 1 reply; 20+ messages in thread
From: Frank Li @ 2024-11-13 20:03 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
On Wed, Nov 13, 2024 at 02:52:36PM -0500, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Add common binding for NXP CPUs sharing the same programming
> model (i.e: audio processing with SOF).
Add binding for NXP audio processor with Sound Open Firmware (SOF) support.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> ---
> .../bindings/sound/fsl,sof-cpu.yaml | 35 +++++++++++++++++++
> 1 file changed, 35 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml
>
> diff --git a/Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml b/Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml
> new file mode 100644
> index 000000000000..6d63fcd71154
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml
> @@ -0,0 +1,35 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/sound/fsl,sof-cpu.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: NXP audio CPU common properties
audio processor?
> +
> +maintainers:
> + - Daniel Baluta <daniel.baluta@nxp.com>
> +
> +properties:
> + reg:
> + maxItems: 1
> +
> + mboxes:
> + maxItems: 4
> +
> + mbox-names:
> + items:
> + - const: txdb0
> + - const: txdb1
> + - const: rxdb0
> + - const: rxdb1
> +
> + memory-region:
> + maxItems: 1
> +
> +required:
> + - reg
> + - mboxes
> + - mbox-names
> + - memory-region
> +
> +additionalProperties: true
example ?
Frank
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 2/5] ASoC: dt-bindings: add binding for imx95's CM7 core
2024-11-13 19:52 ` [PATCH v2 2/5] ASoC: dt-bindings: add binding for imx95's CM7 core Laurentiu Mihalcea
@ 2024-11-13 20:07 ` Frank Li
0 siblings, 0 replies; 20+ messages in thread
From: Frank Li @ 2024-11-13 20:07 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
title needn't 'binding'.
Add imx95's CM7 core, which used for audio processing.
On Wed, Nov 13, 2024 at 02:52:37PM -0500, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Add binding for imx95's CM7 core.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> ---
> .../bindings/sound/fsl,imx95-cm7-sof.yaml | 44 +++++++++++++++++++
> 1 file changed, 44 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/sound/fsl,imx95-cm7-sof.yaml
>
> diff --git a/Documentation/devicetree/bindings/sound/fsl,imx95-cm7-sof.yaml b/Documentation/devicetree/bindings/sound/fsl,imx95-cm7-sof.yaml
> new file mode 100644
> index 000000000000..f11e03bbcaba
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/fsl,imx95-cm7-sof.yaml
> @@ -0,0 +1,44 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/sound/fsl,imx95-cm7-sof.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: NXP imx95 CM7 core
> +
> +maintainers:
> + - Daniel Baluta <daniel.baluta@nxp.com>
> +
> +description: NXP imx95 CM7 core used for audio processing
> +
> +allOf:
> + - $ref: fsl,sof-cpu.yaml#
> +
> +properties:
> + compatible:
> + const: fsl,imx95-cm7-sof
> +
> + port:
> + description: SAI3 port
> + $ref: audio-graph-port.yaml#
> + unevaluatedProperties: false
> +
> +required:
> + - compatible
> + - port
> +
> +unevaluatedProperties: false
> +
> +examples:
> + - |
> + cm7-cpu@80000000 {
> + compatible = "fsl,imx95-cm7-sof";
example dts align to 4 chars
> + reg = <0x80000000 0x6100000>;
> + mboxes = <&mu7 2 0>, <&mu7 2 1>, <&mu7 3 0>, <&mu7 3 1>;
> + mbox-names = "txdb0", "txdb1", "rxdb0", "rxdb1";
> + memory-region = <&adma_res>;
> + cpu: port {
> + /* SAI3-WM8962 link */
> + cpu_ep: endpoint { remote-endpoint = <&wm8962_ep>; };
> + };
needn't label cpu and cpu_ep here.
> + };
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/5] ASoC: dt-bindings: audio-graph-card2: add widgets and hp-det-gpios support
2024-11-13 19:52 ` [PATCH v2 3/5] ASoC: dt-bindings: audio-graph-card2: add widgets and hp-det-gpios support Laurentiu Mihalcea
@ 2024-11-13 20:11 ` Frank Li
2024-12-12 9:59 ` Laurentiu Mihalcea
0 siblings, 1 reply; 20+ messages in thread
From: Frank Li @ 2024-11-13 20:11 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
On Wed, Nov 13, 2024 at 02:52:38PM -0500, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Introduce the 'widgets' property, allowing the creation of widgets from
> 4 template widgets: Microphone, Line, Headphone, and Speaker. Also
> introduce the 'hp-det-gpios' property, which allows using headphone
> detection using the specified GPIO.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> ---
> .../devicetree/bindings/sound/audio-graph-card2.yaml | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml b/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
> index f943f90d8b15..94588353f852 100644
> --- a/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
> +++ b/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
> @@ -37,6 +37,10 @@ properties:
> codec2codec:
> type: object
> description: Codec to Codec node
> + hp-det-gpios:
> + $ref: audio-graph.yaml#/properties/hp-det-gpios
> + widgets:
> + $ref: audio-graph.yaml#/properties/widgets
why not direct ref Documentation/devicetree/bindings/sound/audio-graph.yaml
and define these again here.
Frank
>
> required:
> - compatible
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 4/5] ASoC: SOF: imx: add driver for imx95
2024-11-13 19:52 ` [PATCH v2 4/5] ASoC: SOF: imx: add driver for imx95 Laurentiu Mihalcea
@ 2024-11-13 20:17 ` Frank Li
2024-12-12 11:11 ` Laurentiu Mihalcea
0 siblings, 1 reply; 20+ messages in thread
From: Frank Li @ 2024-11-13 20:17 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
On Wed, Nov 13, 2024 at 02:52:39PM -0500, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Add SOF driver for imx95.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> ---
> sound/soc/sof/imx/Kconfig | 8 +
> sound/soc/sof/imx/Makefile | 2 +
> sound/soc/sof/imx/imx95.c | 401 +++++++++++++++++++++++++++++++++++++
why not reused exist one? look likes simular.
Frank
> 3 files changed, 411 insertions(+)
> create mode 100644 sound/soc/sof/imx/imx95.c
>
> diff --git a/sound/soc/sof/imx/Kconfig b/sound/soc/sof/imx/Kconfig
> index 4751b04d5e6f..51a70a193533 100644
> --- a/sound/soc/sof/imx/Kconfig
> +++ b/sound/soc/sof/imx/Kconfig
> @@ -50,4 +50,12 @@ config SND_SOC_SOF_IMX8ULP
> Say Y if you have such a device.
> If unsure select "N".
>
> +config SND_SOC_SOF_IMX95
> + tristate "SOF support for i.MX95"
> + depends on IMX_DSP
> + help
> + This adds support for Sound Open Firmware for NXP i.MX95 platforms.
> + Say Y if you have such a device.
> + If unsure select "N".
> +
> endif ## SND_SOC_SOF_IMX_TOPLEVEL
> diff --git a/sound/soc/sof/imx/Makefile b/sound/soc/sof/imx/Makefile
> index be0bf0736dfa..715ac3798668 100644
> --- a/sound/soc/sof/imx/Makefile
> +++ b/sound/soc/sof/imx/Makefile
> @@ -2,10 +2,12 @@
> snd-sof-imx8-y := imx8.o
> snd-sof-imx8m-y := imx8m.o
> snd-sof-imx8ulp-y := imx8ulp.o
> +snd-sof-imx95-y := imx95.o
>
> snd-sof-imx-common-y := imx-common.o
>
> obj-$(CONFIG_SND_SOC_SOF_IMX8) += snd-sof-imx8.o
> obj-$(CONFIG_SND_SOC_SOF_IMX8M) += snd-sof-imx8m.o
> obj-$(CONFIG_SND_SOC_SOF_IMX8ULP) += snd-sof-imx8ulp.o
> +obj-$(CONFIG_SND_SOC_SOF_IMX95) += snd-sof-imx95.o
> obj-$(CONFIG_SND_SOC_SOF_IMX_COMMON) += imx-common.o
> diff --git a/sound/soc/sof/imx/imx95.c b/sound/soc/sof/imx/imx95.c
> new file mode 100644
> index 000000000000..5a0e44f5bd48
> --- /dev/null
> +++ b/sound/soc/sof/imx/imx95.c
> @@ -0,0 +1,401 @@
> +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
> +/*
> + * Copyright 2024 NXP
> + */
> +
> +#include <linux/arm-smccc.h>
> +#include <linux/clk.h>
> +#include <linux/firmware/imx/dsp.h>
> +#include <linux/module.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_reserved_mem.h>
> +#include <sound/sof.h>
> +
> +#include "../sof-of-dev.h"
> +#include "../ops.h"
> +
> +#define IMX_SIP_SRC 0xC2000005
> +#define IMX_SIP_SRC_M_RESET_ADDR_SET 0x03
> +
> +#define IMX95_CPU_VEC_FLAGS_BOOT BIT(29)
> +
> +#define IMX_SIP_LMM 0xC200000F
> +#define IMX_SIP_LMM_BOOT 0x0
> +#define IMX_SIP_LMM_SHUTDOWN 0x1
> +
> +#define IMX95_M7_LM_ID 0x1
> +
> +#define MBOX_DSPBOX_OFFSET 0x1000
> +#define MBOX_WINDOW_OFFSET 0x6000000
> +
> +struct imx95_priv {
> + struct platform_device *ipc_dev;
> + struct imx_dsp_ipc *ipc_handle;
> + resource_size_t bootaddr;
> +};
> +
> +static void imx95_ipc_handle_reply(struct imx_dsp_ipc *ipc)
> +{
> + unsigned long flags;
> + struct snd_sof_dev *sdev = imx_dsp_get_data(ipc);
> +
> + spin_lock_irqsave(&sdev->ipc_lock, flags);
> + snd_sof_ipc_process_reply(sdev, 0);
> + spin_unlock_irqrestore(&sdev->ipc_lock, flags);
> +}
> +
> +static void imx95_ipc_handle_request(struct imx_dsp_ipc *ipc)
> +{
> + snd_sof_ipc_msgs_rx(imx_dsp_get_data(ipc));
> +}
> +
> +static struct imx_dsp_ops ipc_ops = {
> + .handle_reply = imx95_ipc_handle_reply,
> + .handle_request = imx95_ipc_handle_request,
> +};
> +
> +static int imx95_disable_enable_core(bool enable)
> +{
> + struct arm_smccc_res res;
> +
> + if (enable)
> + arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_BOOT, IMX95_M7_LM_ID,
> + 0, 0, 0, 0, 0, &res);
> + else
> + arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_SHUTDOWN, IMX95_M7_LM_ID,
> + 0, 0, 0, 0, 0, &res);
> +
> + return res.a0;
> +}
> +
> +static int imx95_run(struct snd_sof_dev *sdev)
> +{
> + return imx95_disable_enable_core(true);
> +}
> +
> +static int imx95_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
> +{
> + struct imx95_priv *priv = sdev->pdata->hw_pdata;
> +
> + sof_mailbox_write(sdev, sdev->host_box.offset,
> + msg->msg_data, msg->msg_size);
> +
> + imx_dsp_ring_doorbell(priv->ipc_handle, 0);
> +
> + return 0;
> +}
> +
> +static int imx95_get_mailbox_offset(struct snd_sof_dev *sdev)
> +{
> + return MBOX_DSPBOX_OFFSET + MBOX_WINDOW_OFFSET;
> +}
> +
> +static int imx95_get_bar_index(struct snd_sof_dev *sdev, u32 type)
> +{
> + switch (type) {
> + case SOF_FW_BLK_TYPE_SRAM:
> + return type;
> + default:
> + return -EINVAL;
> + }
> +}
> +
> +static int imx95_get_window_offset(struct snd_sof_dev *sdev, u32 id)
> +{
> + return MBOX_WINDOW_OFFSET;
> +}
> +
> +static int imx95_set_power_state(struct snd_sof_dev *sdev,
> + const struct sof_dsp_power_state *target_state)
> +{
> + sdev->dsp_power_state = *target_state;
> +
> + return 0;
> +}
> +
> +static int imx95_suspend_resume(struct snd_sof_dev *sdev, bool suspend)
> +{
> + struct imx95_priv *priv;
> + int ret, i;
> +
> + priv = sdev->pdata->hw_pdata;
> +
> + if (suspend) {
> + ret = imx95_disable_enable_core(false);
> + if (ret) {
> + dev_err(sdev->dev, "failed to stop core\n");
> + return ret;
> + }
> + }
> +
> + for (i = 0; i < DSP_MU_CHAN_NUM; i++) {
> + if (suspend)
> + imx_dsp_free_channel(priv->ipc_handle, i);
> + else
> + imx_dsp_request_channel(priv->ipc_handle, i);
> + }
> +
> + return 0;
> +}
> +
> +static int imx95_runtime_resume(struct snd_sof_dev *sdev)
> +{
> + int ret;
> + const struct sof_dsp_power_state target_state = {
> + .state = SOF_DSP_PM_D0,
> + };
> +
> + ret = imx95_suspend_resume(sdev, false);
> + if (ret < 0) {
> + dev_err(sdev->dev, "failed to runtime resume: %d\n", ret);
> + return ret;
> + }
> +
> + return snd_sof_dsp_set_power_state(sdev, &target_state);
> +}
> +
> +static int imx95_resume(struct snd_sof_dev *sdev)
> +{
> + int ret;
> + const struct sof_dsp_power_state target_state = {
> + .state = SOF_DSP_PM_D0,
> + };
> +
> + ret = imx95_suspend_resume(sdev, false);
> + if (ret < 0) {
> + dev_err(sdev->dev, "failed to resume: %d\n", ret);
> + return ret;
> + }
> +
> + if (pm_runtime_suspended(sdev->dev)) {
> + pm_runtime_disable(sdev->dev);
> + pm_runtime_set_active(sdev->dev);
> + pm_runtime_mark_last_busy(sdev->dev);
> + pm_runtime_enable(sdev->dev);
> + pm_runtime_idle(sdev->dev);
> + }
> +
> + return snd_sof_dsp_set_power_state(sdev, &target_state);
> +}
> +
> +static int imx95_runtime_suspend(struct snd_sof_dev *sdev)
> +{
> + int ret;
> + const struct sof_dsp_power_state target_state = {
> + .state = SOF_DSP_PM_D3,
> + };
> +
> + ret = imx95_suspend_resume(sdev, true);
> + if (ret < 0) {
> + dev_err(sdev->dev, "failed to runtime suspend: %d\n", ret);
> + return ret;
> + }
> +
> + return snd_sof_dsp_set_power_state(sdev, &target_state);
> +}
> +
> +static int imx95_suspend(struct snd_sof_dev *sdev, unsigned int target_state)
> +{
> + int ret;
> + const struct sof_dsp_power_state target_power_state = {
> + .state = target_state,
> + };
> +
> + if (!pm_runtime_suspended(sdev->dev)) {
> + ret = imx95_suspend_resume(sdev, true);
> + if (ret < 0) {
> + dev_err(sdev->dev, "failed to suspend: %d\n", ret);
> + return ret;
> + }
> + }
> +
> + return snd_sof_dsp_set_power_state(sdev, &target_power_state);
> +}
> +
> +static struct snd_soc_dai_driver imx95_dai[] = {
> + {
> + .name = "sai3",
> + .playback = {
> + .channels_min = 1,
> + .channels_max = 32,
> + },
> + .capture = {
> + .channels_min = 1,
> + .channels_max = 32,
> + },
> + },
> +};
> +
> +static int imx95_probe(struct snd_sof_dev *sdev)
> +{
> + struct platform_device *pdev;
> + struct imx95_priv *priv;
> + struct resource *res;
> + struct arm_smccc_res smc_ret;
> + int ret;
> +
> + pdev = container_of(sdev->dev, struct platform_device, dev);
> +
> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return dev_err_probe(&pdev->dev, -ENOMEM, "failed to alloc priv\n");
> +
> + sdev->pdata->hw_pdata = priv;
> +
> + /* map SRAM */
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res)
> + return dev_err_probe(&pdev->dev, -ENODEV,
> + "failed to fetch SRAM region\n");
> +
> + sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap(&pdev->dev, res->start,
> + resource_size(res));
> + if (IS_ERR(sdev->bar[SOF_FW_BLK_TYPE_SRAM]))
> + return dev_err_probe(&pdev->dev,
> + PTR_ERR(sdev->bar[SOF_FW_BLK_TYPE_SRAM]),
> + "failed to map SRAM region\n");
> +
> + sdev->mmio_bar = SOF_FW_BLK_TYPE_SRAM;
> + sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM;
> + sdev->dsp_box.offset = MBOX_DSPBOX_OFFSET + MBOX_WINDOW_OFFSET;
> + priv->bootaddr = res->start;
> +
> + ret = of_reserved_mem_device_init(sdev->dev);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "failed to bind DMA region\n");
> +
> + priv->ipc_dev = platform_device_register_data(&pdev->dev, "imx-dsp",
> + PLATFORM_DEVID_NONE,
> + pdev, sizeof(*pdev));
> + if (IS_ERR(priv->ipc_dev))
> + return dev_err_probe(&pdev->dev, PTR_ERR(priv->ipc_dev),
> + "failed to create IPC device\n");
> +
> + priv->ipc_handle = dev_get_drvdata(&priv->ipc_dev->dev);
> + if (!priv->ipc_handle) {
> + ret = -EPROBE_DEFER;
> + dev_err(&pdev->dev, "failed to fetch ipc handle\n");
> + goto err_unregister_ipc_dev;
> + }
> +
> + priv->ipc_handle->ops = &ipc_ops;
> + imx_dsp_set_data(priv->ipc_handle, sdev);
> +
> + /* set core boot reset address */
> + arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M_RESET_ADDR_SET, priv->bootaddr,
> + IMX95_CPU_VEC_FLAGS_BOOT, 0, 0, 0, 0, &smc_ret);
> + if ((int)smc_ret.a0 < 0) {
> + ret = smc_ret.a0;
> + dev_err(&pdev->dev, "failed to set boot address: %d", ret);
> + goto err_unregister_ipc_dev;
> + }
> +
> + return 0;
> +
> +err_unregister_ipc_dev:
> + platform_device_unregister(priv->ipc_dev);
> +
> + return ret;
> +}
> +
> +static void imx95_remove(struct snd_sof_dev *sdev)
> +{
> + struct imx95_priv *priv;
> +
> + priv = sdev->pdata->hw_pdata;
> +
> + if (imx95_disable_enable_core(false))
> + dev_err(sdev->dev, "failed to stop core\n");
> +
> + platform_device_unregister(priv->ipc_dev);
> +}
> +
> +static const struct snd_sof_dsp_ops sof_imx95_ops = {
> + .probe = imx95_probe,
> + .remove = imx95_remove,
> +
> + /* mandatory "DSP" ops */
> + .run = imx95_run,
> + .block_read = sof_block_read,
> + .block_write = sof_block_write,
> + .send_msg = imx95_send_msg,
> + .load_firmware = snd_sof_load_firmware_memcpy,
> + .ipc_msg_data = sof_ipc_msg_data,
> +
> + .mailbox_read = sof_mailbox_read,
> + .mailbox_write = sof_mailbox_write,
> +
> + .get_mailbox_offset = imx95_get_mailbox_offset,
> + .get_bar_index = imx95_get_bar_index,
> + .get_window_offset = imx95_get_window_offset,
> +
> + .pcm_open = sof_stream_pcm_open,
> + .pcm_close = sof_stream_pcm_close,
> + .set_stream_data_offset = sof_set_stream_data_offset,
> +
> + .runtime_suspend = imx95_runtime_suspend,
> + .runtime_resume = imx95_runtime_resume,
> +
> + .resume = imx95_resume,
> + .suspend = imx95_suspend,
> +
> + .set_power_state = imx95_set_power_state,
> +
> + .drv = imx95_dai,
> + .num_drv = ARRAY_SIZE(imx95_dai),
> +
> + .hw_info = SNDRV_PCM_INFO_MMAP |
> + SNDRV_PCM_INFO_MMAP_VALID |
> + SNDRV_PCM_INFO_INTERLEAVED |
> + SNDRV_PCM_INFO_PAUSE |
> + SNDRV_PCM_INFO_BATCH |
> + SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
> +};
> +
> +static struct snd_sof_of_mach sof_imx95_machs[] = {
> + {
> + .compatible = "fsl,imx95-19x19-evk",
> + .sof_tplg_filename = "sof-imx95-wm8962.tplg",
> + .drv_name = "asoc-audio-graph-card2",
> + },
> + {
> + },
> +};
> +
> +static struct sof_dev_desc sof_of_imx95_desc = {
> + .of_machines = sof_imx95_machs,
> + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3),
> + .ipc_default = SOF_IPC_TYPE_3,
> + .default_fw_path = {
> + [SOF_IPC_TYPE_3] = "imx/sof",
> + },
> + .default_tplg_path = {
> + [SOF_IPC_TYPE_3] = "imx/sof-tplg",
> + },
> + .default_fw_filename = {
> + [SOF_IPC_TYPE_3] = "sof-imx95.ri",
> + },
> + .ops = &sof_imx95_ops,
> +};
> +
> +static const struct of_device_id sof_of_imx95_ids[] = {
> + { .compatible = "fsl,imx95-cm7-sof", .data = &sof_of_imx95_desc },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, sof_of_imx95_ids);
> +
> +static struct platform_driver snd_sof_of_imx95_driver = {
> + .probe = sof_of_probe,
> + .remove = sof_of_remove,
> + .driver = {
> + .name = "sof-audio-of-imx95",
> + .pm = &sof_of_pm,
> + .of_match_table = sof_of_imx95_ids,
> + },
> +};
> +module_platform_driver(snd_sof_of_imx95_driver);
> +
> +MODULE_LICENSE("Dual BSD/GPL");
> +MODULE_DESCRIPTION("SOF support for i.MX95 platforms");
> +MODULE_AUTHOR("Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>");
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 5/5] arm64: dts: imx: add imx95 dts for sof
2024-11-13 19:52 ` [PATCH v2 5/5] arm64: dts: imx: add imx95 dts for sof Laurentiu Mihalcea
@ 2024-11-13 20:21 ` Frank Li
2024-12-12 10:04 ` Laurentiu Mihalcea
0 siblings, 1 reply; 20+ messages in thread
From: Frank Li @ 2024-11-13 20:21 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
On Wed, Nov 13, 2024 at 02:52:40PM -0500, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Add imx95 DTS for SOF usage.
>
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> ---
> arch/arm64/boot/dts/freescale/Makefile | 1 +
> .../dts/freescale/imx95-19x19-evk-sof.dts | 74 +++++++++++++++++++
look like it should be dt overlay.
> 2 files changed, 75 insertions(+)
> create mode 100644 arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts
>
> diff --git a/arch/arm64/boot/dts/freescale/Makefile b/arch/arm64/boot/dts/freescale/Makefile
> index 42e6482a31cb..0a313133d013 100644
> --- a/arch/arm64/boot/dts/freescale/Makefile
> +++ b/arch/arm64/boot/dts/freescale/Makefile
> @@ -269,6 +269,7 @@ dtb-$(CONFIG_ARCH_MXC) += imx93-tqma9352-mba93xxca.dtb
> dtb-$(CONFIG_ARCH_MXC) += imx93-tqma9352-mba93xxla.dtb
> dtb-$(CONFIG_ARCH_MXC) += imx93-var-som-symphony.dtb
> dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-evk.dtb
> +dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-evk-sof.dtb
>
> imx8mm-kontron-dl-dtbs := imx8mm-kontron-bl.dtb imx8mm-kontron-dl.dtbo
>
> diff --git a/arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts b/arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts
> new file mode 100644
> index 000000000000..3fa4c252e355
> --- /dev/null
> +++ b/arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts
> @@ -0,0 +1,74 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +/*
> + * Copyright 2024 NXP
> + */
> +
> +/dts-v1/;
> +
> +#include "imx95-19x19-evk.dts"
> +
> +/ {
> + reserved-memory {
> + adma_res: memory@86100000 {
> + compatible = "shared-dma-pool";
> + reg = <0x0 0x86100000 0x0 0x100000>;
> + no-map;
> + };
> + };
> +
> + sound-wm8962 {
> + status = "disabled";
> + };
> +
> + sof-sound-wm8962 {
> + compatible = "audio-graph-card2";
> + links = <&cpu>;
> + label = "wm8962-audio";
> + hp-det-gpios = <&gpio2 11 GPIO_ACTIVE_HIGH>;
> + pinctrl-names = "default";
> + pinctrl-0 = <&pinctrl_hp>;
> + widgets =
> + "Headphone", "Headphones",
> + "Microphone", "Headset Mic";
> + routing =
> + "Headphones", "HPOUTL",
> + "Headphones", "HPOUTR",
> + "Headset Mic", "MICBIAS",
> + "IN3R", "Headset Mic",
> + "IN1R", "Headset Mic";
> + };
> +
> + sof_cpu: cm7-cpu@80000000 {
> + compatible = "fsl,imx95-cm7-sof";
> + reg = <0x0 0x80000000 0x0 0x6100000>;
> + memory-region = <&adma_res>;
> + mboxes = <&mu7 2 0>, <&mu7 2 1>, <&mu7 3 0>, <&mu7 3 1>;
> + mbox-names = "txdb0", "txdb1", "rxdb0", "rxdb1";
> + cpu: port {
> + cpu_ep: endpoint { remote-endpoint = <&codec_ep>; };
> + };
> + };
please sort by node name.
> +};
> +
> +&edma2 {
> + dma-channel-mask = <0xc0000000>, <0x0>;
> +};
Why need change dma mask here ?
> +
> +&sai3 {
> + status = "disabled";
> +};
> +
> +&wm8962 {
> + assigned-clocks = <&scmi_clk IMX95_CLK_AUDIOPLL1_VCO>,
> + <&scmi_clk IMX95_CLK_AUDIOPLL2_VCO>,
> + <&scmi_clk IMX95_CLK_AUDIOPLL1>,
> + <&scmi_clk IMX95_CLK_AUDIOPLL2>,
> + <&scmi_clk IMX95_CLK_SAI3>;
> + assigned-clock-parents = <0>, <0>, <0>, <0>, <&scmi_clk IMX95_CLK_AUDIOPLL1>;
> + assigned-clock-rates = <3932160000>, <3612672000>,
> + <393216000>, <361267200>,
> + <12288000>;
> + port {
> + codec_ep: endpoint { remote-endpoint = <&cpu_ep>; };
> + };
> +};
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 1/5] ASoC: dt-bindings: add common binding for NXP CPUs
2024-11-13 20:03 ` Frank Li
@ 2024-11-15 17:33 ` Rob Herring
0 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2024-11-15 17:33 UTC (permalink / raw)
To: Frank Li
Cc: Laurentiu Mihalcea, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
On Wed, Nov 13, 2024 at 03:03:06PM -0500, Frank Li wrote:
> On Wed, Nov 13, 2024 at 02:52:36PM -0500, Laurentiu Mihalcea wrote:
> > From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> >
> > Add common binding for NXP CPUs sharing the same programming
> > model (i.e: audio processing with SOF).
>
> Add binding for NXP audio processor with Sound Open Firmware (SOF) support.
>
> >
> > Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> > ---
> > .../bindings/sound/fsl,sof-cpu.yaml | 35 +++++++++++++++++++
> > 1 file changed, 35 insertions(+)
> > create mode 100644 Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml b/Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml
> > new file mode 100644
> > index 000000000000..6d63fcd71154
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/sound/fsl,sof-cpu.yaml
> > @@ -0,0 +1,35 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/sound/fsl,sof-cpu.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: NXP audio CPU common properties
>
> audio processor?
>
> > +
> > +maintainers:
> > + - Daniel Baluta <daniel.baluta@nxp.com>
> > +
> > +properties:
> > + reg:
> > + maxItems: 1
> > +
> > + mboxes:
> > + maxItems: 4
> > +
> > + mbox-names:
> > + items:
> > + - const: txdb0
> > + - const: txdb1
> > + - const: rxdb0
> > + - const: rxdb1
> > +
> > + memory-region:
> > + maxItems: 1
> > +
> > +required:
> > + - reg
> > + - mboxes
> > + - mbox-names
> > + - memory-region
> > +
> > +additionalProperties: true
>
> example ?
Common bindings generally don't have one.
Rob
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/5] ASoC: dt-bindings: audio-graph-card2: add widgets and hp-det-gpios support
2024-11-13 20:11 ` Frank Li
@ 2024-12-12 9:59 ` Laurentiu Mihalcea
2024-12-13 0:40 ` Kuninori Morimoto
0 siblings, 1 reply; 20+ messages in thread
From: Laurentiu Mihalcea @ 2024-12-12 9:59 UTC (permalink / raw)
To: Frank Li
Cc: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
On 11/13/2024 10:11 PM, Frank Li wrote:
> On Wed, Nov 13, 2024 at 02:52:38PM -0500, Laurentiu Mihalcea wrote:
>> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>>
>> Introduce the 'widgets' property, allowing the creation of widgets from
>> 4 template widgets: Microphone, Line, Headphone, and Speaker. Also
>> introduce the 'hp-det-gpios' property, which allows using headphone
>> detection using the specified GPIO.
>>
>> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>> ---
>> .../devicetree/bindings/sound/audio-graph-card2.yaml | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml b/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
>> index f943f90d8b15..94588353f852 100644
>> --- a/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
>> +++ b/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
>> @@ -37,6 +37,10 @@ properties:
>> codec2codec:
>> type: object
>> description: Codec to Codec node
>> + hp-det-gpios:
>> + $ref: audio-graph.yaml#/properties/hp-det-gpios
>> + widgets:
>> + $ref: audio-graph.yaml#/properties/widgets
> why not direct ref Documentation/devicetree/bindings/sound/audio-graph.yaml
> and define these again here.
We don't actually want all the properties from 'audio-graph.yaml' (for the moment at least). Also ref-ing 'audio-graph.yaml' will make the 'dais' property required, which is not targeted in this patch. Maybe Kuninori Morimoto can comment more on this.
>
> Frank
>
>> required:
>> - compatible
>> --
>> 2.34.1
>>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 5/5] arm64: dts: imx: add imx95 dts for sof
2024-11-13 20:21 ` Frank Li
@ 2024-12-12 10:04 ` Laurentiu Mihalcea
0 siblings, 0 replies; 20+ messages in thread
From: Laurentiu Mihalcea @ 2024-12-12 10:04 UTC (permalink / raw)
To: Frank Li
Cc: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
On 11/13/2024 10:21 PM, Frank Li wrote:
> On Wed, Nov 13, 2024 at 02:52:40PM -0500, Laurentiu Mihalcea wrote:
>> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>>
>> Add imx95 DTS for SOF usage.
>>
>> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>> ---
>> arch/arm64/boot/dts/freescale/Makefile | 1 +
>> .../dts/freescale/imx95-19x19-evk-sof.dts | 74 +++++++++++++++++++
> look like it should be dt overlay.
ah, interesting idea, but I don't really see its usage here? As far as I was able to understand the overlays are used to dynamically change the DTB (via u-boot), which we don't really need at the moment.
>
>> 2 files changed, 75 insertions(+)
>> create mode 100644 arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts
>>
>> diff --git a/arch/arm64/boot/dts/freescale/Makefile b/arch/arm64/boot/dts/freescale/Makefile
>> index 42e6482a31cb..0a313133d013 100644
>> --- a/arch/arm64/boot/dts/freescale/Makefile
>> +++ b/arch/arm64/boot/dts/freescale/Makefile
>> @@ -269,6 +269,7 @@ dtb-$(CONFIG_ARCH_MXC) += imx93-tqma9352-mba93xxca.dtb
>> dtb-$(CONFIG_ARCH_MXC) += imx93-tqma9352-mba93xxla.dtb
>> dtb-$(CONFIG_ARCH_MXC) += imx93-var-som-symphony.dtb
>> dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-evk.dtb
>> +dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-evk-sof.dtb
>>
>> imx8mm-kontron-dl-dtbs := imx8mm-kontron-bl.dtb imx8mm-kontron-dl.dtbo
>>
>> diff --git a/arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts b/arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts
>> new file mode 100644
>> index 000000000000..3fa4c252e355
>> --- /dev/null
>> +++ b/arch/arm64/boot/dts/freescale/imx95-19x19-evk-sof.dts
>> @@ -0,0 +1,74 @@
>> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
>> +/*
>> + * Copyright 2024 NXP
>> + */
>> +
>> +/dts-v1/;
>> +
>> +#include "imx95-19x19-evk.dts"
>> +
>> +/ {
>> + reserved-memory {
>> + adma_res: memory@86100000 {
>> + compatible = "shared-dma-pool";
>> + reg = <0x0 0x86100000 0x0 0x100000>;
>> + no-map;
>> + };
>> + };
>> +
>> + sound-wm8962 {
>> + status = "disabled";
>> + };
>> +
>> + sof-sound-wm8962 {
>> + compatible = "audio-graph-card2";
>> + links = <&cpu>;
>> + label = "wm8962-audio";
>> + hp-det-gpios = <&gpio2 11 GPIO_ACTIVE_HIGH>;
>> + pinctrl-names = "default";
>> + pinctrl-0 = <&pinctrl_hp>;
>> + widgets =
>> + "Headphone", "Headphones",
>> + "Microphone", "Headset Mic";
>> + routing =
>> + "Headphones", "HPOUTL",
>> + "Headphones", "HPOUTR",
>> + "Headset Mic", "MICBIAS",
>> + "IN3R", "Headset Mic",
>> + "IN1R", "Headset Mic";
>> + };
>> +
>> + sof_cpu: cm7-cpu@80000000 {
>> + compatible = "fsl,imx95-cm7-sof";
>> + reg = <0x0 0x80000000 0x0 0x6100000>;
>> + memory-region = <&adma_res>;
>> + mboxes = <&mu7 2 0>, <&mu7 2 1>, <&mu7 3 0>, <&mu7 3 1>;
>> + mbox-names = "txdb0", "txdb1", "rxdb0", "rxdb1";
>> + cpu: port {
>> + cpu_ep: endpoint { remote-endpoint = <&codec_ep>; };
>> + };
>> + };
> please sort by node name.
Fix in v3
>
>> +};
>> +
>> +&edma2 {
>> + dma-channel-mask = <0xc0000000>, <0x0>;
>> +};
> Why need change dma mask here ?
Channels 30 and 31 are reserved for firmware usage
>
>> +
>> +&sai3 {
>> + status = "disabled";
>> +};
>> +
>> +&wm8962 {
>> + assigned-clocks = <&scmi_clk IMX95_CLK_AUDIOPLL1_VCO>,
>> + <&scmi_clk IMX95_CLK_AUDIOPLL2_VCO>,
>> + <&scmi_clk IMX95_CLK_AUDIOPLL1>,
>> + <&scmi_clk IMX95_CLK_AUDIOPLL2>,
>> + <&scmi_clk IMX95_CLK_SAI3>;
>> + assigned-clock-parents = <0>, <0>, <0>, <0>, <&scmi_clk IMX95_CLK_AUDIOPLL1>;
>> + assigned-clock-rates = <3932160000>, <3612672000>,
>> + <393216000>, <361267200>,
>> + <12288000>;
>> + port {
>> + codec_ep: endpoint { remote-endpoint = <&cpu_ep>; };
>> + };
>> +};
>> --
>> 2.34.1
>>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 4/5] ASoC: SOF: imx: add driver for imx95
2024-11-13 20:17 ` Frank Li
@ 2024-12-12 11:11 ` Laurentiu Mihalcea
2024-12-12 15:13 ` Frank Li
0 siblings, 1 reply; 20+ messages in thread
From: Laurentiu Mihalcea @ 2024-12-12 11:11 UTC (permalink / raw)
To: Frank Li
Cc: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
On 11/13/2024 10:17 PM, Frank Li wrote:
> On Wed, Nov 13, 2024 at 02:52:39PM -0500, Laurentiu Mihalcea wrote:
>> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>>
>> Add SOF driver for imx95.
>>
>> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>> ---
>> sound/soc/sof/imx/Kconfig | 8 +
>> sound/soc/sof/imx/Makefile | 2 +
>> sound/soc/sof/imx/imx95.c | 401 +++++++++++++++++++++++++++++++++++++
> why not reused exist one? look likes simular.
>
> Frank
the SOF drivers do indeed have some similarities, but each of them has their own quirks which IMO makes it a bit harder to add the 95 support. We need to figure out the common parts and then move them to imx-common, but I believe this can be solved incrementally.
>
>> 3 files changed, 411 insertions(+)
>> create mode 100644 sound/soc/sof/imx/imx95.c
>>
>> diff --git a/sound/soc/sof/imx/Kconfig b/sound/soc/sof/imx/Kconfig
>> index 4751b04d5e6f..51a70a193533 100644
>> --- a/sound/soc/sof/imx/Kconfig
>> +++ b/sound/soc/sof/imx/Kconfig
>> @@ -50,4 +50,12 @@ config SND_SOC_SOF_IMX8ULP
>> Say Y if you have such a device.
>> If unsure select "N".
>>
>> +config SND_SOC_SOF_IMX95
>> + tristate "SOF support for i.MX95"
>> + depends on IMX_DSP
>> + help
>> + This adds support for Sound Open Firmware for NXP i.MX95 platforms.
>> + Say Y if you have such a device.
>> + If unsure select "N".
>> +
>> endif ## SND_SOC_SOF_IMX_TOPLEVEL
>> diff --git a/sound/soc/sof/imx/Makefile b/sound/soc/sof/imx/Makefile
>> index be0bf0736dfa..715ac3798668 100644
>> --- a/sound/soc/sof/imx/Makefile
>> +++ b/sound/soc/sof/imx/Makefile
>> @@ -2,10 +2,12 @@
>> snd-sof-imx8-y := imx8.o
>> snd-sof-imx8m-y := imx8m.o
>> snd-sof-imx8ulp-y := imx8ulp.o
>> +snd-sof-imx95-y := imx95.o
>>
>> snd-sof-imx-common-y := imx-common.o
>>
>> obj-$(CONFIG_SND_SOC_SOF_IMX8) += snd-sof-imx8.o
>> obj-$(CONFIG_SND_SOC_SOF_IMX8M) += snd-sof-imx8m.o
>> obj-$(CONFIG_SND_SOC_SOF_IMX8ULP) += snd-sof-imx8ulp.o
>> +obj-$(CONFIG_SND_SOC_SOF_IMX95) += snd-sof-imx95.o
>> obj-$(CONFIG_SND_SOC_SOF_IMX_COMMON) += imx-common.o
>> diff --git a/sound/soc/sof/imx/imx95.c b/sound/soc/sof/imx/imx95.c
>> new file mode 100644
>> index 000000000000..5a0e44f5bd48
>> --- /dev/null
>> +++ b/sound/soc/sof/imx/imx95.c
>> @@ -0,0 +1,401 @@
>> +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
>> +/*
>> + * Copyright 2024 NXP
>> + */
>> +
>> +#include <linux/arm-smccc.h>
>> +#include <linux/clk.h>
>> +#include <linux/firmware/imx/dsp.h>
>> +#include <linux/module.h>
>> +#include <linux/of_platform.h>
>> +#include <linux/of_reserved_mem.h>
>> +#include <sound/sof.h>
>> +
>> +#include "../sof-of-dev.h"
>> +#include "../ops.h"
>> +
>> +#define IMX_SIP_SRC 0xC2000005
>> +#define IMX_SIP_SRC_M_RESET_ADDR_SET 0x03
>> +
>> +#define IMX95_CPU_VEC_FLAGS_BOOT BIT(29)
>> +
>> +#define IMX_SIP_LMM 0xC200000F
>> +#define IMX_SIP_LMM_BOOT 0x0
>> +#define IMX_SIP_LMM_SHUTDOWN 0x1
>> +
>> +#define IMX95_M7_LM_ID 0x1
>> +
>> +#define MBOX_DSPBOX_OFFSET 0x1000
>> +#define MBOX_WINDOW_OFFSET 0x6000000
>> +
>> +struct imx95_priv {
>> + struct platform_device *ipc_dev;
>> + struct imx_dsp_ipc *ipc_handle;
>> + resource_size_t bootaddr;
>> +};
>> +
>> +static void imx95_ipc_handle_reply(struct imx_dsp_ipc *ipc)
>> +{
>> + unsigned long flags;
>> + struct snd_sof_dev *sdev = imx_dsp_get_data(ipc);
>> +
>> + spin_lock_irqsave(&sdev->ipc_lock, flags);
>> + snd_sof_ipc_process_reply(sdev, 0);
>> + spin_unlock_irqrestore(&sdev->ipc_lock, flags);
>> +}
>> +
>> +static void imx95_ipc_handle_request(struct imx_dsp_ipc *ipc)
>> +{
>> + snd_sof_ipc_msgs_rx(imx_dsp_get_data(ipc));
>> +}
>> +
>> +static struct imx_dsp_ops ipc_ops = {
>> + .handle_reply = imx95_ipc_handle_reply,
>> + .handle_request = imx95_ipc_handle_request,
>> +};
>> +
>> +static int imx95_disable_enable_core(bool enable)
>> +{
>> + struct arm_smccc_res res;
>> +
>> + if (enable)
>> + arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_BOOT, IMX95_M7_LM_ID,
>> + 0, 0, 0, 0, 0, &res);
>> + else
>> + arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_SHUTDOWN, IMX95_M7_LM_ID,
>> + 0, 0, 0, 0, 0, &res);
>> +
>> + return res.a0;
>> +}
>> +
>> +static int imx95_run(struct snd_sof_dev *sdev)
>> +{
>> + return imx95_disable_enable_core(true);
>> +}
>> +
>> +static int imx95_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
>> +{
>> + struct imx95_priv *priv = sdev->pdata->hw_pdata;
>> +
>> + sof_mailbox_write(sdev, sdev->host_box.offset,
>> + msg->msg_data, msg->msg_size);
>> +
>> + imx_dsp_ring_doorbell(priv->ipc_handle, 0);
>> +
>> + return 0;
>> +}
>> +
>> +static int imx95_get_mailbox_offset(struct snd_sof_dev *sdev)
>> +{
>> + return MBOX_DSPBOX_OFFSET + MBOX_WINDOW_OFFSET;
>> +}
>> +
>> +static int imx95_get_bar_index(struct snd_sof_dev *sdev, u32 type)
>> +{
>> + switch (type) {
>> + case SOF_FW_BLK_TYPE_SRAM:
>> + return type;
>> + default:
>> + return -EINVAL;
>> + }
>> +}
>> +
>> +static int imx95_get_window_offset(struct snd_sof_dev *sdev, u32 id)
>> +{
>> + return MBOX_WINDOW_OFFSET;
>> +}
>> +
>> +static int imx95_set_power_state(struct snd_sof_dev *sdev,
>> + const struct sof_dsp_power_state *target_state)
>> +{
>> + sdev->dsp_power_state = *target_state;
>> +
>> + return 0;
>> +}
>> +
>> +static int imx95_suspend_resume(struct snd_sof_dev *sdev, bool suspend)
>> +{
>> + struct imx95_priv *priv;
>> + int ret, i;
>> +
>> + priv = sdev->pdata->hw_pdata;
>> +
>> + if (suspend) {
>> + ret = imx95_disable_enable_core(false);
>> + if (ret) {
>> + dev_err(sdev->dev, "failed to stop core\n");
>> + return ret;
>> + }
>> + }
>> +
>> + for (i = 0; i < DSP_MU_CHAN_NUM; i++) {
>> + if (suspend)
>> + imx_dsp_free_channel(priv->ipc_handle, i);
>> + else
>> + imx_dsp_request_channel(priv->ipc_handle, i);
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static int imx95_runtime_resume(struct snd_sof_dev *sdev)
>> +{
>> + int ret;
>> + const struct sof_dsp_power_state target_state = {
>> + .state = SOF_DSP_PM_D0,
>> + };
>> +
>> + ret = imx95_suspend_resume(sdev, false);
>> + if (ret < 0) {
>> + dev_err(sdev->dev, "failed to runtime resume: %d\n", ret);
>> + return ret;
>> + }
>> +
>> + return snd_sof_dsp_set_power_state(sdev, &target_state);
>> +}
>> +
>> +static int imx95_resume(struct snd_sof_dev *sdev)
>> +{
>> + int ret;
>> + const struct sof_dsp_power_state target_state = {
>> + .state = SOF_DSP_PM_D0,
>> + };
>> +
>> + ret = imx95_suspend_resume(sdev, false);
>> + if (ret < 0) {
>> + dev_err(sdev->dev, "failed to resume: %d\n", ret);
>> + return ret;
>> + }
>> +
>> + if (pm_runtime_suspended(sdev->dev)) {
>> + pm_runtime_disable(sdev->dev);
>> + pm_runtime_set_active(sdev->dev);
>> + pm_runtime_mark_last_busy(sdev->dev);
>> + pm_runtime_enable(sdev->dev);
>> + pm_runtime_idle(sdev->dev);
>> + }
>> +
>> + return snd_sof_dsp_set_power_state(sdev, &target_state);
>> +}
>> +
>> +static int imx95_runtime_suspend(struct snd_sof_dev *sdev)
>> +{
>> + int ret;
>> + const struct sof_dsp_power_state target_state = {
>> + .state = SOF_DSP_PM_D3,
>> + };
>> +
>> + ret = imx95_suspend_resume(sdev, true);
>> + if (ret < 0) {
>> + dev_err(sdev->dev, "failed to runtime suspend: %d\n", ret);
>> + return ret;
>> + }
>> +
>> + return snd_sof_dsp_set_power_state(sdev, &target_state);
>> +}
>> +
>> +static int imx95_suspend(struct snd_sof_dev *sdev, unsigned int target_state)
>> +{
>> + int ret;
>> + const struct sof_dsp_power_state target_power_state = {
>> + .state = target_state,
>> + };
>> +
>> + if (!pm_runtime_suspended(sdev->dev)) {
>> + ret = imx95_suspend_resume(sdev, true);
>> + if (ret < 0) {
>> + dev_err(sdev->dev, "failed to suspend: %d\n", ret);
>> + return ret;
>> + }
>> + }
>> +
>> + return snd_sof_dsp_set_power_state(sdev, &target_power_state);
>> +}
>> +
>> +static struct snd_soc_dai_driver imx95_dai[] = {
>> + {
>> + .name = "sai3",
>> + .playback = {
>> + .channels_min = 1,
>> + .channels_max = 32,
>> + },
>> + .capture = {
>> + .channels_min = 1,
>> + .channels_max = 32,
>> + },
>> + },
>> +};
>> +
>> +static int imx95_probe(struct snd_sof_dev *sdev)
>> +{
>> + struct platform_device *pdev;
>> + struct imx95_priv *priv;
>> + struct resource *res;
>> + struct arm_smccc_res smc_ret;
>> + int ret;
>> +
>> + pdev = container_of(sdev->dev, struct platform_device, dev);
>> +
>> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
>> + if (!priv)
>> + return dev_err_probe(&pdev->dev, -ENOMEM, "failed to alloc priv\n");
>> +
>> + sdev->pdata->hw_pdata = priv;
>> +
>> + /* map SRAM */
>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> + if (!res)
>> + return dev_err_probe(&pdev->dev, -ENODEV,
>> + "failed to fetch SRAM region\n");
>> +
>> + sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap(&pdev->dev, res->start,
>> + resource_size(res));
>> + if (IS_ERR(sdev->bar[SOF_FW_BLK_TYPE_SRAM]))
>> + return dev_err_probe(&pdev->dev,
>> + PTR_ERR(sdev->bar[SOF_FW_BLK_TYPE_SRAM]),
>> + "failed to map SRAM region\n");
>> +
>> + sdev->mmio_bar = SOF_FW_BLK_TYPE_SRAM;
>> + sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM;
>> + sdev->dsp_box.offset = MBOX_DSPBOX_OFFSET + MBOX_WINDOW_OFFSET;
>> + priv->bootaddr = res->start;
>> +
>> + ret = of_reserved_mem_device_init(sdev->dev);
>> + if (ret)
>> + return dev_err_probe(&pdev->dev, ret,
>> + "failed to bind DMA region\n");
>> +
>> + priv->ipc_dev = platform_device_register_data(&pdev->dev, "imx-dsp",
>> + PLATFORM_DEVID_NONE,
>> + pdev, sizeof(*pdev));
>> + if (IS_ERR(priv->ipc_dev))
>> + return dev_err_probe(&pdev->dev, PTR_ERR(priv->ipc_dev),
>> + "failed to create IPC device\n");
>> +
>> + priv->ipc_handle = dev_get_drvdata(&priv->ipc_dev->dev);
>> + if (!priv->ipc_handle) {
>> + ret = -EPROBE_DEFER;
>> + dev_err(&pdev->dev, "failed to fetch ipc handle\n");
>> + goto err_unregister_ipc_dev;
>> + }
>> +
>> + priv->ipc_handle->ops = &ipc_ops;
>> + imx_dsp_set_data(priv->ipc_handle, sdev);
>> +
>> + /* set core boot reset address */
>> + arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M_RESET_ADDR_SET, priv->bootaddr,
>> + IMX95_CPU_VEC_FLAGS_BOOT, 0, 0, 0, 0, &smc_ret);
>> + if ((int)smc_ret.a0 < 0) {
>> + ret = smc_ret.a0;
>> + dev_err(&pdev->dev, "failed to set boot address: %d", ret);
>> + goto err_unregister_ipc_dev;
>> + }
>> +
>> + return 0;
>> +
>> +err_unregister_ipc_dev:
>> + platform_device_unregister(priv->ipc_dev);
>> +
>> + return ret;
>> +}
>> +
>> +static void imx95_remove(struct snd_sof_dev *sdev)
>> +{
>> + struct imx95_priv *priv;
>> +
>> + priv = sdev->pdata->hw_pdata;
>> +
>> + if (imx95_disable_enable_core(false))
>> + dev_err(sdev->dev, "failed to stop core\n");
>> +
>> + platform_device_unregister(priv->ipc_dev);
>> +}
>> +
>> +static const struct snd_sof_dsp_ops sof_imx95_ops = {
>> + .probe = imx95_probe,
>> + .remove = imx95_remove,
>> +
>> + /* mandatory "DSP" ops */
>> + .run = imx95_run,
>> + .block_read = sof_block_read,
>> + .block_write = sof_block_write,
>> + .send_msg = imx95_send_msg,
>> + .load_firmware = snd_sof_load_firmware_memcpy,
>> + .ipc_msg_data = sof_ipc_msg_data,
>> +
>> + .mailbox_read = sof_mailbox_read,
>> + .mailbox_write = sof_mailbox_write,
>> +
>> + .get_mailbox_offset = imx95_get_mailbox_offset,
>> + .get_bar_index = imx95_get_bar_index,
>> + .get_window_offset = imx95_get_window_offset,
>> +
>> + .pcm_open = sof_stream_pcm_open,
>> + .pcm_close = sof_stream_pcm_close,
>> + .set_stream_data_offset = sof_set_stream_data_offset,
>> +
>> + .runtime_suspend = imx95_runtime_suspend,
>> + .runtime_resume = imx95_runtime_resume,
>> +
>> + .resume = imx95_resume,
>> + .suspend = imx95_suspend,
>> +
>> + .set_power_state = imx95_set_power_state,
>> +
>> + .drv = imx95_dai,
>> + .num_drv = ARRAY_SIZE(imx95_dai),
>> +
>> + .hw_info = SNDRV_PCM_INFO_MMAP |
>> + SNDRV_PCM_INFO_MMAP_VALID |
>> + SNDRV_PCM_INFO_INTERLEAVED |
>> + SNDRV_PCM_INFO_PAUSE |
>> + SNDRV_PCM_INFO_BATCH |
>> + SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
>> +};
>> +
>> +static struct snd_sof_of_mach sof_imx95_machs[] = {
>> + {
>> + .compatible = "fsl,imx95-19x19-evk",
>> + .sof_tplg_filename = "sof-imx95-wm8962.tplg",
>> + .drv_name = "asoc-audio-graph-card2",
>> + },
>> + {
>> + },
>> +};
>> +
>> +static struct sof_dev_desc sof_of_imx95_desc = {
>> + .of_machines = sof_imx95_machs,
>> + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3),
>> + .ipc_default = SOF_IPC_TYPE_3,
>> + .default_fw_path = {
>> + [SOF_IPC_TYPE_3] = "imx/sof",
>> + },
>> + .default_tplg_path = {
>> + [SOF_IPC_TYPE_3] = "imx/sof-tplg",
>> + },
>> + .default_fw_filename = {
>> + [SOF_IPC_TYPE_3] = "sof-imx95.ri",
>> + },
>> + .ops = &sof_imx95_ops,
>> +};
>> +
>> +static const struct of_device_id sof_of_imx95_ids[] = {
>> + { .compatible = "fsl,imx95-cm7-sof", .data = &sof_of_imx95_desc },
>> + { },
>> +};
>> +MODULE_DEVICE_TABLE(of, sof_of_imx95_ids);
>> +
>> +static struct platform_driver snd_sof_of_imx95_driver = {
>> + .probe = sof_of_probe,
>> + .remove = sof_of_remove,
>> + .driver = {
>> + .name = "sof-audio-of-imx95",
>> + .pm = &sof_of_pm,
>> + .of_match_table = sof_of_imx95_ids,
>> + },
>> +};
>> +module_platform_driver(snd_sof_of_imx95_driver);
>> +
>> +MODULE_LICENSE("Dual BSD/GPL");
>> +MODULE_DESCRIPTION("SOF support for i.MX95 platforms");
>> +MODULE_AUTHOR("Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>");
>> --
>> 2.34.1
>>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 4/5] ASoC: SOF: imx: add driver for imx95
2024-12-12 11:11 ` Laurentiu Mihalcea
@ 2024-12-12 15:13 ` Frank Li
2024-12-16 12:23 ` Laurentiu Mihalcea
0 siblings, 1 reply; 20+ messages in thread
From: Frank Li @ 2024-12-12 15:13 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
On Thu, Dec 12, 2024 at 01:11:29PM +0200, Laurentiu Mihalcea wrote:
>
>
> On 11/13/2024 10:17 PM, Frank Li wrote:
> > On Wed, Nov 13, 2024 at 02:52:39PM -0500, Laurentiu Mihalcea wrote:
> >> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> >>
> >> Add SOF driver for imx95.
> >>
> >> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> >> ---
> >> sound/soc/sof/imx/Kconfig | 8 +
> >> sound/soc/sof/imx/Makefile | 2 +
> >> sound/soc/sof/imx/imx95.c | 401 +++++++++++++++++++++++++++++++++++++
> > why not reused exist one? look likes simular.
> >
> > Frank
> the SOF drivers do indeed have some similarities, but each of them has their own quirks which IMO makes it a bit harder to add the 95 support. We need to figure out the common parts and then move them to imx-common, but I believe this can be solved incrementally.
You should create common part firstly, then implement equal function with
existed part. Finially add imx95 part.
Frank
> >
> >> 3 files changed, 411 insertions(+)
> >> create mode 100644 sound/soc/sof/imx/imx95.c
> >>
> >> diff --git a/sound/soc/sof/imx/Kconfig b/sound/soc/sof/imx/Kconfig
> >> index 4751b04d5e6f..51a70a193533 100644
> >> --- a/sound/soc/sof/imx/Kconfig
> >> +++ b/sound/soc/sof/imx/Kconfig
> >> @@ -50,4 +50,12 @@ config SND_SOC_SOF_IMX8ULP
> >> Say Y if you have such a device.
> >> If unsure select "N".
> >>
> >> +config SND_SOC_SOF_IMX95
> >> + tristate "SOF support for i.MX95"
> >> + depends on IMX_DSP
> >> + help
> >> + This adds support for Sound Open Firmware for NXP i.MX95 platforms.
> >> + Say Y if you have such a device.
> >> + If unsure select "N".
> >> +
> >> endif ## SND_SOC_SOF_IMX_TOPLEVEL
> >> diff --git a/sound/soc/sof/imx/Makefile b/sound/soc/sof/imx/Makefile
> >> index be0bf0736dfa..715ac3798668 100644
> >> --- a/sound/soc/sof/imx/Makefile
> >> +++ b/sound/soc/sof/imx/Makefile
> >> @@ -2,10 +2,12 @@
> >> snd-sof-imx8-y := imx8.o
> >> snd-sof-imx8m-y := imx8m.o
> >> snd-sof-imx8ulp-y := imx8ulp.o
> >> +snd-sof-imx95-y := imx95.o
> >>
> >> snd-sof-imx-common-y := imx-common.o
> >>
> >> obj-$(CONFIG_SND_SOC_SOF_IMX8) += snd-sof-imx8.o
> >> obj-$(CONFIG_SND_SOC_SOF_IMX8M) += snd-sof-imx8m.o
> >> obj-$(CONFIG_SND_SOC_SOF_IMX8ULP) += snd-sof-imx8ulp.o
> >> +obj-$(CONFIG_SND_SOC_SOF_IMX95) += snd-sof-imx95.o
> >> obj-$(CONFIG_SND_SOC_SOF_IMX_COMMON) += imx-common.o
> >> diff --git a/sound/soc/sof/imx/imx95.c b/sound/soc/sof/imx/imx95.c
> >> new file mode 100644
> >> index 000000000000..5a0e44f5bd48
> >> --- /dev/null
> >> +++ b/sound/soc/sof/imx/imx95.c
> >> @@ -0,0 +1,401 @@
> >> +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
> >> +/*
> >> + * Copyright 2024 NXP
> >> + */
> >> +
> >> +#include <linux/arm-smccc.h>
> >> +#include <linux/clk.h>
> >> +#include <linux/firmware/imx/dsp.h>
> >> +#include <linux/module.h>
> >> +#include <linux/of_platform.h>
> >> +#include <linux/of_reserved_mem.h>
> >> +#include <sound/sof.h>
> >> +
> >> +#include "../sof-of-dev.h"
> >> +#include "../ops.h"
> >> +
> >> +#define IMX_SIP_SRC 0xC2000005
> >> +#define IMX_SIP_SRC_M_RESET_ADDR_SET 0x03
> >> +
> >> +#define IMX95_CPU_VEC_FLAGS_BOOT BIT(29)
> >> +
> >> +#define IMX_SIP_LMM 0xC200000F
> >> +#define IMX_SIP_LMM_BOOT 0x0
> >> +#define IMX_SIP_LMM_SHUTDOWN 0x1
> >> +
> >> +#define IMX95_M7_LM_ID 0x1
> >> +
> >> +#define MBOX_DSPBOX_OFFSET 0x1000
> >> +#define MBOX_WINDOW_OFFSET 0x6000000
> >> +
> >> +struct imx95_priv {
> >> + struct platform_device *ipc_dev;
> >> + struct imx_dsp_ipc *ipc_handle;
> >> + resource_size_t bootaddr;
> >> +};
> >> +
> >> +static void imx95_ipc_handle_reply(struct imx_dsp_ipc *ipc)
> >> +{
> >> + unsigned long flags;
> >> + struct snd_sof_dev *sdev = imx_dsp_get_data(ipc);
> >> +
> >> + spin_lock_irqsave(&sdev->ipc_lock, flags);
> >> + snd_sof_ipc_process_reply(sdev, 0);
> >> + spin_unlock_irqrestore(&sdev->ipc_lock, flags);
> >> +}
> >> +
> >> +static void imx95_ipc_handle_request(struct imx_dsp_ipc *ipc)
> >> +{
> >> + snd_sof_ipc_msgs_rx(imx_dsp_get_data(ipc));
> >> +}
> >> +
> >> +static struct imx_dsp_ops ipc_ops = {
> >> + .handle_reply = imx95_ipc_handle_reply,
> >> + .handle_request = imx95_ipc_handle_request,
> >> +};
> >> +
> >> +static int imx95_disable_enable_core(bool enable)
> >> +{
> >> + struct arm_smccc_res res;
> >> +
> >> + if (enable)
> >> + arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_BOOT, IMX95_M7_LM_ID,
> >> + 0, 0, 0, 0, 0, &res);
> >> + else
> >> + arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_SHUTDOWN, IMX95_M7_LM_ID,
> >> + 0, 0, 0, 0, 0, &res);
> >> +
> >> + return res.a0;
> >> +}
> >> +
> >> +static int imx95_run(struct snd_sof_dev *sdev)
> >> +{
> >> + return imx95_disable_enable_core(true);
> >> +}
> >> +
> >> +static int imx95_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
> >> +{
> >> + struct imx95_priv *priv = sdev->pdata->hw_pdata;
> >> +
> >> + sof_mailbox_write(sdev, sdev->host_box.offset,
> >> + msg->msg_data, msg->msg_size);
> >> +
> >> + imx_dsp_ring_doorbell(priv->ipc_handle, 0);
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static int imx95_get_mailbox_offset(struct snd_sof_dev *sdev)
> >> +{
> >> + return MBOX_DSPBOX_OFFSET + MBOX_WINDOW_OFFSET;
> >> +}
> >> +
> >> +static int imx95_get_bar_index(struct snd_sof_dev *sdev, u32 type)
> >> +{
> >> + switch (type) {
> >> + case SOF_FW_BLK_TYPE_SRAM:
> >> + return type;
> >> + default:
> >> + return -EINVAL;
> >> + }
> >> +}
> >> +
> >> +static int imx95_get_window_offset(struct snd_sof_dev *sdev, u32 id)
> >> +{
> >> + return MBOX_WINDOW_OFFSET;
> >> +}
> >> +
> >> +static int imx95_set_power_state(struct snd_sof_dev *sdev,
> >> + const struct sof_dsp_power_state *target_state)
> >> +{
> >> + sdev->dsp_power_state = *target_state;
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static int imx95_suspend_resume(struct snd_sof_dev *sdev, bool suspend)
> >> +{
> >> + struct imx95_priv *priv;
> >> + int ret, i;
> >> +
> >> + priv = sdev->pdata->hw_pdata;
> >> +
> >> + if (suspend) {
> >> + ret = imx95_disable_enable_core(false);
> >> + if (ret) {
> >> + dev_err(sdev->dev, "failed to stop core\n");
> >> + return ret;
> >> + }
> >> + }
> >> +
> >> + for (i = 0; i < DSP_MU_CHAN_NUM; i++) {
> >> + if (suspend)
> >> + imx_dsp_free_channel(priv->ipc_handle, i);
> >> + else
> >> + imx_dsp_request_channel(priv->ipc_handle, i);
> >> + }
> >> +
> >> + return 0;
> >> +}
> >> +
> >> +static int imx95_runtime_resume(struct snd_sof_dev *sdev)
> >> +{
> >> + int ret;
> >> + const struct sof_dsp_power_state target_state = {
> >> + .state = SOF_DSP_PM_D0,
> >> + };
> >> +
> >> + ret = imx95_suspend_resume(sdev, false);
> >> + if (ret < 0) {
> >> + dev_err(sdev->dev, "failed to runtime resume: %d\n", ret);
> >> + return ret;
> >> + }
> >> +
> >> + return snd_sof_dsp_set_power_state(sdev, &target_state);
> >> +}
> >> +
> >> +static int imx95_resume(struct snd_sof_dev *sdev)
> >> +{
> >> + int ret;
> >> + const struct sof_dsp_power_state target_state = {
> >> + .state = SOF_DSP_PM_D0,
> >> + };
> >> +
> >> + ret = imx95_suspend_resume(sdev, false);
> >> + if (ret < 0) {
> >> + dev_err(sdev->dev, "failed to resume: %d\n", ret);
> >> + return ret;
> >> + }
> >> +
> >> + if (pm_runtime_suspended(sdev->dev)) {
> >> + pm_runtime_disable(sdev->dev);
> >> + pm_runtime_set_active(sdev->dev);
> >> + pm_runtime_mark_last_busy(sdev->dev);
> >> + pm_runtime_enable(sdev->dev);
> >> + pm_runtime_idle(sdev->dev);
> >> + }
> >> +
> >> + return snd_sof_dsp_set_power_state(sdev, &target_state);
> >> +}
> >> +
> >> +static int imx95_runtime_suspend(struct snd_sof_dev *sdev)
> >> +{
> >> + int ret;
> >> + const struct sof_dsp_power_state target_state = {
> >> + .state = SOF_DSP_PM_D3,
> >> + };
> >> +
> >> + ret = imx95_suspend_resume(sdev, true);
> >> + if (ret < 0) {
> >> + dev_err(sdev->dev, "failed to runtime suspend: %d\n", ret);
> >> + return ret;
> >> + }
> >> +
> >> + return snd_sof_dsp_set_power_state(sdev, &target_state);
> >> +}
> >> +
> >> +static int imx95_suspend(struct snd_sof_dev *sdev, unsigned int target_state)
> >> +{
> >> + int ret;
> >> + const struct sof_dsp_power_state target_power_state = {
> >> + .state = target_state,
> >> + };
> >> +
> >> + if (!pm_runtime_suspended(sdev->dev)) {
> >> + ret = imx95_suspend_resume(sdev, true);
> >> + if (ret < 0) {
> >> + dev_err(sdev->dev, "failed to suspend: %d\n", ret);
> >> + return ret;
> >> + }
> >> + }
> >> +
> >> + return snd_sof_dsp_set_power_state(sdev, &target_power_state);
> >> +}
> >> +
> >> +static struct snd_soc_dai_driver imx95_dai[] = {
> >> + {
> >> + .name = "sai3",
> >> + .playback = {
> >> + .channels_min = 1,
> >> + .channels_max = 32,
> >> + },
> >> + .capture = {
> >> + .channels_min = 1,
> >> + .channels_max = 32,
> >> + },
> >> + },
> >> +};
> >> +
> >> +static int imx95_probe(struct snd_sof_dev *sdev)
> >> +{
> >> + struct platform_device *pdev;
> >> + struct imx95_priv *priv;
> >> + struct resource *res;
> >> + struct arm_smccc_res smc_ret;
> >> + int ret;
> >> +
> >> + pdev = container_of(sdev->dev, struct platform_device, dev);
> >> +
> >> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> >> + if (!priv)
> >> + return dev_err_probe(&pdev->dev, -ENOMEM, "failed to alloc priv\n");
> >> +
> >> + sdev->pdata->hw_pdata = priv;
> >> +
> >> + /* map SRAM */
> >> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >> + if (!res)
> >> + return dev_err_probe(&pdev->dev, -ENODEV,
> >> + "failed to fetch SRAM region\n");
> >> +
> >> + sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap(&pdev->dev, res->start,
> >> + resource_size(res));
> >> + if (IS_ERR(sdev->bar[SOF_FW_BLK_TYPE_SRAM]))
> >> + return dev_err_probe(&pdev->dev,
> >> + PTR_ERR(sdev->bar[SOF_FW_BLK_TYPE_SRAM]),
> >> + "failed to map SRAM region\n");
> >> +
> >> + sdev->mmio_bar = SOF_FW_BLK_TYPE_SRAM;
> >> + sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM;
> >> + sdev->dsp_box.offset = MBOX_DSPBOX_OFFSET + MBOX_WINDOW_OFFSET;
> >> + priv->bootaddr = res->start;
> >> +
> >> + ret = of_reserved_mem_device_init(sdev->dev);
> >> + if (ret)
> >> + return dev_err_probe(&pdev->dev, ret,
> >> + "failed to bind DMA region\n");
> >> +
> >> + priv->ipc_dev = platform_device_register_data(&pdev->dev, "imx-dsp",
> >> + PLATFORM_DEVID_NONE,
> >> + pdev, sizeof(*pdev));
> >> + if (IS_ERR(priv->ipc_dev))
> >> + return dev_err_probe(&pdev->dev, PTR_ERR(priv->ipc_dev),
> >> + "failed to create IPC device\n");
> >> +
> >> + priv->ipc_handle = dev_get_drvdata(&priv->ipc_dev->dev);
> >> + if (!priv->ipc_handle) {
> >> + ret = -EPROBE_DEFER;
> >> + dev_err(&pdev->dev, "failed to fetch ipc handle\n");
> >> + goto err_unregister_ipc_dev;
> >> + }
> >> +
> >> + priv->ipc_handle->ops = &ipc_ops;
> >> + imx_dsp_set_data(priv->ipc_handle, sdev);
> >> +
> >> + /* set core boot reset address */
> >> + arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M_RESET_ADDR_SET, priv->bootaddr,
> >> + IMX95_CPU_VEC_FLAGS_BOOT, 0, 0, 0, 0, &smc_ret);
> >> + if ((int)smc_ret.a0 < 0) {
> >> + ret = smc_ret.a0;
> >> + dev_err(&pdev->dev, "failed to set boot address: %d", ret);
> >> + goto err_unregister_ipc_dev;
> >> + }
> >> +
> >> + return 0;
> >> +
> >> +err_unregister_ipc_dev:
> >> + platform_device_unregister(priv->ipc_dev);
> >> +
> >> + return ret;
> >> +}
> >> +
> >> +static void imx95_remove(struct snd_sof_dev *sdev)
> >> +{
> >> + struct imx95_priv *priv;
> >> +
> >> + priv = sdev->pdata->hw_pdata;
> >> +
> >> + if (imx95_disable_enable_core(false))
> >> + dev_err(sdev->dev, "failed to stop core\n");
> >> +
> >> + platform_device_unregister(priv->ipc_dev);
> >> +}
> >> +
> >> +static const struct snd_sof_dsp_ops sof_imx95_ops = {
> >> + .probe = imx95_probe,
> >> + .remove = imx95_remove,
> >> +
> >> + /* mandatory "DSP" ops */
> >> + .run = imx95_run,
> >> + .block_read = sof_block_read,
> >> + .block_write = sof_block_write,
> >> + .send_msg = imx95_send_msg,
> >> + .load_firmware = snd_sof_load_firmware_memcpy,
> >> + .ipc_msg_data = sof_ipc_msg_data,
> >> +
> >> + .mailbox_read = sof_mailbox_read,
> >> + .mailbox_write = sof_mailbox_write,
> >> +
> >> + .get_mailbox_offset = imx95_get_mailbox_offset,
> >> + .get_bar_index = imx95_get_bar_index,
> >> + .get_window_offset = imx95_get_window_offset,
> >> +
> >> + .pcm_open = sof_stream_pcm_open,
> >> + .pcm_close = sof_stream_pcm_close,
> >> + .set_stream_data_offset = sof_set_stream_data_offset,
> >> +
> >> + .runtime_suspend = imx95_runtime_suspend,
> >> + .runtime_resume = imx95_runtime_resume,
> >> +
> >> + .resume = imx95_resume,
> >> + .suspend = imx95_suspend,
> >> +
> >> + .set_power_state = imx95_set_power_state,
> >> +
> >> + .drv = imx95_dai,
> >> + .num_drv = ARRAY_SIZE(imx95_dai),
> >> +
> >> + .hw_info = SNDRV_PCM_INFO_MMAP |
> >> + SNDRV_PCM_INFO_MMAP_VALID |
> >> + SNDRV_PCM_INFO_INTERLEAVED |
> >> + SNDRV_PCM_INFO_PAUSE |
> >> + SNDRV_PCM_INFO_BATCH |
> >> + SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
> >> +};
> >> +
> >> +static struct snd_sof_of_mach sof_imx95_machs[] = {
> >> + {
> >> + .compatible = "fsl,imx95-19x19-evk",
> >> + .sof_tplg_filename = "sof-imx95-wm8962.tplg",
> >> + .drv_name = "asoc-audio-graph-card2",
> >> + },
> >> + {
> >> + },
> >> +};
> >> +
> >> +static struct sof_dev_desc sof_of_imx95_desc = {
> >> + .of_machines = sof_imx95_machs,
> >> + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3),
> >> + .ipc_default = SOF_IPC_TYPE_3,
> >> + .default_fw_path = {
> >> + [SOF_IPC_TYPE_3] = "imx/sof",
> >> + },
> >> + .default_tplg_path = {
> >> + [SOF_IPC_TYPE_3] = "imx/sof-tplg",
> >> + },
> >> + .default_fw_filename = {
> >> + [SOF_IPC_TYPE_3] = "sof-imx95.ri",
> >> + },
> >> + .ops = &sof_imx95_ops,
> >> +};
> >> +
> >> +static const struct of_device_id sof_of_imx95_ids[] = {
> >> + { .compatible = "fsl,imx95-cm7-sof", .data = &sof_of_imx95_desc },
> >> + { },
> >> +};
> >> +MODULE_DEVICE_TABLE(of, sof_of_imx95_ids);
> >> +
> >> +static struct platform_driver snd_sof_of_imx95_driver = {
> >> + .probe = sof_of_probe,
> >> + .remove = sof_of_remove,
> >> + .driver = {
> >> + .name = "sof-audio-of-imx95",
> >> + .pm = &sof_of_pm,
> >> + .of_match_table = sof_of_imx95_ids,
> >> + },
> >> +};
> >> +module_platform_driver(snd_sof_of_imx95_driver);
> >> +
> >> +MODULE_LICENSE("Dual BSD/GPL");
> >> +MODULE_DESCRIPTION("SOF support for i.MX95 platforms");
> >> +MODULE_AUTHOR("Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>");
> >> --
> >> 2.34.1
> >>
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/5] ASoC: dt-bindings: audio-graph-card2: add widgets and hp-det-gpios support
2024-12-12 9:59 ` Laurentiu Mihalcea
@ 2024-12-13 0:40 ` Kuninori Morimoto
0 siblings, 0 replies; 20+ messages in thread
From: Kuninori Morimoto @ 2024-12-13 0:40 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Frank Li, Rob Herring, Krzysztof Kozlowski, Shawn Guo,
Daniel Baluta, Mark Brown, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
Hi
> >> diff --git a/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml b/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
> >> index f943f90d8b15..94588353f852 100644
> >> --- a/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
> >> +++ b/Documentation/devicetree/bindings/sound/audio-graph-card2.yaml
> >> @@ -37,6 +37,10 @@ properties:
> >> codec2codec:
> >> type: object
> >> description: Codec to Codec node
> >> + hp-det-gpios:
> >> + $ref: audio-graph.yaml#/properties/hp-det-gpios
> >> + widgets:
> >> + $ref: audio-graph.yaml#/properties/widgets
>
> > why not direct ref Documentation/devicetree/bindings/sound/audio-graph.yaml
> > and define these again here.
>
> We don't actually want all the properties from 'audio-graph.yaml'
> (for the moment at least). Also ref-ing 'audio-graph.yaml' will make the
> 'dais' property required, which is not targeted in this patch.
> Maybe Kuninori Morimoto can comment more on this.
I'm not a DT yaml expert, but audio-graph.yaml is for audio-graph-card and
its custom card. unfortunately audio-graph-card2 is using different style,
so ref audio-graph.yaml on audio-graph-card2 is impossible, or makes yaml
more complex.
Thank you for your help !!
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 4/5] ASoC: SOF: imx: add driver for imx95
2024-12-12 15:13 ` Frank Li
@ 2024-12-16 12:23 ` Laurentiu Mihalcea
2024-12-18 13:01 ` Daniel Baluta
0 siblings, 1 reply; 20+ messages in thread
From: Laurentiu Mihalcea @ 2024-12-16 12:23 UTC (permalink / raw)
To: Frank Li
Cc: Rob Herring, Krzysztof Kozlowski, Shawn Guo, Daniel Baluta,
Mark Brown, Kuninori Morimoto, Takashi Iwai, Bard Liao,
Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel, devicetree,
linux-sound, imx, linux-kernel
On 12/12/2024 5:13 PM, Frank Li wrote:
> On Thu, Dec 12, 2024 at 01:11:29PM +0200, Laurentiu Mihalcea wrote:
>>
>> On 11/13/2024 10:17 PM, Frank Li wrote:
>>> On Wed, Nov 13, 2024 at 02:52:39PM -0500, Laurentiu Mihalcea wrote:
>>>> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>>>>
>>>> Add SOF driver for imx95.
>>>>
>>>> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>>>> ---
>>>> sound/soc/sof/imx/Kconfig | 8 +
>>>> sound/soc/sof/imx/Makefile | 2 +
>>>> sound/soc/sof/imx/imx95.c | 401 +++++++++++++++++++++++++++++++++++++
>>> why not reused exist one? look likes simular.
>>>
>>> Frank
>> the SOF drivers do indeed have some similarities, but each of them has their own quirks which IMO makes it a bit harder to add the 95 support. We need to figure out the common parts and then move them to imx-common, but I believe this can be solved incrementally.
> You should create common part firstly, then implement equal function with
> existed part. Finially add imx95 part.
>
> Frank
Yes, I'm aware of how this _should_ be done, but, like I mentioned, the change is not trivial and will
require tweaking the other drivers as well. As such, I'd like to get the 95 support in as-is firstly.
Are there any other thoughts on this?
>
>>>> 3 files changed, 411 insertions(+)
>>>> create mode 100644 sound/soc/sof/imx/imx95.c
>>>>
>>>> diff --git a/sound/soc/sof/imx/Kconfig b/sound/soc/sof/imx/Kconfig
>>>> index 4751b04d5e6f..51a70a193533 100644
>>>> --- a/sound/soc/sof/imx/Kconfig
>>>> +++ b/sound/soc/sof/imx/Kconfig
>>>> @@ -50,4 +50,12 @@ config SND_SOC_SOF_IMX8ULP
>>>> Say Y if you have such a device.
>>>> If unsure select "N".
>>>>
>>>> +config SND_SOC_SOF_IMX95
>>>> + tristate "SOF support for i.MX95"
>>>> + depends on IMX_DSP
>>>> + help
>>>> + This adds support for Sound Open Firmware for NXP i.MX95 platforms.
>>>> + Say Y if you have such a device.
>>>> + If unsure select "N".
>>>> +
>>>> endif ## SND_SOC_SOF_IMX_TOPLEVEL
>>>> diff --git a/sound/soc/sof/imx/Makefile b/sound/soc/sof/imx/Makefile
>>>> index be0bf0736dfa..715ac3798668 100644
>>>> --- a/sound/soc/sof/imx/Makefile
>>>> +++ b/sound/soc/sof/imx/Makefile
>>>> @@ -2,10 +2,12 @@
>>>> snd-sof-imx8-y := imx8.o
>>>> snd-sof-imx8m-y := imx8m.o
>>>> snd-sof-imx8ulp-y := imx8ulp.o
>>>> +snd-sof-imx95-y := imx95.o
>>>>
>>>> snd-sof-imx-common-y := imx-common.o
>>>>
>>>> obj-$(CONFIG_SND_SOC_SOF_IMX8) += snd-sof-imx8.o
>>>> obj-$(CONFIG_SND_SOC_SOF_IMX8M) += snd-sof-imx8m.o
>>>> obj-$(CONFIG_SND_SOC_SOF_IMX8ULP) += snd-sof-imx8ulp.o
>>>> +obj-$(CONFIG_SND_SOC_SOF_IMX95) += snd-sof-imx95.o
>>>> obj-$(CONFIG_SND_SOC_SOF_IMX_COMMON) += imx-common.o
>>>> diff --git a/sound/soc/sof/imx/imx95.c b/sound/soc/sof/imx/imx95.c
>>>> new file mode 100644
>>>> index 000000000000..5a0e44f5bd48
>>>> --- /dev/null
>>>> +++ b/sound/soc/sof/imx/imx95.c
>>>> @@ -0,0 +1,401 @@
>>>> +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
>>>> +/*
>>>> + * Copyright 2024 NXP
>>>> + */
>>>> +
>>>> +#include <linux/arm-smccc.h>
>>>> +#include <linux/clk.h>
>>>> +#include <linux/firmware/imx/dsp.h>
>>>> +#include <linux/module.h>
>>>> +#include <linux/of_platform.h>
>>>> +#include <linux/of_reserved_mem.h>
>>>> +#include <sound/sof.h>
>>>> +
>>>> +#include "../sof-of-dev.h"
>>>> +#include "../ops.h"
>>>> +
>>>> +#define IMX_SIP_SRC 0xC2000005
>>>> +#define IMX_SIP_SRC_M_RESET_ADDR_SET 0x03
>>>> +
>>>> +#define IMX95_CPU_VEC_FLAGS_BOOT BIT(29)
>>>> +
>>>> +#define IMX_SIP_LMM 0xC200000F
>>>> +#define IMX_SIP_LMM_BOOT 0x0
>>>> +#define IMX_SIP_LMM_SHUTDOWN 0x1
>>>> +
>>>> +#define IMX95_M7_LM_ID 0x1
>>>> +
>>>> +#define MBOX_DSPBOX_OFFSET 0x1000
>>>> +#define MBOX_WINDOW_OFFSET 0x6000000
>>>> +
>>>> +struct imx95_priv {
>>>> + struct platform_device *ipc_dev;
>>>> + struct imx_dsp_ipc *ipc_handle;
>>>> + resource_size_t bootaddr;
>>>> +};
>>>> +
>>>> +static void imx95_ipc_handle_reply(struct imx_dsp_ipc *ipc)
>>>> +{
>>>> + unsigned long flags;
>>>> + struct snd_sof_dev *sdev = imx_dsp_get_data(ipc);
>>>> +
>>>> + spin_lock_irqsave(&sdev->ipc_lock, flags);
>>>> + snd_sof_ipc_process_reply(sdev, 0);
>>>> + spin_unlock_irqrestore(&sdev->ipc_lock, flags);
>>>> +}
>>>> +
>>>> +static void imx95_ipc_handle_request(struct imx_dsp_ipc *ipc)
>>>> +{
>>>> + snd_sof_ipc_msgs_rx(imx_dsp_get_data(ipc));
>>>> +}
>>>> +
>>>> +static struct imx_dsp_ops ipc_ops = {
>>>> + .handle_reply = imx95_ipc_handle_reply,
>>>> + .handle_request = imx95_ipc_handle_request,
>>>> +};
>>>> +
>>>> +static int imx95_disable_enable_core(bool enable)
>>>> +{
>>>> + struct arm_smccc_res res;
>>>> +
>>>> + if (enable)
>>>> + arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_BOOT, IMX95_M7_LM_ID,
>>>> + 0, 0, 0, 0, 0, &res);
>>>> + else
>>>> + arm_smccc_smc(IMX_SIP_LMM, IMX_SIP_LMM_SHUTDOWN, IMX95_M7_LM_ID,
>>>> + 0, 0, 0, 0, 0, &res);
>>>> +
>>>> + return res.a0;
>>>> +}
>>>> +
>>>> +static int imx95_run(struct snd_sof_dev *sdev)
>>>> +{
>>>> + return imx95_disable_enable_core(true);
>>>> +}
>>>> +
>>>> +static int imx95_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
>>>> +{
>>>> + struct imx95_priv *priv = sdev->pdata->hw_pdata;
>>>> +
>>>> + sof_mailbox_write(sdev, sdev->host_box.offset,
>>>> + msg->msg_data, msg->msg_size);
>>>> +
>>>> + imx_dsp_ring_doorbell(priv->ipc_handle, 0);
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +static int imx95_get_mailbox_offset(struct snd_sof_dev *sdev)
>>>> +{
>>>> + return MBOX_DSPBOX_OFFSET + MBOX_WINDOW_OFFSET;
>>>> +}
>>>> +
>>>> +static int imx95_get_bar_index(struct snd_sof_dev *sdev, u32 type)
>>>> +{
>>>> + switch (type) {
>>>> + case SOF_FW_BLK_TYPE_SRAM:
>>>> + return type;
>>>> + default:
>>>> + return -EINVAL;
>>>> + }
>>>> +}
>>>> +
>>>> +static int imx95_get_window_offset(struct snd_sof_dev *sdev, u32 id)
>>>> +{
>>>> + return MBOX_WINDOW_OFFSET;
>>>> +}
>>>> +
>>>> +static int imx95_set_power_state(struct snd_sof_dev *sdev,
>>>> + const struct sof_dsp_power_state *target_state)
>>>> +{
>>>> + sdev->dsp_power_state = *target_state;
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +static int imx95_suspend_resume(struct snd_sof_dev *sdev, bool suspend)
>>>> +{
>>>> + struct imx95_priv *priv;
>>>> + int ret, i;
>>>> +
>>>> + priv = sdev->pdata->hw_pdata;
>>>> +
>>>> + if (suspend) {
>>>> + ret = imx95_disable_enable_core(false);
>>>> + if (ret) {
>>>> + dev_err(sdev->dev, "failed to stop core\n");
>>>> + return ret;
>>>> + }
>>>> + }
>>>> +
>>>> + for (i = 0; i < DSP_MU_CHAN_NUM; i++) {
>>>> + if (suspend)
>>>> + imx_dsp_free_channel(priv->ipc_handle, i);
>>>> + else
>>>> + imx_dsp_request_channel(priv->ipc_handle, i);
>>>> + }
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +static int imx95_runtime_resume(struct snd_sof_dev *sdev)
>>>> +{
>>>> + int ret;
>>>> + const struct sof_dsp_power_state target_state = {
>>>> + .state = SOF_DSP_PM_D0,
>>>> + };
>>>> +
>>>> + ret = imx95_suspend_resume(sdev, false);
>>>> + if (ret < 0) {
>>>> + dev_err(sdev->dev, "failed to runtime resume: %d\n", ret);
>>>> + return ret;
>>>> + }
>>>> +
>>>> + return snd_sof_dsp_set_power_state(sdev, &target_state);
>>>> +}
>>>> +
>>>> +static int imx95_resume(struct snd_sof_dev *sdev)
>>>> +{
>>>> + int ret;
>>>> + const struct sof_dsp_power_state target_state = {
>>>> + .state = SOF_DSP_PM_D0,
>>>> + };
>>>> +
>>>> + ret = imx95_suspend_resume(sdev, false);
>>>> + if (ret < 0) {
>>>> + dev_err(sdev->dev, "failed to resume: %d\n", ret);
>>>> + return ret;
>>>> + }
>>>> +
>>>> + if (pm_runtime_suspended(sdev->dev)) {
>>>> + pm_runtime_disable(sdev->dev);
>>>> + pm_runtime_set_active(sdev->dev);
>>>> + pm_runtime_mark_last_busy(sdev->dev);
>>>> + pm_runtime_enable(sdev->dev);
>>>> + pm_runtime_idle(sdev->dev);
>>>> + }
>>>> +
>>>> + return snd_sof_dsp_set_power_state(sdev, &target_state);
>>>> +}
>>>> +
>>>> +static int imx95_runtime_suspend(struct snd_sof_dev *sdev)
>>>> +{
>>>> + int ret;
>>>> + const struct sof_dsp_power_state target_state = {
>>>> + .state = SOF_DSP_PM_D3,
>>>> + };
>>>> +
>>>> + ret = imx95_suspend_resume(sdev, true);
>>>> + if (ret < 0) {
>>>> + dev_err(sdev->dev, "failed to runtime suspend: %d\n", ret);
>>>> + return ret;
>>>> + }
>>>> +
>>>> + return snd_sof_dsp_set_power_state(sdev, &target_state);
>>>> +}
>>>> +
>>>> +static int imx95_suspend(struct snd_sof_dev *sdev, unsigned int target_state)
>>>> +{
>>>> + int ret;
>>>> + const struct sof_dsp_power_state target_power_state = {
>>>> + .state = target_state,
>>>> + };
>>>> +
>>>> + if (!pm_runtime_suspended(sdev->dev)) {
>>>> + ret = imx95_suspend_resume(sdev, true);
>>>> + if (ret < 0) {
>>>> + dev_err(sdev->dev, "failed to suspend: %d\n", ret);
>>>> + return ret;
>>>> + }
>>>> + }
>>>> +
>>>> + return snd_sof_dsp_set_power_state(sdev, &target_power_state);
>>>> +}
>>>> +
>>>> +static struct snd_soc_dai_driver imx95_dai[] = {
>>>> + {
>>>> + .name = "sai3",
>>>> + .playback = {
>>>> + .channels_min = 1,
>>>> + .channels_max = 32,
>>>> + },
>>>> + .capture = {
>>>> + .channels_min = 1,
>>>> + .channels_max = 32,
>>>> + },
>>>> + },
>>>> +};
>>>> +
>>>> +static int imx95_probe(struct snd_sof_dev *sdev)
>>>> +{
>>>> + struct platform_device *pdev;
>>>> + struct imx95_priv *priv;
>>>> + struct resource *res;
>>>> + struct arm_smccc_res smc_ret;
>>>> + int ret;
>>>> +
>>>> + pdev = container_of(sdev->dev, struct platform_device, dev);
>>>> +
>>>> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
>>>> + if (!priv)
>>>> + return dev_err_probe(&pdev->dev, -ENOMEM, "failed to alloc priv\n");
>>>> +
>>>> + sdev->pdata->hw_pdata = priv;
>>>> +
>>>> + /* map SRAM */
>>>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>> + if (!res)
>>>> + return dev_err_probe(&pdev->dev, -ENODEV,
>>>> + "failed to fetch SRAM region\n");
>>>> +
>>>> + sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap(&pdev->dev, res->start,
>>>> + resource_size(res));
>>>> + if (IS_ERR(sdev->bar[SOF_FW_BLK_TYPE_SRAM]))
>>>> + return dev_err_probe(&pdev->dev,
>>>> + PTR_ERR(sdev->bar[SOF_FW_BLK_TYPE_SRAM]),
>>>> + "failed to map SRAM region\n");
>>>> +
>>>> + sdev->mmio_bar = SOF_FW_BLK_TYPE_SRAM;
>>>> + sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM;
>>>> + sdev->dsp_box.offset = MBOX_DSPBOX_OFFSET + MBOX_WINDOW_OFFSET;
>>>> + priv->bootaddr = res->start;
>>>> +
>>>> + ret = of_reserved_mem_device_init(sdev->dev);
>>>> + if (ret)
>>>> + return dev_err_probe(&pdev->dev, ret,
>>>> + "failed to bind DMA region\n");
>>>> +
>>>> + priv->ipc_dev = platform_device_register_data(&pdev->dev, "imx-dsp",
>>>> + PLATFORM_DEVID_NONE,
>>>> + pdev, sizeof(*pdev));
>>>> + if (IS_ERR(priv->ipc_dev))
>>>> + return dev_err_probe(&pdev->dev, PTR_ERR(priv->ipc_dev),
>>>> + "failed to create IPC device\n");
>>>> +
>>>> + priv->ipc_handle = dev_get_drvdata(&priv->ipc_dev->dev);
>>>> + if (!priv->ipc_handle) {
>>>> + ret = -EPROBE_DEFER;
>>>> + dev_err(&pdev->dev, "failed to fetch ipc handle\n");
>>>> + goto err_unregister_ipc_dev;
>>>> + }
>>>> +
>>>> + priv->ipc_handle->ops = &ipc_ops;
>>>> + imx_dsp_set_data(priv->ipc_handle, sdev);
>>>> +
>>>> + /* set core boot reset address */
>>>> + arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M_RESET_ADDR_SET, priv->bootaddr,
>>>> + IMX95_CPU_VEC_FLAGS_BOOT, 0, 0, 0, 0, &smc_ret);
>>>> + if ((int)smc_ret.a0 < 0) {
>>>> + ret = smc_ret.a0;
>>>> + dev_err(&pdev->dev, "failed to set boot address: %d", ret);
>>>> + goto err_unregister_ipc_dev;
>>>> + }
>>>> +
>>>> + return 0;
>>>> +
>>>> +err_unregister_ipc_dev:
>>>> + platform_device_unregister(priv->ipc_dev);
>>>> +
>>>> + return ret;
>>>> +}
>>>> +
>>>> +static void imx95_remove(struct snd_sof_dev *sdev)
>>>> +{
>>>> + struct imx95_priv *priv;
>>>> +
>>>> + priv = sdev->pdata->hw_pdata;
>>>> +
>>>> + if (imx95_disable_enable_core(false))
>>>> + dev_err(sdev->dev, "failed to stop core\n");
>>>> +
>>>> + platform_device_unregister(priv->ipc_dev);
>>>> +}
>>>> +
>>>> +static const struct snd_sof_dsp_ops sof_imx95_ops = {
>>>> + .probe = imx95_probe,
>>>> + .remove = imx95_remove,
>>>> +
>>>> + /* mandatory "DSP" ops */
>>>> + .run = imx95_run,
>>>> + .block_read = sof_block_read,
>>>> + .block_write = sof_block_write,
>>>> + .send_msg = imx95_send_msg,
>>>> + .load_firmware = snd_sof_load_firmware_memcpy,
>>>> + .ipc_msg_data = sof_ipc_msg_data,
>>>> +
>>>> + .mailbox_read = sof_mailbox_read,
>>>> + .mailbox_write = sof_mailbox_write,
>>>> +
>>>> + .get_mailbox_offset = imx95_get_mailbox_offset,
>>>> + .get_bar_index = imx95_get_bar_index,
>>>> + .get_window_offset = imx95_get_window_offset,
>>>> +
>>>> + .pcm_open = sof_stream_pcm_open,
>>>> + .pcm_close = sof_stream_pcm_close,
>>>> + .set_stream_data_offset = sof_set_stream_data_offset,
>>>> +
>>>> + .runtime_suspend = imx95_runtime_suspend,
>>>> + .runtime_resume = imx95_runtime_resume,
>>>> +
>>>> + .resume = imx95_resume,
>>>> + .suspend = imx95_suspend,
>>>> +
>>>> + .set_power_state = imx95_set_power_state,
>>>> +
>>>> + .drv = imx95_dai,
>>>> + .num_drv = ARRAY_SIZE(imx95_dai),
>>>> +
>>>> + .hw_info = SNDRV_PCM_INFO_MMAP |
>>>> + SNDRV_PCM_INFO_MMAP_VALID |
>>>> + SNDRV_PCM_INFO_INTERLEAVED |
>>>> + SNDRV_PCM_INFO_PAUSE |
>>>> + SNDRV_PCM_INFO_BATCH |
>>>> + SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
>>>> +};
>>>> +
>>>> +static struct snd_sof_of_mach sof_imx95_machs[] = {
>>>> + {
>>>> + .compatible = "fsl,imx95-19x19-evk",
>>>> + .sof_tplg_filename = "sof-imx95-wm8962.tplg",
>>>> + .drv_name = "asoc-audio-graph-card2",
>>>> + },
>>>> + {
>>>> + },
>>>> +};
>>>> +
>>>> +static struct sof_dev_desc sof_of_imx95_desc = {
>>>> + .of_machines = sof_imx95_machs,
>>>> + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3),
>>>> + .ipc_default = SOF_IPC_TYPE_3,
>>>> + .default_fw_path = {
>>>> + [SOF_IPC_TYPE_3] = "imx/sof",
>>>> + },
>>>> + .default_tplg_path = {
>>>> + [SOF_IPC_TYPE_3] = "imx/sof-tplg",
>>>> + },
>>>> + .default_fw_filename = {
>>>> + [SOF_IPC_TYPE_3] = "sof-imx95.ri",
>>>> + },
>>>> + .ops = &sof_imx95_ops,
>>>> +};
>>>> +
>>>> +static const struct of_device_id sof_of_imx95_ids[] = {
>>>> + { .compatible = "fsl,imx95-cm7-sof", .data = &sof_of_imx95_desc },
>>>> + { },
>>>> +};
>>>> +MODULE_DEVICE_TABLE(of, sof_of_imx95_ids);
>>>> +
>>>> +static struct platform_driver snd_sof_of_imx95_driver = {
>>>> + .probe = sof_of_probe,
>>>> + .remove = sof_of_remove,
>>>> + .driver = {
>>>> + .name = "sof-audio-of-imx95",
>>>> + .pm = &sof_of_pm,
>>>> + .of_match_table = sof_of_imx95_ids,
>>>> + },
>>>> +};
>>>> +module_platform_driver(snd_sof_of_imx95_driver);
>>>> +
>>>> +MODULE_LICENSE("Dual BSD/GPL");
>>>> +MODULE_DESCRIPTION("SOF support for i.MX95 platforms");
>>>> +MODULE_AUTHOR("Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>");
>>>> --
>>>> 2.34.1
>>>>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 4/5] ASoC: SOF: imx: add driver for imx95
2024-12-16 12:23 ` Laurentiu Mihalcea
@ 2024-12-18 13:01 ` Daniel Baluta
2024-12-18 17:06 ` Frank Li
0 siblings, 1 reply; 20+ messages in thread
From: Daniel Baluta @ 2024-12-18 13:01 UTC (permalink / raw)
To: Laurentiu Mihalcea
Cc: Frank Li, Rob Herring, Krzysztof Kozlowski, Shawn Guo,
Daniel Baluta, Mark Brown, Kuninori Morimoto, Takashi Iwai,
Bard Liao, Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel,
devicetree, linux-sound, imx, linux-kernel
> >>> Frank
> >> the SOF drivers do indeed have some similarities, but each of them has their own quirks which IMO makes it a bit harder to add the 95 support. We need to figure out the common parts and then move them to imx-common, but I believe this can be solved incrementally.
> > You should create common part firstly, then implement equal function with
> > existed part. Finially add imx95 part.
> >
> > Frank
>
> Yes, I'm aware of how this _should_ be done, but, like I mentioned, the change is not trivial and will
> require tweaking the other drivers as well. As such, I'd like to get the 95 support in as-is firstly.
>
> Are there any other thoughts on this?
Laurentiu, Frank please trim the emails and keep only the relevant
part for discussion.
As for this matter I think we should go with the current version Laurentiu sent.
It is inline with the implementation for imx8qxp, imx8qm, imx8mp and
imx8ulp which we already have upstream.
There is always space for refactorization and improvements. The
current version of the code
is simple enough to go in as it is.
With this,
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
thanks,
Daniel.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 4/5] ASoC: SOF: imx: add driver for imx95
2024-12-18 13:01 ` Daniel Baluta
@ 2024-12-18 17:06 ` Frank Li
0 siblings, 0 replies; 20+ messages in thread
From: Frank Li @ 2024-12-18 17:06 UTC (permalink / raw)
To: Daniel Baluta
Cc: Laurentiu Mihalcea, Rob Herring, Krzysztof Kozlowski, Shawn Guo,
Daniel Baluta, Mark Brown, Kuninori Morimoto, Takashi Iwai,
Bard Liao, Peter Ujfalusi, Jaroslav Kysela, linux-arm-kernel,
devicetree, linux-sound, imx, linux-kernel
On Wed, Dec 18, 2024 at 03:01:11PM +0200, Daniel Baluta wrote:
> > >>> Frank
> > >> the SOF drivers do indeed have some similarities, but each of them has their own quirks which IMO makes it a bit harder to add the 95 support. We need to figure out the common parts and then move them to imx-common, but I believe this can be solved incrementally.
> > > You should create common part firstly, then implement equal function with
> > > existed part. Finially add imx95 part.
> > >
> > > Frank
> >
> > Yes, I'm aware of how this _should_ be done, but, like I mentioned, the change is not trivial and will
> > require tweaking the other drivers as well. As such, I'd like to get the 95 support in as-is firstly.
> >
> > Are there any other thoughts on this?
>
> Laurentiu, Frank please trim the emails and keep only the relevant
> part for discussion.
>
> As for this matter I think we should go with the current version Laurentiu sent.
>
> It is inline with the implementation for imx8qxp, imx8qm, imx8mp and
> imx8ulp which we already have upstream.
>
> There is always space for refactorization and improvements. The
> current version of the code
> is simple enough to go in as it is.
Need provide enough reason in commit message show why need create new one,
and but not reused existed one, which help maintainer and reviewer to judge
if it make sense.
Frank
>
> With this,
>
> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
>
> thanks,
> Daniel.
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-12-18 17:08 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-13 19:52 [PATCH v2 0/5] add sof support on imx95 Laurentiu Mihalcea
2024-11-13 19:52 ` [PATCH v2 1/5] ASoC: dt-bindings: add common binding for NXP CPUs Laurentiu Mihalcea
2024-11-13 20:03 ` Frank Li
2024-11-15 17:33 ` Rob Herring
2024-11-13 19:52 ` [PATCH v2 2/5] ASoC: dt-bindings: add binding for imx95's CM7 core Laurentiu Mihalcea
2024-11-13 20:07 ` Frank Li
2024-11-13 19:52 ` [PATCH v2 3/5] ASoC: dt-bindings: audio-graph-card2: add widgets and hp-det-gpios support Laurentiu Mihalcea
2024-11-13 20:11 ` Frank Li
2024-12-12 9:59 ` Laurentiu Mihalcea
2024-12-13 0:40 ` Kuninori Morimoto
2024-11-13 19:52 ` [PATCH v2 4/5] ASoC: SOF: imx: add driver for imx95 Laurentiu Mihalcea
2024-11-13 20:17 ` Frank Li
2024-12-12 11:11 ` Laurentiu Mihalcea
2024-12-12 15:13 ` Frank Li
2024-12-16 12:23 ` Laurentiu Mihalcea
2024-12-18 13:01 ` Daniel Baluta
2024-12-18 17:06 ` Frank Li
2024-11-13 19:52 ` [PATCH v2 5/5] arm64: dts: imx: add imx95 dts for sof Laurentiu Mihalcea
2024-11-13 20:21 ` Frank Li
2024-12-12 10:04 ` Laurentiu Mihalcea
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).