From 651e3e06a5b2374acf9d2ba3328d8318d8f52fe9 Mon Sep 17 00:00:00 2001 From: Johnny Lin Date: Mon, 19 Dec 2022 21:36:00 +0800 Subject: [PATCH] drivers/ocp/vpd: add get_cxl_mode_from_vpd() cxl_mode VPD variable supports 3 modes: CXL_DISABLED, CXL_SYSTEM_MEMORY and CXL_SPM. Change-Id: Ib3bf85fbe687680db3c11efa908c4fb351be9c44 Signed-off-by: Johnny Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/71100 Tested-by: build bot (Jenkins) Reviewed-by: Jonathan Zhang Reviewed-by: David Hendricks --- src/drivers/ocp/include/vpd.h | 1 + src/drivers/ocp/vpd/vpd_util.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/drivers/ocp/include/vpd.h b/src/drivers/ocp/include/vpd.h index f4517c4660..d58f79120f 100644 --- a/src/drivers/ocp/include/vpd.h +++ b/src/drivers/ocp/include/vpd.h @@ -81,4 +81,5 @@ enum cxl_memory_mode { int get_int_from_vpd_range(const char *const key, const int fallback, const int min, const int max); bool get_bool_from_vpd(const char *const key, const bool fallback); +int get_cxl_mode_from_vpd(void); #endif diff --git a/src/drivers/ocp/vpd/vpd_util.c b/src/drivers/ocp/vpd/vpd_util.c index 3a66b884f2..27d7bccb5c 100644 --- a/src/drivers/ocp/vpd/vpd_util.c +++ b/src/drivers/ocp/vpd/vpd_util.c @@ -38,3 +38,8 @@ bool get_bool_from_vpd(const char *const key, const bool fallback) return (bool)val; } + +int get_cxl_mode_from_vpd(void) +{ + return get_int_from_vpd_range(CXL_MODE, CXL_MODE_DEFAULT, 0, CXL_MODE_MAX-1); +}