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>
This commit is contained in:
Sumeet Pawnikar 2021-08-25 19:48:02 +05:30 committed by Tim Wawrzynczak
parent 2909b487a2
commit dc0e066406
2 changed files with 17 additions and 0 deletions

View File

@ -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_ */

View File

@ -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;
}