Skip to contentSkip to conversation

Allwinner sun6i message box support

PATCH Superseded Samuel Holland 4 participants 15 messages Dec 15, 2019 – Jan 2, 2020

Subsystems (5)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Samuel Holland

author maintainer
#0 lore raw

v5 cover Allwinner sun6i message box support

This series adds support for the "hardware message box" in sun8i, sun9i, and sun50i SoCs, used for communication with the ARISC management processor (the platform's equivalent of the ARM SCP). The end goal is to use the arm_scpi driver as a client, communicating with firmware running on the ARISC CPU.

I have tested this driver with various firmware programs on the A64, H5, and H6 SoCs (including specifically this arm_scpi patch on A64 and H6), and Ondrej Jirman has tested the driver on the A83T (using a similar patch to arm_scpi).

The change to make the arm_scpi compatible with unidirectional mailbox controllers is attached to the end of this patch series. While it would be nice to get this merged too, I don't consider it a prerequisite to getting the driver merged. And even without the driver, the clock change (patch #1) can go in at any time.

Thanks,
Samuel

Changes from v4:
- Rebased on sunxi-next
- Dropped AR100 clock patch, as it was controversial and unnecessary
- Renamed sunxi-msgbox to sun6i-msgbox and sun6i-a31-msgbox
- Added comments about not asserting the reset line
- Dropped A80 DTS changes as they were untested
- Added Ondrej's Tested-by for A83T
- Dropped the demo; replaced with a real arm_scpi fix

Changes from v3:
- Rebased on sunxi-next
- Added Rob's Reviewed-by for patch 3
- Fixed a crash when receiving a message on a disabled channel
- Cleaned up some comments/formatting in the driver
- Fixed #mbox-cells in sunxi-h3-h5.dtsi (patch 7)
- Removed the irqchip example (no longer relevant to the fw design)
- Added a demo/example client that uses the driver and a toy firmware

Changes from v2:
- Merge patches 1-3
- Add a comment in the code explaining the CLK_IS_CRITICAL usage
- Add a patch to mark the AR100 clocks as critical
- Use YAML for the device tree binding
- Include a not-for-merge example usage of the mailbox

Changes from v1:
- Marked message box clocks as critical instead of hacks in the driver
- 8 unidirectional channels instead of 4 bidirectional pairs
- Use per-SoC compatible strings and an A31 fallback compatible
- Dropped the mailbox framework patch
- Include DT patches for SoCs that document the message box

Samuel Holland (8):
clk: sunxi-ng: Mark msgbox clocks as critical
dt-bindings: mailbox: Add a sun6i message box binding
mailbox: sun6i-msgbox: Add a new mailbox driver
ARM: dts: sunxi: a83t: Add msgbox node
ARM: dts: sunxi: h3/h5: Add msgbox node
arm64: dts: allwinner: a64: Add msgbox node
arm64: dts: allwinner: h6: Add msgbox node
firmware: arm_scpi: Support unidirectional mailbox channels

 .../mailbox/allwinner,sun6i-a31-msgbox.yaml   |  78 ++++
 arch/arm/boot/dts/sun8i-a83t.dtsi             |  10 +
 arch/arm/boot/dts/sunxi-h3-h5.dtsi            |  10 +
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi |  10 +
 arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi  |  10 +
 drivers/clk/sunxi-ng/ccu-sun50i-a64.c         |   3 +-
 drivers/clk/sunxi-ng/ccu-sun50i-h6.c          |   3 +-
 drivers/clk/sunxi-ng/ccu-sun8i-a23.c          |   3 +-
 drivers/clk/sunxi-ng/ccu-sun8i-a33.c          |   3 +-
 drivers/clk/sunxi-ng/ccu-sun8i-a83t.c         |   3 +-
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c           |   3 +-
 drivers/clk/sunxi-ng/ccu-sun9i-a80.c          |   3 +-
 drivers/firmware/arm_scpi.c                   |  58 ++-
 drivers/mailbox/Kconfig                       |   9 +
 drivers/mailbox/Makefile                      |   2 +
 drivers/mailbox/sun6i-msgbox.c                | 332 ++++++++++++++++++
 16 files changed, 520 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml
 create mode 100644 drivers/mailbox/sun6i-msgbox.c
Signature · 1 line
2.23.0
author maintainer
#1 lore raw

PATCH v5 1/8 clk: sunxi-ng: Mark msgbox clocks as critical

The msgbox clock is critical because the hardware it controls is shared between Linux and system firmware. The message box may be used by the EL3 secure monitor's PSCI implementation. On 64-bit sunxi SoCs, this is provided by ARM TF-A; 32-bit SoCs use a different implementation. The secure monitor uses the message box to forward requests to power management firmware running on a separate CPU.

It is not enough for the secure monitor to enable the clock each time Linux performs a SMC into EL3, as both the firmware and Linux can run concurrently on separate CPUs. So it is never safe for Linux to turn this clock off, and it should be marked as critical.

At this time, such power management firmware only exists for the A64 and H5 SoCs. However, it makes sense to take care of all CCU drivers now for consistency, and to ease the transition in the future once firmware is ported to the other SoCs.

---
 drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 3 ++-
 drivers/clk/sunxi-ng/ccu-sun50i-h6.c  | 3 ++-
 drivers/clk/sunxi-ng/ccu-sun8i-a23.c  | 3 ++-
 drivers/clk/sunxi-ng/ccu-sun8i-a33.c  | 3 ++-
 drivers/clk/sunxi-ng/ccu-sun8i-a83t.c | 3 ++-
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c   | 3 ++-
 drivers/clk/sunxi-ng/ccu-sun9i-a80.c  | 3 ++-
 7 files changed, 14 insertions(+), 7 deletions(-)
drivers/clk/sunxi-ng/ccu-sun50i-a64.c +2 -1
index 49bd7a4c015c..045121b50da3 100644
@@ -342,8 +342,9 @@ static SUNXI_CCU_GATE(bus_de_clk,	"bus-de",	"ahb1",
 		      0x064, BIT(12), 0);
 static SUNXI_CCU_GATE(bus_gpu_clk,	"bus-gpu",	"ahb1",
 		      0x064, BIT(20), 0);
+/* Used for communication between firmware components at runtime */
 static SUNXI_CCU_GATE(bus_msgbox_clk,	"bus-msgbox",	"ahb1",
-		      0x064, BIT(21), 0);
+		      0x064, BIT(21), CLK_IS_CRITICAL);
 static SUNXI_CCU_GATE(bus_spinlock_clk,	"bus-spinlock",	"ahb1",
 		      0x064, BIT(22), 0);
 
