Skip to contentSkip to conversation

mailbox: Add Marvell MHU driver

PATCH Superseded Paul Cercueil 2 participants 5 messages Nov 23

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover mailbox: Add Marvell MHU driver

Hi Jassi,

This is the v3 of my patchset that adds support for the mailbox found in the OcteonTX and OcteonTX2 based SoCs, which is used for SCMI communication.

This v3 fixes a few things that Sashiko complained about.

Changes in v3:

[2/2]:
- Request an interrupt vector of exactly 3 interrupts
- Pass IRQF_NO_AUTOEN to devm_request_irq()
- Invert success condition of mrvl_mhu_last_tx_done()

Cheers,
-Paul

George Cherian (2):
dt-bindings: mailbox: add Marvell MHU
mailbox: marvell-mhu: add Marvell MHU driver

 .../bindings/mailbox/marvell,mhu.yaml         |  61 +++++
 MAINTAINERS                                   |   7 +
 drivers/mailbox/Kconfig                       |  11 +
 drivers/mailbox/Makefile                      |   2 +
 drivers/mailbox/marvell_mhu.c                 | 238 ++++++++++++++++++
 5 files changed, 319 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/marvell,mhu.yaml
 create mode 100644 drivers/mailbox/marvell_mhu.c
Signature · 1 line
2.47.3
#1 lore raw

PATCH v3 1/2 dt-bindings: mailbox: add Marvell MHU

From: George Cherian <[email protected]>

Marvell Message Handling Unit is a mailbox controller present in Marvell OcteonTx and OcteonTX2 SoC family.

---

v3: No change

v2:
- Fix binding path in MAINTAINERS file
- Move MAINTAINERS entry so that it's in alphabetical order
- Fix formatting of DT example

---
 .../bindings/mailbox/marvell,mhu.yaml         | 61 +++++++++++++++++++
 MAINTAINERS                                   |  6 ++
 2 files changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/marvell,mhu.yaml
Documentation/devicetree/bindings/mailbox/marvell,mhu.yaml new file +61 -0
new file mode 100644
index 000000000000..5cf20d5642ac
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/marvell,mhu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Marvell Message Handling Unit
+
+maintainers:
+  - Sujeet Baranwal <[email protected]>
+  - George Cherian <[email protected]>
+
+description:
+  The Control-Processors Cluster (CPC) provides Arm-platform specification
+  entities for managing the system. One of the CPC processors is the System
+  Control Processor (SCP). The SCP is responsible, among others, for booting
+  the chip, clock and power initialization, controlling power consumption
+  through DVFS, monitoring temperature sensors and controlling AVS. The SCP,
+  as each XCP, contains mailboxes for software-to-software communications.
+  Mailbox writes cause an interrupt to the local XCP core or to the AP.
+  This driver exposes AP-SCP Message Handling Unit to the system, providing
+  the mailbox communication mechanism to the system, with the intention
+  of plugging into the SCMI framework. It is designed to work with Marvell
+  OcteonTX and OcteonTX2-based platforms.
+  The mailbox has no other usage than SCMI communication. In case of
+  configurations running without SCMI support it should be disabled.
+
+properties:
+  compatible:
+    enum:
+      - marvell,octeontx-mhu
+      - marvell,octeontx2-mhu
+      - marvell,cn10-mhu
+
+  reg:
+    maxItems: 1
+
+  "#mbox-cells":
+    description: Index of the channel
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - "#mbox-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    ecam {
+        #address-cells = <3>;
+        #size-cells = <2>;
+
+        mailbox@1c,0 {
+            compatible = "marvell,octeontx2-mhu";
+            reg = <0xe000 0x0 0x0 0 0>;
+            #mbox-cells = <1>;
+        };
+    };
+...
MAINTAINERS +6 -0
index 65e8a4b5c90b..8f6f98acc8fc 100644
@@ -15825,6 +15825,12 @@ L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
 F:	arch/arm64/boot/dts/marvell/armada-8040-mcbin.dts
 
