Skip to contentSkip to conversation

Add MT8186 ADSP dt-binding

PATCH Superseded Tinghan Shen 3 participants 10 messages Jun 9, 2022 – Jun 16, 2022

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#1 lore raw

PATCH v2 1/3 dt-bindings: dsp: mediatek: Use meaningful names for mbox

In reply to Tinghan Shen

Rename mbox according to action instead of 'mbox0' and 'mbox1'.

---
 .../devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml        | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml +3 -3
index b7e68b0dfa13..6cedd6868cc5 100644
@@ -55,8 +55,8 @@ properties:
 
   mbox-names:
     items:
-      - const: mbox0
-      - const: mbox1
+      - const: rep
+      - const: req
 
   memory-region:
     items:
@@ -100,6 +100,6 @@ examples:
        memory-region = <&adsp_dma_mem_reserved>,
                        <&adsp_mem_reserved>;
        power-domains = <&spm 6>; //MT8195_POWER_DOMAIN_ADSP
-       mbox-names = "mbox0", "mbox1";
+       mbox-names = "rep", "req";
        mboxes = <&adsp_mailbox0>, <&adsp_mailbox1>;
     };
Signature · 1 line
2.18.0
#7 lore raw

PATCH v2 3/3 dt-bindings: dsp: mediatek: add mt8186 dsp document

In reply to Tinghan Shen

This patch adds mt8186 dsp document. The dsp is used for Sound Open Firmware driver node. It includes registers, clocks, memory regions, and mailbox for dsp.

---
 .../bindings/dsp/mediatek,mt8186-dsp.yaml     | 91 +++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml
Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml new file +91 -0
new file mode 100644
index 000000000000..33c78f89d296
@@ -0,0 +1,91 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dsp/mediatek,mt8186-dsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek mt8186 DSP core
+
+maintainers:
+  - Tinghan Shen <[email protected]>
+
+description: |
+  MediaTek mt8186 SoC contains a DSP core used for
+  advanced pre- and post- audio processing.
+
+properties:
+  compatible:
+    const: mediatek,mt8186-dsp
+
+  reg:
+    items:
+      - description: Address and size of the DSP config registers
+      - description: Address and size of the DSP SRAM
+      - description: Address and size of the DSP secure registers
+      - description: Address and size of the DSP bus registers
+
+  reg-names:
+    items:
+      - const: cfg
+      - const: sram
+      - const: sec
+      - const: bus
+
+  clocks:
+    items:
+      - description: mux for audio dsp clock
+      - description: mux for audio dsp local bus
+
+  clock-names:
+    items:
+      - const: audiodsp
+      - const: adsp_bus
+
+  power-domains:
+    maxItems: 1
+
+  mboxes:
+    items:
+      - description: ipc reply between host and audio DSP.
+      - description: ipc request between host and audio DSP.
+
+  mbox-names:
+    items:
+      - const: rep
+      - const: req
+
+  memory-region:
+    items:
+      - description: dma buffer between host and DSP.
+      - description: DSP system memory.
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+  - power-domains
+  - mbox-names
+  - mboxes
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8186-clk.h>
+    dsp@10680000 {
+        compatible = "mediatek,mt8186-dsp";
+        reg = <0x10680000 0x2000>,
+              <0x10800000 0x100000>,
+              <0x1068b000 0x100>,
+              <0x1068f000 0x1000>;
+        reg-names = "cfg", "sram", "sec", "bus";
+        clocks = <&topckgen CLK_TOP_AUDIODSP>,
+                 <&topckgen CLK_TOP_ADSP_BUS>;
+        clock-names = "audiodsp",
+                      "adsp_bus";
+        power-domains = <&spm 6>;
+        mbox-names = "rep", "req";
+        mboxes = <&adsp_mailbox0>, <&adsp_mailbox1>;
+    };
Signature · 1 line
2.18.0
#4 lore raw

PATCH v2 2/3 firmware: mediatek: Use meaningful names for mbox

In reply to Tinghan Shen

Rename mbox according to action instead of 'mbox0' and 'mbox1'

---
 drivers/firmware/mtk-adsp-ipc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/firmware/mtk-adsp-ipc.c +5 -1