drivers/clk/sunxi-ng/ccu-sun50i-h6.c +2 -1
index f2497d0a4683..91da52ca3c75 100644
@@ -349,8 +349,9 @@ static SUNXI_CCU_GATE(bus_vp9_clk, "bus-vp9", "psi-ahb1-ahb2",
 static SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "psi-ahb1-ahb2",
 		      0x70c, BIT(0), 0);
 
+/* Used for communication between firmware components at runtime */
 static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "psi-ahb1-ahb2",
-		      0x71c, BIT(0), 0);
+		      0x71c, BIT(0), CLK_IS_CRITICAL);
 
 static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "psi-ahb1-ahb2",
 		      0x72c, BIT(0), 0);
drivers/clk/sunxi-ng/ccu-sun8i-a23.c +2 -1
index 103aa504f6c8..5a28583f57e2 100644
@@ -255,8 +255,9 @@ static SUNXI_CCU_GATE(bus_de_fe_clk,	"bus-de-fe",	"ahb1",
 		      0x064, BIT(14), 0);
 static SUNXI_CCU_GATE(bus_gpu_clk,	"bus-gpu",	"ahb1",
 		      0x064, BIT(20), 0);
+/* Used for communication between firmware components at runtime */
 static SUNXI_CCU_GATE(bus_msgbox_clk,	"bus-msgbox",	"ahb1",
-		      0x064, BIT(21), 0);
+		      0x064, BIT(21), CLK_IS_CRITICAL);
 static SUNXI_CCU_GATE(bus_spinlock_clk,	"bus-spinlock",	"ahb1",
 		      0x064, BIT(22), 0);
 static SUNXI_CCU_GATE(bus_drc_clk,	"bus-drc",	"ahb1",
drivers/clk/sunxi-ng/ccu-sun8i-a33.c +2 -1
index 91838cd11037..50cf3726ef30 100644
@@ -267,8 +267,9 @@ static SUNXI_CCU_GATE(bus_de_fe_clk,	"bus-de-fe",	"ahb1",
 		      0x064, BIT(14), 0);
 static SUNXI_CCU_GATE(bus_gpu_clk,	"bus-gpu",	"ahb1",
 		      0x064, BIT(20), 0);
+/* Used for communication between firmware components at runtime */
 static SUNXI_CCU_GATE(bus_msgbox_clk,	"bus-msgbox",	"ahb1",
-		      0x064, BIT(21), 0);
+		      0x064, BIT(21), CLK_IS_CRITICAL);
 static SUNXI_CCU_GATE(bus_spinlock_clk,	"bus-spinlock",	"ahb1",
 		      0x064, BIT(22), 0);
 static SUNXI_CCU_GATE(bus_drc_clk,	"bus-drc",	"ahb1",
drivers/clk/sunxi-ng/ccu-sun8i-a83t.c +2 -1
index 2b434521c5cc..4ab3a76f4ffa 100644
@@ -339,8 +339,9 @@ static SUNXI_CCU_GATE(bus_de_clk,	"bus-de",	"ahb1",
 		      0x064, BIT(12), 0);
 static SUNXI_CCU_GATE(bus_gpu_clk,	"bus-gpu",	"ahb1",
 		      0x064, BIT(20), 0);
+/* Used for communication between firmware components at runtime */
 static SUNXI_CCU_GATE(bus_msgbox_clk,	"bus-msgbox",	"ahb1",
-		      0x064, BIT(21), 0);
+		      0x064, BIT(21), CLK_IS_CRITICAL);
 static SUNXI_CCU_GATE(bus_spinlock_clk,	"bus-spinlock",	"ahb1",
 		      0x064, BIT(22), 0);
 
drivers/clk/sunxi-ng/ccu-sun8i-h3.c +2 -1
index 6b636362379e..7429d3fe8fb7 100644
@@ -273,8 +273,9 @@ static SUNXI_CCU_GATE(bus_de_clk,	"bus-de",	"ahb1",
 		      0x064, BIT(12), 0);
 static SUNXI_CCU_GATE(bus_gpu_clk,	"bus-gpu",	"ahb1",
 		      0x064, BIT(20), 0);
+/* Used for communication between firmware components at runtime */
 static SUNXI_CCU_GATE(bus_msgbox_clk,	"bus-msgbox",	"ahb1",
-		      0x064, BIT(21), 0);
+		      0x064, BIT(21), CLK_IS_CRITICAL);
 static SUNXI_CCU_GATE(bus_spinlock_clk,	"bus-spinlock",	"ahb1",
 		      0x064, BIT(22), 0);
 
