[PATCH 1/3] lib: utils: Add MPXY RPMI mailbox driver for voltage
Joshua Yeong
joshua.yeong at starfivetech.com
Mon Oct 13 08:31:36 PDT 2025
Add voltage service group for RPMI/MPXY support
Signed-off-by: Joshua Yeong <joshua.yeong at starfivetech.com>
---
include/sbi_utils/mailbox/rpmi_msgprot.h | 81 ++++++++++++++++++++++++
lib/utils/mpxy/Kconfig | 4 ++
lib/utils/mpxy/fdt_mpxy_rpmi_voltage.c | 76 ++++++++++++++++++++++
lib/utils/mpxy/objects.mk | 3 +
platform/generic/configs/defconfig | 1 +
5 files changed, 165 insertions(+)
create mode 100644 lib/utils/mpxy/fdt_mpxy_rpmi_voltage.c
diff --git a/include/sbi_utils/mailbox/rpmi_msgprot.h b/include/sbi_utils/mailbox/rpmi_msgprot.h
index a761b560..6b5a553c 100644
--- a/include/sbi_utils/mailbox/rpmi_msgprot.h
+++ b/include/sbi_utils/mailbox/rpmi_msgprot.h
@@ -216,6 +216,7 @@ enum rpmi_servicegroup_id {
RPMI_SRVGRP_SYSTEM_SUSPEND = 0x0004,
RPMI_SRVGRP_HSM = 0x0005,
RPMI_SRVGRP_CPPC = 0x0006,
+ RPMI_SRVGRP_VOLTAGE = 0x00007,
RPMI_SRVGRP_CLOCK = 0x0008,
RPMI_SRVGRP_ID_MAX_COUNT,
@@ -611,6 +612,86 @@ struct rpmi_cppc_hart_list_resp {
u32 hartid[(RPMI_MSG_DATA_SIZE(RPMI_SLOT_SIZE_MIN) - (sizeof(u32) * 3)) / sizeof(u32)];
};
+/** RPMI Voltage ServiceGroup Service IDs */
+enum rpmi_voltage_service_id {
+ RPMI_VOLTAGE_SRV_ENABLE_NOTIFICATION = 0x01,
+ RPMI_VOLTAGE_SRV_GET_NUM_DOMAINS = 0x02,
+ RPMI_VOLTAGE_SRV_GET_ATTRIBUTES = 0x03,
+ RPMI_VOLTAGE_SRV_GET_SUPPORTED_LEVELS = 0x04,
+ RPMI_VOLTAGE_SRV_SET_CONFIG = 0x05,
+ RPMI_VOLTAGE_SRV_GET_CONFIG = 0x06,
+ RPMI_VOLTAGE_SRV_SET_LEVEL = 0x07,
+ RPMI_VOLTAGE_SRV_GET_LEVEL = 0x08,
+ RPMI_VOLTAGE_SRV_MAX_COUNT,
+};
+
+struct rpmi_voltage_get_num_domains_resp {
+ s32 status;
+ u32 num_domains;
+};
+
+struct rpmi_voltage_get_attributes_req {
+ u32 domain_id;
+};
+
+struct rpmi_voltage_get_attributes_resp {
+ s32 status;
+ u32 flags;
+ u32 num_levels;
+ u32 transition_latency;
+ u8 name[16];
+};
+
+struct rpmi_voltage_get_supported_rate_req {
+ u32 domain_id;
+ u32 index;
+};
+
+struct rpmi_voltage_get_supported_rate_resp {
+ s32 status;
+ u32 flags;
+ u32 remaining;
+ u32 returned;
+ u32 level[0];
+};
+
+struct rpmi_voltage_set_config_req {
+ u32 domain_id;
+#define RPMI_CLOCK_CONFIG_ENABLE (1U << 0)
+ u32 config;
+};
+
+struct rpmi_voltage_set_config_resp {
+ s32 status;
+};
+
+struct rpmi_voltage_get_config_req {
+ u32 domain_id;
+};
+
+struct rpmi_voltage_get_config_resp {
+ s32 status;
+ u32 config;
+};
+
+struct rpmi_voltage_set_level_req {
+ u32 domain_id;
+ s32 level;
+};
+
+struct rpmi_voltage_set_level_resp {
+ s32 status;
+};
+
+struct rpmi_voltage_get_level_req {
+ u32 domain_id;
+};
+
+struct rpmi_voltage_get_level_resp {
+ s32 status;
+ s32 level;
+};
+
/** RPMI Clock ServiceGroup Service IDs */
enum rpmi_clock_service_id {
RPMI_CLOCK_SRV_ENABLE_NOTIFICATION = 0x01,
diff --git a/lib/utils/mpxy/Kconfig b/lib/utils/mpxy/Kconfig
index 8d1f5183..f720af2c 100644
--- a/lib/utils/mpxy/Kconfig
+++ b/lib/utils/mpxy/Kconfig
@@ -22,6 +22,10 @@ config FDT_MPXY_RPMI_SYSMSI
bool "MPXY driver for RPMI system MSI service group"
default n
+config FDT_MPXY_RPMI_VOLTAGE
+ bool "MPXY driver for RPMI voltage service group"
+ default n
+
endif
endmenu
diff --git a/lib/utils/mpxy/fdt_mpxy_rpmi_voltage.c b/lib/utils/mpxy/fdt_mpxy_rpmi_voltage.c
new file mode 100644
index 00000000..a281924e
--- /dev/null
+++ b/lib/utils/mpxy/fdt_mpxy_rpmi_voltage.c
@@ -0,0 +1,76 @@
+#include <sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h>
+
+static struct mpxy_rpmi_service_data voltage_services[] = {
+{
+ .id = RPMI_VOLTAGE_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_VOLTAGE_SRV_GET_NUM_DOMAINS,
+ .min_tx_len = 0,
+ .max_tx_len = 0,
+ .min_rx_len = sizeof(struct rpmi_voltage_get_num_domains_resp),
+ .max_rx_len = sizeof(struct rpmi_voltage_get_num_domains_resp),
+},
+{
+ .id = RPMI_VOLTAGE_SRV_GET_ATTRIBUTES,
+ .min_tx_len = sizeof(struct rpmi_voltage_get_attributes_req),
+ .max_tx_len = sizeof(struct rpmi_voltage_get_attributes_req),
+ .min_rx_len = sizeof(struct rpmi_voltage_get_attributes_resp),
+ .max_rx_len = sizeof(struct rpmi_voltage_get_attributes_resp),
+},
+{
+ .id = RPMI_VOLTAGE_SRV_GET_SUPPORTED_LEVELS,
+ .min_tx_len = sizeof(struct rpmi_voltage_get_supported_rate_req),
+ .max_tx_len = sizeof(struct rpmi_voltage_get_supported_rate_req),
+ .min_rx_len = sizeof(struct rpmi_voltage_get_supported_rate_resp),
+ .max_rx_len = -1U,
+},
+{
+ .id = RPMI_VOLTAGE_SRV_SET_CONFIG,
+ .min_tx_len = sizeof(struct rpmi_voltage_set_config_req),
+ .max_tx_len = sizeof(struct rpmi_voltage_set_config_req),
+ .min_rx_len = sizeof(struct rpmi_voltage_set_config_resp),
+ .max_rx_len = sizeof(struct rpmi_voltage_set_config_resp),
+},
+{
+ .id = RPMI_VOLTAGE_SRV_GET_CONFIG,
+ .min_tx_len = sizeof(struct rpmi_voltage_get_config_req),
+ .max_tx_len = sizeof(struct rpmi_voltage_get_config_req),
+ .min_rx_len = sizeof(struct rpmi_voltage_get_config_resp),
+ .max_rx_len = sizeof(struct rpmi_voltage_get_config_resp),
+},
+{
+ .id = RPMI_VOLTAGE_SRV_SET_LEVEL,
+ .min_tx_len = sizeof(struct rpmi_voltage_set_level_req),
+ .max_tx_len = sizeof(struct rpmi_voltage_set_level_req),
+ .min_rx_len = sizeof(struct rpmi_voltage_set_level_resp),
+ .max_rx_len = sizeof(struct rpmi_voltage_set_level_resp),
+},
+{
+ .id = RPMI_VOLTAGE_SRV_GET_LEVEL,
+ .min_tx_len = sizeof(struct rpmi_voltage_get_level_req),
+ .max_tx_len = sizeof(struct rpmi_voltage_get_level_req),
+ .min_rx_len = sizeof(struct rpmi_voltage_get_level_resp),
+ .max_rx_len = sizeof(struct rpmi_voltage_get_level_resp),
+},
+};
+
+static const struct mpxy_rpmi_mbox_data voltage_data = {
+ .servicegrp_id = RPMI_SRVGRP_VOLTAGE,
+ .num_services = RPMI_VOLTAGE_SRV_MAX_COUNT,
+ .service_data = voltage_services,
+};
+
+static const struct fdt_match voltage_match[] = {
+ { .compatible = "riscv,rpmi-mpxy-voltage", .data = &voltage_data },
+ { },
+};
+
+const struct fdt_driver fdt_mpxy_rpmi_voltage = {
+ .match_table = voltage_match,
+ .init = mpxy_rpmi_mbox_init,
+};
diff --git a/lib/utils/mpxy/objects.mk b/lib/utils/mpxy/objects.mk
index 5b6e9bdf..a71c56af 100644
--- a/lib/utils/mpxy/objects.mk
+++ b/lib/utils/mpxy/objects.mk
@@ -17,3 +17,6 @@ libsbiutils-objs-$(CONFIG_FDT_MPXY_RPMI_CLOCK) += mpxy/fdt_mpxy_rpmi_clock.o
carray-fdt_mpxy_drivers-$(CONFIG_FDT_MPXY_RPMI_SYSMSI) += fdt_mpxy_rpmi_sysmsi
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
diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
index fb90bb3e..10992619 100644
--- a/platform/generic/configs/defconfig
+++ b/platform/generic/configs/defconfig
@@ -59,4 +59,5 @@ CONFIG_FDT_TIMER_PLMT=y
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_SYSMSI=y
--
2.43.0
More information about the opensbi
mailing list