Skip to contentSkip to conversation

mailbox: arm_mhu: Add ARM MHU doorbell controller driver

PATCH In review Sudeep Holla 2 participants 7 messages Oct 8, 2020 – Oct 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover mailbox: arm_mhu: Add ARM MHU doorbell controller driver

Hi,

These series adds ARM MHU doorbell controller driver based on the discussion[1]. The DT patches are just repost from Viresh's last posting[2]

Regards,
Sudeep

v1[3]->v2:
- No updates to binding patches(1-2)
- Fixed memory leak and improved logic to find free channel reusing mhu_db_mbox_to_channel as suggested by Jassi

[1] https://lore.kernel.org/r/20200909044618.deyx37pzocxiga7u@vireshk-i7
[2] https://lore.kernel.org/r/3874de094d193a08624a00a35067a3237e0b42b1.1600249102.git.viresh.kumar@linaro.org
[3] https://lore.kernel.org/r/[email protected]

Sudeep Holla (3):
dt-bindings: mailbox: add doorbell support to ARM MHU
mailbox: arm_mhu: Match only if compatible is "arm,mhu"
mailbox: arm_mhu: Add ARM MHU doorbell driver

Viresh Kumar (1):
dt-bindings: mailbox : arm,mhu: Convert to Json-schema

 .../devicetree/bindings/mailbox/arm,mhu.yaml  | 135 +++++++
 .../devicetree/bindings/mailbox/arm-mhu.txt   |  43 ---
 drivers/mailbox/Makefile                      |   2 +-
 drivers/mailbox/arm_mhu.c                     |   3 +
 drivers/mailbox/arm_mhu_db.c                  | 354 ++++++++++++++++++
 5 files changed, 493 insertions(+), 44 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mailbox/arm,mhu.yaml
 delete mode 100644 Documentation/devicetree/bindings/mailbox/arm-mhu.txt
 create mode 100644 drivers/mailbox/arm_mhu_db.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/4 dt-bindings: mailbox : arm,mhu: Convert to Json-schema

From: Viresh Kumar <[email protected]>

Convert the DT binding over to Json-schema.

---
 .../devicetree/bindings/mailbox/arm,mhu.yaml  | 87 +++++++++++++++++++
 .../devicetree/bindings/mailbox/arm-mhu.txt   | 43 ---------
 2 files changed, 87 insertions(+), 43 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mailbox/arm,mhu.yaml
 delete mode 100644 Documentation/devicetree/bindings/mailbox/arm-mhu.txt
Documentation/devicetree/bindings/mailbox/arm,mhu.yaml new file +87 -0
new file mode 100644
index 000000000000..2c8df7979c22
@@ -0,0 +1,87 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/arm,mhu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ARM MHU Mailbox Controller
+
+maintainers:
+  - Jassi Brar <[email protected]>
+
+description: |
+  The ARM's Message-Handling-Unit (MHU) is a mailbox controller that has 3
+  independent channels/links to communicate with remote processor(s).  MHU links
+  are hardwired on a platform. A link raises interrupt for any received data.
+  However, there is no specified way of knowing if the sent data has been read
+  by the remote. This driver assumes the sender polls STAT register and the
+  remote clears it after having read the data.  The last channel is specified to
+  be a 'Secure' resource, hence can't be used by Linux running NS.
+
+# We need a select here so we don't match all nodes with 'arm,primecell'
+select:
+  properties:
+    compatible:
+      contains:
+        const: arm,mhu
+  required:
+    - compatible
+
+properties:
+  compatible:
+    items:
+      - const: arm,mhu
+      - const: arm,primecell
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    items:
+      - description: low-priority non-secure
+      - description: high-priority non-secure
+      - description: Secure
+    maxItems: 3
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: apb_pclk
+
+  '#mbox-cells':
+    description: Index of the channel.
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - '#mbox-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        mhuA: mailbox@2b1f0000 {
+            #mbox-cells = <1>;
+            compatible = "arm,mhu", "arm,primecell";
+            reg = <0 0x2b1f0000 0 0x1000>;
+            interrupts = <0 36 4>, /* LP-NonSecure */
+                         <0 35 4>, /* HP-NonSecure */
+                         <0 37 4>; /* Secure */
+            clocks = <&clock 0 2 1>;
+            clock-names = "apb_pclk";
+        };
+
+        mhu_client_scb: scb@2e000000 {
+            compatible = "fujitsu,mb86s70-scb-1.0";
+            reg = <0 0x2e000000 0 0x4000>;
+            mboxes = <&mhuA 1>; /* HP-NonSecure */
+        };
+    };
Documentation/devicetree/bindings/mailbox/arm-mhu.txt deleted +0 -43

43 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/4 dt-bindings: mailbox: add doorbell support to ARM MHU

In reply to Sudeep Holla

The ARM MHU's reference manual states following:

"The MHU drives the signal using a 32-bit register, with all 32 bits logically ORed together. The MHU provides a set of registers to enable software to set, clear, and check the status of each of the bits of this register independently. The use of 32 bits for each interrupt line enables software to provide more information about the source of the interrupt. For example, each bit of the register can be associated with a type of event that can contribute to raising the interrupt."

