coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ramstage.c
Go to the documentation of this file.
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>
8 #include <soc/gpio_soc_defs.h>
9 #include <soc/pci_devs.h>
10 #include <soc/soc_chip.h>
11 #include <string.h>
13 #include "board_id.h"
15 
16 const struct cpu_power_limits limits[] = {
17  /* SKU_ID, TDP (Watts), pl1_min, pl1_max, pl2_min, pl2_max, PL4 */
18  /* PL2 values are for performance configuration */
19  { PCI_DID_INTEL_ADL_P_ID_7, 15, 3000, 15000, 55000, 55000, 123000 },
20  { PCI_DID_INTEL_ADL_P_ID_6, 15, 3000, 15000, 55000, 55000, 123000 },
21  { PCI_DID_INTEL_ADL_P_ID_5, 28, 4000, 28000, 64000, 64000, 140000 },
22  { PCI_DID_INTEL_ADL_P_ID_3, 28, 4000, 28000, 64000, 64000, 140000 },
23  { PCI_DID_INTEL_ADL_P_ID_3, 45, 5000, 45000, 115000, 115000, 215000 },
24 };
25 
26 WEAK_DEV_PTR(dptf_policy);
28 {
29  const struct device *policy_dev = DEV_PTR(dptf_policy);
30  if (!policy_dev)
31  return;
32 
33  struct drivers_intel_dptf_config *config = config_of(policy_dev);
34 
36 
37  u8 tdp = get_cpu_tdp();
38 
39  for (size_t i = 0; i < ARRAY_SIZE(limits); i++) {
40  if (mchid == limits[i].mchid && tdp == limits[i].cpu_tdp) {
41  struct dptf_power_limits *settings = &config->controls.power_limits;
42  config_t *conf = config_of_soc();
43  struct soc_power_limits_config *soc_config = conf->power_limits_config;
44  settings->pl1.min_power = limits[i].pl1_min_power;
45  settings->pl1.max_power = limits[i].pl1_max_power;
46  settings->pl2.min_power = limits[i].pl2_min_power;
47  settings->pl2.max_power = limits[i].pl2_max_power;
48  soc_config->tdp_pl4 = DIV_ROUND_UP(limits[i].pl4_power,
50  printk(BIOS_INFO, "Overriding power limits PL1 (%u, %u) PL2 (%u, %u) PL4 (%u)\n",
51  limits[i].pl1_min_power,
52  limits[i].pl1_max_power,
53  limits[i].pl2_min_power,
54  limits[i].pl2_max_power,
55  limits[i].pl4_power);
56  }
57  }
58 }
59 
60 static const struct typec_aux_bias_pads pad_config = { GPP_E23, GPP_E22 };
61 
62 static const struct board_id_iom_port_config {
63  int board_id;
65 } port_config[] = {
74 };
75 
77 {
78  /* Skip filling aux bias gpio pads for Windows SKUs */
79  if (!(CONFIG(BOARD_INTEL_ADLRVP_P_EXT_EC) || CONFIG(BOARD_INTEL_ADLRVP_M_EXT_EC)))
80  return;
81 
83  int board_id = get_board_id();
84  for (int i = 0; i < ARRAY_SIZE(port_config); i++) {
85  if (board_id != port_config[i].board_id)
86  continue;
87 
88  memcpy(&config->typec_aux_bias_pads[port_config[i].port], &pad_config,
89  sizeof(pad_config));
90  }
91 }
92 
94 {
97 }
#define GPP_E23
#define GPP_E22
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define DIV_ROUND_UP(x, y)
Definition: helpers.h:60
typec_port_index
Definition: tcss.h:72
@ TYPE_C_PORT_2
Definition: tcss.h:75
@ TYPE_C_PORT_1
Definition: tcss.h:74
@ TYPE_C_PORT_0
Definition: tcss.h:73
#define printk(level,...)
Definition: stdlib.h:16
@ CONFIG
Definition: dsi_common.h:201
uint32_t board_id(void)
board_id() - Get the board version
Definition: ec_boardid.c:6
#define DEV_PTR(_alias)
Definition: device.h:403
static DEVTREE_CONST void * config_of(const struct device *dev)
Definition: device.h:382
#define config_of_soc()
Definition: device.h:394
@ ADL_M_LP4
Definition: variants.h:24
@ ADL_P_LP4_1
Definition: variants.h:12
@ ADL_P_LP4_2
Definition: variants.h:13
@ ADL_P_LP5_1
Definition: variants.h:18
@ ADL_P_DDR4_2
Definition: variants.h:22
@ ADL_M_LP5
Definition: variants.h:25
@ ADL_P_DDR4_1
Definition: variants.h:21
@ ADL_P_LP5_2
Definition: variants.h:19
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
void variant_update_power_limits(const struct cpu_power_limits *limits, size_t num_entries)
Definition: ramstage.c:51
WEAK_DEV_PTR(dptf_policy)
void variant_devtree_update(void)
Definition: ramstage.c:63
const struct cpu_power_limits limits[]
Definition: ramstage.c:11
enum board_config config
Definition: memory.c:448
static uint8_t get_board_id(void)
Definition: boardid.c:14
static void variant_update_typec_init_config(void)
Definition: ramstage.c:76
static const struct board_id_iom_port_config port_config[]
#define PCI_DEVICE_ID
Definition: pci_def.h:9
#define PCI_DID_INTEL_ADL_P_ID_7
Definition: pci_ids.h:4069
#define PCI_DID_INTEL_ADL_P_ID_3
Definition: pci_ids.h:4065
#define PCI_DID_INTEL_ADL_P_ID_5
Definition: pci_ids.h:4067
#define PCI_DID_INTEL_ADL_P_ID_6
Definition: pci_ids.h:4068
static __always_inline uint16_t pci_s_read_config16(pci_devfn_t dev, uint16_t reg)
Definition: pci_io_cfg.h:86
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
#define MILLIWATTS_TO_WATTS
Definition: power_limit.h:18
u8 get_cpu_tdp(void)
Definition: power_limit.c:199
u16 mchid
enum soc_intel_alderlake_cpu_tdps cpu_tdp
Definition: chip.h:49
unsigned short uint16_t
Definition: stdint.h:11
uint8_t u8
Definition: stdint.h:45
enum typec_port_index port
Definition: ramstage.c:64
unsigned int pl1_min_power
Definition: variants.h:42
unsigned int pl1_max_power
Definition: variants.h:43
unsigned int pl2_max_power
Definition: variants.h:45
unsigned int pl2_min_power
Definition: variants.h:44
Definition: device.h:107
struct dptf_power_limit_config pl2
Definition: acpigen_dptf.h:135
struct dptf_power_limit_config pl1
Definition: acpigen_dptf.h:134