From ca8a8de999824bfae5b66b32a237246805ed857c Mon Sep 17 00:00:00 2001 From: Felix Held Date: Fri, 24 Mar 2023 00:07:24 +0100 Subject: soc/amd: factor out common get_pstate_core_power implementation Now that all get_pstate_core_power implementations in each SoC's acpi.c file is identical, factor it out into a common implementation. This implementation will also work for Stoneyridge which isn't using the common P state code yet. Signed-off-by: Felix Held Change-Id: Iba3833024a5e3ca5a47ffb1c1afdbfd884313c96 Reviewed-on: https://review.coreboot.org/c/coreboot/+/73997 Reviewed-by: Eric Lai Reviewed-by: Fred Reitberger Tested-by: build bot (Jenkins) --- src/soc/amd/mendocino/acpi.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'src/soc/amd/mendocino') diff --git a/src/soc/amd/mendocino/acpi.c b/src/soc/amd/mendocino/acpi.c index 519283f7d5..6c48bae062 100644 --- a/src/soc/amd/mendocino/acpi.c +++ b/src/soc/amd/mendocino/acpi.c @@ -134,42 +134,6 @@ uint32_t get_pstate_core_freq(union pstate_msr pstate_reg) return core_freq; } -uint32_t get_pstate_core_power(union pstate_msr pstate_reg) -{ - uint32_t voltage_in_uvolts, current_value_amps, current_divisor, power_in_mw; - - /* Get Voltage from core voltage ID */ - voltage_in_uvolts = get_pstate_core_uvolts(pstate_reg); - - /* Current value in amps */ - current_value_amps = pstate_reg.idd_value; - - /* Current divisor */ - current_divisor = pstate_reg.idd_div; - - /* Power in mW */ - power_in_mw = (voltage_in_uvolts) / 10 * current_value_amps; - - switch (current_divisor) { - case 0: - power_in_mw = power_in_mw / 100L; - break; - case 1: - power_in_mw = power_in_mw / 1000L; - break; - case 2: - power_in_mw = power_in_mw / 10000L; - break; - case 3: - /* current_divisor is set to an undefined value.*/ - printk(BIOS_WARNING, "Undefined current_divisor set for enabled P-state .\n"); - power_in_mw = 0; - break; - } - - return power_in_mw; -} - const acpi_cstate_t cstate_cfg_table[] = { [0] = { .ctype = 1, -- cgit v1.2.3