drivers/clk/sunxi-ng/ccu-sun9i-a80.c +2 -1
index ef29582676f6..471e841aabdf 100644
@@ -748,8 +748,9 @@ static SUNXI_CCU_GATE(bus_usb_clk,	"bus-usb",	"ahb1",
 		      0x584, BIT(1), 0);
 static SUNXI_CCU_GATE(bus_gmac_clk,	"bus-gmac",	"ahb1",
 		      0x584, BIT(17), 0);
+/* Used for communication between firmware components at runtime */
 static SUNXI_CCU_GATE(bus_msgbox_clk,	"bus-msgbox",	"ahb1",
-		      0x584, BIT(21), 0);
+		      0x584, BIT(21), CLK_IS_CRITICAL);
 static SUNXI_CCU_GATE(bus_spinlock_clk,	"bus-spinlock",	"ahb1",
 		      0x584, BIT(22), 0);
 static SUNXI_CCU_GATE(bus_hstimer_clk,	"bus-hstimer",	"ahb1",
Signature · 1 line
2.23.0
#2 lore raw

Re: [PATCH v5 1/8] clk: sunxi-ng: Mark msgbox clocks as critical

Quoted 12 lines · Samuel Holland

The msgbox clock is critical because the hardware it controls is shared between Linux and system firmware. The message box may be used by the EL3 secure monitor's PSCI implementation. On 64-bit sunxi SoCs, this is provided by ARM TF-A; 32-bit SoCs use a different implementation. The secure monitor uses the message box to forward requests to power management firmware running on a separate CPU.

It is not enough for the secure monitor to enable the clock each time Linux performs a SMC into EL3, as both the firmware and Linux can run concurrently on separate CPUs. So it is never safe for Linux to turn this clock off, and it should be marked as critical.

Quoted 6 lines

At this time, such power management firmware only exists for the A64 and H5 SoCs. However, it makes sense to take care of all CCU drivers now for consistency, and to ease the transition in the future once firmware is ported to the other SoCs.

This is pretty much the same case than for the AR100 clock though, right?

I'm still not sure about why we should enable it that clock all the time, even if you're not using the ARISC.

Maxime

author maintainer
#3 lore raw

PATCH v5 2/8 dt-bindings: mailbox: Add a sun6i message box binding

In reply to Samuel Holland

This mailbox hardware is present in Allwinner sun6i, sun8i, sun9i, and sun50i SoCs. Add a device tree binding for it. As it has only been tested on the A83T, A64, H3/H5, and H6 SoCs, only those compatibles are included.

---
 .../mailbox/allwinner,sun6i-a31-msgbox.yaml   | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +78 -0
new file mode 100644
index 000000000000..dd746e07acfd
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/allwinner,sun6i-a31-msgbox.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner sunxi Message Box
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+description: |
+  The hardware message box on sun6i, sun8i, sun9i, and sun50i SoCs is a
+  two-user mailbox controller containing 8 unidirectional FIFOs. An interrupt
+  is raised for received messages, but software must poll to know when a
+  transmitted message has been acknowledged by the remote user. Each FIFO can
+  hold four 32-bit messages; when a FIFO is full, clients must wait before
+  attempting more transmissions.
+
+  Refer to ./mailbox.txt for generic information about mailbox device-tree
+  bindings.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - allwinner,sun8i-a83t-msgbox
+          - allwinner,sun8i-h3-msgbox
+          - allwinner,sun50i-a64-msgbox
+          - allwinner,sun50i-h6-msgbox
+      - const: allwinner,sun6i-a31-msgbox
+
+  reg:
+    items:
+      - description: MMIO register range
+
+  clocks:
+    maxItems: 1
+    description: bus clock
+
+  resets:
+    maxItems: 1
+    description: bus reset
+
+  interrupts:
+    maxItems: 1
+    description: controller interrupt
+
+  '#mbox-cells':
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - resets
+  - interrupts
+  - '#mbox-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/sun8i-h3-ccu.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/reset/sun8i-h3-ccu.h>
+
+    msgbox: mailbox@1c17000 {
+            compatible = "allwinner,sun8i-h3-msgbox",
+                         "allwinner,sun6i-a31-msgbox";
+            reg = <0x01c17000 0x1000>;
+            clocks = <&ccu CLK_BUS_MSGBOX>;
+            resets = <&ccu RST_BUS_MSGBOX>;
+            interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
+            #mbox-cells = <1>;
+    };
+
+...
Signature · 1 line
2.23.0
#4 lore raw

Re: [PATCH v5 2/8] dt-bindings: mailbox: Add a sun6i message box binding

Hi,

Quoted 38 lines · Samuel Holland

This mailbox hardware is present in Allwinner sun6i, sun8i, sun9i, and sun50i SoCs. Add a device tree binding for it. As it has only been tested on the A83T, A64, H3/H5, and H6 SoCs, only those compatibles are included.

---
 .../mailbox/allwinner,sun6i-a31-msgbox.yaml   | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +21 -0
new file mode 100644
index 000000000000..dd746e07acfd
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/allwinner,sun6i-a31-msgbox.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner sunxi Message Box
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+description: |
+  The hardware message box on sun6i, sun8i, sun9i, and sun50i SoCs is a
+  two-user mailbox controller containing 8 unidirectional FIFOs. An interrupt
+  is raised for received messages, but software must poll to know when a
+  transmitted message has been acknowledged by the remote user. Each FIFO can
+  hold four 32-bit messages; when a FIFO is full, clients must wait before
+  attempting more transmissions.
+
+  Refer to ./mailbox.txt for generic information about mailbox device-tree
+  bindings.

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 31

Quoted 10 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +10 -0
+
+properties:
+  compatible:
+     items:
+      - enum:
+          - allwinner,sun8i-a83t-msgbox
+          - allwinner,sun8i-h3-msgbox
+          - allwinner,sun50i-a64-msgbox
+          - allwinner,sun50i-h6-msgbox
+      - const: allwinner,sun6i-a31-msgbox

This will fail for the A31, since it won't have two compatibles but just one.

You can have something like this if you want to do it with an enum:

compatible:
oneOf:
- const: allwinner,sun6i-a31-msgbox
- items:
- enum:
- allwinner,sun8i-a83t-msgbox
- allwinner,sun8i-h3-msgbox
- allwinner,sun50i-a64-msgbox
- allwinner,sun50i-h6-msgbox
- const: allwinner,sun6i-a31-msgbox

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 35

Quoted 3 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +3 -0
+  reg:
+    items:
+      - description: MMIO register range

There's no need for an obvious description like this. Just set it to maxItems: 1

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 47

Quoted 12 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +12 -0
+
+  clocks:
+    maxItems: 1
+    description: bus clock
+
+  resets:
+    maxItems: 1
+    description: bus reset
+
+  interrupts:
+    maxItems: 1
+    description: controller interrupt

Ditto, you can drop the description here.

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 50

Quoted 2 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +2 -0
+  '#mbox-cells':
+    const: 1

However, you should document what the argument is about?

Quoted 15 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +15 -0
+required:
+  - compatible
+  - reg
+  - clocks
+  - resets
+  - interrupts
+  - '#mbox-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/sun8i-h3-ccu.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/reset/sun8i-h3-ccu.h>

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 76

Quoted 10 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +10 -0
+
+    msgbox: mailbox@1c17000 {
+            compatible = "allwinner,sun8i-h3-msgbox",
+                         "allwinner,sun6i-a31-msgbox";
+            reg = <0x01c17000 0x1000>;
+            clocks = <&ccu CLK_BUS_MSGBOX>;
+            resets = <&ccu RST_BUS_MSGBOX>;
+            interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
+            #mbox-cells = <1>;
+    };

Look good otherwise, thanks!
Maxime

author maintainer
#5 lore raw

Re: [PATCH v5 2/8] dt-bindings: mailbox: Add a sun6i message box binding

Hi,

Quoted 46 lines · Maxime Ripard

Hi,

Quoted 43 lines · Samuel Holland

This mailbox hardware is present in Allwinner sun6i, sun8i, sun9i, and sun50i SoCs. Add a device tree binding for it. As it has only been tested on the A83T, A64, H3/H5, and H6 SoCs, only those compatibles are included.

---
 .../mailbox/allwinner,sun6i-a31-msgbox.yaml   | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +26 -0
new file mode 100644
index 000000000000..dd746e07acfd
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/allwinner,sun6i-a31-msgbox.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner sunxi Message Box
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+description: |
+  The hardware message box on sun6i, sun8i, sun9i, and sun50i SoCs is a
+  two-user mailbox controller containing 8 unidirectional FIFOs. An interrupt
+  is raised for received messages, but software must poll to know when a
+  transmitted message has been acknowledged by the remote user. Each FIFO can
+  hold four 32-bit messages; when a FIFO is full, clients must wait before
+  attempting more transmissions.
+
+  Refer to ./mailbox.txt for generic information about mailbox device-tree
+  bindings.
+
+properties:
+  compatible:
+     items:
+      - enum:
Quoted 8 lines

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 31

Quoted 5 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +5 -0
+          - allwinner,sun8i-a83t-msgbox
+          - allwinner,sun8i-h3-msgbox
+          - allwinner,sun50i-a64-msgbox
+          - allwinner,sun50i-h6-msgbox
+      - const: allwinner,sun6i-a31-msgbox

This will fail for the A31, since it won't have two compatibles but just one.

You asked me earlier to only include compatibles that had been tested, so I did. This hasn't been tested on the A31, so there's no A31-only compatible.

Quoted 13 lines

You can have something like this if you want to do it with an enum:

compatible:
oneOf:
- const: allwinner,sun6i-a31-msgbox
- items:
- enum:
- allwinner,sun8i-a83t-msgbox
- allwinner,sun8i-h3-msgbox
- allwinner,sun50i-a64-msgbox
- allwinner,sun50i-h6-msgbox
- const: allwinner,sun6i-a31-msgbox

Quoted 6 lines

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 35

Quoted 3 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +3 -0
+  reg:
+    items:
+      - description: MMIO register range

There's no need for an obvious description like this. Just set it to maxItems: 1

Will do for v6.

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +6 -0
+
+  clocks:
+    maxItems: 1
+    description: bus clock
+
+  resets:
Quoted 8 lines

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 47

Quoted 6 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +6 -0
+    maxItems: 1
+    description: bus reset
+
+  interrupts:
+    maxItems: 1
+    description: controller interrupt

Ditto, you can drop the description here.

Will do for v6.

Quoted 4 lines

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 50

Quoted 2 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +2 -0
+  '#mbox-cells':
+    const: 1

However, you should document what the argument is about?

Ok. "Number of cells used to encode a mailbox specifier" should work.

Quoted 20 lines
Quoted 20 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +20 -0
+required:
+  - compatible
+  - reg
+  - clocks
+  - resets
+  - interrupts
+  - '#mbox-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/sun8i-h3-ccu.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/reset/sun8i-h3-ccu.h>
+
+    msgbox: mailbox@1c17000 {
+            compatible = "allwinner,sun8i-h3-msgbox",
+                         "allwinner,sun6i-a31-msgbox";
+            reg = <0x01c17000 0x1000>;
Quoted 9 lines

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 76

Quoted 5 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +5 -0
+            clocks = <&ccu CLK_BUS_MSGBOX>;
+            resets = <&ccu RST_BUS_MSGBOX>;
+            interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
+            #mbox-cells = <1>;
+    };

Look good otherwise, thanks!
Maxime

Thanks,
Samuel

#6 lore raw

Re: [PATCH v5 2/8] dt-bindings: mailbox: Add a sun6i message box binding

Hi,

Quoted 56 lines · Samuel Holland
Quoted 46 lines · Maxime Ripard

Hi,

Quoted 43 lines · Samuel Holland

This mailbox hardware is present in Allwinner sun6i, sun8i, sun9i, and sun50i SoCs. Add a device tree binding for it. As it has only been tested on the A83T, A64, H3/H5, and H6 SoCs, only those compatibles are included.

---
 .../mailbox/allwinner,sun6i-a31-msgbox.yaml   | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +26 -0
new file mode 100644
index 000000000000..dd746e07acfd
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/allwinner,sun6i-a31-msgbox.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner sunxi Message Box
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+description: |
+  The hardware message box on sun6i, sun8i, sun9i, and sun50i SoCs is a
+  two-user mailbox controller containing 8 unidirectional FIFOs. An interrupt
+  is raised for received messages, but software must poll to know when a
+  transmitted message has been acknowledged by the remote user. Each FIFO can
+  hold four 32-bit messages; when a FIFO is full, clients must wait before
+  attempting more transmissions.
+
+  Refer to ./mailbox.txt for generic information about mailbox device-tree
+  bindings.
+
+properties:
+  compatible:
+     items:
+      - enum:
Quoted 8 lines

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 31

Quoted 5 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +5 -0
+          - allwinner,sun8i-a83t-msgbox
+          - allwinner,sun8i-h3-msgbox
+          - allwinner,sun50i-a64-msgbox
+          - allwinner,sun50i-h6-msgbox
+      - const: allwinner,sun6i-a31-msgbox

This will fail for the A31, since it won't have two compatibles but just one.

Quoted 2 lines

You asked me earlier to only include compatibles that had been tested, so I did. This hasn't been tested on the A31, so there's no A31-only compatible.

The binding is the description, and that description already matches the A31 compatible, and it's completely abstract from whether we have software to support it.

We have bindings that have no drivers in the tree for example, but are just there to make the representation complete.

In this case, we shouldn't enable it in the A31 DTSI, but we should document the binding properly.

Quoted 6 lines
Quoted 4 lines

Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml line 50

Quoted 2 lines
Documentation/devicetree/bindings/mailbox/allwinner,sun6i-a31-msgbox.yaml new file +2 -0
+  '#mbox-cells':
+    const: 1

However, you should document what the argument is about?

Ok. "Number of cells used to encode a mailbox specifier" should work.

It's not really what I meant, what I meant is what is is that specifier you're talking about here. The customers' mailbox properties will have a phandle and a number: what is this number representing?

Maxime

author maintainer
#7 lore raw

PATCH v5 3/8 mailbox: sun6i-msgbox: Add a new mailbox driver

In reply to Samuel Holland

Allwinner sun6i, sun8i, sun9i, and sun50i SoCs contain a hardware message box used for communication between the ARM CPUs and the ARISC management coprocessor. This mailbox contains 8 unidirectional 4-message FIFOs.

Add a driver for it, so it can be used for SCPI or other communication protocols.

---
 drivers/mailbox/Kconfig        |   9 +
 drivers/mailbox/Makefile       |   2 +
 drivers/mailbox/sun6i-msgbox.c | 332 +++++++++++++++++++++++++++++++++
 3 files changed, 343 insertions(+)
 create mode 100644 drivers/mailbox/sun6i-msgbox.c
drivers/mailbox/Kconfig +9 -0
index ab4eb750bbdd..5a577a6734cf 100644
@@ -227,4 +227,13 @@ config ZYNQMP_IPI_MBOX
 	  message to the IPI buffer and will access the IPI control
 	  registers to kick the other processor or enquire status.
 
+config SUN6I_MSGBOX
+	tristate "Allwinner sun6i/sun8i/sun9i/sun50i Message Box"
+	depends on ARCH_SUNXI || COMPILE_TEST
+	default ARCH_SUNXI
+	help
+	  Mailbox implementation for the hardware message box present in
+	  various Allwinner SoCs. This mailbox is used for communication
+	  between the application CPUs and the power management coprocessor.
+
 endif
drivers/mailbox/Makefile +2 -0
index c22fad6f696b..2e4364ef5c47 100644
@@ -48,3 +48,5 @@ obj-$(CONFIG_STM32_IPCC) 	+= stm32-ipcc.o
 obj-$(CONFIG_MTK_CMDQ_MBOX)	+= mtk-cmdq-mailbox.o
 
 obj-$(CONFIG_ZYNQMP_IPI_MBOX)	+= zynqmp-ipi-mailbox.o
+
+obj-$(CONFIG_SUN6I_MSGBOX)	+= sun6i-msgbox.o
drivers/mailbox/sun6i-msgbox.c new file +332 -0

332 lines not on this page · raw message

Signature · 1 line
2.23.0
#8 lore raw

Re: [PATCH v5 3/8] mailbox: sun6i-msgbox: Add a new mailbox driver

Quoted 16 lines · Samuel Holland

Allwinner sun6i, sun8i, sun9i, and sun50i SoCs contain a hardware message box used for communication between the ARM CPUs and the ARISC management coprocessor. This mailbox contains 8 unidirectional 4-message FIFOs.

Add a driver for it, so it can be used for SCPI or other communication protocols.

---
 drivers/mailbox/Kconfig        |   9 +
 drivers/mailbox/Makefile       |   2 +
 drivers/mailbox/sun6i-msgbox.c | 332 +++++++++++++++++++++++++++++++++
 3 files changed, 343 insertions(+)
 create mode 100644 drivers/mailbox/sun6i-msgbox.c

[...]

Quoted 6 lines
drivers/mailbox/sun6i-msgbox.c new file +0 -0
new file mode 100644
index 000000000000..7a41e732457c
@@ -0,0 +1,332 @@

[...]

Quoted 24 lines
drivers/mailbox/sun6i-msgbox.c new file +24 -0
+static int sun6i_msgbox_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct mbox_chan *chans;
+	struct reset_control *reset;
+	struct resource *res;
+	struct sun6i_msgbox *mbox;
+	int i, ret;
+
+	mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL);
+	if (!mbox)
+		return -ENOMEM;
+
+	chans = devm_kcalloc(dev, NUM_CHANS, sizeof(*chans), GFP_KERNEL);
+	if (!chans)
+		return -ENOMEM;
+
+	for (i = 0; i < NUM_CHANS; ++i)
+		chans[i].con_priv = mbox;
+
+	mbox->clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(mbox->clk)) {
+		ret = PTR_ERR(mbox->clk);
+		dev_err(dev, "Failed to get clock: %d\n", ret);

drivers/mailbox/sun6i-msgbox.c line 234

Quoted 10 lines
drivers/mailbox/sun6i-msgbox.c new file +10 -0
+		return ret;
+	}
+
+	ret = clk_prepare_enable(mbox->clk);
+	if (ret) {
+		dev_err(dev, "Failed to enable clock: %d\n", ret);
+		return ret;
+	}
+
+	reset = devm_reset_control_get(dev, NULL);

