blob: 5c36721ef54b7f3935af9244b604a818850bb0df [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>
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070012#include <intelblocks/tco.h>
13#include <intelblocks/thermal.h>
14#include <soc/p2sb.h>
15#include <soc/pci_devs.h>
16#include <soc/pcr_ids.h>
17#include <soc/pm.h>
18#include <soc/smbus.h>
19#include <soc/soc_chip.h>
20#include <soc/systemagent.h>
21#include <spi-generic.h>
22
23static void pch_finalize(void)
24{
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070025 config_t *config;
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070026
27 /* TCO Lock down */
28 tco_lockdown();
29
30 /* TODO: Add Thermal Configuration */
31
32 /*
33 * Disable ACPI PM timer based on dt policy
34 *
35 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
36 * Disabling ACPI PM timer also switches off TCO
37 *
38 * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is
39 * just required to get to chip config. PCH_DEV_PMC is hidden by this
40 * point and hence removed from the root bus. pcidev_path_on_root thus
41 * returns NULL for PCH_DEV_PMC device.
42 */
43 config = config_of_soc();
Subrata Banik0359d9d2020-09-28 18:43:47 +053044 if (config->PmTimerDisabled)
45 pmc_disable_acpi_timer();
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070046
Tan, Lean Sheng05dfe312020-08-25 20:40:17 -070047 pmc_clear_pmcon_sts();
48}
49
50static void soc_finalize(void *unused)
51{
52 printk(BIOS_DEBUG, "Finalizing chipset.\n");
53
54 pch_finalize();
55 apm_control(APM_CNT_FINALIZE);
56
57 /* Indicate finalize step with post code */
58 post_code(POST_OS_BOOT);
59}
60
61BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
62BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);