1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/pci_ids.h>
4 #include <device/pci_ops.h>
6 #include <soc/ramstage.h>
7 #include <soc/vr_config.h>
8 #include <console/console.h>
9 #include <intelblocks/cpulib.h>
11 /* Default values for domain configuration. */
12 static const struct vr_config default_configs
[NUM_VR_DOMAINS
] = {
14 .vr_config_enable
= 1,
15 .psi1threshold
= VR_CFG_AMP(20),
16 .psi2threshold
= VR_CFG_AMP(4),
17 .psi3threshold
= VR_CFG_AMP(1),
23 .voltage_limit
= 1520,
26 .vr_config_enable
= 1,
27 .psi1threshold
= VR_CFG_AMP(20),
28 .psi2threshold
= VR_CFG_AMP(5),
29 .psi3threshold
= VR_CFG_AMP(1),
35 .voltage_limit
= 1520,
38 .vr_config_enable
= 1,
39 .psi1threshold
= VR_CFG_AMP(20),
40 .psi2threshold
= VR_CFG_AMP(5),
41 .psi3threshold
= VR_CFG_AMP(1),
47 .voltage_limit
= 1520,
50 .vr_config_enable
= 1,
51 .psi1threshold
= VR_CFG_AMP(20),
52 .psi2threshold
= VR_CFG_AMP(5),
53 .psi3threshold
= VR_CFG_AMP(1),
59 .voltage_limit
= 1520,
63 static uint16_t get_sku_icc_max(int domain
)
65 const uint16_t tdp
= cpu_get_power_max() / 1000;
67 static uint16_t mch_id
= 0, igd_id
= 0;
69 struct device
*dev
= pcidev_path_on_root(SA_DEVFN_ROOT
);
70 mch_id
= dev
? pci_read_config16(dev
, PCI_DEVICE_ID
) : 0xffff;
73 struct device
*dev
= pcidev_path_on_root(SA_DEVFN_IGD
);
74 igd_id
= dev
? pci_read_config16(dev
, PCI_DEVICE_ID
) : 0xffff;
78 * Iccmax table from Doc #559100 Section 7.2 DC Specifications, the
79 * Iccmax is the same among KBL-Y but KBL-U/R.
80 * Addendum for AML-Y #594883, IccMax for IA core is 28A.
81 * KBL-S #335195, KBL-H #335190, SKL-S #332687, SKL-H #332986,
84 * Platform Segment SA IA GT (GT/GTx)
85 * ---------------------------------------------------------------------
86 * KBL/SKL-S (95W) quad 11.1 100 45
87 * SKL-S (80W) quad 11.1 82 45
88 * KBL/SKL-S (65W) quad 11.1 79 45
89 * SKL-S (45W) quad 11.1 70 0
90 * KBL/SKL-S (35W) quad 11.1 66 35
91 * SKL-S (25W) quad 11.1 55 35
93 * KBL/SKL-S (54W) dual 11.1 58 48
94 * KBL/SKL-S (51W) dual 11.1 45 48
95 * KBL/SKL-S (35W) dual 11.1 40 48
97 * SKL-H + OPC (65W) GT4 quad 8 74 105/24
98 * SKL-H + OPC (45W) GT4 quad 8 74 94/20
99 * SKL-H + OPC (35W) GT4 quad 8 66 94/20
101 * SKL-H (35W) GT2 dual 11.1 60 55
103 * KBL/SKL-H (45W) GT2 quad 11.1 68 55
104 * KBL-H (18W) GT2 quad 6.6 60 55
106 * SKL-U + OPC (28W) GT3 dual 5.1 32 57/19
107 * SKL-U + OPC (15W) GT3 dual 5.1 29 57/19
108 * SKL-U (15W) GT2 dual 4.5 29 31
110 * KBL-U + OPC (28W) GT3 dual 5.1 32 57/19
111 * KBL-U + OPC (15W) GT3 dual 5.1 32 57/19
112 * KBL-U (15W) GT1/2 dual 4.5 32 31
113 * KBL-U [*] (15W) GT1 quad 4.5 29 31
115 * KBL-U/R (15W) GT2 quad 6 64 31
117 * SKL/KBL-Y (6W) 4.1 24 24
118 * SKL/KBL-Y (4.5W) 4.1 24 24
120 * [*] Pentium/Celeron CPUs with HD Graphics 610
124 case PCI_DID_INTEL_SKL_ID_S_2
: /* fallthrough */
125 case PCI_DID_INTEL_KBL_ID_S
: {
126 uint16_t icc_max
[NUM_VR_DOMAINS
] = VR_CFG_ALL_DOMAINS_ICC(11.1, 40, 48, 48);
128 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(58);
130 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(45);
132 return icc_max
[domain
];
134 case PCI_DID_INTEL_SKL_ID_S_4
: /* fallthrough */
135 case PCI_DID_INTEL_KBL_ID_DT_2
: /* fallthrough */
136 case PCI_DID_INTEL_KBL_ID_DT
: {
137 uint16_t icc_max
[NUM_VR_DOMAINS
] = VR_CFG_ALL_DOMAINS_ICC(11.1, 55, 45, 45);
139 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(100);
141 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(82);
143 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(79);
144 else if (tdp
>= 45) {
145 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(70);
146 icc_max
[VR_GT_SLICED
] = 0;
147 icc_max
[VR_GT_UNSLICED
] = 0;
148 } else if (tdp
>= 25) {
150 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(66);
152 icc_max
[VR_GT_SLICED
] = VR_CFG_AMP(35);
153 icc_max
[VR_GT_UNSLICED
] = VR_CFG_AMP(35);
156 return icc_max
[domain
];
158 case PCI_DID_INTEL_SKL_ID_H_4
: {
159 uint16_t icc_max
[NUM_VR_DOMAINS
] = VR_CFG_ALL_DOMAINS_ICC(11.1, 60, 94, 20);
161 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(74);
163 icc_max
[VR_GT_SLICED
] = VR_CFG_AMP(105);
164 icc_max
[VR_GT_UNSLICED
] = VR_CFG_AMP(24);
167 return icc_max
[domain
];
169 case PCI_DID_INTEL_SKL_ID_H_2
: /* fallthrough */
170 case PCI_DID_INTEL_SKL_ID_H_EM
: /* fallthrough */
171 case PCI_DID_INTEL_KBL_ID_H
: {
172 uint16_t icc_max
[NUM_VR_DOMAINS
] = VR_CFG_ALL_DOMAINS_ICC(6.6, 60, 55, 55);
175 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(68);
177 icc_max
[VR_SYSTEM_AGENT
] = VR_CFG_AMP(11.1);
180 return icc_max
[domain
];
182 case PCI_DID_INTEL_SKL_ID_U
: {
183 uint16_t icc_max
[NUM_VR_DOMAINS
] = VR_CFG_ALL_DOMAINS_ICC(5.1, 29, 57, 19);
185 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(32);
186 else if (igd_id
!= PCI_DID_INTEL_SKL_GT3E_SULTM_1
) {
187 const uint16_t icc_max_gt2
[NUM_VR_DOMAINS
] =
188 VR_CFG_ALL_DOMAINS_ICC(4.5, 29, 31, 31);
190 return icc_max_gt2
[domain
];
192 return icc_max
[domain
];
194 case PCI_DID_INTEL_KBL_U_R
: {
195 const uint16_t icc_max
[NUM_VR_DOMAINS
] =
196 VR_CFG_ALL_DOMAINS_ICC(6, 64, 31, 31);
197 return icc_max
[domain
];
199 case PCI_DID_INTEL_SKL_ID_Y
: /* fallthrough */
200 case PCI_DID_INTEL_KBL_ID_Y
: {
201 uint16_t icc_max
[NUM_VR_DOMAINS
] = VR_CFG_ALL_DOMAINS_ICC(4.1, 24, 24, 24);
203 if (igd_id
== PCI_DID_INTEL_AML_GT2_ULX
)
204 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(28);
206 return icc_max
[domain
];
208 case PCI_DID_INTEL_KBL_ID_U
: {
209 uint16_t icc_max
[NUM_VR_DOMAINS
] = VR_CFG_ALL_DOMAINS_ICC(4.5, 32, 31, 31);
211 if (igd_id
== PCI_DID_INTEL_KBL_GT1_SULTM
)
212 icc_max
[VR_IA_CORE
] = VR_CFG_AMP(29);
214 else if ((igd_id
== PCI_DID_INTEL_KBL_GT3E_SULTM_1
) ||
215 (igd_id
== PCI_DID_INTEL_KBL_GT3E_SULTM_2
)) {
216 const uint16_t icc_max_gt3
[NUM_VR_DOMAINS
] =
217 VR_CFG_ALL_DOMAINS_ICC(5.1, 32, 57, 19);
219 return icc_max_gt3
[domain
];
222 return icc_max
[domain
];
225 printk(BIOS_ERR
, "Unknown MCH (0x%x) in %s\n", mch_id
, __func__
);
230 static uint16_t get_sku_ac_dc_loadline(const int domain
)
232 static uint16_t mch_id
= 0, igd_id
= 0;
234 struct device
*dev
= pcidev_path_on_root(SA_DEVFN_ROOT
);
235 mch_id
= dev
? pci_read_config16(dev
, PCI_DEVICE_ID
) : 0xffff;
238 struct device
*dev
= pcidev_path_on_root(SA_DEVFN_IGD
);
239 igd_id
= dev
? pci_read_config16(dev
, PCI_DEVICE_ID
) : 0xffff;
243 case PCI_DID_INTEL_SKL_ID_S_2
: /* fallthrough */
244 case PCI_DID_INTEL_SKL_ID_S_4
: /* fallthrough */
245 case PCI_DID_INTEL_KBL_ID_S
: /* fallthrough */
246 case PCI_DID_INTEL_KBL_ID_DT
: /* fallthrough */
247 case PCI_DID_INTEL_KBL_ID_DT_2
: {
248 /* SA Loadline is not specified */
249 const uint16_t loadline
[NUM_VR_DOMAINS
] =
250 VR_CFG_ALL_DOMAINS_LOADLINE(0, 2.1, 3.1, 3.1);
251 return loadline
[domain
];
253 case PCI_DID_INTEL_SKL_ID_H_2
: /* fallthrough */
254 case PCI_DID_INTEL_SKL_ID_H_EM
: /* fallthrough */
255 case PCI_DID_INTEL_SKL_ID_H_4
: /* fallthrough */
256 case PCI_DID_INTEL_KBL_ID_H
: {
257 const uint16_t loadline
[NUM_VR_DOMAINS
] =
258 VR_CFG_ALL_DOMAINS_LOADLINE(10, 1.8, 2.65, 2.65);
260 if (igd_id
== PCI_DID_INTEL_SKL_GT4_SHALM
) {
261 const uint16_t loadline_gt4
[NUM_VR_DOMAINS
] =
262 VR_CFG_ALL_DOMAINS_LOADLINE(6, 1.6, 1.4, 6);
263 return loadline_gt4
[domain
];
266 return loadline
[domain
];
268 case PCI_DID_INTEL_SKL_ID_Y
: /* fallthrough */
269 case PCI_DID_INTEL_KBL_ID_Y
: {
270 uint16_t loadline
[NUM_VR_DOMAINS
] =
271 VR_CFG_ALL_DOMAINS_LOADLINE(18, 5.9, 5.7, 5.7);
273 if (igd_id
== PCI_DID_INTEL_AML_GT2_ULX
)
274 loadline
[VR_IA_CORE
] = VR_CFG_MOHMS(4);
276 return loadline
[domain
];
278 case PCI_DID_INTEL_SKL_ID_U
: /* fallthrough */
279 case PCI_DID_INTEL_KBL_U_R
: /* fallthrough */
280 case PCI_DID_INTEL_KBL_ID_U
: {
281 uint16_t loadline
[NUM_VR_DOMAINS
] =
282 VR_CFG_ALL_DOMAINS_LOADLINE(10.3, 2.4, 3.1, 3.1);
284 if ((igd_id
== PCI_DID_INTEL_SKL_GT3E_SULTM_1
) ||
285 (igd_id
== PCI_DID_INTEL_SKL_GT3E_SULTM_2
) ||
286 (igd_id
== PCI_DID_INTEL_KBL_GT3E_SULTM_1
) ||
287 (igd_id
== PCI_DID_INTEL_KBL_GT3E_SULTM_2
)) {
288 loadline
[VR_GT_UNSLICED
] = VR_CFG_MOHMS(2);
289 loadline
[VR_GT_SLICED
] = VR_CFG_MOHMS(6);
292 return loadline
[domain
];
295 printk(BIOS_ERR
, "Unknown MCH (0x%x) in %s\n", mch_id
, __func__
);
300 void fill_vr_domain_config(void *params
,
301 int domain
, const struct vr_config
*chip_cfg
)
303 FSP_SIL_UPD
*vr_params
= (FSP_SIL_UPD
*)params
;
304 const struct vr_config
*cfg
;
306 if (domain
< 0 || domain
>= NUM_VR_DOMAINS
)
309 /* Use device tree override if requested. */
310 if (chip_cfg
->vr_config_enable
)
313 cfg
= &default_configs
[domain
];
315 vr_params
->VrConfigEnable
[domain
] = cfg
->vr_config_enable
;
316 vr_params
->Psi1Threshold
[domain
] = cfg
->psi1threshold
;
317 vr_params
->Psi2Threshold
[domain
] = cfg
->psi2threshold
;
318 vr_params
->Psi3Threshold
[domain
] = cfg
->psi3threshold
;
319 vr_params
->Psi3Enable
[domain
] = cfg
->psi3enable
;
320 vr_params
->Psi4Enable
[domain
] = cfg
->psi4enable
;
321 vr_params
->ImonSlope
[domain
] = cfg
->imon_slope
;
322 vr_params
->ImonOffset
[domain
] = cfg
->imon_offset
;
324 /* If board provided non-zero value, use it. */
326 vr_params
->IccMax
[domain
] = cfg
->icc_max
;
328 vr_params
->IccMax
[domain
] = get_sku_icc_max(domain
);
329 vr_params
->VrVoltageLimit
[domain
] = cfg
->voltage_limit
;
331 if (cfg
->ac_loadline
)
332 vr_params
->AcLoadline
[domain
] = cfg
->ac_loadline
;
334 vr_params
->AcLoadline
[domain
] = get_sku_ac_dc_loadline(domain
);
335 if (cfg
->dc_loadline
)
336 vr_params
->DcLoadline
[domain
] = cfg
->dc_loadline
;
338 vr_params
->DcLoadline
[domain
] = get_sku_ac_dc_loadline(domain
);