summaryrefslogtreecommitdiff
path: root/src/soc
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2023-03-24 00:07:24 +0100
committerFelix Held <felix-coreboot@felixheld.de>2023-03-27 12:03:05 +0000
commitca8a8de999824bfae5b66b32a237246805ed857c (patch)
tree2817769b27a1662a1263a4f8254c719de464103c /src/soc
parent2c9de49a971497fadaf5272fd1bacee7a316dbfc (diff)
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 <felix-coreboot@felixheld.de> Change-Id: Iba3833024a5e3ca5a47ffb1c1afdbfd884313c96 Reviewed-on: https://review.coreboot.org/c/coreboot/+/73997 Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/amd/cezanne/acpi.c36
-rw-r--r--src/soc/amd/common/block/acpi/cpu_power_state.c36
-rw-r--r--src/soc/amd/common/block/include/amdblocks/cpu.h1
-rw-r--r--src/soc/amd/glinda/acpi.c36
-rw-r--r--src/soc/amd/mendocino/acpi.c36
-rw-r--r--src/soc/amd/phoenix/acpi.c36
-rw-r--r--src/soc/amd/picasso/acpi.c36
7 files changed, 36 insertions, 181 deletions
diff --git a/src/soc/amd/cezanne/acpi.c b/src/soc/amd/cezanne/acpi.c
index 9c60d5ecf6..e883009e27 100644
--- a/src/soc/amd/cezanne/acpi.c
+++ b/src/soc/amd/cezanne/acpi.c
@@ -132,42 +132,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,
diff --git a/src/soc/amd/common/block/acpi/cpu_power_state.c b/src/soc/amd/common/block/acpi/cpu_power_state.c
index 811bea09b2..d518ea082e 100644
--- a/src/soc/amd/common/block/acpi/cpu_power_state.c
+++ b/src/soc/amd/common/block/acpi/cpu_power_state.c
@@ -10,6 +10,42 @@
#include <soc/msr.h>
#include <types.h>
+static 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;
+}
+
/*
* Populate structure describing enabled p-states and return count of enabled p-states.
*/
diff --git a/src/soc/amd/common/block/include/amdblocks/cpu.h b/src/soc/amd/common/block/include/amdblocks/cpu.h
index 8c868cb99f..18b300dfdd 100644
--- a/src/soc/amd/common/block/include/amdblocks/cpu.h
+++ b/src/soc/amd/common/block/include/amdblocks/cpu.h
@@ -19,7 +19,6 @@ 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);
#endif /* AMD_BLOCK_CPU_H */
diff --git a/src/soc/amd/glinda/acpi.c b/src/soc/amd/glinda/acpi.c
index c165937ec2..850bc6c5af 100644
--- a/src/soc/amd/glinda/acpi.c
+++ b/src/soc/amd/glinda/acpi.c
@@ -109,42 +109,6 @@ uint32_t get_pstate_core_freq(union pstate_msr pstate_reg)
return PSTATE_DEF_CORE_FREQ_BASE * core_freq_mul;
}
-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,
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,
diff --git a/src/soc/amd/phoenix/acpi.c b/src/soc/amd/phoenix/acpi.c
index 6a7c560a0d..c98ec680b8 100644
--- a/src/soc/amd/phoenix/acpi.c
+++ b/src/soc/amd/phoenix/acpi.c
@@ -135,42 +135,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,
diff --git a/src/soc/amd/picasso/acpi.c b/src/soc/amd/picasso/acpi.c
index a32c073b25..2379d4347b 100644
--- a/src/soc/amd/picasso/acpi.c
+++ b/src/soc/amd/picasso/acpi.c
@@ -136,42 +136,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,