Tim Wawrzynczak has submitted this change. ( https://review.coreboot.org/c/coreboot/+/57143 )
Change subject: soc/intel/common: get tdp of CPU for different SKUs ......................................................................
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 sumeet.r.pawnikar@intel.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/57143 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: EricR Lai ericr_lai@compal.corp-partner.google.com --- M src/soc/intel/common/block/include/intelblocks/power_limit.h M src/soc/intel/common/block/power_limit/power_limit.c 2 files changed, 17 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified EricR Lai: Looks good to me, approved
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 2fa25de..934eaa4 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 @@ 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 e6c65c3..417dd04 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 @@ 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; +}