Jérémy Compostella has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/85443?usp=email )
Change subject: soc/intel/pantherlake: Add soc_get_sku_power_limits() support ......................................................................
soc/intel/pantherlake: Add soc_get_sku_power_limits() support
soc_get_sku_power_limits() implementation is required to use variant_update_cpu_power_limits() which we would like to leverage for Google fatcat missing battery use-case.
BUG=b:377798581 TEST=TBD
Change-Id: Ib89979e7933da62c8ddfec09ecf27f86b7ac0e09 Signed-off-by: Jeremy Compostella jeremy.compostella@intel.com --- M src/soc/intel/pantherlake/systemagent.c 1 file changed, 38 insertions(+), 26 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/43/85443/1
diff --git a/src/soc/intel/pantherlake/systemagent.c b/src/soc/intel/pantherlake/systemagent.c index e7a0701..1fa558a 100644 --- a/src/soc/intel/pantherlake/systemagent.c +++ b/src/soc/intel/pantherlake/systemagent.c @@ -137,25 +137,33 @@ sa_add_fixed_mmio_resources(dev, resource_cnt, cfg_rsrc, count); }
-static void configure_tdp(struct device *dev) +static u16 get_sa_pci_id(void) { - struct soc_power_limits_config *soc_config; + static u16 sa_pci_id; struct device *sa; - uint16_t sa_pci_id; - u8 tdp; - size_t i; - bool config_tdp = false; + + if (sa_pci_id) + return sa_pci_id; + + sa = pcidev_path_on_root(PCI_DEVFN_ROOT); + sa_pci_id = sa ? pci_read_config16(sa, PCI_DEVICE_ID) : 0xffff; + + return sa_pci_id; +} + +struct soc_power_limits_config *soc_get_sku_power_limits(void) +{ struct soc_intel_pantherlake_config *config; + u16 sa_pci_id; + u8 tdp;
config = config_of_soc();
/* Get System Agent PCI ID */ - sa = pcidev_path_on_root(PCI_DEVFN_ROOT); - sa_pci_id = sa ? pci_read_config16(sa, PCI_DEVICE_ID) : 0xFFFF; - - if (sa_pci_id == 0xFFFF) { + sa_pci_id = get_sa_pci_id(); + if (sa_pci_id == 0xffff) { printk(BIOS_WARNING, "Unknown SA PCI Device!\n"); - return; + return NULL; }
tdp = get_cpu_tdp(); @@ -164,22 +172,26 @@ * Choose power limits configuration based on the CPU SA PCI ID and * CPU TDP value. */ - for (i = 0; i < ARRAY_SIZE(cpuid_to_ptl); i++) { - if (sa_pci_id == cpuid_to_ptl[i].cpu_id && - tdp == cpuid_to_ptl[i].cpu_tdp) { - soc_config = &config->power_limits_config[cpuid_to_ptl[i].limits]; - set_power_limits(MOBILE_SKU_PL1_TIME_SEC, soc_config); - config_tdp = true; - printk(BIOS_DEBUG, "Configured power limits for SA PCI ID: 0x%4x\n", - sa_pci_id); - break; - } - } + for (size_t i = 0; i < ARRAY_SIZE(cpuid_to_ptl); i++) + if (sa_pci_id == cpuid_to_ptl[i].cpu_id && tdp == cpuid_to_ptl[i].cpu_tdp) + return &config->power_limits_config[cpuid_to_ptl[i].limits];
- if (!config_tdp) { - printk(BIOS_WARNING, "Skipped power limits configuration for SA PCI ID: 0x%4x\n", - sa_pci_id); - return; + return NULL; +} + +static void configure_tdp(struct device *dev) +{ + struct soc_power_limits_config *power_limits; + + power_limits = soc_get_sku_power_limits(); + if (power_limits) { + set_power_limits(MOBILE_SKU_PL1_TIME_SEC, power_limits); + printk(BIOS_DEBUG, "Configured power limits for SA PCI ID: 0x%4x\n", + get_sa_pci_id()); + } else { + printk(BIOS_WARNING, + "Skipped power limits configuration for SA PCI ID: 0x%4x\n", + get_sa_pci_id()); } }