index cb255a99170c..3de94765d659 100644
@@ -83,7 +83,11 @@ static int mtk_adsp_ipc_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	for (i = 0; i < MTK_ADSP_MBOX_NUM; i++) {
-		chan_name = kasprintf(GFP_KERNEL, "mbox%d", i);
+		if (i < MTK_ADSP_MBOX_NUM / 2)
+			chan_name = kasprintf(GFP_KERNEL, "rep");
+		else
+			chan_name = kasprintf(GFP_KERNEL, "req");
+
 		if (!chan_name) {
 			ret = -ENOMEM;
 			goto out;
Signature · 1 line
2.18.0
#0 lore raw

v2 cover Add MT8186 ADSP dt-binding

v1 -> v2:
1. Change mbox-names from mbox0/mbox1 to rep/req for both mt8186 and mt8195.
2. rename clock-names and remove unused headers

Tinghan Shen (3):
dt-bindings: dsp: mediatek: Use meaningful names for mbox
firmware: mediatek: Use meaningful names for mbox
dt-bindings: dsp: mediatek: add mt8186 dsp document

 .../bindings/dsp/mediatek,mt8186-dsp.yaml     | 91 +++++++++++++++++++
 .../bindings/dsp/mediatek,mt8195-dsp.yaml     |  6 +-
 drivers/firmware/mtk-adsp-ipc.c               |  6 +-
 3 files changed, 99 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml
Signature · 1 line
2.18.0
#5 lore raw

Re: [PATCH v2 2/3] firmware: mediatek: Use meaningful names for mbox

In reply to Tinghan Shen

Il 09/06/22 10:31, Tinghan Shen ha scritto:

Quoted 14 lines

Rename mbox according to action instead of 'mbox0' and 'mbox1'

---
  drivers/firmware/mtk-adsp-ipc.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
drivers/firmware/mtk-adsp-ipc.c +0 -0
index cb255a99170c..3de94765d659 100644
@@ -83,7 +83,11 @@ static int mtk_adsp_ipc_probe(struct platform_device *pdev)
  		return -ENOMEM;
 

drivers/firmware/mtk-adsp-ipc.c static int mtk_adsp_ipc_probe(struct platform_device *pdev) · line 93

Quoted 10 lines
drivers/firmware/mtk-adsp-ipc.c +5 -1
  	for (i = 0; i < MTK_ADSP_MBOX_NUM; i++) {
-		chan_name = kasprintf(GFP_KERNEL, "mbox%d", i);
+		if (i < MTK_ADSP_MBOX_NUM / 2)
+			chan_name = kasprintf(GFP_KERNEL, "rep");
+		else
+			chan_name = kasprintf(GFP_KERNEL, "req");
+
  		if (!chan_name) {
  			ret = -ENOMEM;
  			goto out;

At this point, just call them "reply" and "request", as that simply provides a perfectly clear explanation.

Besides, I'm sorry but I really don't like this code, it's really too much fragile and will have to be changed entirely if a third mbox is introduced.

I can suggest a cooler way:

static const char * const adsp_mbox_ch_names[MTK_ADSP_MBOX_NUM] = { "rep", "req" };

for (i = 0; i < ARRAY_SIZE(adsp_mbox_ch_names); i++) {
	/* we can delete chan_name and also avoid a kfree if we do... */

	.... code ....

	adsp_chan->ch = mbox_request_channel_byname(cl, adsp_mbox_ch_names[i]);

	... etc etc ...
}

Cheers,
Angelo

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: dsp: mediatek: Use meaningful names for mbox

In reply to Tinghan Shen

Il 09/06/22 10:30, Tinghan Shen ha scritto:

Quoted 12 lines

Rename mbox according to action instead of 'mbox0' and 'mbox1'.

---
  .../devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml        | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml +0 -0
index b7e68b0dfa13..6cedd6868cc5 100644

Documentation/devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml properties: · line 59

Quoted 7 lines
Documentation/devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml +2 -2
@@ -55,8 +55,8 @@ properties:
 
    mbox-names:
      items:
-      - const: mbox0
-      - const: mbox1
+      - const: rep
+      - const: req

"reply", "request" - as said on patch [2/3]....

P.S.: Adding context for anyone else reading this patch, mt8195 devicetrees didn't
get any dsp node yet.

Documentation/devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml examples: · line 105

Quoted 11 lines
Documentation/devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml +1 -1
    memory-region:
      items:
@@ -100,6 +100,6 @@ examples:
         memory-region = <&adsp_dma_mem_reserved>,
                         <&adsp_mem_reserved>;
         power-domains = <&spm 6>; //MT8195_POWER_DOMAIN_ADSP
-       mbox-names = "mbox0", "mbox1";
+       mbox-names = "rep", "req";
         mboxes = <&adsp_mailbox0>, <&adsp_mailbox1>;
      };

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#6 lore raw

Re: [PATCH v2 2/3] firmware: mediatek: Use meaningful names for mbox

In reply to AngeloGioacchino Del Regno

Hi Angelo,

Quoted 46 lines · AngeloGioacchino Del Regno

Il 09/06/22 10:31, Tinghan Shen ha scritto:

Quoted 14 lines

Rename mbox according to action instead of 'mbox0' and 'mbox1'

---
  drivers/firmware/mtk-adsp-ipc.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
drivers/firmware/mtk-adsp-ipc.c +0 -0
index cb255a99170c..3de94765d659 100644
@@ -83,7 +83,11 @@ static int mtk_adsp_ipc_probe(struct platform_device *pdev)
  		return -ENOMEM;
 

drivers/firmware/mtk-adsp-ipc.c static int mtk_adsp_ipc_probe(struct platform_device *pdev) · line 93

Quoted 10 lines
drivers/firmware/mtk-adsp-ipc.c +5 -1
  	for (i = 0; i < MTK_ADSP_MBOX_NUM; i++) {
-		chan_name = kasprintf(GFP_KERNEL, "mbox%d", i);
+		if (i < MTK_ADSP_MBOX_NUM / 2)
+			chan_name = kasprintf(GFP_KERNEL, "rep");
+		else
+			chan_name = kasprintf(GFP_KERNEL, "req");
+
  		if (!chan_name) {
  			ret = -ENOMEM;
  			goto out;

At this point, just call them "reply" and "request", as that simply provides a perfectly clear explanation.

Besides, I'm sorry but I really don't like this code, it's really too much fragile and will have to be changed entirely if a third mbox is introduced.

I can suggest a cooler way:

static const char * const adsp_mbox_ch_names[MTK_ADSP_MBOX_NUM] = { "rep", "req" };

for (i = 0; i < ARRAY_SIZE(adsp_mbox_ch_names); i++) {
	/* we can delete chan_name and also avoid a kfree if we do... */

	.... code ....

	adsp_chan->ch = mbox_request_channel_byname(cl, adsp_mbox_ch_names[i]);

	... etc etc ...
}
Quoted 2 lines

Cheers,
Angelo

Ok, I'll update in the next version.
Thank you!

Best regards,
TingHan

#3 lore raw

Re: [PATCH v2 1/3] dt-bindings: dsp: mediatek: Use meaningful names for mbox

In reply to Tinghan Shen
Quoted 12 lines · Tinghan Shen

Rename mbox according to action instead of 'mbox0' and 'mbox1'.

---
 .../devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml        | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml +0 -0
index b7e68b0dfa13..6cedd6868cc5 100644

Documentation/devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml properties: · line 60

Quoted 8 lines
Documentation/devicetree/bindings/dsp/mediatek,mt8195-dsp.yaml +2 -2
@@ -55,8 +55,8 @@ properties:
 
   mbox-names:
     items:
-      - const: mbox0
-      - const: mbox1
+      - const: rep
+      - const: req
 

More common is rx/tx, which I proposed last time.

Best regards,
Krzysztof

#8 lore raw

Re: [PATCH v2 3/3] dt-bindings: dsp: mediatek: add mt8186 dsp document

In reply to Tinghan Shen
Quoted 56 lines · Tinghan Shen

This patch adds mt8186 dsp document. The dsp is used for Sound Open Firmware driver node. It includes registers, clocks, memory regions, and mailbox for dsp.

---
 .../bindings/dsp/mediatek,mt8186-dsp.yaml     | 91 +++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml
Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml new file +40 -0
new file mode 100644
index 000000000000..33c78f89d296
@@ -0,0 +1,91 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dsp/mediatek,mt8186-dsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek mt8186 DSP core
+
+maintainers:
+  - Tinghan Shen <[email protected]>
+
+description: |
+  MediaTek mt8186 SoC contains a DSP core used for
+  advanced pre- and post- audio processing.
+
+properties:
+  compatible:
+    const: mediatek,mt8186-dsp
+
+  reg:
+    items:
+      - description: Address and size of the DSP config registers
+      - description: Address and size of the DSP SRAM
+      - description: Address and size of the DSP secure registers
+      - description: Address and size of the DSP bus registers
+
+  reg-names:
+    items:
+      - const: cfg
+      - const: sram
+      - const: sec
+      - const: bus
+
+  clocks:
+    items:
+      - description: mux for audio dsp clock
+      - description: mux for audio dsp local bus
+
+  clock-names:
+    items:

Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml line 50

Quoted 10 lines
Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml new file +10 -0
+      - const: audiodsp
+      - const: adsp_bus
+
+  power-domains:
+    maxItems: 1
+
+  mboxes:
+    items:
+      - description: ipc reply between host and audio DSP.
+      - description: ipc request between host and audio DSP.

"IPC request between" does not specify who sends the request. Host or DSP?

See existing bindings for some better examples, e.g.:
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml which clearly states who receives from who.

Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml line 55

Quoted 5 lines
Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml new file +5 -0
+
+  mbox-names:
+    items:
+      - const: rep
+      - const: req

tx/rx

Best regards,
Krzysztof

#9 lore raw

Re: [PATCH v2 3/3] dt-bindings: dsp: mediatek: add mt8186 dsp document

Hi Krzysztof,

Quoted 85 lines · Krzysztof Kozlowski
Quoted 61 lines · Tinghan Shen

This patch adds mt8186 dsp document. The dsp is used for Sound Open Firmware driver node. It includes registers, clocks, memory regions, and mailbox for dsp.

---
 .../bindings/dsp/mediatek,mt8186-dsp.yaml     | 91 +++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml
Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml new file +4 -0
new file mode 100644
index 000000000000..33c78f89d296
@@ -0,0 +1,91 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/dsp/mediatek,mt8186-dsp.yaml*__;Iw!!CTRNKA9wMg0ARbw!0iJc3XTOVoKM_s-soALULRxog7f0GZLppKL0FCcIrYfh91fW2HmlpzSUZjVmoUR5PrasY2BmVGvmvv_IwZtlmOdXYw$

+$schema:
https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!0iJc3XTOVoKM_s-soALULRxog7f0GZLppKL0FCcIrYfh91fW2HmlpzSUZjVmoUR5PrasY2BmVGvmvv_IwZujnl7wMw$

Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml new file +35 -0
+
+title: MediaTek mt8186 DSP core
+
+maintainers:
+  - Tinghan Shen <[email protected]>
+
+description: |
+  MediaTek mt8186 SoC contains a DSP core used for
+  advanced pre- and post- audio processing.
+
+properties:
+  compatible:
+    const: mediatek,mt8186-dsp
+
+  reg:
+    items:
+      - description: Address and size of the DSP config registers
+      - description: Address and size of the DSP SRAM
+      - description: Address and size of the DSP secure registers
+      - description: Address and size of the DSP bus registers
+
+  reg-names:
+    items:
+      - const: cfg
+      - const: sram
+      - const: sec
+      - const: bus
+
+  clocks:
+    items:
+      - description: mux for audio dsp clock
+      - description: mux for audio dsp local bus
+
+  clock-names:
+    items:

Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml line 50

Quoted 10 lines
Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml new file +10 -0
+      - const: audiodsp
+      - const: adsp_bus
+
+  power-domains:
+    maxItems: 1
+
+  mboxes:
+    items:
+      - description: ipc reply between host and audio DSP.
+      - description: ipc request between host and audio DSP.

"IPC request between" does not specify who sends the request. Host or DSP?

See existing bindings for some better examples, e.g.:
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml which clearly states who receives from who.

Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml line 55

Quoted 5 lines
Documentation/devicetree/bindings/dsp/mediatek,mt8186-dsp.yaml new file +5 -0
+
+  mbox-names:
+    items:
+      - const: rep
+      - const: req
Quoted 7 lines

tx/rx

Best regards,
Krzysztof

OK. I'll update in the next version.

Thanks,
TingHan