Please use devm_reset_control_get_exclusive() explicitly.

regards
Philipp

author maintainer
#9 lore raw

PATCH v5 4/8 ARM: dts: sunxi: a83t: Add msgbox node

In reply to Samuel Holland

The A83T SoC contains a message box that can be used to send messages and interrupts back and forth between the ARM application CPUs and the ARISC coprocessor. Add a device tree node for it.

---
 arch/arm/boot/dts/sun8i-a83t.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/sun8i-a83t.dtsi +10 -0
index 53c38deb8a08..464b57d03dc0 100644
@@ -592,6 +592,16 @@
 			clock-names = "bus", "mod";
 		};
 
+		msgbox: mailbox@1c17000 {
+			compatible = "allwinner,sun8i-a83t-msgbox",
+				     "allwinner,sun6i-a31-msgbox";
+			reg = <0x01c17000 0x1000>;
+			clocks = <&ccu CLK_BUS_MSGBOX>;
+			resets = <&ccu RST_BUS_MSGBOX>;
+			interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
+			#mbox-cells = <1>;
+		};
+
 		usb_otg: usb@1c19000 {
 			compatible = "allwinner,sun8i-a83t-musb",
 				     "allwinner,sun8i-a33-musb";
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author maintainer
#10 lore raw

PATCH v5 5/8 ARM: dts: sunxi: h3/h5: Add msgbox node

In reply to Samuel Holland

The H3 and H5 SoCs contain a message box that can be used to send messages and interrupts back and forth between the ARM application CPUs and the ARISC coprocessor. Add a device tree node for it.

---
 arch/arm/boot/dts/sunxi-h3-h5.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/sunxi-h3-h5.dtsi +10 -0
index 0afea59486c2..6c5b283962a1 100644
@@ -233,6 +233,16 @@
 			reg = <0x1c14000 0x400>;
 		};
 
