blob: 6ed60e7eefc494afc68b6f55b63ecb6684a38723 [file] [log] [blame]
Angel Pons16f6aa82020-04-05 15:47:21 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Subrata Banik91e89c52019-11-01 18:30:01 +05302
3/*
4 * This file is created based on Intel Tiger Lake Processor PCH Datasheet
5 * Document number: 575857
6 * Chapter number: 4, 29
7 */
8
Subrata Banik91e89c52019-11-01 18:30:01 +05309#include <bootstate.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -070010#include <commonlib/console/post_codes.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053011#include <console/console.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053012#include <cpu/x86/smm.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -070013#include <device/mmio.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053014#include <device/pci.h>
15#include <intelblocks/lpc_lib.h>
16#include <intelblocks/pcr.h>
Subrata Banik0359d9d2020-09-28 18:43:47 +053017#include <intelblocks/pmclib.h>
Tim Wawrzynczak58966082021-08-25 09:32:19 -060018#include <intelblocks/systemagent.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053019#include <intelblocks/tco.h>
20#include <intelblocks/thermal.h>
Tim Wawrzynczak58966082021-08-25 09:32:19 -060021#include <intelpch/lockdown.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053022#include <soc/p2sb.h>
23#include <soc/pci_devs.h>
24#include <soc/pcr_ids.h>
25#include <soc/pm.h>
26#include <soc/smbus.h>
27#include <soc/soc_chip.h>
28#include <soc/systemagent.h>
Ricardo Quesada470ca5712021-07-16 16:39:28 -070029#include <spi-generic.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053030
Subrata Banik91e89c52019-11-01 18:30:01 +053031static void pch_finalize(void)
32{
Subrata Banik91e89c52019-11-01 18:30:01 +053033 config_t *config;
Subrata Banik91e89c52019-11-01 18:30:01 +053034
35 /* TCO Lock down */
36 tco_lockdown();
37
Subrata Banik2fff3912020-01-16 10:13:28 +053038 /* TODO: Add Thermal Configuration */
Subrata Banik91e89c52019-11-01 18:30:01 +053039
40 /*
41 * Disable ACPI PM timer based on dt policy
42 *
43 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
44 * Disabling ACPI PM timer also switches off TCO
45 *
46 * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is
47 * just required to get to chip config. PCH_DEV_PMC is hidden by this
48 * point and hence removed from the root bus. pcidev_path_on_root thus
49 * returns NULL for PCH_DEV_PMC device.
50 */
51 config = config_of_soc();
Subrata Banik0359d9d2020-09-28 18:43:47 +053052 if (config->PmTimerDisabled)
53 pmc_disable_acpi_timer();
Subrata Banik91e89c52019-11-01 18:30:01 +053054
Subrata Banik91e89c52019-11-01 18:30:01 +053055 pmc_clear_pmcon_sts();
56}
57
John Zhao5d16a252020-05-01 22:04:00 -070058static void tbt_finalize(void)
59{
60 int i;
61 const struct device *dev;
62
63 /* Disable Thunderbolt PCIe root ports bus master */
64 for (i = 0; i < NUM_TBT_FUNCTIONS; i++) {
65 dev = pcidev_path_on_root(SA_DEVFN_TBT(i));
66 if (dev)
67 pci_dev_disable_bus_master(dev);
68 }
69}
70
Tim Wawrzynczak58966082021-08-25 09:32:19 -060071static void sa_finalize(void)
72{
73 if (get_lockdown_config() == CHIPSET_LOCKDOWN_COREBOOT)
74 sa_lock_pam();
75}
76
Subrata Banik91e89c52019-11-01 18:30:01 +053077static void soc_finalize(void *unused)
78{
79 printk(BIOS_DEBUG, "Finalizing chipset.\n");
80
81 pch_finalize();
Kyösti Mälkkib6585482020-06-01 15:11:14 +030082 apm_control(APM_CNT_FINALIZE);
John Zhao5d16a252020-05-01 22:04:00 -070083 tbt_finalize();
Tim Wawrzynczak58966082021-08-25 09:32:19 -060084 sa_finalize();
Subrata Banik91e89c52019-11-01 18:30:01 +053085
86 /* Indicate finalize step with post code */
87 post_code(POST_OS_BOOT);
88}
89
90BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
91BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);