aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoshua Yeong <joshua.yeong@starfivetech.com>2025-10-13 23:31:36 +0800
committerAnup Patel <anup@brainfault.org>2025-11-04 10:32:57 +0530
commitfa911ebe72ec9f8b82947ebc99daf1d0ec2f53e2 (patch)
tree218beaa02a8d8f1ac5294dfb26fbffd8810ea977 /lib
parent0250db4dad85248c08a53df4056634dac5ed7169 (diff)
downloadopensbi-fa911ebe72ec9f8b82947ebc99daf1d0ec2f53e2.zip
opensbi-fa911ebe72ec9f8b82947ebc99daf1d0ec2f53e2.tar.gz
opensbi-fa911ebe72ec9f8b82947ebc99daf1d0ec2f53e2.tar.bz2
lib: utils: Add MPXY RPMI mailbox driver for voltage
Add voltage service group for RPMI/MPXY support Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> Reviewed-by: Rahul Pathak <rpathak@ventanamicro.com> Link: https://lore.kernel.org/r/20251013153138.1574512-2-joshua.yeong@starfivetech.com Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/mpxy/Kconfig4
-rw-r--r--lib/utils/mpxy/fdt_mpxy_rpmi_voltage.c77
-rw-r--r--lib/utils/mpxy/objects.mk3
3 files changed, 84 insertions, 0 deletions
diff --git a/lib/utils/mpxy/Kconfig b/lib/utils/mpxy/Kconfig
index 8d1f518..f720af2 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 0000000..9067397
--- /dev/null
+++ b/lib/utils/mpxy/fdt_mpxy_rpmi_voltage.c
@@ -0,0 +1,77 @@
+#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 = {
+ .experimental = true,
+ .match_table = voltage_match,
+ .init = mpxy_rpmi_mbox_init,
+};
diff --git a/lib/utils/mpxy/objects.mk b/lib/utils/mpxy/objects.mk
index 5b6e9bd..a71c56a 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