+		msgbox: mailbox@1c17000 {
+			compatible = "allwinner,sun8i-h3-msgbox",
+				     "allwinner,sun6i-a31-msgbox";
+			reg = <0x01c17000 0x1000>;
+			clocks = <&ccu CLK_BUS_MSGBOX>;
+			resets = <&ccu RST_BUS_MSGBOX>;
+			interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
+			#mbox-cells = <1>;
+		};
+
 		usb_otg: usb@1c19000 {
 			compatible = "allwinner,sun8i-h3-musb";
 			reg = <0x01c19000 0x400>;
Signature · 1 line
2.23.0
author maintainer
#11 lore raw

PATCH v5 6/8 arm64: dts: allwinner: a64: Add msgbox node

In reply to Samuel Holland

The A64 SoC contains a message box that can be used to send messages and interrupts back and forth between the ARM application CPUs and the ARISC coprocessor. Add a device tree node for it.

---
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +10 -0
index 27e48234f1c2..10edb4b59203 100644
@@ -496,6 +496,16 @@
 			resets = <&ccu RST_BUS_CE>;
 		};
 
+		msgbox: mailbox@1c17000 {
+			compatible = "allwinner,sun50i-a64-msgbox",
+				     "allwinner,sun6i-a31-msgbox";
+			reg = <0x01c17000 0x1000>;
+			clocks = <&ccu CLK_BUS_MSGBOX>;
+			resets = <&ccu RST_BUS_MSGBOX>;
+			interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
+			#mbox-cells = <1>;
+		};
+
 		usb_otg: usb@1c19000 {
 			compatible = "allwinner,sun8i-a33-musb";
 			reg = <0x01c19000 0x0400>;
Signature · 1 line
2.23.0
author maintainer
#12 lore raw

PATCH v5 7/8 arm64: dts: allwinner: h6: Add msgbox node

In reply to Samuel Holland

The H6 SoC contains a message box that can be used to send messages and interrupts back and forth between the ARM application CPUs and the ARISC coprocessor. Add a device tree node for it.

---
 arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +10 -0
index 8e5999cd08bb..70ee56ba2091 100644
@@ -240,6 +240,16 @@
 			#dma-cells = <1>;
 		};
 