+MARVELL MHU MAILBOX DRIVER
+M:	Sujeet Baranwal <[email protected]>
+M:	George Cherian <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/mailbox/marvell,mhu.yaml
+
 MARVELL MV643XX ETHERNET DRIVER
 M:	Sebastian Hesselbarth <[email protected]>
 L:	[email protected]
Signature · 1 line
2.47.3
#2 lore raw

PATCH v3 2/2 mailbox: marvell-mhu: add Marvell MHU driver

In reply to Paul Cercueil

From: George Cherian <[email protected]>

Add support for Message Handling Units on Marvell OcteonTx and OcteonTx2 platforms. The module uses mailbox controller interface to provide communication between SCP and AP using SCMI protocol over a single shared memory communication channel.

---

v3:
- Request an interrupt vector of exactly 3 interrupts
- Pass IRQF_NO_AUTOEN to devm_request_irq()
- Invert success condition of mrvl_mhu_last_tx_done()

v2:
- Add Kconfig dependency on PCI
- Order includes properly
- Remove duplicated macros
- Pass a pointer to the "mhu" variable to mrvl_mhu_setup_irq(), instead of getting it from drvdata. Then we don't even need to set drvdata.
- Use devm functions unconditionally. This fixes an issue where pci_free_irq_vectors() was called while IRQs were still in place. It also allows to drop mrvl_mhu_remove().
- Use pcim_iomap_region() instead of pcim_request_region() + pcim_iomap().
- Enable IRQ in .startup(), disable it in .shutdown().
- ACK the IRQ after calling mbox_chan_received_data()
- Fix register used for polling TX done
- Clean up macros

---
 MAINTAINERS                   |   1 +
 drivers/mailbox/Kconfig       |  11 ++
 drivers/mailbox/Makefile      |   2 +
 drivers/mailbox/marvell_mhu.c | 238 ++++++++++++++++++++++++++++++++++
 4 files changed, 252 insertions(+)
 create mode 100644 drivers/mailbox/marvell_mhu.c
MAINTAINERS +1 -0
index 8f6f98acc8fc..06c49bef8390 100644
@@ -15830,6 +15830,7 @@ M:	Sujeet Baranwal <[email protected]>
 M:	George Cherian <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/mailbox/marvell,mhu.yaml
+F:	drivers/mailbox/marvell_mhu.c
 
 MARVELL MV643XX ETHERNET DRIVER
 M:	Sebastian Hesselbarth <[email protected]>
drivers/mailbox/Kconfig +11 -0
index ab869769e278..62744399cdb8 100644
@@ -195,6 +195,17 @@ config MAILBOX_TEST
 	  Test client to help with testing new Controller driver
 	  implementations.
 
+config MARVELL_MHU
+	tristate "Marvell Message Handling Unit"
+	depends on (ARM64 || COMPILE_TEST) && 64BIT
+	depends on PCI && OF
+	help
+	  This driver adds support for Marvell MHU controller.
+	  The MHU mailbox is used by SCMI for OcteonTX and OcteonTX2
+	  to control various aspects of platform operation like cpufreq
+	  or sensors. The controller supports single channel to SCP.
+	  Say Y here to build this module. If unsure say N.
+
 config POLARFIRE_SOC_MAILBOX
 	tristate "PolarFire SoC (MPFS) Mailbox"
 	depends on HAS_IOMEM
drivers/mailbox/Makefile +2 -0
index 45dc59bb3e7f..83b26e7bbd27 100644
@@ -49,6 +49,8 @@ obj-$(CONFIG_BCM_PDC_MBOX)	+= bcm-pdc-mailbox.o
 
 obj-$(CONFIG_BCM_FLEXRM_MBOX)	+= bcm-flexrm-mailbox.o
 
+obj-$(CONFIG_MARVELL_MHU)	+= marvell_mhu.o
+
 obj-$(CONFIG_POLARFIRE_SOC_MAILBOX)	+= mailbox-mpfs.o
 
 obj-$(CONFIG_MCHP_SBI_IPC_MBOX)		+= mailbox-mchp-ipc-sbi.o
