Add RISC-V RPMI device power service support
Subsystems (5)
Joshua Yeong
maintainerv3 cover Add RISC-V RPMI device power service support
The RISC-V Platform Management Interface (RPMI) specification defines a modular and extensible messaging protocol between the supervisor software and a platform microcontroller (PuC). Among the service groups it defines is the device power service group (service group ID 0x00009), which allows the supervisor to enumerate the power domains of platform devices managed by the PuC, query their attributes, and get/set their power state.
This series adds supervisor-side support for that service group:
- DT bindings for the power domain controller exposed to the supervisor ("riscv,rpmi-device-power") and for the SBI MPXY channel that the SBI implementation uses to expose the service group to the supervisor ("riscv,rpmi-mpxy-device-power").
- A generic power domain (genpd) provider driver under drivers/pmdomain/riscv/ which talks to the PuC over an SBI MPXY mailbox channel. At probe it queries GET_NUM_DOMAINS, then for each domain queries GET_ATTRS for the name and transition latency and GET_STATE for the initial state, and registers the whole set as a onecell genpd provider. Domain power on/off is driven through SET_STATE with the generic ON/OFF power state parameters, so devices can simply reference a domain through the "power-domains" property.
The series is based on the existing RISC-V RPMI/MPXY infrastructure already present in the tree (drivers/mailbox/riscv-sbi-mpxy-mbox.c and include/linux/mailbox/riscv-rpmi-message.h), and only adds the device power service group definitions on top of it.
Changes in v3:
- Move the MAINTAINERS change into its own patch, and add a new "RISC-V RPMI DEVICE POWER DRIVER" section scoped to this driver and its bindings instead of adding an M: entry to the existing "RISC-V RPMI AND MPXY DRIVERS" section, which covers drivers maintained by others.
- Drop the redundant trailing "bindings" from the dt-bindings subject.
- Compare only the value field of the RPMI power state word. The word also carries a context bit, so a full word comparison would report -EIO after a successful transition, and would drop a domain at probe, whenever the PuC reports context as lost.
- Check the pm_genpd_init() return value and leave a failed domain out of the onecell array. Every failure path in pm_genpd_init() returns before the genpd is linked into gpd_list, so the previous code could hand a half initialised genpd to of_genpd_add_provider_onecell() and then list_del() an uninitialised list head in the unwind loop.
- Set GENPD_FLAG_DEV_NAME_FW. The domain names come from the PuC and are not guaranteed to be unique or non-empty, and were used verbatim as the sysfs and debugfs names, where a duplicate fails device_add() with -EEXIST and takes down the whole provider.
v1: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]
Testing
=======
The series was tested under QEMU with the RPMI device power service implemented in firmware.
Components:
- OpenSBI: latest master branch
https://github.com/riscv-software-src/opensbi
- QEMU: the RPMI-enabled tree at
https://github.com/yeongjoshua/qemu/tree/rpmi-v11.1.0
Kernel config: enable CONFIG_RISCV_RPMI_DEVICE_POWER (default y on RISC-V when MAILBOX is enabled) along with the SBI MPXY mailbox driver.
Run with:
qemu-system-riscv64 \
-M virt -m 2G -smp 4 \
-bios fw_dynamic.bin \
-kernel Image \
-M rpmi=true \
-nographic \
-initrd rootfs-busybox.cpio \
-append "root=/dev/ram rw console=ttyS0,115200 no_console_suspend mem=2048M earlycon=uart8250,mmio,0x10000000"The RPMI device power domains advertised by the emulated platform microcontroller show up as generic power domains and can be inspected through /sys/kernel/debug/pm_genpd/. The series was additionally booted with CONFIG_PROVE_LOCKING, CONFIG_DEBUG_MUTEXES and CONFIG_DEBUG_ATOMIC_SLEEP enabled, with no lockdep reports.
Joshua Yeong (3):
dt-bindings: power: Add RPMI device power service
pmdomain: riscv: Add RPMI device power service
MAINTAINERS: Add RISC-V RPMI device power driver
.../power/riscv,rpmi-device-power.yaml | 65 +++ .../power/riscv,rpmi-mpxy-device-power.yaml | 65 +++ MAINTAINERS | 8 + drivers/pmdomain/Kconfig | 1 + drivers/pmdomain/Makefile | 1 + drivers/pmdomain/riscv/Kconfig | 15 + drivers/pmdomain/riscv/Makefile | 3 + .../pmdomain/riscv/riscv-rpmi-device-power.c | 485 ++++++++++++++++++ include/linux/mailbox/riscv-rpmi-message.h | 11 + 9 files changed, 654 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/riscv,rpmi-device-power.yaml create mode 100644 Documentation/devicetree/bindings/power/riscv,rpmi-mpxy-device-power.yaml create mode 100644 drivers/pmdomain/riscv/Kconfig create mode 100644 drivers/pmdomain/riscv/Makefile create mode 100644 drivers/pmdomain/riscv/riscv-rpmi-device-power.c
base-commit: 8d3ae59288f1e7d58d76558a6ee96d533bc5019f --
2.43.0
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Joshua Yeong
maintainerPATCH v3 1/3 dt-bindings: power: Add RPMI device power service
Add device tree bindings for the RISC-V Platform Management Interface (RPMI) device power service group, both for the supervisor-facing power domain controller and for the SBI MPXY channel which the SBI implementation uses to expose the service group.
--- .../power/riscv,rpmi-device-power.yaml | 65 +++++++++++++++++++ .../power/riscv,rpmi-mpxy-device-power.yaml | 65 +++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/riscv,rpmi-device-power.yaml create mode 100644 Documentation/devicetree/bindings/power/riscv,rpmi-mpxy-device-power.yaml
Documentation/devicetree/bindings/power/riscv,rpmi-device-power.yaml new file +65 -0
@@ -0,0 +1,65 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/riscv,rpmi-device-power.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RISC-V RPMI device power service group based power domain controller + +maintainers: + - Joshua Yeong <[email protected]> + +description: | + The RISC-V Platform Management Interface (RPMI) [1] defines a + messaging protocol which is modular and extensible. The supervisor + software can send/receive RPMI messages via SBI MPXY extension [2] + or some dedicated supervisor-mode RPMI transport. + + The RPMI specification [1] defines device power service group for + accessing and controlling the power state of platform devices managed + by a platform microcontroller. The supervisor software can access RPMI + device power service group via SBI MPXY channel or some dedicated + supervisor-mode RPMI transport. + + =========================================== + References + =========================================== + + [1] RISC-V Platform Management Interface (RPMI) v1.0 (or higher) + https://github.com/riscv-non-isa/riscv-rpmi/releases + + [2] RISC-V Supervisor Binary Interface (SBI) v3.0 (or higher) + https://github.com/riscv-non-isa/riscv-sbi-doc/releases + +properties: + compatible: + description: + Intended for use by the supervisor software. + const: riscv,rpmi-device-power + + mboxes: + maxItems: 1 + description: + Mailbox channel of the underlying RPMI transport or SBI message proxy channel. + + "#power-domain-cells": + const: 1 + description: + Platform specific DOMAIN_ID as defined by the RISC-V Platform Management + Interface (RPMI) specification. + +required: + - compatible + - mboxes + - "#power-domain-cells" + +additionalProperties: false + +examples: + - | + power-controller { + compatible = "riscv,rpmi-device-power"; + mboxes = <&mpxy_mbox 0x1002 0x0>; + #power-domain-cells = <1>; + }; +...
Documentation/devicetree/bindings/power/riscv,rpmi-mpxy-device-power.yaml new file +65 -0
65 lines not on this page · raw message
Signature · 7 lines
2.43.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v3 1/3] dt-bindings: power: Add RPMI device power service
Quoted 6 lines · Joshua Yeong
Add device tree bindings for the RISC-V Platform Management Interface (RPMI) device power service group, both for the supervisor-facing power domain controller and for the SBI MPXY channel which the SBI implementation uses to expose the service group.
Signed-off-by Joshua Yeong <[email protected]>
pw-bot: not-applicable
Joshua Yeong
maintainerPATCH v3 2/3 pmdomain: riscv: Add RPMI device power service
In reply to Joshua YeongAdd a generic power domain provider on top of the RISC-V Platform Management Interface (RPMI) device power service group, reached through an SBI MPXY channel.
The driver enumerates the device power domains advertised by the platform microcontroller, queries their attributes and initial state, and registers them as an onecell genpd provider so that devices can reference them through the "power-domains" property.
--- drivers/pmdomain/Kconfig | 1 + drivers/pmdomain/Makefile | 1 + drivers/pmdomain/riscv/Kconfig | 15 + drivers/pmdomain/riscv/Makefile | 3 + .../pmdomain/riscv/riscv-rpmi-device-power.c | 485 ++++++++++++++++++ include/linux/mailbox/riscv-rpmi-message.h | 11 + 6 files changed, 516 insertions(+) create mode 100644 drivers/pmdomain/riscv/Kconfig create mode 100644 drivers/pmdomain/riscv/Makefile create mode 100644 drivers/pmdomain/riscv/riscv-rpmi-device-power.c
drivers/pmdomain/Kconfig +1 -0
@@ -11,6 +11,7 @@ source "drivers/pmdomain/marvell/Kconfig" source "drivers/pmdomain/mediatek/Kconfig" source "drivers/pmdomain/qcom/Kconfig" source "drivers/pmdomain/renesas/Kconfig" +source "drivers/pmdomain/riscv/Kconfig" source "drivers/pmdomain/rockchip/Kconfig" source "drivers/pmdomain/samsung/Kconfig" source "drivers/pmdomain/st/Kconfig"
drivers/pmdomain/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-y += marvell/ obj-y += mediatek/ obj-y += qcom/ obj-y += renesas/ +obj-y += riscv/ obj-y += rockchip/ obj-y += samsung/ obj-y += st/
drivers/pmdomain/riscv/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config RISCV_RPMI_DEVICE_POWER + bool "RISC-V RPMI Based Device Power driver" + depends on RISCV || COMPILE_TEST + depends on MAILBOX + depends on PM + default RISCV + select PM_GENERIC_DOMAINS + help + Support for device power domains based on the device power service + group defined by the RISC-V platform management interface (RPMI) + specification. The power domains advertised by the platform + microcontroller are registered as generic power domains, so that + devices can reference them through the "power-domains" property.
drivers/pmdomain/riscv/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_RISCV_RPMI_DEVICE_POWER) += riscv-rpmi-device-power.o
drivers/pmdomain/riscv/riscv-rpmi-device-power.c new file +485 -0
485 lines not on this page · raw message
include/linux/mailbox/riscv-rpmi-message.h +11 -0
@@ -93,6 +93,7 @@ static inline int rpmi_to_linux_error(int rpmi_error)/* RPMI service group IDs */ #define RPMI_SRVGRP_SYSTEM_MSI 0x00002#define RPMI_SRVGRP_CLOCK 0x00008 +#define RPMI_SRVGRP_DEVICE_POWER 0x00009/* RPMI clock service IDs */ enum rpmi_clock_service_id {
@@ -119,6 +120,16 @@ enum rpmi_sysmsi_service_id {RPMI_SYSMSI_SRV_ID_MAX_COUNT }; +/* RPMI device power service IDs */ +enum rpmi_device_power_service_id { +RPMI_DP_SRV_ENABLE_NOTIFICATION =0x01 , +RPMI_DP_SRV_GET_NUM_DOMAINS =0x02 , +RPMI_DP_SRV_GET_ATTRS =0x03 , +RPMI_DP_SRV_SET_STATE =0x04 , +RPMI_DP_SRV_GET_STATE =0x05 , +RPMI_DP_SRV_ID_MAX_COUNT , +}; +/* RPMI Linux mailbox attribute IDs */ enum rpmi_mbox_attribute_id {RPMI_MBOX_ATTR_SPEC_VERSION ,
Signature · 1 line
2.43.0
Joshua Yeong
maintainerPATCH v3 3/3 MAINTAINERS: Add RISC-V RPMI device power driver
In reply to Joshua YeongAdd a separate entry for the RPMI device power driver and its bindings, rather than extending the existing RISC-V RPMI and MPXY drivers entry, which covers drivers maintained by others.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -23308,6 +23308,14 @@ F: drivers/irqchip/irq-riscv-rpmi-sysmsi.c F: drivers/mailbox/riscv-sbi-mpxy-mbox.c F: include/linux/mailbox/riscv-rpmi-message.h +RISC-V RPMI DEVICE POWER DRIVER +M: Joshua Yeong <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/power/riscv,rpmi-device-power.yaml +F: Documentation/devicetree/bindings/power/riscv,rpmi-mpxy-device-power.yaml +F: drivers/pmdomain/riscv/ + RISC-V SPACEMIT SoC Support M: Yixun Lan <[email protected]> L: [email protected]
Signature · 1 line
2.43.0
Quoted 109 lines · Joshua Yeong
The RISC-V Platform Management Interface (RPMI) specification defines a modular and extensible messaging protocol between the supervisor software and a platform microcontroller (PuC). Among the service groups it defines is the device power service group (service group ID
0x00009), which allows the supervisor to enumerate the power domains of platform devices managed by the PuC, query their attributes, and get/set their power state.This series adds supervisor-side support for that service group:
- DT bindings for the power domain controller exposed to the supervisor ("riscv,rpmi-device-power") and for the SBI MPXY channel that the SBI implementation uses to expose the service group to the supervisor ("riscv,rpmi-mpxy-device-power").
- A generic power domain (genpd) provider driver under
drivers/pmdomain/riscv/which talks to the PuC over an SBI MPXY mailbox channel. At probe it queriesGET_NUM_DOMAINS, then for each domain queriesGET_ATTRSfor the name and transition latency andGET_STATEfor the initial state, and registers the whole set as a onecell genpd provider. Domain power on/off is driven throughSET_STATEwith the generic ON/OFF power state parameters, so devices can simply reference a domain through the "power-domains" property.The series is based on the existing RISC-V RPMI/MPXY infrastructure already present in the tree (
drivers/mailbox/riscv-sbi-mpxy-mbox.candinclude/linux/mailbox/riscv-rpmi-message.h), and only adds the device power service group definitions on top of it.Changes in v3:
- Move theMAINTAINERSchange into its own patch, and add a new "RISC-V RPMI DEVICE POWER DRIVER" section scoped to this driver and its bindings instead of adding an M: entry to the existing "RISC-V RPMI AND MPXY DRIVERS" section, which covers drivers maintained by others.
- Drop the redundant trailing "bindings" from the dt-bindings subject.
- Compare only the value field of the RPMI power state word. The word also carries a context bit, so a full word comparison would report-EIOafter a successful transition, and would drop a domain at probe, whenever the PuC reports context as lost.
- Check thepm_genpd_init()return value and leave a failed domain out of the onecell array. Every failure path inpm_genpd_init()returns before the genpd is linked intogpd_list, so the previous code could hand a half initialised genpd toof_genpd_add_provider_onecell()and thenlist_del()an uninitialised list head in the unwind loop.
- SetGENPD_FLAG_DEV_NAME_FW. The domain names come from the PuC and are not guaranteed to be unique or non-empty, and were used verbatim as the sysfs and debugfs names, where a duplicate failsdevice_add()with-EEXISTand takes down the whole provider.v1: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]Testing
=======The series was tested under QEMU with the RPMI device power service implemented in firmware.
Components:
- OpenSBI: latest master branch
https://github.com/riscv-software-src/opensbi- QEMU: the RPMI-enabled tree at
https://github.com/yeongjoshua/qemu/tree/rpmi-v11.1.0Kernel config: enable
CONFIG_RISCV_RPMI_DEVICE_POWER(default y on RISC-V when MAILBOX is enabled) along with the SBI MPXY mailbox driver.Run with:
qemu-system-riscv64 \ -M virt -m 2G -smp 4 \ -bios fw_dynamic.bin \ -kernel Image \ -M rpmi=true \ -nographic \ -initrd rootfs-busybox.cpio \ -append "root=/dev/ram rw console=ttyS0,115200 no_console_suspend mem=2048M earlycon=uart8250,mmio,0x10000000"The RPMI device power domains advertised by the emulated platform microcontroller show up as generic power domains and can be inspected through
/sys/kernel/debug/pm_genpd/. The series was additionally booted withCONFIG_PROVE_LOCKING,CONFIG_DEBUG_MUTEXESandCONFIG_DEBUG_ATOMIC_SLEEPenabled, with no lockdep reports.Joshua Yeong (3):
dt-bindings: power: Add RPMI device power service
pmdomain: riscv: Add RPMI device power service
MAINTAINERS: Add RISC-V RPMI device power driver.../power/riscv,rpmi-device-power.yaml | 65 +++ .../power/riscv,rpmi-mpxy-device-power.yaml | 65 +++ MAINTAINERS | 8 + drivers/pmdomain/Kconfig | 1 + drivers/pmdomain/Makefile | 1 + drivers/pmdomain/riscv/Kconfig | 15 + drivers/pmdomain/riscv/Makefile | 3 + .../pmdomain/riscv/riscv-rpmi-device-power.c | 485 ++++++++++++++++++ include/linux/mailbox/riscv-rpmi-message.h | 11 + 9 files changed, 654 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/riscv,rpmi-device-power.yaml create mode 100644 Documentation/devicetree/bindings/power/riscv,rpmi-mpxy-device-power.yaml create mode 100644 drivers/pmdomain/riscv/Kconfig create mode 100644 drivers/pmdomain/riscv/Makefile create mode 100644 drivers/pmdomain/riscv/riscv-rpmi-device-power.c
Quoted 3 lines
base-commit:
8d3ae59288f1e7d58d76558a6ee96d533bc5019f--
2.43.0
The v3 series applied for next, thanks!
Kind regards
Uffe
This series was applied to riscv/linux.git (fixes) by Ulf Hansson <[email protected]>:
Hello:
This series was applied to riscv/linux.git (fixes) by Ulf Hansson <[email protected]>:
Quoted 8 lines · On Thu, 3 Sep 2026 17:23:44 +0800 you wrote:
The RISC-V Platform Management Interface (RPMI) specification defines a modular and extensible messaging protocol between the supervisor software and a platform microcontroller (PuC). Among the service groups it defines is the device power service group (service group ID
0x00009), which allows the supervisor to enumerate the power domains of platform devices managed by the PuC, query their attributes, and get/set their power state.[...]
Here is the summary with links:
- [v3,1/3] dt-bindings: power: Add RPMI device power service
https://git.kernel.org/riscv/c/53d17430e0ef - [v3,2/3] pmdomain: riscv: Add RPMI device power service https://git.kernel.org/riscv/c/f94fe707c5b7 - [v3,3/3] MAINTAINERS: Add RISC-V RPMI device power driver https://git.kernel.org/riscv/c/396a18344d12
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html