[PATCH 2/3] lib: utils: Add MPXY RPMI mailbox driver for device power

Anup Patel anup at brainfault.org
Mon Nov 3 21:12:26 PST 2025


On Mon, Oct 13, 2025 at 9:02 PM Joshua Yeong
<joshua.yeong at starfivetech.com> wrote:
>
> Add MPXY RPMI mailbox driver for device power.
>
> Signed-off-by: Joshua Yeong <joshua.yeong at starfivetech.com>

I have marked the driver as experimental until the DT compatible
string is accepted on LKML.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
>  include/sbi_utils/mailbox/rpmi_msgprot.h    | 45 +++++++++++++++++
>  lib/utils/mpxy/Kconfig                      |  4 ++
>  lib/utils/mpxy/fdt_mpxy_rpmi_device_power.c | 55 +++++++++++++++++++++
>  lib/utils/mpxy/objects.mk                   |  3 ++
>  platform/generic/configs/defconfig          |  1 +
>  5 files changed, 108 insertions(+)
>  create mode 100644 lib/utils/mpxy/fdt_mpxy_rpmi_device_power.c
>
> diff --git a/include/sbi_utils/mailbox/rpmi_msgprot.h b/include/sbi_utils/mailbox/rpmi_msgprot.h
> index 6b5a553c..4e915a08 100644
> --- a/include/sbi_utils/mailbox/rpmi_msgprot.h
> +++ b/include/sbi_utils/mailbox/rpmi_msgprot.h
> @@ -218,6 +218,7 @@ enum rpmi_servicegroup_id {
>         RPMI_SRVGRP_CPPC = 0x0006,
>         RPMI_SRVGRP_VOLTAGE = 0x00007,
>         RPMI_SRVGRP_CLOCK = 0x0008,
> +       RPMI_SRVGRP_DEVICE_POWER = 0x0009,
>         RPMI_SRVGRP_ID_MAX_COUNT,
>
>         /* Reserved range for service groups */
> @@ -784,4 +785,48 @@ struct rpmi_clock_get_rate_resp {
>         u32 clock_rate_high;
>  };
>
> +/** RPMI Device Power ServiceGroup Service IDs */
> +enum rpmi_dpwr_service_id {
> +       RPMI_DPWR_SRV_ENABLE_NOTIFICATION = 0x01,
> +       RPMI_DPWR_SRV_GET_NUM_DOMAINS = 0x02,
> +       RPMI_DPWR_SRV_GET_ATTRIBUTES = 0x03,
> +       RPMI_DPWR_SRV_SET_STATE = 0x04,
> +       RPMI_DPWR_SRV_GET_STATE = 0x05,
> +       RPMI_DPWR_SRV_MAX_COUNT,
> +};
> +
> +struct rpmi_dpwr_get_num_domain_resp {
> +       s32 status;
> +       u32 num_domain;
> +};
> +
> +struct rpmi_dpwr_get_attrs_req {
> +       u32 domain_id;
> +};
> +
> +struct rpmi_dpwr_get_attrs_resp {
> +       s32 status;
> +       u32 flags;
> +       u32 transition_latency;
> +       u8 name[16];
> +};
> +
> +struct rpmi_dpwr_set_state_req {
> +       u32 domain_id;
> +       u32 state;
> +};
> +
> +struct rpmi_dpwr_set_state_resp {
> +       s32 status;
> +};
> +
> +struct rpmi_dpwr_get_state_req {
> +       u32 domain_id;
> +};
> +
> +struct rpmi_dpwr_get_state_resp {
> +       s32 status;
> +       u32 state;
> +};
> +
>  #endif /* !__RPMI_MSGPROT_H__ */
> diff --git a/lib/utils/mpxy/Kconfig b/lib/utils/mpxy/Kconfig
> index f720af2c..25288671 100644
> --- a/lib/utils/mpxy/Kconfig
> +++ b/lib/utils/mpxy/Kconfig
> @@ -26,6 +26,10 @@ config FDT_MPXY_RPMI_VOLTAGE
>         bool "MPXY driver for RPMI voltage service group"
>         default n
>
> +config FDT_MPXY_RPMI_DEVICE_POWER
> +       bool "MPXY driver for RPMI device power service group"
> +       default n
> +
>  endif
>
>  endmenu
> diff --git a/lib/utils/mpxy/fdt_mpxy_rpmi_device_power.c b/lib/utils/mpxy/fdt_mpxy_rpmi_device_power.c
> new file mode 100644
> index 00000000..9978b727
> --- /dev/null
> +++ b/lib/utils/mpxy/fdt_mpxy_rpmi_device_power.c
> @@ -0,0 +1,55 @@
> +#include <sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h>
> +
> +static struct mpxy_rpmi_service_data dpwr_services[] = {
> +{
> +       .id = RPMI_DPWR_SRV_ENABLE_NOTIFICATION,
> +       .min_tx_len = sizeof(struct rpmi_enable_notification_req),
> +       .max_tx_len = sizeof(struct rpmi_enable_notification_req),
> +       .min_rx_len = sizeof(struct rpmi_enable_notification_resp),
> +       .max_rx_len = sizeof(struct rpmi_enable_notification_resp),
> +},
> +{
> +       .id = RPMI_DPWR_SRV_GET_NUM_DOMAINS,
> +       .min_tx_len = 0,
> +       .max_tx_len = 0,
> +       .min_rx_len = sizeof(struct rpmi_dpwr_get_num_domain_resp),
> +       .max_rx_len = sizeof(struct rpmi_dpwr_get_num_domain_resp),
> +},
> +{
> +       .id = RPMI_DPWR_SRV_GET_ATTRIBUTES,
> +       .min_tx_len = sizeof(struct rpmi_dpwr_get_attrs_req),
> +       .max_tx_len = sizeof(struct rpmi_dpwr_get_attrs_req),
> +       .min_rx_len = sizeof(struct rpmi_dpwr_get_attrs_resp),
> +       .max_rx_len = sizeof(struct rpmi_dpwr_get_attrs_resp),
> +},
> +{
> +       .id = RPMI_DPWR_SRV_SET_STATE,
> +       .min_tx_len = sizeof(struct rpmi_dpwr_set_state_req),
> +       .max_tx_len = sizeof(struct rpmi_dpwr_set_state_req),
> +       .min_rx_len = sizeof(struct rpmi_dpwr_set_state_resp),
> +       .max_rx_len = sizeof(struct rpmi_dpwr_set_state_resp),
> +},
> +{
> +       .id = RPMI_DPWR_SRV_GET_STATE,
> +       .min_tx_len = sizeof(struct rpmi_dpwr_get_state_req),
> +       .max_tx_len = sizeof(struct rpmi_dpwr_get_state_req),
> +       .min_rx_len = sizeof(struct rpmi_dpwr_get_state_resp),
> +       .max_rx_len = sizeof(struct rpmi_dpwr_get_state_resp),
> +},
> +};
> +
> +static const struct mpxy_rpmi_mbox_data dpwr_data = {
> +       .servicegrp_id = RPMI_SRVGRP_DEVICE_POWER,
> +       .num_services = RPMI_DPWR_SRV_MAX_COUNT,
> +       .service_data = dpwr_services,
> +};
> +
> +static const struct fdt_match dpwr_match[] = {
> +       { .compatible = "riscv,rpmi-mpxy-device-power", .data = &dpwr_data },
> +       { },
> +};
> +
> +const struct fdt_driver fdt_mpxy_rpmi_device_power = {
> +       .match_table = dpwr_match,
> +       .init = mpxy_rpmi_mbox_init,
> +};
> diff --git a/lib/utils/mpxy/objects.mk b/lib/utils/mpxy/objects.mk
> index a71c56af..45b3281b 100644
> --- a/lib/utils/mpxy/objects.mk
> +++ b/lib/utils/mpxy/objects.mk
> @@ -20,3 +20,6 @@ libsbiutils-objs-$(CONFIG_FDT_MPXY_RPMI_SYSMSI) += mpxy/fdt_mpxy_rpmi_sysmsi.o
>
>  carray-fdt_mpxy_drivers-$(CONFIG_FDT_MPXY_RPMI_VOLTAGE) += fdt_mpxy_rpmi_voltage
>  libsbiutils-objs-$(CONFIG_FDT_MPXY_RPMI_VOLTAGE) += mpxy/fdt_mpxy_rpmi_voltage.o
> +
> +carray-fdt_mpxy_drivers-$(CONFIG_FDT_MPXY_RPMI_DEVICE_POWER) += fdt_mpxy_rpmi_device_power
> +libsbiutils-objs-$(CONFIG_FDT_MPXY_RPMI_DEVICE_POWER) += mpxy/fdt_mpxy_rpmi_device_power.o
> diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
> index 10992619..5e819b3b 100644
> --- a/platform/generic/configs/defconfig
> +++ b/platform/generic/configs/defconfig
> @@ -60,4 +60,5 @@ CONFIG_FDT_MPXY=y
>  CONFIG_FDT_MPXY_RPMI_MBOX=y
>  CONFIG_FDT_MPXY_RPMI_CLOCK=y
>  CONFIG_FDT_MPXY_RPMI_VOLTAGE=y
> +CONFIG_FDT_MPXY_RPMI_DEVICE_POWER=y
>  CONFIG_FDT_MPXY_RPMI_SYSMSI=y
> --
> 2.43.0
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi



More information about the opensbi mailing list