This patch thus extends the MHU controller's DT binding to add support for doorbell mode.

Though the same MHU hardware controller is used in the two modes, A new compatible string is added here to represent the combination of the MHU hardware and the firmware sitting on the other side (which expects each bit to represent a different signal now).

---
 .../devicetree/bindings/mailbox/arm,mhu.yaml  | 60 +++++++++++++++++--
 1 file changed, 54 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/mailbox/arm,mhu.yaml +54 -6
index 2c8df7979c22..d43791a2dde7 100644
@@ -18,20 +18,40 @@ description: |
   remote clears it after having read the data.  The last channel is specified to
   be a 'Secure' resource, hence can't be used by Linux running NS.
 
+  The MHU hardware also allows operations in doorbell mode. The MHU drives the
+  interrupt signal using a 32-bit register, with all 32-bits logically ORed
+  together. It provides a set of registers to enable software to set, clear and
+  check the status of each of the bits of this register independently. The use
+  of 32 bits per interrupt line enables software to provide more information
+  about the source of the interrupt. For example, each bit of the register can
+  be associated with a type of event that can contribute to raising the
+  interrupt. Each of the 32-bits can be used as "doorbell" to alert the remote
+  processor.
+
 # We need a select here so we don't match all nodes with 'arm,primecell'
 select:
   properties:
     compatible:
       contains:
-        const: arm,mhu
+        enum:
+          - arm,mhu
+          - arm,mhu-doorbell
   required:
     - compatible
 
 properties:
   compatible:
-    items:
-      - const: arm,mhu
-      - const: arm,primecell
+    oneOf:
+      - description: Data transfer mode
+        items:
+          - const: arm,mhu
+          - const: arm,primecell
+
+      - description: Doorbell mode
+        items:
+          - const: arm,mhu-doorbell
+          - const: arm,primecell
+
 
   reg:
     maxItems: 1
@@ -51,8 +71,11 @@ description: |
       - const: apb_pclk
 
   '#mbox-cells':
-    description: Index of the channel.
-    const: 1
+    description: |
+      Set to 1 in data transfer mode and represents index of the channel.
+      Set to 2 in doorbell mode and represents index of the channel and doorbell
+      number.
+    enum: [ 1, 2 ]
 
 required:
   - compatible
@@ -63,6 +86,7 @@ description: |
 additionalProperties: false
 
 examples:
+  # Data transfer mode.
   - |
     soc {
         #address-cells = <2>;
@@ -85,3 +109,27 @@ additionalProperties: false
             mboxes = <&mhuA 1>; /* HP-NonSecure */
         };
     };
+
+  # Doorbell mode.
+  - |
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        mhuB: mailbox@2b2f0000 {
+            #mbox-cells = <2>;
+            compatible = "arm,mhu-doorbell", "arm,primecell";
+            reg = <0 0x2b2f0000 0 0x1000>;
+            interrupts = <0 36 4>, /* LP-NonSecure */
+                         <0 35 4>, /* HP-NonSecure */
+                         <0 37 4>; /* Secure */
+            clocks = <&clock 0 2 1>;
+            clock-names = "apb_pclk";
+        };
+
+        mhu_client_scpi: scpi@2f000000 {
+            compatible = "arm,scpi";
+            reg = <0 0x2f000000 0 0x200>;
+            mboxes = <&mhuB 1 4>; /* HP-NonSecure, 5th doorbell */
+        };
+    };
Signature · 1 line
2.17.1
#3 lore raw

PATCH v2 3/4 mailbox: arm_mhu: Match only if compatible is "arm,mhu"

In reply to Sudeep Holla

Since we will be soon adding a separate driver based on this ARM MHU driver to support doorbell mode, let us add explicit check to match the default compatible for this driver. This is needed as the probe and match reuses the AMBA device ids currently and don't have any explicit compatible check.

---
 drivers/mailbox/arm_mhu.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mailbox/arm_mhu.c +3 -0
index 9da236552bd7..b7fbf276eb62 100644
@@ -113,6 +113,9 @@ static int mhu_probe(struct amba_device *adev, const struct amba_id *id)
 	struct device *dev = &adev->dev;
 	int mhu_reg[MHU_CHANS] = {MHU_LP_OFFSET, MHU_HP_OFFSET, MHU_SEC_OFFSET};
 
+	if (!of_device_is_compatible(dev->of_node, "arm,mhu"))
+		return -ENODEV;
+
 	/* Allocate memory for device */
 	mhu = devm_kzalloc(dev, sizeof(*mhu), GFP_KERNEL);
 	if (!mhu)
Signature · 1 line
2.17.1
#4 lore raw

PATCH v2 4/4 mailbox: arm_mhu: Add ARM MHU doorbell driver

In reply to Sudeep Holla

The MHU drives the signal using a 32-bit register, with all 32 bits logically ORed together. The MHU provides a set of registers to enable software to set, clear, and check the status of each of the bits of this register independently. The use of 32 bits for each interrupt line enables software to provide more information about the source of the interrupt. For example, each bit of the register can be associated with a type of event that can contribute to raising the interrupt.

