blob: 275413b4efaf6395514c86df9002a9db0ab859bb [file] [log] [blame]
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -07001/* SPDX-License-Identifier: GPL-2.0-only */
2
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -07003#include <bootstate.h>
4#include <console/console.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -07005#include <commonlib/console/post_codes.h>
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -07006#include <cpu/x86/smm.h>
7#include <device/mmio.h>
8#include <device/pci.h>
Lean Sheng Tan2afcbc12022-04-21 15:14:23 +02009#include <intelblocks/cse.h>
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070010#include <intelblocks/lpc_lib.h>
11#include <intelblocks/pcr.h>
Subrata Banik0359d9d2020-09-28 18:43:47 +053012#include <intelblocks/pmclib.h>
Tim Wawrzynczak26a77eb2021-08-26 09:20:44 -060013#include <intelblocks/systemagent.h>
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070014#include <intelblocks/tco.h>
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070015#include <soc/p2sb.h>
16#include <soc/pci_devs.h>
17#include <soc/pcr_ids.h>
18#include <soc/pm.h>
19#include <soc/smbus.h>
20#include <soc/soc_chip.h>
21#include <soc/systemagent.h>
22#include <spi-generic.h>
23
24static void pch_finalize(void)
25{
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070026 /* TCO Lock down */
27 tco_lockdown();
28
29 /* TODO: Add Thermal Configuration */
30
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070031 pmc_clear_pmcon_sts();
32}
33
Lean Sheng Tan2afcbc12022-04-21 15:14:23 +020034static void heci_finalize(void)
35{
36 heci_set_to_d0i3();
37 if (CONFIG(DISABLE_HECI1_AT_PRE_BOOT))
38 heci1_disable();
39}
40
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070041static void soc_finalize(void *unused)
42{
43 printk(BIOS_DEBUG, "Finalizing chipset.\n");
44
45 pch_finalize();
46 apm_control(APM_CNT_FINALIZE);
Lean Sheng Tan2afcbc12022-04-21 15:14:23 +020047 if (CONFIG(USE_FSP_NOTIFY_PHASE_READY_TO_BOOT) &&
48 CONFIG(USE_FSP_NOTIFY_PHASE_END_OF_FIRMWARE))
49 heci_finalize();
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070050
51 /* Indicate finalize step with post code */
lilacious40cb3fe2023-06-21 23:24:14 +020052 post_code(POSTCODE_OS_BOOT);
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070053}
54
55BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
56BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);