coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
vr_config.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/pci_ids.h>
4 #include <device/pci_ops.h>
5 #include <fsp/api.h>
6 #include <soc/ramstage.h>
7 #include <soc/vr_config.h>
8 #include <console/console.h>
9 #include <intelblocks/cpulib.h>
10 
11 /*
12  * VR Configurations for IA and GT domains for ADL-P SKU's.
13  * Per doc#627345 ADL_P Partial Intel PlatformDesignStudio Rev 2.0.0, update PD
14  *
15  * +----------------+-----------+-------+-------+---------+-------------+----------+
16  * | SKU | Setting | AC LL | DC LL | ICC MAX | TDC Current | TDC Time |
17  * | | |(mOhms)|(mOhms)| (A) | (A) | (msec) |
18  * +----------------+-----------+-------+-------+---------+-------------+----------+
19  * | ADL-P 682(45W) | IA | 2.3 | 2.3 | 160 | 57 | 28000 |
20  * + +-----------+-------+-------+---------+-------------+----------+
21  * | | GT | 3.2 | 3.2 | 55 | 57 | 28000 |
22  * +----------------+-----------+-------+-------+---------+-------------+----------+
23  * | ADL-P 482(45W) | IA | 2.3 | 2.3 | 120 | 47 | 28000 |
24  * + 442(45W) +-----------+-------+-------+---------+-------------+----------+
25  * | | GT | 3.2 | 3.2 | 55 | 47 | 28000 |
26  * +----------------+-----------+-------+-------+---------+-------------+----------+
27  * | ADL-P 682(28W) | IA | 2.3 | 2.3 | 109 | 40 | 28000 |
28  * + +-----------+-------+-------+---------+-------------+----------+
29  * | | GT | 3.2 | 3.2 | 55 | 40 | 28000 |
30  * +----------------+-----------+-------+-------+---------+-------------+----------+
31  * | ADL-P 482(28W) | IA | 2.3 | 2.3 | 85 | 32 | 28000 |
32  * + +-----------+-------+-------+---------+-------------+----------+
33  * | | GT | 3.2 | 3.2 | 55 | 32 | 28000 |
34  * +----------------+-----------+-------+-------+---------+-------------+----------+
35  * | ADL-P 282(15W) | IA | 2.8 | 2.8 | 80 | 20 | 28000 |
36  * + +-----------+-------+-------+---------+-------------+----------+
37  * | | GT | 3.2 | 3.2 | 40 | 20 | 28000 |
38  * +----------------+-----------+-------+-------+---------+-------------+----------+
39  */
40 
41 struct vr_lookup {
45 };
46 
47 static uint32_t load_table(const struct vr_lookup *tbl, const int tbl_entries, const int domain,
48  const uint16_t mch_id, uint8_t tdp)
49 {
50  for (size_t i = 0; i < tbl_entries; i++) {
51  if (tbl[i].mchid != mch_id || tbl[i].tdp != tdp)
52  continue;
53  return tbl[i].conf[domain];
54  }
55 
56  printk(BIOS_ERR, "Unknown MCH (0x%x) in %s\n", mch_id, __func__);
57  return 0;
58 }
59 
60 /* Per the power map from #613643, update ADL-P 6+8+2 (28W) VR configuration */
61 static const struct vr_lookup vr_config_ll[] = {
72 };
73 
74 static const struct vr_lookup vr_config_icc[] = {
85 };
86 
87 static const struct vr_lookup vr_config_tdc_timewindow[] = {
88  { PCI_DID_INTEL_ADL_P_ID_1, 45, VR_CFG_ALL_DOMAINS_TDC(28000, 28000) },
89  { PCI_DID_INTEL_ADL_P_ID_3, 45, VR_CFG_ALL_DOMAINS_TDC(28000, 28000) },
90  { PCI_DID_INTEL_ADL_P_ID_4, 45, VR_CFG_ALL_DOMAINS_TDC(28000, 28000) },
91  { PCI_DID_INTEL_ADL_P_ID_5, 45, VR_CFG_ALL_DOMAINS_TDC(28000, 28000) },
92  { PCI_DID_INTEL_ADL_P_ID_3, 28, VR_CFG_ALL_DOMAINS_TDC(28000, 28000) },
93  { PCI_DID_INTEL_ADL_P_ID_5, 28, VR_CFG_ALL_DOMAINS_TDC(28000, 28000) },
94  { PCI_DID_INTEL_ADL_P_ID_7, 28, VR_CFG_ALL_DOMAINS_TDC(28000, 28000) },
95  { PCI_DID_INTEL_ADL_P_ID_6, 15, VR_CFG_ALL_DOMAINS_TDC(28000, 28000) },
96  { PCI_DID_INTEL_ADL_P_ID_7, 15, VR_CFG_ALL_DOMAINS_TDC(28000, 28000) },
98 };
99 
100 static const struct vr_lookup vr_config_tdc_currentlimit[] = {
111 };
112 
114  int domain, const struct vr_config *chip_cfg)
115 {
116  const struct vr_config *cfg;
117 
118  if (domain < 0 || domain >= NUM_VR_DOMAINS)
119  return;
120 
121  /* Use device tree override if requested */
122  if (chip_cfg->vr_config_enable) {
123  cfg = chip_cfg;
124 
125  if (cfg->ac_loadline)
126  s_cfg->AcLoadline[domain] = cfg->ac_loadline;
127  if (cfg->dc_loadline)
128  s_cfg->DcLoadline[domain] = cfg->dc_loadline;
129  if (cfg->icc_max)
130  s_cfg->IccMax[domain] = cfg->icc_max;
131  s_cfg->TdcTimeWindow[domain] = cfg->tdc_timewindow;
132  s_cfg->TdcCurrentLimit[domain] = cfg->tdc_currentlimit;
133  } else {
134  uint16_t mch_id = 0;
135  uint8_t tdp = get_cpu_tdp();
136 
137  if (!mch_id) {
139  mch_id = dev ? pci_read_config16(dev, PCI_DEVICE_ID) : 0xffff;
140  }
141 
142  s_cfg->AcLoadline[domain] = load_table(vr_config_ll, ARRAY_SIZE(vr_config_ll),
143  domain, mch_id, tdp);
144  s_cfg->DcLoadline[domain] = load_table(vr_config_ll, ARRAY_SIZE(vr_config_ll),
145  domain, mch_id, tdp);
146  s_cfg->IccMax[domain] = load_table(vr_config_icc, ARRAY_SIZE(vr_config_icc),
147  domain, mch_id, tdp);
148  s_cfg->TdcTimeWindow[domain] = load_table(vr_config_tdc_timewindow,
150  domain, mch_id, tdp);
151  s_cfg->TdcCurrentLimit[domain] = load_table(vr_config_tdc_currentlimit,
153  domain, mch_id, tdp);
154  }
155 
156  /* Check TdcTimeWindow and TdcCurrentLimit,
157  Set TdcEnable and Set VR TDC Input current to root mean square */
158  if (s_cfg->TdcTimeWindow[domain] != 0 && s_cfg->TdcCurrentLimit[domain] != 0) {
159  s_cfg->TdcEnable[domain] = 1;
160  s_cfg->Irms[domain] = 1;
161  }
162 }
#define VR_CFG_ALL_DOMAINS_TDC_CURRENT(ia, gt)
Definition: vr_config.h:64
#define VR_CFG_ALL_DOMAINS_ICC(ia, gt)
Definition: vr_config.h:52
#define VR_CFG_ALL_DOMAINS_TDC(ia, gt)
Definition: vr_config.h:58
@ NUM_VR_DOMAINS
Definition: vr_config.h:43
#define VR_CFG_ALL_DOMAINS_LOADLINE(ia, gt)
Definition: vr_config.h:46
static const struct vr_lookup vr_config_icc[]
Definition: vr_config.c:74
void fill_vr_domain_config(FSP_S_CONFIG *s_cfg, int domain, const struct vr_config *chip_cfg)
Definition: vr_config.c:113
static const struct vr_lookup vr_config_ll[]
Definition: vr_config.c:61
static const struct vr_lookup vr_config_tdc_currentlimit[]
Definition: vr_config.c:100
static const struct vr_lookup vr_config_tdc_timewindow[]
Definition: vr_config.c:87
static uint32_t load_table(const struct vr_lookup *tbl, const int tbl_entries, const int domain, const uint16_t mch_id, uint8_t tdp)
Definition: vr_config.c:47
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
DEVTREE_CONST struct device * pcidev_path_on_root(pci_devfn_t devfn)
Definition: device_const.c:255
#define FSP_S_CONFIG
Definition: fsp_upd.h:9
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
#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_4
Definition: pci_ids.h:4066
#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_10
Definition: pci_ids.h:4072
#define PCI_DID_INTEL_ADL_P_ID_6
Definition: pci_ids.h:4068
#define PCI_DID_INTEL_ADL_P_ID_1
Definition: pci_ids.h:4064
u8 get_cpu_tdp(void)
Definition: power_limit.c:199
u16 mchid
#define SA_DEVFN_ROOT
Definition: pci_devs.h:23
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8
Definition: device.h:107
uint32_t tdc_timewindow
Definition: vr_config.h:26
uint16_t icc_max
Definition: vr_config.h:22
uint16_t tdc_currentlimit
Definition: vr_config.h:30
bool vr_config_enable
Definition: vr_config.h:13
uint16_t ac_loadline
Definition: vr_config.h:17
uint16_t dc_loadline
Definition: vr_config.h:18
uint8_t tdp
Definition: vr_config.c:43
uint16_t mchid
Definition: vr_config.c:42
uint32_t conf[NUM_VR_DOMAINS]
Definition: vr_config.c:44