From 3d4128299f87681b82a1485fa116ed59680eca97 Mon Sep 17 00:00:00 2001 From: Tony Huang Date: Mon, 6 May 2024 16:11:28 +0800 Subject: mb/google/rex/var/baseboard/ovis: Support CPU power limits per variant There is no direct way to override CPU default power_limits for different SKUs. This CL add structure variant_get_soc_power_limit_config() for variants to define and configure the values of soc_power_limits_config for current CPU SKU. Variants can override these values i.e. pl1, pl2, psyspl2 in variant_devtree_update(). BUG=b:320410462 BRANCH=firmware-rex-15709.B TEST=FSP debug emerge-ovis coreboot intelfsp check overrides setting Change-Id: Ib60fa4e3fc502d0aeb0c94ad46ba5a55b4dd027c Signed-off-by: Tony Huang Reviewed-on: https://review.coreboot.org/c/coreboot/+/82199 Reviewed-by: Subrata Banik Reviewed-by: Eric Lai Tested-by: build bot (Jenkins) --- .../baseboard/include/baseboard/variants.h | 3 +++ .../google/rex/variants/baseboard/ovis/ramstage.c | 27 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'src/mainboard/google') diff --git a/src/mainboard/google/rex/variants/baseboard/include/baseboard/variants.h b/src/mainboard/google/rex/variants/baseboard/include/baseboard/variants.h index bd3d535c16..8a97d00deb 100644 --- a/src/mainboard/google/rex/variants/baseboard/include/baseboard/variants.h +++ b/src/mainboard/google/rex/variants/baseboard/include/baseboard/variants.h @@ -24,6 +24,9 @@ int variant_memory_sku(void); bool variant_is_half_populated(void); void variant_update_soc_chip_config(struct soc_intel_meteorlake_config *config); +/* Get soc power limit config struct for current CPU sku */ +struct soc_power_limits_config *variant_get_soc_power_limit_config(void); + enum s0ix_entry { S0IX_EXIT, S0IX_ENTRY, diff --git a/src/mainboard/google/rex/variants/baseboard/ovis/ramstage.c b/src/mainboard/google/rex/variants/baseboard/ovis/ramstage.c index 1eec1ec01b..2798be6c7b 100644 --- a/src/mainboard/google/rex/variants/baseboard/ovis/ramstage.c +++ b/src/mainboard/google/rex/variants/baseboard/ovis/ramstage.c @@ -1,8 +1,35 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ #include +#include #include +#include #include +#include + +struct soc_power_limits_config *variant_get_soc_power_limit_config(void) +{ + config_t *config = config_of_soc(); + uint16_t mchid = pci_s_read_config16(PCI_DEV(0, 0, 0), PCI_DEVICE_ID); + u8 tdp = get_cpu_tdp(); + size_t i = 0; + + if (mchid == 0xffff) + return NULL; + + for (i = 0; i < ARRAY_SIZE(cpuid_to_mtl); i++) { + if (mchid == cpuid_to_mtl[i].cpu_id && tdp == cpuid_to_mtl[i].cpu_tdp) { + return &config->power_limits_config[cpuid_to_mtl[i].limits]; + } + } + + if (i == ARRAY_SIZE(cpuid_to_mtl)) { + printk(BIOS_ERR, "Cannot find correct ovis sku index.\n"); + return NULL; + } + + return NULL; +} /* * SKU_ID, TDP (Watts), pl1_min (milliWatts), pl1_max (milliWatts), -- cgit v1.2.3