Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 1 | /* 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> |
Subrata Banik | 06a8922 | 2021-09-09 21:58:48 +0530 | [diff] [blame^] | 8 | #include <soc/gpio_soc_defs.h> |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 9 | #include <soc/pci_devs.h> |
Subrata Banik | 06a8922 | 2021-09-09 21:58:48 +0530 | [diff] [blame^] | 10 | #include <soc/soc_chip.h> |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 11 | #include <drivers/intel/dptf/chip.h> |
Subrata Banik | 06a8922 | 2021-09-09 21:58:48 +0530 | [diff] [blame^] | 12 | #include "board_id.h" |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 13 | |
| 14 | const struct cpu_power_limits limits[] = { |
| 15 | /* SKU_ID, pl1_min, pl1_max, pl2_min, pl2_max */ |
| 16 | /* PL2 values are for performance configuration */ |
| 17 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_7, 3000, 15000, 55000, 55000 }, |
| 18 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_5, 4000, 28000, 64000, 64000 }, |
| 19 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_3, 5000, 45000, 115000, 115000 }, |
| 20 | }; |
| 21 | |
| 22 | void variant_update_power_limits(void) |
| 23 | { |
| 24 | const struct device_path policy_path[] = { |
| 25 | { .type = DEVICE_PATH_PCI, .pci.devfn = SA_DEVFN_DPTF}, |
| 26 | { .type = DEVICE_PATH_GENERIC, .generic.id = 0} |
| 27 | }; |
| 28 | |
| 29 | const struct device *policy_dev = find_dev_nested_path(pci_root_bus(), |
| 30 | policy_path, ARRAY_SIZE(policy_path)); |
| 31 | if (!policy_dev) |
| 32 | return; |
| 33 | |
| 34 | struct drivers_intel_dptf_config *config = policy_dev->chip_info; |
| 35 | |
| 36 | uint16_t mchid = pci_s_read_config16(PCI_DEV(0, 0, 0), PCI_DEVICE_ID); |
| 37 | |
| 38 | for (size_t i = 0; i < ARRAY_SIZE(limits); i++) { |
| 39 | if (mchid == limits[i].mchid) { |
| 40 | struct dptf_power_limits *settings = &config->controls.power_limits; |
| 41 | settings->pl1.min_power = limits[i].pl1_min_power; |
| 42 | settings->pl1.max_power = limits[i].pl1_max_power; |
| 43 | settings->pl2.min_power = limits[i].pl2_min_power; |
| 44 | settings->pl2.max_power = limits[i].pl2_max_power; |
Bora Guvendik | 01a4dde | 2021-09-03 12:28:05 -0700 | [diff] [blame] | 45 | printk(BIOS_INFO, "Overriding DPTF power limits PL1 (%u, %u) PL2 (%u, %u)\n", |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 46 | limits[i].pl1_min_power, |
| 47 | limits[i].pl1_max_power, |
| 48 | limits[i].pl2_min_power, |
| 49 | limits[i].pl2_max_power); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
Subrata Banik | 06a8922 | 2021-09-09 21:58:48 +0530 | [diff] [blame^] | 54 | static const struct typec_aux_bias_pads pad_config = { GPP_E23, GPP_E22 }; |
| 55 | |
| 56 | static const struct board_id_iom_port_config { |
| 57 | int board_id; |
| 58 | enum typec_port_index port; |
| 59 | } port_config[] = { |
| 60 | { ADL_P_LP4_1, TYPE_C_PORT_2 }, |
| 61 | { ADL_P_LP4_2, TYPE_C_PORT_2 }, |
| 62 | { ADL_P_DDR4_1, TYPE_C_PORT_2 }, |
| 63 | { ADL_P_DDR4_2, TYPE_C_PORT_2 }, |
| 64 | { ADL_P_LP5_1, TYPE_C_PORT_2 }, |
| 65 | { ADL_P_LP5_2, TYPE_C_PORT_2 }, |
| 66 | { ADL_M_LP4, TYPE_C_PORT_1 }, |
| 67 | { ADL_M_LP5, TYPE_C_PORT_0 }, |
| 68 | }; |
| 69 | |
| 70 | static void variant_update_typec_init_config(void) |
| 71 | { |
| 72 | /* Skip filling aux bias gpio pads for Windows SKUs */ |
| 73 | if (!(CONFIG(BOARD_INTEL_ADLRVP_P_EXT_EC) || CONFIG(BOARD_INTEL_ADLRVP_M_EXT_EC))) |
| 74 | return; |
| 75 | |
| 76 | config_t *config = config_of_soc(); |
| 77 | int board_id = get_board_id(); |
| 78 | for (int i = 0; i < ARRAY_SIZE(port_config); i++) { |
| 79 | if (board_id != port_config[i].board_id) |
| 80 | continue; |
| 81 | |
| 82 | memcpy(&config->typec_aux_bias_pads[port_config[i].port], &pad_config, |
| 83 | sizeof(pad_config)); |
| 84 | } |
| 85 | } |
| 86 | |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 87 | void variant_devtree_update(void) |
| 88 | { |
| 89 | variant_update_power_limits(); |
Subrata Banik | 06a8922 | 2021-09-09 21:58:48 +0530 | [diff] [blame^] | 90 | variant_update_typec_init_config(); |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 91 | } |