blob: 332bddeb7734888010afeca29b7b14afcd623ad9 [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 <device/mmio.h>
10#include <bootstate.h>
11#include <console/console.h>
12#include <console/post_codes.h>
13#include <cpu/x86/smm.h>
14#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>
Subrata Banik91e89c52019-11-01 18:30:01 +053018#include <intelblocks/tco.h>
19#include <intelblocks/thermal.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053020#include <spi-generic.h>
21#include <soc/p2sb.h>
22#include <soc/pci_devs.h>
23#include <soc/pcr_ids.h>
24#include <soc/pm.h>
25#include <soc/smbus.h>
26#include <soc/soc_chip.h>
27#include <soc/systemagent.h>
Subrata Banik91e89c52019-11-01 18:30:01 +053028
Subrata Banik91e89c52019-11-01 18:30:01 +053029static void pch_finalize(void)
30{
Subrata Banik91e89c52019-11-01 18:30:01 +053031 config_t *config;
Subrata Banik91e89c52019-11-01 18:30:01 +053032
33 /* TCO Lock down */
34 tco_lockdown();
35
Subrata Banik2fff3912020-01-16 10:13:28 +053036 /* TODO: Add Thermal Configuration */
Subrata Banik91e89c52019-11-01 18:30:01 +053037
38 /*
39 * Disable ACPI PM timer based on dt policy
40 *
41 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
42 * Disabling ACPI PM timer also switches off TCO
43 *
44 * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is
45 * just required to get to chip config. PCH_DEV_PMC is hidden by this
46 * point and hence removed from the root bus. pcidev_path_on_root thus
47 * returns NULL for PCH_DEV_PMC device.
48 */
49 config = config_of_soc();
Subrata Banik0359d9d2020-09-28 18:43:47 +053050 if (config->PmTimerDisabled)
51 pmc_disable_acpi_timer();
Subrata Banik91e89c52019-11-01 18:30:01 +053052
Subrata Banik91e89c52019-11-01 18:30:01 +053053 pmc_clear_pmcon_sts();
54}
55
John Zhao5d16a252020-05-01 22:04:00 -070056static void tbt_finalize(void)
57{
58 int i;
59 const struct device *dev;
60
61 /* Disable Thunderbolt PCIe root ports bus master */
62 for (i = 0; i < NUM_TBT_FUNCTIONS; i++) {
63 dev = pcidev_path_on_root(SA_DEVFN_TBT(i));
64 if (dev)
65 pci_dev_disable_bus_master(dev);
66 }
67}
68
Subrata Banik91e89c52019-11-01 18:30:01 +053069static void soc_finalize(void *unused)
70{
71 printk(BIOS_DEBUG, "Finalizing chipset.\n");
72
73 pch_finalize();
Kyösti Mälkkib6585482020-06-01 15:11:14 +030074 apm_control(APM_CNT_FINALIZE);
John Zhao5d16a252020-05-01 22:04:00 -070075 tbt_finalize();
Subrata Banik91e89c52019-11-01 18:30:01 +053076
77 /* Indicate finalize step with post code */
78 post_code(POST_OS_BOOT);
79}
80
81BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
82BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);