+		msgbox: mailbox@3003000 {
+			compatible = "allwinner,sun50i-h6-msgbox",
+				     "allwinner,sun6i-a31-msgbox";
+			reg = <0x03003000 0x1000>;
+			clocks = <&ccu CLK_BUS_MSGBOX>;
+			resets = <&ccu RST_BUS_MSGBOX>;
+			interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>;
+			#mbox-cells = <1>;
+		};
+
 		sid: efuse@3006000 {
 			compatible = "allwinner,sun50i-h6-sid";
 			reg = <0x03006000 0x400>;
Signature · 1 line
2.23.0
author maintainer
#13 lore raw

PATCH v5 8/8 firmware: arm_scpi: Support unidirectional mailbox channels

In reply to Samuel Holland

Some mailbox controllers have only unidirectional channels, so we need a pair of them for each SCPI channel. If a mbox-names property is present, look for "rx" and "tx" mbox channels; otherwise, the existing behavior is preserved, and a single mbox channel is used for each SCPI channel.

Note that since the mailbox framework only supports a single phandle with each name (mbox_request_channel_byname always returns the first one), this new mode only supports a single SCPI channel.

---
 drivers/firmware/arm_scpi.c | 58 +++++++++++++++++++++++++++++--------
 1 file changed, 46 insertions(+), 12 deletions(-)
drivers/firmware/arm_scpi.c +46 -12
index a80c331c3a6e..36ff9dd8d0fa 100644
@@ -231,7 +231,8 @@ struct scpi_xfer {
 
 struct scpi_chan {
 	struct mbox_client cl;
-	struct mbox_chan *chan;
+	struct mbox_chan *rx_chan;
+	struct mbox_chan *tx_chan;
 	void __iomem *tx_payload;
 	void __iomem *rx_payload;
 	struct list_head rx_pending;
@@ -505,7 +506,7 @@ static int scpi_send_message(u8 idx, void *tx_buf, unsigned int tx_len,
 	msg->rx_len = rx_len;
 	reinit_completion(&msg->done);
 
-	ret = mbox_send_message(scpi_chan->chan, msg);
+	ret = mbox_send_message(scpi_chan->tx_chan, msg);
 	if (ret < 0 || !rx_buf)
 		goto out;
 
@@ -854,8 +855,13 @@ static void scpi_free_channels(void *data)
 	struct scpi_drvinfo *info = data;
 	int i;
 
-	for (i = 0; i < info->num_chans; i++)
-		mbox_free_channel(info->channels[i].chan);
+	for (i = 0; i < info->num_chans; i++) {
+		struct scpi_chan *pchan = &info->channels[i];
+
+		if (pchan->tx_chan != pchan->rx_chan)
+			mbox_free_channel(pchan->tx_chan);
+		mbox_free_channel(pchan->rx_chan);
+	}
 }
 
 static int scpi_remove(struct platform_device *pdev)
@@ -903,6 +909,7 @@ static int scpi_probe(struct platform_device *pdev)
 	struct resource res;
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
+	bool use_mbox_names = false;
 
 	scpi_info = devm_kzalloc(dev, sizeof(*scpi_info), GFP_KERNEL);
 	if (!scpi_info)
@@ -916,6 +923,14 @@ static int scpi_probe(struct platform_device *pdev)
 		dev_err(dev, "no mboxes property in '%pOF'\n", np);
 		return -ENODEV;
 	}
+	if (of_get_property(dev->of_node, "mbox-names", NULL)) {
+		use_mbox_names = true;
+		if (count != 2) {
+			dev_err(dev, "need exactly 2 mboxes with mbox-names\n");
+			return -ENODEV;
+		}
+		count /= 2;
+	}
 
 	scpi_info->channels = devm_kcalloc(dev, count, sizeof(struct scpi_chan),
 					   GFP_KERNEL);
@@ -961,15 +976,34 @@ static int scpi_probe(struct platform_device *pdev)
 		mutex_init(&pchan->xfers_lock);
 
 		ret = scpi_alloc_xfer_list(dev, pchan);
-		if (!ret) {
-			pchan->chan = mbox_request_channel(cl, idx);
-			if (!IS_ERR(pchan->chan))
-				continue;
-			ret = PTR_ERR(pchan->chan);
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev, "failed to get channel%d err %d\n",
-					idx, ret);
+		if (ret)
+			return ret;
+
+		if (use_mbox_names) {
+			pchan->rx_chan = mbox_request_channel_byname(cl, "rx");
+			if (IS_ERR(pchan->rx_chan)) {
+				ret = PTR_ERR(pchan->rx_chan);
+				goto fail;
+			}
+			pchan->tx_chan = mbox_request_channel_byname(cl, "tx");
+			if (IS_ERR(pchan->rx_chan)) {
+				ret = PTR_ERR(pchan->tx_chan);
+				goto fail;
+			}
+		} else {
+			pchan->rx_chan = mbox_request_channel(cl, idx);
+			if (IS_ERR(pchan->rx_chan)) {
+				ret = PTR_ERR(pchan->rx_chan);
+				goto fail;
+			}
+			pchan->tx_chan = pchan->rx_chan;
 		}
+		continue;
+
+fail:
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "failed to get channel%d err %d\n",
+				idx, ret);
 		return ret;
 	}
 
