soc/amd/common/acpi/cpu_power_state: factor out get_visible_pstate_count

Factor out the MSR access into a function with a more descriptive name.

Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: I331c3205390edcbd8749b2d52b7cc7ac3a8ced5a
Reviewed-on: https://review.coreboot.org/c/coreboot/+/74020
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com>
This commit is contained in:
Felix Held 2023-03-25 03:02:52 +01:00
parent 3ee7453e0e
commit e91392a5fe
1 changed files with 6 additions and 1 deletions

View File

@ -46,6 +46,11 @@ static uint32_t get_pstate_core_power(union pstate_msr pstate_reg)
return power_in_mw; return power_in_mw;
} }
static uint32_t get_visible_pstate_count(void)
{
return (rdmsr(PS_LIM_REG).lo & PS_LIM_MAX_VAL_MASK) >> PS_MAX_VAL_SHFT;
}
/* /*
* Populate structure describing enabled p-states and return count of enabled p-states. * Populate structure describing enabled p-states and return count of enabled p-states.
*/ */
@ -57,7 +62,7 @@ static size_t get_pstate_info(struct acpi_sw_pstate *pstate_values,
uint32_t max_pstate; uint32_t max_pstate;
pstate_count = 0; pstate_count = 0;
max_pstate = (rdmsr(PS_LIM_REG).lo & PS_LIM_MAX_VAL_MASK) >> PS_MAX_VAL_SHFT; max_pstate = get_visible_pstate_count();
for (pstate = 0; pstate <= max_pstate; pstate++) { for (pstate = 0; pstate <= max_pstate; pstate++) {
pstate_reg.raw = rdmsr(PSTATE_MSR(pstate)).raw; pstate_reg.raw = rdmsr(PSTATE_MSR(pstate)).raw;