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 }, |
Tracy Wu | 3e97178 | 2021-09-27 22:16:57 +0800 | [diff] [blame] | 18 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_6, 3000, 15000, 55000, 55000 }, |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 19 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_5, 4000, 28000, 64000, 64000 }, |
| 20 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_3, 5000, 45000, 115000, 115000 }, |
| 21 | }; |
| 22 | |
Furquan Shaikh | 4f5e8e0 | 2021-09-22 23:38:17 -0700 | [diff] [blame] | 23 | WEAK_DEV_PTR(dptf_policy); |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 24 | void variant_update_power_limits(void) |
| 25 | { |
Furquan Shaikh | 4f5e8e0 | 2021-09-22 23:38:17 -0700 | [diff] [blame] | 26 | const struct device *policy_dev = DEV_PTR(dptf_policy); |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 27 | if (!policy_dev) |
| 28 | return; |
| 29 | |
Furquan Shaikh | 4f5e8e0 | 2021-09-22 23:38:17 -0700 | [diff] [blame] | 30 | struct drivers_intel_dptf_config *config = config_of(policy_dev); |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 31 | |
| 32 | uint16_t mchid = pci_s_read_config16(PCI_DEV(0, 0, 0), PCI_DEVICE_ID); |
| 33 | |
| 34 | for (size_t i = 0; i < ARRAY_SIZE(limits); i++) { |
| 35 | if (mchid == limits[i].mchid) { |
| 36 | struct dptf_power_limits *settings = &config->controls.power_limits; |
| 37 | settings->pl1.min_power = limits[i].pl1_min_power; |
| 38 | settings->pl1.max_power = limits[i].pl1_max_power; |
| 39 | settings->pl2.min_power = limits[i].pl2_min_power; |
| 40 | settings->pl2.max_power = limits[i].pl2_max_power; |
Bora Guvendik | 01a4dde | 2021-09-03 12:28:05 -0700 | [diff] [blame] | 41 | 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] | 42 | limits[i].pl1_min_power, |
| 43 | limits[i].pl1_max_power, |
| 44 | limits[i].pl2_min_power, |
| 45 | limits[i].pl2_max_power); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
Subrata Banik | 06a8922 | 2021-09-09 21:58:48 +0530 | [diff] [blame] | 50 | static const struct typec_aux_bias_pads pad_config = { GPP_E23, GPP_E22 }; |
| 51 | |
| 52 | static const struct board_id_iom_port_config { |
| 53 | int board_id; |
| 54 | enum typec_port_index port; |
| 55 | } port_config[] = { |
| 56 | { ADL_P_LP4_1, TYPE_C_PORT_2 }, |
| 57 | { ADL_P_LP4_2, TYPE_C_PORT_2 }, |
| 58 | { ADL_P_DDR4_1, TYPE_C_PORT_2 }, |
| 59 | { ADL_P_DDR4_2, TYPE_C_PORT_2 }, |
| 60 | { ADL_P_LP5_1, TYPE_C_PORT_2 }, |
| 61 | { ADL_P_LP5_2, TYPE_C_PORT_2 }, |
| 62 | { ADL_M_LP4, TYPE_C_PORT_1 }, |
| 63 | { ADL_M_LP5, TYPE_C_PORT_0 }, |
| 64 | }; |
| 65 | |
| 66 | static void variant_update_typec_init_config(void) |
| 67 | { |
| 68 | /* Skip filling aux bias gpio pads for Windows SKUs */ |
| 69 | if (!(CONFIG(BOARD_INTEL_ADLRVP_P_EXT_EC) || CONFIG(BOARD_INTEL_ADLRVP_M_EXT_EC))) |
| 70 | return; |
| 71 | |
| 72 | config_t *config = config_of_soc(); |
| 73 | int board_id = get_board_id(); |
| 74 | for (int i = 0; i < ARRAY_SIZE(port_config); i++) { |
| 75 | if (board_id != port_config[i].board_id) |
| 76 | continue; |
| 77 | |
| 78 | memcpy(&config->typec_aux_bias_pads[port_config[i].port], &pad_config, |
| 79 | sizeof(pad_config)); |
| 80 | } |
| 81 | } |
| 82 | |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 83 | void variant_devtree_update(void) |
| 84 | { |
| 85 | variant_update_power_limits(); |
Subrata Banik | 06a8922 | 2021-09-09 21:58:48 +0530 | [diff] [blame] | 86 | variant_update_typec_init_config(); |
Sumeet Pawnikar | 698ee27 | 2021-08-09 16:08:40 +0530 | [diff] [blame] | 87 | } |