Angel Pons | 2712398 | 2020-04-05 13:22:30 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Nick Vaccaro | 2dd7b6b | 2018-08-09 16:18:02 -0700 | [diff] [blame] | 2 | |
| 3 | #include <baseboard/variants.h> |
| 4 | #include <chip.h> |
| 5 | #include <device/device.h> |
| 6 | #include <device/pci_ids.h> |
| 7 | #include <device/pci_ops.h> |
Sumeet R Pawnikar | 97c5464 | 2020-05-10 01:24:11 +0530 | [diff] [blame] | 8 | #include <intelblocks/power_limit.h> |
Nick Vaccaro | 2dd7b6b | 2018-08-09 16:18:02 -0700 | [diff] [blame] | 9 | |
| 10 | /* PL2 limit in watts for AML and KBL */ |
| 11 | #define PL2_AML 18 |
| 12 | #define PL2_KBL 15 |
| 13 | |
| 14 | static uint32_t get_pl2(void) |
| 15 | { |
Kyösti Mälkki | 71756c21 | 2019-07-12 13:10:19 +0300 | [diff] [blame] | 16 | struct device *igd_dev = pcidev_path_on_root(SA_DEVFN_IGD); |
Nick Vaccaro | 2dd7b6b | 2018-08-09 16:18:02 -0700 | [diff] [blame] | 17 | uint16_t id; |
Kyösti Mälkki | 71756c21 | 2019-07-12 13:10:19 +0300 | [diff] [blame] | 18 | |
| 19 | id = pci_read_config16(igd_dev, PCI_DEVICE_ID); |
Nick Vaccaro | 2dd7b6b | 2018-08-09 16:18:02 -0700 | [diff] [blame] | 20 | /* Assume we only have KLB-Y and AML-Y SKUs */ |
| 21 | if (id == PCI_DEVICE_ID_INTEL_KBL_GT2_SULXM) |
| 22 | return PL2_KBL; |
| 23 | |
| 24 | return PL2_AML; |
| 25 | } |
| 26 | |
| 27 | /* Override dev tree settings per board */ |
| 28 | void variant_devtree_update(void) |
| 29 | { |
Sumeet R Pawnikar | 97c5464 | 2020-05-10 01:24:11 +0530 | [diff] [blame] | 30 | struct soc_power_limits_config *soc_conf; |
Kyösti Mälkki | d5f645c | 2019-09-28 00:20:27 +0300 | [diff] [blame] | 31 | config_t *cfg = config_of_soc(); |
Nick Vaccaro | 2dd7b6b | 2018-08-09 16:18:02 -0700 | [diff] [blame] | 32 | |
Sumeet R Pawnikar | 97c5464 | 2020-05-10 01:24:11 +0530 | [diff] [blame] | 33 | soc_conf = &cfg->power_limits_config; |
Nick Vaccaro | 2dd7b6b | 2018-08-09 16:18:02 -0700 | [diff] [blame] | 34 | /* Update PL2 based on CPU */ |
Sumeet R Pawnikar | 97c5464 | 2020-05-10 01:24:11 +0530 | [diff] [blame] | 35 | soc_conf->tdp_pl2_override = get_pl2(); |
Nick Vaccaro | 2dd7b6b | 2018-08-09 16:18:02 -0700 | [diff] [blame] | 36 | } |