drivers/mailbox/marvell_mhu.c new file +238 -0

238 lines not on this page · raw message

Signature · 1 line
2.47.3
#3 lore raw

Re: [PATCH v3 2/2] mailbox: marvell-mhu: add Marvell MHU driver

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] mailbox: marvell-mhu: undeclared ioread64()/iowrite64() under COMPILE_TEST --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] mailbox: marvell-mhu: undeclared ioread64()/iowrite64() under COMPILE_TEST
--

commit e362a8700ec12375ab4fa67b4954b2473fced942
Author: George Cherian <[email protected]>

mailbox: marvell-mhu: add Marvell MHU driver

This commit adds a mailbox controller driver for the Marvell Message Handling Unit on OcteonTX and OcteonTX2 platforms.

Quoted 5 lines
drivers/mailbox/marvell_mhu.c new file +0 -0
new file mode 100644
index 0000000000000..de7690897cc99

[ ... ]

Quoted 10 lines
drivers/mailbox/marvell_mhu.c new file +10 -0
+static int mrvl_mhu_send_data(struct mbox_chan *chan, void *data)
+{
+	const u64 doorbell = 0xff;  /* Arbitrary value, SCP requires a value */
+	struct mrvl_mhu *mhu = chan->con_priv;
+
+	/* signal SCP */
+	iowrite64(doorbell, mhu->base + AP0_TO_SCP_MBOX);
+
+	return 0;
+}

drivers/mailbox/marvell_mhu.c line 108

Quoted 10 lines
drivers/mailbox/marvell_mhu.c new file +10 -0
+
+static bool mrvl_mhu_last_tx_done(struct mbox_chan *chan)
+{
+	struct mrvl_mhu *mhu = chan->con_priv;
+	u64 status;
+
+	status = ioread64(mhu->base + AP0_TO_SCP_MBOX_LINT);
+
+	return status == 0;
+}

[Severity: Medium]
As reported by kernel test robot on v2 [1], does this fail to build under CONFIG_COMPILE_TEST on 64-bit architectures with CONFIG_GENERIC_IOMAP=y (such as x86_64 and powerpc64)?

On CONFIG_GENERIC_IOMAP architectures, ioread64() and iowrite64() are not declared unless linux/io-64-nonatomic-lo-hi.h (or hi-lo.h) is included. Using readq() and writeq() directly, or including one of the 64-bit non-atomic I/O headers, would avoid the implicit function declaration error.

[1] https://lore.kernel.org/r/[email protected]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#4 lore raw
In reply to Paul Cercueil

You can ignore this v3.

It does not compile always with COMPILE_TEST, so I'll send a v4.

Cheers,
-Paul

Le lundi 23 novembre 2026 à 10:45 +0100, Paul Cercueil a écrit :

Quoted 30 lines

Hi Jassi,

This is the v3 of my patchset that adds support for the mailbox found in the OcteonTX and OcteonTX2 based SoCs, which is used for SCMI communication.

This v3 fixes a few things that Sashiko complained about.

Changes in v3:

[2/2]:
 - Request an interrupt vector of exactly 3 interrupts
 - Pass IRQF_NO_AUTOEN to devm_request_irq()
 - Invert success condition of mrvl_mhu_last_tx_done()

Cheers,
-Paul

George Cherian (2):
  dt-bindings: mailbox: add Marvell MHU
  mailbox: marvell-mhu: add Marvell MHU driver

 .../bindings/mailbox/marvell,mhu.yaml         |  61 +++++ MAINTAINERS                                   |   7 + drivers/mailbox/Kconfig                       |  11 + drivers/mailbox/Makefile                      |   2 + drivers/mailbox/marvell_mhu.c                 | 238 ++++++++++++++++++

 5 files changed, 319 insertions(+)

 create mode 100644 Documentation/devicetree/bindings/mailbox/marvell,mhu.yaml create mode 100644 drivers/mailbox/marvell_mhu.c