This patch adds a separate the MHU controller driver for doorbel mode of operation using the extended DT binding to add support the same.

---
 drivers/mailbox/Makefile     |   2 +-
 drivers/mailbox/arm_mhu_db.c | 354 +++++++++++++++++++++++++++++++++++
 2 files changed, 355 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mailbox/arm_mhu_db.c
drivers/mailbox/Makefile +1 -1
index 60d224b723a1..2e06e02b2e03 100644
@@ -5,7 +5,7 @@ obj-$(CONFIG_MAILBOX)		+= mailbox.o
 
 obj-$(CONFIG_MAILBOX_TEST)	+= mailbox-test.o
 
-obj-$(CONFIG_ARM_MHU)	+= arm_mhu.o
+obj-$(CONFIG_ARM_MHU)	+= arm_mhu.o arm_mhu_db.o
 
 obj-$(CONFIG_IMX_MBOX)	+= imx-mailbox.o
 
drivers/mailbox/arm_mhu_db.c new file +354 -0

354 lines not on this page · raw message

Signature · 1 line
2.17.1
#5 lore raw
In reply to Sudeep Holla
Quoted 25 lines · Sudeep Holla

Hi,

These series adds ARM MHU doorbell controller driver based on the discussion[1]. The DT patches are just repost from Viresh's last posting[2]

Regards,
Sudeep

v1[3]->v2:
- No updates to binding patches(1-2)
- Fixed memory leak and improved logic to find free channel reusing mhu_db_mbox_to_channel as suggested by Jassi

[1] https://lore.kernel.org/r/20200909044618.deyx37pzocxiga7u@vireshk-i7
[2] https://lore.kernel.org/r/3874de094d193a08624a00a35067a3237e0b42b1.1600249102.git.viresh.kumar@linaro.org
[3] https://lore.kernel.org/r/[email protected]

Sudeep Holla (3):
dt-bindings: mailbox: add doorbell support to ARM MHU
mailbox: arm_mhu: Match only if compatible is "arm,mhu"
mailbox: arm_mhu: Add ARM MHU doorbell driver

Viresh Kumar (1):
dt-bindings: mailbox : arm,mhu: Convert to Json-schema

Quoted 9 lines
 .../devicetree/bindings/mailbox/arm,mhu.yaml  | 135 +++++++
 .../devicetree/bindings/mailbox/arm-mhu.txt   |  43 ---
 drivers/mailbox/Makefile                      |   2 +-
 drivers/mailbox/arm_mhu.c                     |   3 +
 drivers/mailbox/arm_mhu_db.c                  | 354 ++++++++++++++++++
 5 files changed, 493 insertions(+), 44 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mailbox/arm,mhu.yaml
 delete mode 100644 Documentation/devicetree/bindings/mailbox/arm-mhu.txt
 create mode 100644 drivers/mailbox/arm_mhu_db.c

MAINTAINERS ?

Signature · 1 line
viresh
#6 lore raw
Quoted 36 lines · Viresh Kumar
Quoted 25 lines · Sudeep Holla

Hi,

These series adds ARM MHU doorbell controller driver based on the discussion[1]. The DT patches are just repost from Viresh's last posting[2]

Regards,
Sudeep

v1[3]->v2:
- No updates to binding patches(1-2)
- Fixed memory leak and improved logic to find free channel reusing mhu_db_mbox_to_channel as suggested by Jassi

[1] https://lore.kernel.org/r/20200909044618.deyx37pzocxiga7u@vireshk-i7
[2] https://lore.kernel.org/r/3874de094d193a08624a00a35067a3237e0b42b1.1600249102.git.viresh.kumar@linaro.org
[3] https://lore.kernel.org/r/[email protected]

Sudeep Holla (3):
dt-bindings: mailbox: add doorbell support to ARM MHU
mailbox: arm_mhu: Match only if compatible is "arm,mhu"
mailbox: arm_mhu: Add ARM MHU doorbell driver

Viresh Kumar (1):
dt-bindings: mailbox : arm,mhu: Convert to Json-schema

Quoted 9 lines
 .../devicetree/bindings/mailbox/arm,mhu.yaml  | 135 +++++++
 .../devicetree/bindings/mailbox/arm-mhu.txt   |  43 ---
 drivers/mailbox/Makefile                      |   2 +-
 drivers/mailbox/arm_mhu.c                     |   3 +
 drivers/mailbox/arm_mhu_db.c                  | 354 ++++++++++++++++++
 5 files changed, 493 insertions(+), 44 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mailbox/arm,mhu.yaml
 delete mode 100644 Documentation/devicetree/bindings/mailbox/arm-mhu.txt
 create mode 100644 drivers/mailbox/arm_mhu_db.c
Quoted 1 line

MAINTAINERS ?

Duh ! Generated patches before I added and totally forgot to regenerate. Will wait for Jassi's response and then will post as addon if no comments or will respin the series. Sorry for that.

Signature · 2 lines
Regards,
Sudeep