blob: 3d1430fbe3a7b6dfddc3c582d1643ba69b3c6af2 [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>
9#include <intelblocks/lpc_lib.h>
10#include <intelblocks/pcr.h>
Subrata Banik0359d9d2020-09-28 18:43:47 +053011#include <intelblocks/pmclib.h>
Tim Wawrzynczak26a77eb2021-08-26 09:20:44 -060012#include <intelblocks/systemagent.h>
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070013#include <intelblocks/tco.h>
14#include <intelblocks/thermal.h>
Tim Wawrzynczak26a77eb2021-08-26 09:20:44 -060015#include <intelpch/lockdown.h>
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070016#include <soc/p2sb.h>
17#include <soc/pci_devs.h>
18#include <soc/pcr_ids.h>
19#include <soc/pm.h>
20#include <soc/smbus.h>
21#include <soc/soc_chip.h>
22#include <soc/systemagent.h>
23#include <spi-generic.h>
24
25static void pch_finalize(void)
26{
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070027 config_t *config;
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070028
29 /* TCO Lock down */
30 tco_lockdown();
31
32 /* TODO: Add Thermal Configuration */
33
34 /*
35 * Disable ACPI PM timer based on dt policy
36 *
37 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
38 * Disabling ACPI PM timer also switches off TCO
39 *
40 * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is
41 * just required to get to chip config. PCH_DEV_PMC is hidden by this
42 * point and hence removed from the root bus. pcidev_path_on_root thus
43 * returns NULL for PCH_DEV_PMC device.
44 */
45 config = config_of_soc();
Subrata Banik0359d9d2020-09-28 18:43:47 +053046 if (config->PmTimerDisabled)
47 pmc_disable_acpi_timer();
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070048
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070049 pmc_clear_pmcon_sts();
50}
51
Tim Wawrzynczak26a77eb2021-08-26 09:20:44 -060052static void sa_finalize(void)
53{
54 if (get_lockdown_config() == CHIPSET_LOCKDOWN_COREBOOT)
55 sa_lock_pam();
56}
57
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070058static void soc_finalize(void *unused)
59{
60 printk(BIOS_DEBUG, "Finalizing chipset.\n");
61
62 pch_finalize();
63 apm_control(APM_CNT_FINALIZE);
Tim Wawrzynczak26a77eb2021-08-26 09:20:44 -060064 sa_finalize();
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070065
66 /* Indicate finalize step with post code */
67 post_code(POST_OS_BOOT);
68}
69
70BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
71BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);