blob: 9804227f80bd5f174f0d74019c9772528ac58453 [file] [log] [blame]
Simon Glass42bf7db2019-12-08 17:40:19 -07001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2019 Google LLC
4 * Written by Simon Glass <sjg@chromium.org>
5 */
6
7#include <common.h>
8#include <acpi_s3.h>
9#include <binman.h>
10#include <dm.h>
11#include <irq.h>
12#include <asm/intel_pinctrl.h>
13#include <asm/io.h>
14#include <asm/intel_regs.h>
15#include <asm/msr.h>
16#include <asm/msr-index.h>
17#include <asm/pci.h>
18#include <asm/arch/cpu.h>
19#include <asm/arch/systemagent.h>
20#include <asm/arch/fsp/fsp_configs.h>
21#include <asm/arch/fsp/fsp_s_upd.h>
22
23#define PCH_P2SB_E0 0xe0
24#define HIDE_BIT BIT(0)
25
26#define INTEL_GSPI_MAX 3
27#define INTEL_I2C_DEV_MAX 8
28#define MAX_USB2_PORTS 8
29
30enum {
31 CHIPSET_LOCKDOWN_FSP = 0, /* FSP handles locking per UPDs */
32 CHIPSET_LOCKDOWN_COREBOOT, /* coreboot handles locking */
33};
34
35enum i2c_speed {
36 I2C_SPEED_STANDARD = 100000,
37 I2C_SPEED_FAST = 400000,
38 I2C_SPEED_FAST_PLUS = 1000000,
39 I2C_SPEED_HIGH = 3400000,
40 I2C_SPEED_FAST_ULTRA = 5000000,
41};
42
43/*
44 * Timing values are in units of clock period, with the clock speed
45 * provided by the SOC
46 *
47 * TODO(sjg@chromium.org): Connect this up to the I2C driver
48 */
49struct dw_i2c_speed_config {
50 enum i2c_speed speed;
51 /* SCL high and low period count */
52 u16 scl_lcnt;
53 u16 scl_hcnt;
54 /*
55 * SDA hold time should be 300ns in standard and fast modes
56 * and long enough for deterministic logic level change in
57 * fast-plus and high speed modes.
58 *
59 * [15:0] SDA TX Hold Time
60 * [23:16] SDA RX Hold Time
61 */
62 u32 sda_hold;
63};
64
65/* Serial IRQ control. SERIRQ_QUIET is the default (0) */
66enum serirq_mode {
67 SERIRQ_QUIET,
68 SERIRQ_CONTINUOUS,
69 SERIRQ_OFF,
70};
71
72/*
73 * This I2C controller has support for 3 independent speed configs but can
74 * support both FAST_PLUS and HIGH speeds through the same set of speed
75 * config registers. These are treated separately so the speed config values
76 * can be provided via ACPI to the OS.
77 */
78#define DW_I2C_SPEED_CONFIG_COUNT 4
79
80struct dw_i2c_bus_config {
81 /* Bus should be enabled in TPL with temporary base */
82 int early_init;
83 /* Bus speed in Hz, default is I2C_SPEED_FAST (400 KHz) */
84 enum i2c_speed speed;
85 /*
86 * If rise_time_ns is non-zero the calculations for lcnt and hcnt
87 * registers take into account the times of the bus. However, if
88 * there is a match in speed_config those register values take
89 * precedence
90 */
91 int rise_time_ns;
92 int fall_time_ns;
93 int data_hold_time_ns;
94 /* Specific bus speed configuration */
95 struct dw_i2c_speed_config speed_config[DW_I2C_SPEED_CONFIG_COUNT];
96};
97
98struct gspi_cfg {
99 /* Bus speed in MHz */
100 u32 speed_mhz;
101 /* Bus should be enabled prior to ramstage with temporary base */
102 u8 early_init;
103};
104
105/*
106 * This structure will hold data required by common blocks.
107 * These are soc specific configurations which will be filled by soc.
108 * We'll fill this structure once during init and use the data in common block.
109 */
110struct soc_intel_common_config {
111 int chipset_lockdown;
112 struct gspi_cfg gspi[INTEL_GSPI_MAX];
113 struct dw_i2c_bus_config i2c[INTEL_I2C_DEV_MAX];
114};
115
116enum pnp_settings {
117 PNP_PERF,
118 PNP_POWER,
119 PNP_PERF_POWER,
120};
121
122struct usb2_eye_per_port {
123 u8 per_port_tx_pe_half;
124 u8 per_port_pe_txi_set;
125 u8 per_port_txi_set;
126 u8 hs_skew_sel;
127 u8 usb_tx_emphasis_en;
128 u8 per_port_rxi_set;
129 u8 hs_npre_drv_sel;
130 u8 override_en;
131};
132
133struct apl_config {
134 /* Common structure containing soc config data required by common code*/
135 struct soc_intel_common_config common_soc_config;
136
137 /*
138 * Mapping from PCIe root port to CLKREQ input on the SOC. The SOC has
139 * four CLKREQ inputs, but six root ports. Root ports without an
140 * associated CLKREQ signal must be marked with "CLKREQ_DISABLED"
141 */
142 u8 pcie_rp_clkreq_pin[MAX_PCIE_PORTS];
143
144 /* Enable/disable hot-plug for root ports (0 = disable, 1 = enable) */
145 u8 pcie_rp_hotplug_enable[MAX_PCIE_PORTS];
146
147 /* De-emphasis enable configuration for each PCIe root port */
148 u8 pcie_rp_deemphasis_enable[MAX_PCIE_PORTS];
149
150 /*
151 * [14:8] DDR mode Number of dealy elements.Each = 125pSec.
152 * [6:0] SDR mode Number of dealy elements.Each = 125pSec.
153 */
154 u32 emmc_tx_cmd_cntl;
155
156 /*
157 * [14:8] HS400 mode Number of dealy elements.Each = 125pSec.
158 * [6:0] SDR104/HS200 mode Number of dealy elements.Each = 125pSec.
159 */
160 u32 emmc_tx_data_cntl1;
161
162 /*
163 * [30:24] SDR50 mode Number of dealy elements.Each = 125pSec.
164 * [22:16] DDR50 mode Number of dealy elements.Each = 125pSec.
165 * [14:8] SDR25/HS50 mode Number of dealy elements.Each = 125pSec.
166 * [6:0] SDR12/Compatibility mode Number of dealy elements.
167 * Each = 125pSec.
168 */
169 u32 emmc_tx_data_cntl2;
170
171 /*
172 * [30:24] SDR50 mode Number of dealy elements.Each = 125pSec.
173 * [22:16] DDR50 mode Number of dealy elements.Each = 125pSec.
174 * [14:8] SDR25/HS50 mode Number of dealy elements.Each = 125pSec.
175 * [6:0] SDR12/Compatibility mode Number of dealy elements.
176 * Each = 125pSec.
177 */
178 u32 emmc_rx_cmd_data_cntl1;
179
180 /*
181 * [14:8] HS400 mode 1 Number of dealy elements.Each = 125pSec.
182 * [6:0] HS400 mode 2 Number of dealy elements.Each = 125pSec.
183 */
184 u32 emmc_rx_strobe_cntl;
185
186 /*
187 * [13:8] Auto Tuning mode Number of dealy elements.Each = 125pSec.
188 * [6:0] SDR104/HS200 Number of dealy elements.Each = 125pSec.
189 */
190 u32 emmc_rx_cmd_data_cntl2;
191
192 /* Select the eMMC max speed allowed */
193 u32 emmc_host_max_speed;
194
195 /* Specifies on which IRQ the SCI will internally appear */
196 u32 sci_irq;
197
198 /* Configure serial IRQ (SERIRQ) line */
199 enum serirq_mode serirq_mode;
200
201 /* Configure LPSS S0ix Enable */
202 bool lpss_s0ix_enable;
203
204 /* Enable DPTF support */
205 bool dptf_enable;
206
207 /* TCC activation offset value in degrees Celsius */
208 int tcc_offset;
209
210 /*
211 * Configure Audio clk gate and power gate
212 * IOSF-SB port ID 92 offset 0x530 [5] and [3]
213 */
214 bool hdaudio_clk_gate_enable;
215 bool hdaudio_pwr_gate_enable;
216 bool hdaudio_bios_config_lockdown;
217
218 /* SLP S3 minimum assertion width */
219 int slp_s3_assertion_width_usecs;
220
221 /* GPIO pin for PERST_0 */
222 u32 prt0_gpio;
223
224 /* USB2 eye diagram settings per port */
225 struct usb2_eye_per_port usb2eye[MAX_USB2_PORTS];
226
227 /* GPIO SD card detect pin */
228 unsigned int sdcard_cd_gpio;
229
230 /*
231 * PRMRR size setting with three options
232 * 0x02000000 - 32MiB
233 * 0x04000000 - 64MiB
234 * 0x08000000 - 128MiB
235 */
236 u32 PrmrrSize;
237
238 /*
239 * Enable SGX feature.
240 * Enabling SGX feature is 2 step process,
241 * (1) set sgx_enable = 1
242 * (2) set PrmrrSize to supported size
243 */
244 bool sgx_enable;
245
246 /*
247 * Select PNP Settings.
248 * (0) Performance,
249 * (1) Power
250 * (2) Power & Performance
251 */
252 enum pnp_settings pnp_settings;
253
254 /*
255 * PMIC PCH_PWROK delay configuration - IPC Configuration
256 * Upd for changing PCH_PWROK delay configuration : I2C_Slave_Address
257 * (31:24) + Register_Offset (23:16) + OR Value (15:8) + AND Value (7:0)
258 */
259 u32 pmic_pmc_ipc_ctrl;
260
261 /*
262 * Options to disable XHCI Link Compliance Mode. Default is FALSE to not
263 * disable Compliance Mode. Set TRUE to disable Compliance Mode.
264 * 0:FALSE(Default), 1:True.
265 */
266 bool disable_compliance_mode;
267
268 /*
269 * Options to change USB3 ModPhy setting for the Integrated Filter (IF)
270 * value. Default is 0 to not changing default IF value (0x12). Set
271 * value with the range from 0x01 to 0xff to change IF value.
272 */
273 u32 mod_phy_if_value;
274
275 /*
276 * Options to bump USB3 LDO voltage. Default is FALSE to not increasing
277 * LDO voltage. Set TRUE to increase LDO voltage with 40mV.
278 * 0:FALSE (default), 1:True.
279 */
280 bool mod_phy_voltage_bump;
281
282 /*
283 * Options to adjust PMIC Vdd2 voltage. Default is 0 to not adjusting
284 * the PMIC Vdd2 default voltage 1.20v. Upd for changing Vdd2 Voltage
285 * configuration: I2C_Slave_Address (31:23) + Register_Offset (23:16)
286 * + OR Value (15:8) + AND Value (7:0) through BUCK5_VID[3:2]:
287 * 00=1.10v, 01=1.15v, 10=1.24v, 11=1.20v (default).
288 */
289 u32 pmic_vdd2_voltage;
290
291 /* Option to enable VTD feature */
292 bool enable_vtd;
293};
294
295static int get_config(struct udevice *dev, struct apl_config *apl)
296{
297 const u8 *ptr;
298 ofnode node;
299 u32 emmc[4];
300 int ret;
301
302 memset(apl, '\0', sizeof(*apl));
303
304 node = dev_read_subnode(dev, "fsp-s");
305 if (!ofnode_valid(node))
306 return log_msg_ret("fsp-s settings", -ENOENT);
307
308 ptr = ofnode_read_u8_array_ptr(node, "pcie-rp-clkreq-pin",
309 MAX_PCIE_PORTS);
310 if (!ptr)
311 return log_msg_ret("pcie-rp-clkreq-pin", -EINVAL);
312 memcpy(apl->pcie_rp_clkreq_pin, ptr, MAX_PCIE_PORTS);
313
314 ret = ofnode_read_u32(node, "prt0-gpio", &apl->prt0_gpio);
315 if (ret)
316 return log_msg_ret("prt0-gpio", ret);
317 ret = ofnode_read_u32(node, "sdcard-cd-gpio", &apl->sdcard_cd_gpio);
318 if (ret)
319 return log_msg_ret("sdcard-cd-gpio", ret);
320
321 ret = ofnode_read_u32_array(node, "emmc", emmc, ARRAY_SIZE(emmc));
322 if (ret)
323 return log_msg_ret("emmc", ret);
324 apl->emmc_tx_data_cntl1 = emmc[0];
325 apl->emmc_tx_data_cntl2 = emmc[1];
326 apl->emmc_rx_cmd_data_cntl1 = emmc[2];
327 apl->emmc_rx_cmd_data_cntl2 = emmc[3];
328
329 apl->dptf_enable = ofnode_read_bool(node, "dptf-enable");
330
331 apl->hdaudio_clk_gate_enable = ofnode_read_bool(node,
332 "hdaudio-clk-gate-enable");
333 apl->hdaudio_pwr_gate_enable = ofnode_read_bool(node,
334 "hdaudio-pwr-gate-enable");
335 apl->hdaudio_bios_config_lockdown = ofnode_read_bool(node,
336 "hdaudio-bios-config-lockdown");
337 apl->lpss_s0ix_enable = ofnode_read_bool(node, "lpss-s0ix-enable");
338
339 /* Santa */
340 apl->usb2eye[1].per_port_pe_txi_set = 7;
341 apl->usb2eye[1].per_port_txi_set = 2;
342
343 return 0;
344}
345
346static void apl_fsp_silicon_init_params_cb(struct apl_config *apl,
347 struct fsp_s_config *cfg)
348{
349 u8 port;
350
351 for (port = 0; port < MAX_USB2_PORTS; port++) {
352 if (apl->usb2eye[port].per_port_tx_pe_half)
353 cfg->port_usb20_per_port_tx_pe_half[port] =
354 apl->usb2eye[port].per_port_tx_pe_half;
355
356 if (apl->usb2eye[port].per_port_pe_txi_set)
357 cfg->port_usb20_per_port_pe_txi_set[port] =
358 apl->usb2eye[port].per_port_pe_txi_set;
359
360 if (apl->usb2eye[port].per_port_txi_set)
361 cfg->port_usb20_per_port_txi_set[port] =
362 apl->usb2eye[port].per_port_txi_set;
363
364 if (apl->usb2eye[port].hs_skew_sel)
365 cfg->port_usb20_hs_skew_sel[port] =
366 apl->usb2eye[port].hs_skew_sel;
367
368 if (apl->usb2eye[port].usb_tx_emphasis_en)
369 cfg->port_usb20_i_usb_tx_emphasis_en[port] =
370 apl->usb2eye[port].usb_tx_emphasis_en;
371
372 if (apl->usb2eye[port].per_port_rxi_set)
373 cfg->port_usb20_per_port_rxi_set[port] =
374 apl->usb2eye[port].per_port_rxi_set;
375
376 if (apl->usb2eye[port].hs_npre_drv_sel)
377 cfg->port_usb20_hs_npre_drv_sel[port] =
378 apl->usb2eye[port].hs_npre_drv_sel;
379 }
380}
381
382int fsps_update_config(struct udevice *dev, ulong rom_offset,
383 struct fsps_upd *upd)
384{
385 struct fsp_s_config *cfg = &upd->config;
386 struct apl_config *apl;
387 struct binman_entry vbt;
388 void *buf;
389 int ret;
390
391 ret = binman_entry_find("intel-vbt", &vbt);
392 if (ret)
393 return log_msg_ret("Cannot find VBT", ret);
394 vbt.image_pos += rom_offset;
395 buf = malloc(vbt.size);
396 if (!buf)
397 return log_msg_ret("Alloc VBT", -ENOMEM);
398
399 /*
400 * Load VBT before devicetree-specific config. This only supports
401 * memory-mapped SPI at present.
402 */
403 bootstage_start(BOOTSTAGE_ID_ACCUM_MMAP_SPI, "mmap_spi");
404 memcpy(buf, (void *)vbt.image_pos, vbt.size);
405 bootstage_accum(BOOTSTAGE_ID_ACCUM_MMAP_SPI);
406 if (*(u32 *)buf != VBT_SIGNATURE)
407 return log_msg_ret("VBT signature", -EINVAL);
408 cfg->graphics_config_ptr = (ulong)buf;
409
410 apl = malloc(sizeof(*apl));
411 if (!apl)
412 return log_msg_ret("config", -ENOMEM);
413 get_config(dev, apl);
414
415 cfg->ish_enable = 0;
416 cfg->enable_sata = 0;
417 cfg->pcie_root_port_en[2] = 0;
418 cfg->pcie_rp_hot_plug[2] = 0;
419 cfg->pcie_root_port_en[3] = 0;
420 cfg->pcie_rp_hot_plug[3] = 0;
421 cfg->pcie_root_port_en[4] = 0;
422 cfg->pcie_rp_hot_plug[4] = 0;
423 cfg->pcie_root_port_en[5] = 0;
424 cfg->pcie_rp_hot_plug[5] = 0;
425 cfg->pcie_root_port_en[1] = 0;
426 cfg->pcie_rp_hot_plug[1] = 0;
427 cfg->usb_otg = 0;
428 cfg->i2c6_enable = 0;
429 cfg->i2c7_enable = 0;
430 cfg->hsuart3_enable = 0;
431 cfg->spi1_enable = 0;
432 cfg->spi2_enable = 0;
433 cfg->sdio_enabled = 0;
434
435 memcpy(cfg->pcie_rp_clk_req_number, apl->pcie_rp_clkreq_pin,
436 sizeof(cfg->pcie_rp_clk_req_number));
437
438 memcpy(cfg->pcie_rp_hot_plug, apl->pcie_rp_hotplug_enable,
439 sizeof(cfg->pcie_rp_hot_plug));
440
441 switch (apl->serirq_mode) {
442 case SERIRQ_QUIET:
443 cfg->sirq_enable = 1;
444 cfg->sirq_mode = 0;
445 break;
446 case SERIRQ_CONTINUOUS:
447 cfg->sirq_enable = 1;
448 cfg->sirq_mode = 1;
449 break;
450 case SERIRQ_OFF:
451 default:
452 cfg->sirq_enable = 0;
453 break;
454 }
455
456 if (apl->emmc_tx_cmd_cntl)
457 cfg->emmc_tx_cmd_cntl = apl->emmc_tx_cmd_cntl;
458 if (apl->emmc_tx_data_cntl1)
459 cfg->emmc_tx_data_cntl1 = apl->emmc_tx_data_cntl1;
460 if (apl->emmc_tx_data_cntl2)
461 cfg->emmc_tx_data_cntl2 = apl->emmc_tx_data_cntl2;
462 if (apl->emmc_rx_cmd_data_cntl1)
463 cfg->emmc_rx_cmd_data_cntl1 = apl->emmc_rx_cmd_data_cntl1;
464 if (apl->emmc_rx_strobe_cntl)
465 cfg->emmc_rx_strobe_cntl = apl->emmc_rx_strobe_cntl;
466 if (apl->emmc_rx_cmd_data_cntl2)
467 cfg->emmc_rx_cmd_data_cntl2 = apl->emmc_rx_cmd_data_cntl2;
468 if (apl->emmc_host_max_speed)
469 cfg->e_mmc_host_max_speed = apl->emmc_host_max_speed;
470
471 cfg->lpss_s0ix_enable = apl->lpss_s0ix_enable;
472
473 cfg->skip_mp_init = true;
474
475 /* Disable setting of EISS bit in FSP */
476 cfg->spi_eiss = 0;
477
478 /* Disable FSP from locking access to the RTC NVRAM */
479 cfg->rtc_lock = 0;
480
481 /* Enable Audio clk gate and power gate */
482 cfg->hd_audio_clk_gate = apl->hdaudio_clk_gate_enable;
483 cfg->hd_audio_pwr_gate = apl->hdaudio_pwr_gate_enable;
484 /* Bios config lockdown Audio clk and power gate */
485 cfg->bios_cfg_lock_down = apl->hdaudio_bios_config_lockdown;
486 apl_fsp_silicon_init_params_cb(apl, cfg);
487
488 cfg->usb_otg = true;
489 cfg->vtd_enable = apl->enable_vtd;
490
491 return 0;
492}
493
494static void p2sb_set_hide_bit(pci_dev_t dev, int hide)
495{
496 pci_x86_clrset_config(dev, PCH_P2SB_E0 + 1, HIDE_BIT,
497 hide ? HIDE_BIT : 0, PCI_SIZE_8);
498}
499
500/* Configure package power limits */
501static int set_power_limits(struct udevice *dev)
502{
503 msr_t rapl_msr_reg, limit;
504 u32 power_unit;
505 u32 tdp, min_power, max_power;
506 u32 pl2_val;
507 u32 override_tdp[2];
508 int ret;
509
510 /* Get units */
511 rapl_msr_reg = msr_read(MSR_PKG_POWER_SKU_UNIT);
512 power_unit = 1 << (rapl_msr_reg.lo & 0xf);
513
514 /* Get power defaults for this SKU */
515 rapl_msr_reg = msr_read(MSR_PKG_POWER_SKU);
516 tdp = rapl_msr_reg.lo & PKG_POWER_LIMIT_MASK;
517 pl2_val = rapl_msr_reg.hi & PKG_POWER_LIMIT_MASK;
518 min_power = (rapl_msr_reg.lo >> 16) & PKG_POWER_LIMIT_MASK;
519 max_power = rapl_msr_reg.hi & PKG_POWER_LIMIT_MASK;
520
521 if (min_power > 0 && tdp < min_power)
522 tdp = min_power;
523
524 if (max_power > 0 && tdp > max_power)
525 tdp = max_power;
526
527 ret = dev_read_u32_array(dev, "tdp-pl-override-mw", override_tdp,
528 ARRAY_SIZE(override_tdp));
529 if (ret)
530 return log_msg_ret("tdp-pl-override-mw", ret);
531
532 /* Set PL1 override value */
533 if (override_tdp[0])
534 tdp = override_tdp[0] * power_unit / 1000;
535
536 /* Set PL2 override value */
537 if (override_tdp[1])
538 pl2_val = override_tdp[1] * power_unit / 1000;
539
540 /* Set long term power limit to TDP */
541 limit.lo = tdp & PKG_POWER_LIMIT_MASK;
542 /* Set PL1 Pkg Power clamp bit */
543 limit.lo |= PKG_POWER_LIMIT_CLAMP;
544
545 limit.lo |= PKG_POWER_LIMIT_EN;
546 limit.lo |= (MB_POWER_LIMIT1_TIME_DEFAULT &
547 PKG_POWER_LIMIT_TIME_MASK) << PKG_POWER_LIMIT_TIME_SHIFT;
548
549 /* Set short term power limit PL2 */
550 limit.hi = pl2_val & PKG_POWER_LIMIT_MASK;
551 limit.hi |= PKG_POWER_LIMIT_EN;
552
553 /* Program package power limits in RAPL MSR */
554 msr_write(MSR_PKG_POWER_LIMIT, limit);
555 log_info("RAPL PL1 %d.%dW\n", tdp / power_unit,
556 100 * (tdp % power_unit) / power_unit);
557 log_info("RAPL PL2 %d.%dW\n", pl2_val / power_unit,
558 100 * (pl2_val % power_unit) / power_unit);
559
560 /*
561 * Sett RAPL MMIO register for Power limits. RAPL driver is using MSR
562 * instead of MMIO, so disable LIMIT_EN bit for MMIO
563 */
564 writel(limit.lo & ~PKG_POWER_LIMIT_EN, MCHBAR_REG(MCHBAR_RAPL_PPL));
565 writel(limit.hi & ~PKG_POWER_LIMIT_EN, MCHBAR_REG(MCHBAR_RAPL_PPL + 4));
566
567 return 0;
568}
569
570int p2sb_unhide(void)
571{
572 pci_dev_t dev = PCI_BDF(0, 0xd, 0);
573 ulong val;
574
575 p2sb_set_hide_bit(dev, 0);
576
577 pci_x86_read_config(dev, PCI_VENDOR_ID, &val, PCI_SIZE_16);
578
579 if (val != PCI_VENDOR_ID_INTEL)
580 return log_msg_ret("p2sb unhide", -EIO);
581
582 return 0;
583}
584
585/* Overwrites the SCI IRQ if another IRQ number is given by device tree */
586static void set_sci_irq(void)
587{
588 /* Skip this for now */
589}
590
591int arch_fsps_preinit(void)
592{
593 struct udevice *itss;
594 int ret;
595
596 ret = uclass_first_device_err(UCLASS_IRQ, &itss);
597 if (ret)
598 return log_msg_ret("no itss", ret);
599 /*
600 * Snapshot the current GPIO IRQ polarities. FSP is setting a default
601 * policy that doesn't honour boards' requirements
602 */
603 irq_snapshot_polarities(itss);
604
605 /*
606 * Clear the GPI interrupt status and enable registers. These
607 * registers do not get reset to default state when booting from S5.
608 */
609 ret = pinctrl_gpi_clear_int_cfg();
610 if (ret)
611 return log_msg_ret("gpi_clear", ret);
612
613 return 0;
614}
615
616int arch_fsp_init_r(void)
617{
618#ifdef CONFIG_HAVE_ACPI_RESUME
619 bool s3wake = gd->arch.prev_sleep_state == ACPI_S3;
620#else
621 bool s3wake = false;
622#endif
623 struct udevice *dev, *itss;
624 int ret;
625
626 /*
627 * This must be called before any devices are probed. Put any probing
628 * into arch_fsps_preinit() above.
629 *
630 * We don't use CONFIG_APL_BOOT_FROM_FAST_SPI_FLASH here since it will
631 * force PCI to be probed.
632 */
633 ret = fsp_silicon_init(s3wake, false);
634 if (ret)
635 return ret;
636
637 ret = uclass_first_device_err(UCLASS_IRQ, &itss);
638 if (ret)
639 return log_msg_ret("no itss", ret);
640 /* Restore GPIO IRQ polarities back to previous settings */
641 irq_restore_polarities(itss);
642
643 /* soc_init() */
644 ret = p2sb_unhide();
645 if (ret)
646 return log_msg_ret("unhide p2sb", ret);
647
648 /* Set RAPL MSR for Package power limits*/
649 ret = uclass_first_device_err(UCLASS_NORTHBRIDGE, &dev);
650 if (ret)
651 return log_msg_ret("Cannot get northbridge", ret);
652 set_power_limits(dev);
653
654 /*
655 * FSP-S routes SCI to IRQ 9. With the help of this function you can
656 * select another IRQ for SCI.
657 */
658 set_sci_irq();
659
660 return 0;
661}