Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/43904 )
Change subject: cpu/intel/common: Fill cpu voltage in SMBIOS tables ......................................................................
cpu/intel/common: Fill cpu voltage in SMBIOS tables
Introduce a weak function to let the platform code provide the processor voltage in 100mV units.
Implement the function on Intel platforms using the MSR_PERF_STATUS msr. On other platforms the processor voltage still reads as unknown.
Change-Id: I31a7efcbeede50d986a1c096a4a59a316e09f825 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/arch/x86/smbios.c M src/cpu/intel/common/Kconfig M src/cpu/intel/common/Makefile.inc A src/cpu/intel/common/voltage.c M src/cpu/intel/haswell/Kconfig M src/cpu/intel/model_2065x/Kconfig M src/include/smbios.h M src/soc/intel/common/block/cpu/Kconfig 8 files changed, 31 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/04/43904/1
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index 9a7029b..8600fba 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -575,6 +575,12 @@ return 0; /* Unknown */ }
+/* Returns the processor voltage in 100mV units */ +unsigned int __weak smbios_cpu_get_voltage(void) +{ + return 0; /* Unknown */ +} + const char *__weak smbios_system_sku(void) { return ""; @@ -748,6 +754,9 @@ t->max_speed = smbios_cpu_get_max_speed_mhz(); t->current_speed = smbios_cpu_get_current_speed_mhz(); } + if (smbios_cpu_get_voltage() > 0) + t->voltage = 0x80 | smbios_cpu_get_voltage(); + *current += len; return len; } diff --git a/src/cpu/intel/common/Kconfig b/src/cpu/intel/common/Kconfig index 0f2a652..1e8bb6c 100644 --- a/src/cpu/intel/common/Kconfig +++ b/src/cpu/intel/common/Kconfig @@ -22,6 +22,9 @@ config CPU_INTEL_COMMON_TIMEBASE bool
+config CPU_INTEL_COMMON_VOLTAGE + bool + config CPU_INTEL_COMMON_HYPERTHREADING bool
diff --git a/src/cpu/intel/common/Makefile.inc b/src/cpu/intel/common/Makefile.inc index 1612012..0dda339 100644 --- a/src/cpu/intel/common/Makefile.inc +++ b/src/cpu/intel/common/Makefile.inc @@ -1,5 +1,6 @@ ramstage-$(CONFIG_CPU_INTEL_COMMON) += common_init.c ramstage-$(CONFIG_CPU_INTEL_COMMON_HYPERTHREADING) += hyperthreading.c +ramstage-$(CONFIG_CPU_INTEL_COMMON_VOLTAGE) += voltage.c
ifeq ($(CONFIG_CPU_INTEL_COMMON_TIMEBASE),y) bootblock-y += fsb.c diff --git a/src/cpu/intel/common/voltage.c b/src/cpu/intel/common/voltage.c new file mode 100644 index 0000000..82765b0 --- /dev/null +++ b/src/cpu/intel/common/voltage.c @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <cpu/x86/msr.h> +#include <smbios.h> + +/* This is not an architectural MSR. */ +#define MSR_PERF_STATUS 0x198 + +#if CONFIG(GENERATE_SMBIOS_TABLES) +unsigned int smbios_cpu_get_voltage(void) +{ + return (rdmsr(MSR_PERF_STATUS).hi & 0xffff) * 10 / 8192; +} +#endif diff --git a/src/cpu/intel/haswell/Kconfig b/src/cpu/intel/haswell/Kconfig index 54cb99f..127ae82 100644 --- a/src/cpu/intel/haswell/Kconfig +++ b/src/cpu/intel/haswell/Kconfig @@ -22,6 +22,7 @@ select PARALLEL_MP select CPU_INTEL_COMMON select CPU_INTEL_COMMON_TIMEBASE + select CPU_INTEL_COMMON_VOLTAGE
config SMM_TSEG_SIZE hex diff --git a/src/cpu/intel/model_2065x/Kconfig b/src/cpu/intel/model_2065x/Kconfig index 39beb22..6cb2e4c 100644 --- a/src/cpu/intel/model_2065x/Kconfig +++ b/src/cpu/intel/model_2065x/Kconfig @@ -19,6 +19,7 @@ select TSC_SYNC_MFENCE select CPU_INTEL_COMMON select CPU_INTEL_COMMON_TIMEBASE + select CPU_INTEL_COMMON_VOLTAGE select PARALLEL_MP
config SMM_TSEG_SIZE diff --git a/src/include/smbios.h b/src/include/smbios.h index 25ea897..48a4de4 100644 --- a/src/include/smbios.h +++ b/src/include/smbios.h @@ -40,6 +40,7 @@
unsigned int smbios_cpu_get_max_speed_mhz(void); unsigned int smbios_cpu_get_current_speed_mhz(void); +unsigned int smbios_cpu_get_voltage(void);
const char *smbios_mainboard_manufacturer(void); const char *smbios_mainboard_product_name(void); diff --git a/src/soc/intel/common/block/cpu/Kconfig b/src/soc/intel/common/block/cpu/Kconfig index 3c29b24..70343fc 100644 --- a/src/soc/intel/common/block/cpu/Kconfig +++ b/src/soc/intel/common/block/cpu/Kconfig @@ -1,5 +1,6 @@ config SOC_INTEL_COMMON_BLOCK_CPU bool + select CPU_INTEL_COMMON_VOLTAGE default n help This option selects Intel Common CPU Model support code