summaryrefslogtreecommitdiff
path: root/src/soc/amd
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc/amd')
-rw-r--r--src/soc/amd/cezanne/acpi.c9
-rw-r--r--src/soc/amd/common/block/cpu/svi2.c6
-rw-r--r--src/soc/amd/common/block/cpu/svi3.c6
-rw-r--r--src/soc/amd/common/block/include/amdblocks/cpu.h1
-rw-r--r--src/soc/amd/glinda/acpi.c9
-rw-r--r--src/soc/amd/mendocino/acpi.c9
-rw-r--r--src/soc/amd/phoenix/acpi.c9
-rw-r--r--src/soc/amd/picasso/acpi.c9
8 files changed, 28 insertions, 30 deletions
diff --git a/src/soc/amd/cezanne/acpi.c b/src/soc/amd/cezanne/acpi.c
index cebdf7c5b9..9c60d5ecf6 100644
--- a/src/soc/amd/cezanne/acpi.c
+++ b/src/soc/amd/cezanne/acpi.c
@@ -134,10 +134,10 @@ uint32_t get_pstate_core_freq(union pstate_msr pstate_reg)
uint32_t get_pstate_core_power(union pstate_msr pstate_reg)
{
- uint32_t voltage_in_uvolts, core_vid, current_value_amps, current_divisor, power_in_mw;
+ uint32_t voltage_in_uvolts, current_value_amps, current_divisor, power_in_mw;
- /* Core voltage ID */
- core_vid = pstate_reg.cpu_vid_0_7;
+ /* 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;
@@ -145,9 +145,6 @@ uint32_t get_pstate_core_power(union pstate_msr pstate_reg)
/* Current divisor */
current_divisor = pstate_reg.idd_div;
- /* Voltage */
- voltage_in_uvolts = get_uvolts_from_vid(core_vid);
-
/* Power in mW */
power_in_mw = (voltage_in_uvolts) / 10 * current_value_amps;
diff --git a/src/soc/amd/common/block/cpu/svi2.c b/src/soc/amd/common/block/cpu/svi2.c
index 0a41b78b26..21d459fb2a 100644
--- a/src/soc/amd/common/block/cpu/svi2.c
+++ b/src/soc/amd/common/block/cpu/svi2.c
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <amdblocks/cpu.h>
+#include <soc/msr.h>
#include <types.h>
/* Value defined in Serial VID Interface 2.0 spec (#48022, NDA only) */
@@ -17,3 +18,8 @@ uint32_t get_uvolts_from_vid(uint16_t core_vid)
(SERIAL_VID_2_DECODE_MICROVOLTS * core_vid);
}
}
+
+uint32_t get_pstate_core_uvolts(union pstate_msr pstate_reg)
+{
+ return get_uvolts_from_vid(pstate_reg.cpu_vid_0_7);
+}
diff --git a/src/soc/amd/common/block/cpu/svi3.c b/src/soc/amd/common/block/cpu/svi3.c
index 35a4a789de..c2e6bed612 100644
--- a/src/soc/amd/common/block/cpu/svi3.c
+++ b/src/soc/amd/common/block/cpu/svi3.c
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <amdblocks/cpu.h>
+#include <soc/msr.h>
#include <types.h>
/* Value defined in Serial VID Interface 3.0 spec (#56413, NDA only) */
@@ -17,3 +18,8 @@ uint32_t get_uvolts_from_vid(uint16_t core_vid)
(SERIAL_VID_3_DECODE_MICROVOLTS * core_vid);
}
}
+
+uint32_t get_pstate_core_uvolts(union pstate_msr pstate_reg)
+{
+ return get_uvolts_from_vid(pstate_reg.cpu_vid_0_7 | pstate_reg.cpu_vid_8 << 8);
+}
diff --git a/src/soc/amd/common/block/include/amdblocks/cpu.h b/src/soc/amd/common/block/include/amdblocks/cpu.h
index cbce028631..8c868cb99f 100644
--- a/src/soc/amd/common/block/include/amdblocks/cpu.h
+++ b/src/soc/amd/common/block/include/amdblocks/cpu.h
@@ -18,6 +18,7 @@ union pstate_msr; /* proper definition is in soc/msr.h */
uint32_t get_uvolts_from_vid(uint16_t core_vid);
uint32_t get_pstate_core_freq(union pstate_msr pstate_reg);
+uint32_t get_pstate_core_uvolts(union pstate_msr pstate_reg);
uint32_t get_pstate_core_power(union pstate_msr pstate_reg);
const acpi_cstate_t *get_cstate_config_data(size_t *size);
diff --git a/src/soc/amd/glinda/acpi.c b/src/soc/amd/glinda/acpi.c
index b9ea0eb784..c165937ec2 100644
--- a/src/soc/amd/glinda/acpi.c
+++ b/src/soc/amd/glinda/acpi.c
@@ -111,10 +111,10 @@ uint32_t get_pstate_core_freq(union pstate_msr pstate_reg)
uint32_t get_pstate_core_power(union pstate_msr pstate_reg)
{
- uint32_t voltage_in_uvolts, core_vid, current_value_amps, current_divisor, power_in_mw;
+ uint32_t voltage_in_uvolts, current_value_amps, current_divisor, power_in_mw;
- /* Core voltage ID */
- core_vid = pstate_reg.cpu_vid_0_7 | pstate_reg.cpu_vid_8 << 8;
+ /* 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;
@@ -122,9 +122,6 @@ uint32_t get_pstate_core_power(union pstate_msr pstate_reg)
/* Current divisor */
current_divisor = pstate_reg.idd_div;
- /* Voltage */
- voltage_in_uvolts = get_uvolts_from_vid(core_vid);
-
/* Power in mW */
power_in_mw = (voltage_in_uvolts) / 10 * current_value_amps;
diff --git a/src/soc/amd/mendocino/acpi.c b/src/soc/amd/mendocino/acpi.c
index 0574ba7627..519283f7d5 100644
--- a/src/soc/amd/mendocino/acpi.c
+++ b/src/soc/amd/mendocino/acpi.c
@@ -136,10 +136,10 @@ uint32_t get_pstate_core_freq(union pstate_msr pstate_reg)
uint32_t get_pstate_core_power(union pstate_msr pstate_reg)
{
- uint32_t voltage_in_uvolts, core_vid, current_value_amps, current_divisor, power_in_mw;
+ uint32_t voltage_in_uvolts, current_value_amps, current_divisor, power_in_mw;
- /* Core voltage ID */
- core_vid = pstate_reg.cpu_vid_0_7 | pstate_reg.cpu_vid_8 << 8;
+ /* 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;
@@ -147,9 +147,6 @@ uint32_t get_pstate_core_power(union pstate_msr pstate_reg)
/* Current divisor */
current_divisor = pstate_reg.idd_div;
- /* Voltage */
- voltage_in_uvolts = get_uvolts_from_vid(core_vid);
-
/* Power in mW */
power_in_mw = (voltage_in_uvolts) / 10 * current_value_amps;
diff --git a/src/soc/amd/phoenix/acpi.c b/src/soc/amd/phoenix/acpi.c
index e147e88aee..6a7c560a0d 100644
--- a/src/soc/amd/phoenix/acpi.c
+++ b/src/soc/amd/phoenix/acpi.c
@@ -137,10 +137,10 @@ uint32_t get_pstate_core_freq(union pstate_msr pstate_reg)
uint32_t get_pstate_core_power(union pstate_msr pstate_reg)
{
- uint32_t voltage_in_uvolts, core_vid, current_value_amps, current_divisor, power_in_mw;
+ uint32_t voltage_in_uvolts, current_value_amps, current_divisor, power_in_mw;
- /* Core voltage ID */
- core_vid = pstate_reg.cpu_vid_0_7 | pstate_reg.cpu_vid_8 << 8;
+ /* 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;
@@ -148,9 +148,6 @@ uint32_t get_pstate_core_power(union pstate_msr pstate_reg)
/* Current divisor */
current_divisor = pstate_reg.idd_div;
- /* Voltage */
- voltage_in_uvolts = get_uvolts_from_vid(core_vid);
-
/* Power in mW */
power_in_mw = (voltage_in_uvolts) / 10 * current_value_amps;
diff --git a/src/soc/amd/picasso/acpi.c b/src/soc/amd/picasso/acpi.c
index d1232e3525..a32c073b25 100644
--- a/src/soc/amd/picasso/acpi.c
+++ b/src/soc/amd/picasso/acpi.c
@@ -138,10 +138,10 @@ uint32_t get_pstate_core_freq(union pstate_msr pstate_reg)
uint32_t get_pstate_core_power(union pstate_msr pstate_reg)
{
- uint32_t voltage_in_uvolts, core_vid, current_value_amps, current_divisor, power_in_mw;
+ uint32_t voltage_in_uvolts, current_value_amps, current_divisor, power_in_mw;
- /* Core voltage ID */
- core_vid = pstate_reg.cpu_vid_0_7;
+ /* 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;
@@ -149,9 +149,6 @@ uint32_t get_pstate_core_power(union pstate_msr pstate_reg)
/* Current divisor */
current_divisor = pstate_reg.idd_div;
- /* Voltage */
- voltage_in_uvolts = get_uvolts_from_vid(core_vid);
-
/* Power in mW */
power_in_mw = (voltage_in_uvolts) / 10 * current_value_amps;