mbox series

[v3,0/5] Add support for RPMI to U-Boot

Message ID 20260902141744.2422566-1-charles.perry@microchip.com
Headers show
Series Add support for RPMI to U-Boot | expand

Message

Charles Perry Sept. 2, 2026, 2:17 p.m. UTC
Hello,

This series adds support for RISC-V Platform Management Interface (RPMI) to
U-Boot. RPMI is an OS-agnostic protocol for communication between an
Application Processor (AP) and a Platform Microcontroller (PuC) [1]. The
goals and purpose of RPMI are similar to ARM's SCMI.

This patchset first adds an abstraction layer for the transport
(UCLASS_RPMI), then adds two transport layer (SBI MPXY and shared memory)
and finally adds one client (or service group in RPMI jargon): the clock
service group.

This series also includes a sandbox mode for which the RPMI transport
doesn't attach to a firmware but contains a simulation of a firmware. This
reuses code from librpmi [2] to create the message responses.

From V3, this series also includes the "mpxy" command line tool created
by Rahul [6].

Apart from the spec [1], this series reuses code from the Linux SBI MPXY
driver [3], OpenSBI shared memory transport [4] and Linux RPMI clock driver
[5].

This was tested on a PIC64-HPSC SoC which features an application cluster
and a system controller with isolated address spaces, hence the need for
RPMI.  I've tested the interoperability between RPMI clients and transports
with an S-Mode U-boot (using the MPXY transport) and M-Mode U-Boot (using
shared memory transport) and the following device tree fragment:

```
        firmware {
                rpmi: mailbox@7000000000 {
                        compatible = "riscv,rpmi-shmem-mbox";
                        reg = <0x70 0x00000000 0x0 0x3000>,
                                <0x70 0x00003000 0x0 0x3000>,
                                <0x70 0x00006000 0x0 0x1000>,
                                <0x70 0x00007000 0x0 0x1000>;
                        reg-names = "a2p-req", "p2a-ack", "p2a-req", "a2p-ack";
                        riscv,slot-size = <64>;
                        #mbox-cells = <1>;
                };

ifndef CONFIG_RISCV_MMODE
                clock-service {
                        compatible = "riscv,rpmi-mpxy-clock";
                        mboxes = <&rpmi 0x8>;
                        riscv,sbi-mpxy-channel-id = <0x1000>;
                };

                mpxy_mbox: mailbox {
                        compatible = "riscv,sbi-mpxy-mbox";
                        #mbox-cells = <2>;
                };
endif

                sysc_clk: clock-controller {
                        compatible = "riscv,rpmi-clock";
ifdef CONFIG_RISCV_MMODE
                        mboxes = <&rpmi 0x8>;
else
                        mboxes = <&mpxy_mbox 0x1000 0x0>;
endif
                        #clock-cells = <1>;
                };
```

[1]: https://github.com/riscv-non-isa/riscv-rpmi
[2]: https://github.com/riscv-software-src/librpmi
[3]: https://elixir.bootlin.com/linux/v7.0.10/source/drivers/mailbox/riscv-sbi-mpxy-mbox.c
[4]: https://elixir.bootlin.com/opensbi/v1.8.1/source/lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c
[5]: https://elixir.bootlin.com/linux/v7.0.10/source/drivers/clk/clk-rpmi.c
[6]: https://lore.kernel.org/all/20260709175605.1070755-1-rahul.pathak@oss.qualcomm.com/

Cc: Rahul Pathak <rahul@summations.net>
Cc: Anup Patel <anup@brainfault.org>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Romain Caritey <romain.caritey@microchip.com>
Cc: Mame Maria Mbaye <MameMaria.Mbaye@microchip.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Cc: Rick Chen <rick@andestech.com>
Cc: Leo Yu-Chi Liang <ycliang@andestech.com>
Cc: Michal Simek <michal.simek@amd.com>
Cc: Conor Dooley <conor@kernel.org>
Cc: Yao Zi <me@ziyao.cc>
Cc: Peng Fan <peng.fan@oss.nxp.com>

Changes in v3:
 - Added the "mpxy" command from Rahul. See [6].

Changes in v2:
 - Drop the device-power service group as the DT bindings for it are not
   mainlined (was patch 5 and 7).
 - Reorder headers in all .c files.
 - Don't null check pointers before free().
 - Improve error messages in rpmi_check_versions() (patch 1).
 - Remove struct sbi_mpxy_rpmi_channel_attrs and struct
   sbi_mpxy_channel_attrs for simpler u32 arrays (patch 2).
 - Remove transition_latency from struct rpmi_clk_def as it's unused (patch 4).
 - Simplify last return path of _rpmi_clk_enable_disable() (patch 4).
 - Move the call to _rpmi_clk_get_rate() from _rpmi_clk_set_rate() to
   rpmi_clk_set_rate() (patch 4).


Charles Perry (4):
  firmware: rpmi: add support for the SBI MPXY transport
  firmware: rpmi: add support for shared memory transport
  drivers: clk: add support for RPMI clocks
  firmware: rpmi: add a test and a sandbox driver

Rahul Pathak (1):
  drivers: firmware: rpmi: Add the mpxy command

 MAINTAINERS                                |   2 +
 arch/riscv/include/asm/sbi.h               |  57 ++
 arch/sandbox/dts/test.dts                  |  12 +
 cmd/riscv/Makefile                         |   1 +
 configs/sandbox_defconfig                  |   2 +
 drivers/clk/Kconfig                        |   7 +
 drivers/clk/Makefile                       |   1 +
 drivers/clk/clk_rpmi.c                     | 344 +++++++++
 drivers/firmware/rpmi/Kconfig              |  27 +-
 drivers/firmware/rpmi/Makefile             |   3 +
 drivers/firmware/rpmi/rpmi-sandbox-clock.c | 446 ++++++++++++
 drivers/firmware/rpmi/rpmi-sandbox.c       | 156 ++++
 drivers/firmware/rpmi/rpmi-sandbox.h       |  47 ++
 drivers/firmware/rpmi/rpmi-sbi-mpxy.c      | 794 +++++++++++++++++++++
 drivers/firmware/rpmi/rpmi-shmem.c         | 473 ++++++++++++
 include/rpmi_proto.h                       |  62 ++
 test/dm/Makefile                           |   1 +
 test/dm/rpmi.c                             |  48 ++
 18 files changed, 2482 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/clk_rpmi.c
 create mode 100644 drivers/firmware/rpmi/rpmi-sandbox-clock.c
 create mode 100644 drivers/firmware/rpmi/rpmi-sandbox.c
 create mode 100644 drivers/firmware/rpmi/rpmi-sandbox.h
 create mode 100644 drivers/firmware/rpmi/rpmi-sbi-mpxy.c
 create mode 100644 drivers/firmware/rpmi/rpmi-shmem.c
 create mode 100644 test/dm/rpmi.c