diff options
author | Felix Held <felix-coreboot@felixheld.de> | 2023-03-10 00:00:47 +0100 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2023-03-20 19:52:27 +0000 |
commit | da02a82f221897e75fe046f9a48eb45ba5409d05 (patch) | |
tree | 07a727bcc2c539c87ad0c953835f9005ae77dd91 /src/soc/amd/cezanne/acpi.c | |
parent | 659e154d68a5dd706e1d99513a9a7947ab3b87fc (diff) |
soc/amd/cezanne: introduce and use pstate_msr bitfield struct
Add the pstate_msr union of a bitfield struct and a raw uint64_t to
allow easier access of the bitfields of the P state MSRs and use this
bitfield struct in get_pstate_core_freq and get_pstate_core_power. The
signature of those two function will be changed in a follow-up commit.
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: If92a4773c669ac2df45396eee52f6de780adbdca
Reviewed-on: https://review.coreboot.org/c/coreboot/+/73644
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
Diffstat (limited to 'src/soc/amd/cezanne/acpi.c')
-rw-r--r-- | src/soc/amd/cezanne/acpi.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/soc/amd/cezanne/acpi.c b/src/soc/amd/cezanne/acpi.c index 057bd76850..e250bfb404 100644 --- a/src/soc/amd/cezanne/acpi.c +++ b/src/soc/amd/cezanne/acpi.c @@ -99,13 +99,15 @@ uint32_t get_pstate_core_freq(msr_t pstate_def) { uint32_t core_freq, core_freq_mul, core_freq_div; bool valid_freq_divisor; + union pstate_msr pstate_reg; + + pstate_reg.raw = pstate_def.raw; /* Core frequency multiplier */ - core_freq_mul = pstate_def.lo & PSTATE_DEF_LO_FREQ_MUL_MASK; + core_freq_mul = pstate_reg.cpu_fid_0_7; /* Core frequency divisor ID */ - core_freq_div = - (pstate_def.lo & PSTATE_DEF_LO_FREQ_DIV_MASK) >> PSTATE_DEF_LO_FREQ_DIV_SHIFT; + core_freq_div = pstate_reg.cpu_dfs_id; if (core_freq_div == 0) { return 0; @@ -136,18 +138,18 @@ uint32_t get_pstate_core_freq(msr_t pstate_def) uint32_t get_pstate_core_power(msr_t pstate_def) { uint32_t voltage_in_uvolts, core_vid, current_value_amps, current_divisor, power_in_mw; + union pstate_msr pstate_reg; + + pstate_reg.raw = pstate_def.raw; /* Core voltage ID */ - core_vid = - (pstate_def.lo & PSTATE_DEF_LO_CORE_VID_MASK) >> PSTATE_DEF_LO_CORE_VID_SHIFT; + core_vid = pstate_reg.cpu_vid_0_7; /* Current value in amps */ - current_value_amps = - (pstate_def.lo & PSTATE_DEF_LO_CUR_VAL_MASK) >> PSTATE_DEF_LO_CUR_VAL_SHIFT; + current_value_amps = pstate_reg.idd_value; /* Current divisor */ - current_divisor = - (pstate_def.lo & PSTATE_DEF_LO_CUR_DIV_MASK) >> PSTATE_DEF_LO_CUR_DIV_SHIFT; + current_divisor = pstate_reg.idd_div; /* Voltage */ if ((core_vid >= 0xF8) && (core_vid <= 0xFF)) { |