Signature · 1 line
2.23.0
#14 lore raw

Re: [PATCH v5 8/8] firmware: arm_scpi: Support unidirectional mailbox channels

Quoted 5 lines · Samuel Holland

Some mailbox controllers have only unidirectional channels, so we need a pair of them for each SCPI channel. If a mbox-names property is present, look for "rx" and "tx" mbox channels; otherwise, the existing behavior is preserved, and a single mbox channel is used for each SCPI channel.

I need to look at the bindings again, but I think you must update it.

Quoted 34 lines

Note that since the mailbox framework only supports a single phandle with each name (mbox_request_channel_byname always returns the first one), this new mode only supports a single SCPI channel.

---
 drivers/firmware/arm_scpi.c | 58 +++++++++++++++++++++++++++++--------
 1 file changed, 46 insertions(+), 12 deletions(-)
drivers/firmware/arm_scpi.c +3 -2
index a80c331c3a6e..36ff9dd8d0fa 100644
@@ -231,7 +231,8 @@ struct scpi_xfer {
 
 struct scpi_chan {
 	struct mbox_client cl;
-	struct mbox_chan *chan;
+	struct mbox_chan *rx_chan;
+	struct mbox_chan *tx_chan;
 	void __iomem *tx_payload;
 	void __iomem *rx_payload;
 	struct list_head rx_pending;
@@ -505,7 +506,7 @@ static int scpi_send_message(u8 idx, void *tx_buf, unsigned int tx_len,
 	msg->rx_len = rx_len;
 	reinit_completion(&msg->done);
 
-	ret = mbox_send_message(scpi_chan->chan, msg);
+	ret = mbox_send_message(scpi_chan->tx_chan, msg);
 	if (ret < 0 || !rx_buf)
 		goto out;
 
@@ -854,8 +855,13 @@ static void scpi_free_channels(void *data)
 	struct scpi_drvinfo *info = data;

drivers/firmware/arm_scpi.c static void scpi_free_channels(void *data) · line 863

Quoted 10 lines
drivers/firmware/arm_scpi.c +6 -2
 	int i;
 
-	for (i = 0; i < info->num_chans; i++)
-		mbox_free_channel(info->channels[i].chan);
+	for (i = 0; i < info->num_chans; i++) {
+		struct scpi_chan *pchan = &info->channels[i];
+
+		if (pchan->tx_chan != pchan->rx_chan)
+			mbox_free_channel(pchan->tx_chan);
+		mbox_free_channel(pchan->rx_chan);

I think mbox_free_channel handles !chan->cl, so just do unconditionally.

Quoted 13 lines
drivers/firmware/arm_scpi.c +2 -0
+	}
 }
 
 static int scpi_remove(struct platform_device *pdev)
@@ -903,6 +909,7 @@ static int scpi_probe(struct platform_device *pdev)
 	struct resource res;
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
+	bool use_mbox_names = false;
 
 	scpi_info = devm_kzalloc(dev, sizeof(*scpi_info), GFP_KERNEL);
 	if (!scpi_info)

drivers/firmware/arm_scpi.c static int scpi_probe(struct platform_device *pdev) · line 926

Quoted 4 lines
drivers/firmware/arm_scpi.c +1 -0
@@ -916,6 +923,14 @@ static int scpi_probe(struct platform_device *pdev)
 		dev_err(dev, "no mboxes property in '%pOF'\n", np);
 		return -ENODEV;
 	}
+	if (of_get_property(dev->of_node, "mbox-names", NULL)) {

So, for this platform, this is required and must fail if it is not found. But instead your check here is optional and may end up populating 2 scpi channels instead of one. I would suggest to make it required and fail for it based on some compatible, otherwise you are not checking correctly.

Something like:

        if (of_match_device(blah_blah_of_match, &pdev->dev)) {
                use_mbox_names = true;
		count = 1;
	}

drivers/firmware/arm_scpi.c static int scpi_probe(struct platform_device *pdev) · line 933

Quoted 7 lines
drivers/firmware/arm_scpi.c +7 -0
+		use_mbox_names = true;
+		if (count != 2) {
+			dev_err(dev, "need exactly 2 mboxes with mbox-names\n");
+			return -ENODEV;
+		}
+		count /= 2;
+	}

Ah, OK then you must update the binding as it's different usage of mailbox.

General query, not related to this patch: If you are in process of implementing the firmware, I suggest to move to SCMI protocol than this one if not too late. This specification is deprecated and no longer updated while SCMI is actively developed and maintained. However it has slightly different notion of tx and rx and the way the specification commands which messages are synchronous and which can be async/delayed.

--
Regards,
Sudeep