From dc0e066406d2ac36c83d4abd871f20e3121f7cc5 Mon Sep 17 00:00:00 2001 From: Sumeet Pawnikar Date: Wed, 25 Aug 2021 19:48:02 +0530 Subject: soc/intel/common: get tdp of CPU for different SKUs Get tdp value of CPU for different SKUs based on PKG POWER MSR. BUG=b:194745919 BRANCH=None TEST=Build FW and test on brya0 board Change-Id: I9fba0a64da2f1d79d633054dddd9fdf1d3d8e258 Signed-off-by: Sumeet Pawnikar Reviewed-on: https://review.coreboot.org/c/coreboot/+/57143 Tested-by: build bot (Jenkins) Reviewed-by: EricR Lai --- .../intel/common/block/include/intelblocks/power_limit.h | 2 ++ src/soc/intel/common/block/power_limit/power_limit.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'src/soc/intel') diff --git a/src/soc/intel/common/block/include/intelblocks/power_limit.h b/src/soc/intel/common/block/include/intelblocks/power_limit.h index 2fa25de5be..934eaa4be7 100644 --- a/src/soc/intel/common/block/include/intelblocks/power_limit.h +++ b/src/soc/intel/common/block/include/intelblocks/power_limit.h @@ -38,4 +38,6 @@ struct soc_power_limits_config { void set_power_limits(u8 power_limit_1_time, struct soc_power_limits_config *config); +u8 get_cpu_tdp(void); + #endif /* _SOC_INTEL_COMMON_BLOCK_POWER_LIMIT_H_ */ diff --git a/src/soc/intel/common/block/power_limit/power_limit.c b/src/soc/intel/common/block/power_limit/power_limit.c index e6c65c3a82..417dd04672 100644 --- a/src/soc/intel/common/block/power_limit/power_limit.c +++ b/src/soc/intel/common/block/power_limit/power_limit.c @@ -195,3 +195,18 @@ void set_power_limits(u8 power_limit_1_time, wrmsr(MSR_TURBO_ACTIVATION_RATIO, limit); } } + +u8 get_cpu_tdp(void) +{ + unsigned int power_unit, cpu_tdp; + + /* Get units */ + msr_t msr = rdmsr(MSR_PKG_POWER_SKU_UNIT); + power_unit = 1 << (msr.lo & 0xf); + + /* Get power defaults for this SKU */ + msr = rdmsr(MSR_PKG_POWER_SKU); + cpu_tdp = msr.lo & 0x7fff; + + return cpu_tdp / power_unit; +} -- cgit v1.2.3