blob: 25a7c5b06214d4cf015bcbee603256569801c8fb [file] [log] [blame]
Sumeet Pawnikar698ee272021-08-09 16:08:40 +05301/* SPDX-License-Identifier: GPL-2.0-or-later */
2
3#include <acpi/acpi_device.h>
4#include <baseboard/variants.h>
5#include <console/console.h>
6#include <device/pci_ids.h>
7#include <device/pci_ops.h>
8#include <soc/pci_devs.h>
9
10#include <drivers/intel/dptf/chip.h>
11
12const struct cpu_power_limits limits[] = {
13 /* SKU_ID, pl1_min, pl1_max, pl2_min, pl2_max */
14 /* PL2 values are for performance configuration */
15 { PCI_DEVICE_ID_INTEL_ADL_P_ID_7, 3000, 15000, 55000, 55000 },
16 { PCI_DEVICE_ID_INTEL_ADL_P_ID_5, 4000, 28000, 64000, 64000 },
17 { PCI_DEVICE_ID_INTEL_ADL_P_ID_3, 5000, 45000, 115000, 115000 },
18};
19
20void variant_update_power_limits(void)
21{
22 const struct device_path policy_path[] = {
23 { .type = DEVICE_PATH_PCI, .pci.devfn = SA_DEVFN_DPTF},
24 { .type = DEVICE_PATH_GENERIC, .generic.id = 0}
25 };
26
27 const struct device *policy_dev = find_dev_nested_path(pci_root_bus(),
28 policy_path, ARRAY_SIZE(policy_path));
29 if (!policy_dev)
30 return;
31
32 struct drivers_intel_dptf_config *config = policy_dev->chip_info;
33
34 uint16_t mchid = pci_s_read_config16(PCI_DEV(0, 0, 0), PCI_DEVICE_ID);
35
36 for (size_t i = 0; i < ARRAY_SIZE(limits); i++) {
37 if (mchid == limits[i].mchid) {
38 struct dptf_power_limits *settings = &config->controls.power_limits;
39 settings->pl1.min_power = limits[i].pl1_min_power;
40 settings->pl1.max_power = limits[i].pl1_max_power;
41 settings->pl2.min_power = limits[i].pl2_min_power;
42 settings->pl2.max_power = limits[i].pl2_max_power;
43 printk(BIOS_INFO, "sumeet: Overriding DPTF power limits PL1 (%u, %u) PL2 (%u, %u)\n",
44 limits[i].pl1_min_power,
45 limits[i].pl1_max_power,
46 limits[i].pl2_min_power,
47 limits[i].pl2_max_power);
48 }
49 }
50}
51
52void variant_devtree_update(void)
53{
54 variant_update_power_limits();
55}