blob: 99ce52eb26afde1f0ee8cb2bb5a8351598e83410 [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>
Subrata Banik06a89222021-09-09 21:58:48 +05308#include <soc/gpio_soc_defs.h>
Sumeet Pawnikar698ee272021-08-09 16:08:40 +05309#include <soc/pci_devs.h>
Subrata Banik06a89222021-09-09 21:58:48 +053010#include <soc/soc_chip.h>
Sumeet Pawnikar698ee272021-08-09 16:08:40 +053011#include <drivers/intel/dptf/chip.h>
Subrata Banik06a89222021-09-09 21:58:48 +053012#include "board_id.h"
Sumeet Pawnikar698ee272021-08-09 16:08:40 +053013
14const 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 Wu3e971782021-09-27 22:16:57 +080018 { PCI_DEVICE_ID_INTEL_ADL_P_ID_6, 3000, 15000, 55000, 55000 },
Sumeet Pawnikar698ee272021-08-09 16:08:40 +053019 { 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 Shaikh4f5e8e02021-09-22 23:38:17 -070023WEAK_DEV_PTR(dptf_policy);
Sumeet Pawnikar698ee272021-08-09 16:08:40 +053024void variant_update_power_limits(void)
25{
Furquan Shaikh4f5e8e02021-09-22 23:38:17 -070026 const struct device *policy_dev = DEV_PTR(dptf_policy);
Sumeet Pawnikar698ee272021-08-09 16:08:40 +053027 if (!policy_dev)
28 return;
29
Furquan Shaikh4f5e8e02021-09-22 23:38:17 -070030 struct drivers_intel_dptf_config *config = config_of(policy_dev);
Sumeet Pawnikar698ee272021-08-09 16:08:40 +053031
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 Guvendik01a4dde2021-09-03 12:28:05 -070041 printk(BIOS_INFO, "Overriding DPTF power limits PL1 (%u, %u) PL2 (%u, %u)\n",
Sumeet Pawnikar698ee272021-08-09 16:08:40 +053042 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 Banik06a89222021-09-09 21:58:48 +053050static const struct typec_aux_bias_pads pad_config = { GPP_E23, GPP_E22 };
51
52static 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
66static 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 Pawnikar698ee272021-08-09 16:08:40 +053083void variant_devtree_update(void)
84{
85 variant_update_power_limits();
Subrata Banik06a89222021-09-09 21:58:48 +053086 variant_update_typec_init_config();
Sumeet Pawnikar698ee272021-08-09 16:08:40 +053087}