Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 3 | #include <bootstate.h> |
| 4 | #include <console/console.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 5 | #include <commonlib/console/post_codes.h> |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 6 | #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 Banik | 0359d9d | 2020-09-28 18:43:47 +0530 | [diff] [blame] | 11 | #include <intelblocks/pmclib.h> |
Tim Wawrzynczak | 26a77eb | 2021-08-26 09:20:44 -0600 | [diff] [blame^] | 12 | #include <intelblocks/systemagent.h> |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 13 | #include <intelblocks/tco.h> |
| 14 | #include <intelblocks/thermal.h> |
Tim Wawrzynczak | 26a77eb | 2021-08-26 09:20:44 -0600 | [diff] [blame^] | 15 | #include <intelpch/lockdown.h> |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 16 | #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 | |
| 25 | static void pch_finalize(void) |
| 26 | { |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 27 | config_t *config; |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 28 | |
| 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 Banik | 0359d9d | 2020-09-28 18:43:47 +0530 | [diff] [blame] | 46 | if (config->PmTimerDisabled) |
| 47 | pmc_disable_acpi_timer(); |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 48 | |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 49 | pmc_clear_pmcon_sts(); |
| 50 | } |
| 51 | |
Tim Wawrzynczak | 26a77eb | 2021-08-26 09:20:44 -0600 | [diff] [blame^] | 52 | static void sa_finalize(void) |
| 53 | { |
| 54 | if (get_lockdown_config() == CHIPSET_LOCKDOWN_COREBOOT) |
| 55 | sa_lock_pam(); |
| 56 | } |
| 57 | |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 58 | static void soc_finalize(void *unused) |
| 59 | { |
| 60 | printk(BIOS_DEBUG, "Finalizing chipset.\n"); |
| 61 | |
| 62 | pch_finalize(); |
| 63 | apm_control(APM_CNT_FINALIZE); |
Tim Wawrzynczak | 26a77eb | 2021-08-26 09:20:44 -0600 | [diff] [blame^] | 64 | sa_finalize(); |
Tan, Lean Sheng | 05dfe31 | 2020-08-25 20:40:17 -0700 | [diff] [blame] | 65 | |
| 66 | /* Indicate finalize step with post code */ |
| 67 | post_code(POST_OS_BOOT); |
| 68 | } |
| 69 | |
| 70 | BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL); |
| 71 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL); |