Angel Pons | 3bd1e3d | 2020-04-05 15:47:17 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 2 | |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 3 | #include <bootstate.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 4 | #include <commonlib/console/post_codes.h> |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 5 | #include <console/console.h> |
Michael Niewöhner | 48fb573 | 2019-09-22 21:56:17 +0200 | [diff] [blame] | 6 | #include <cpu/x86/mp.h> |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 7 | #include <cpu/x86/smm.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 8 | #include <device/mmio.h> |
Subrata Banik | e7ceae7 | 2017-03-08 17:59:40 +0530 | [diff] [blame] | 9 | #include <device/pci.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 10 | #include <device/pci_ops.h> |
Pratik Prajapati | 1b25c8e | 2018-05-18 18:07:25 -0700 | [diff] [blame] | 11 | #include <intelblocks/cpulib.h> |
Subrata Banik | be3e911 | 2022-01-28 03:12:35 +0530 | [diff] [blame] | 12 | #include <intelblocks/cse.h> |
Ravi Sarawadi | 1483d1f | 2017-09-28 17:06:01 -0700 | [diff] [blame] | 13 | #include <intelblocks/lpc_lib.h> |
Subrata Banik | c51df93 | 2018-05-08 11:58:01 +0530 | [diff] [blame] | 14 | #include <intelblocks/p2sb.h> |
Subrata Banik | e7ceae7 | 2017-03-08 17:59:40 +0530 | [diff] [blame] | 15 | #include <intelblocks/pcr.h> |
Subrata Banik | 0359d9d | 2020-09-28 18:43:47 +0530 | [diff] [blame] | 16 | #include <intelblocks/pmclib.h> |
Michael Niewöhner | 5a7dc9e | 2019-09-17 16:03:18 +0200 | [diff] [blame] | 17 | #include <intelblocks/tco.h> |
Subrata Banik | c077b22 | 2019-08-01 10:50:35 +0530 | [diff] [blame] | 18 | #include <intelblocks/thermal.h> |
Dhaval Sharma | 9dca83c | 2016-01-18 17:28:20 +0530 | [diff] [blame] | 19 | #include <soc/me.h> |
Rizwan Qureshi | cf73c13 | 2016-08-04 20:01:12 +0530 | [diff] [blame] | 20 | #include <soc/p2sb.h> |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 21 | #include <soc/pci_devs.h> |
Subrata Banik | e7ceae7 | 2017-03-08 17:59:40 +0530 | [diff] [blame] | 22 | #include <soc/pcr_ids.h> |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 23 | #include <soc/pm.h> |
Barnali Sarkar | 0dddcd7 | 2016-08-02 17:49:56 +0530 | [diff] [blame] | 24 | #include <soc/smbus.h> |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 25 | #include <soc/systemagent.h> |
Ricardo Quesada | 470ca571 | 2021-07-16 16:39:28 -0700 | [diff] [blame] | 26 | #include <spi-generic.h> |
Subrata Banik | e7ceae7 | 2017-03-08 17:59:40 +0530 | [diff] [blame] | 27 | |
Elyes HAOUAS | c338507 | 2019-03-21 15:38:06 +0100 | [diff] [blame] | 28 | #include "chip.h" |
| 29 | |
Subrata Banik | e7ceae7 | 2017-03-08 17:59:40 +0530 | [diff] [blame] | 30 | #define PSF_BASE_ADDRESS 0xA00 |
| 31 | #define PCR_PSFX_T0_SHDW_PCIEN 0x1C |
| 32 | #define PCR_PSFX_T0_SHDW_PCIEN_FUNDIS (1 << 8) |
Archana Patni | 7846e34 | 2015-11-11 01:29:23 +0530 | [diff] [blame] | 33 | |
Subrata Banik | be3e911 | 2022-01-28 03:12:35 +0530 | [diff] [blame] | 34 | void soc_disable_heci1_using_pcr(void) |
Barnali Sarkar | fbf1018 | 2017-08-11 18:38:38 +0530 | [diff] [blame] | 35 | { |
Archana Patni | 7846e34 | 2015-11-11 01:29:23 +0530 | [diff] [blame] | 36 | /* unhide p2sb device */ |
Subrata Banik | c51df93 | 2018-05-08 11:58:01 +0530 | [diff] [blame] | 37 | p2sb_unhide(); |
Archana Patni | 7846e34 | 2015-11-11 01:29:23 +0530 | [diff] [blame] | 38 | |
| 39 | /* disable heci */ |
Subrata Banik | e7ceae7 | 2017-03-08 17:59:40 +0530 | [diff] [blame] | 40 | pcr_or32(PID_PSF1, PSF_BASE_ADDRESS + PCR_PSFX_T0_SHDW_PCIEN, |
| 41 | PCR_PSFX_T0_SHDW_PCIEN_FUNDIS); |
Archana Patni | 7846e34 | 2015-11-11 01:29:23 +0530 | [diff] [blame] | 42 | |
Patrick Rudolph | 5199e82 | 2019-09-26 14:00:14 +0200 | [diff] [blame] | 43 | p2sb_disable_sideband_access(); |
Archana Patni | 7846e34 | 2015-11-11 01:29:23 +0530 | [diff] [blame] | 44 | } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 45 | |
Subrata Banik | c51df93 | 2018-05-08 11:58:01 +0530 | [diff] [blame] | 46 | static void pch_finalize_script(struct device *dev) |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 47 | { |
Michael Niewöhner | 5a7dc9e | 2019-09-17 16:03:18 +0200 | [diff] [blame] | 48 | tco_lockdown(); |
| 49 | |
Dhaval Sharma | 9dca83c | 2016-01-18 17:28:20 +0530 | [diff] [blame] | 50 | /* Display me status before we hide it */ |
| 51 | intel_me_status(); |
| 52 | |
Archana Patni | 6c1bf27 | 2015-12-18 23:38:21 +0530 | [diff] [blame] | 53 | /* |
Subrata Banik | 771d611 | 2017-11-29 16:17:13 +0530 | [diff] [blame] | 54 | * Set low maximum temp value used for dynamic thermal sensor |
| 55 | * shutdown consideration. |
| 56 | * |
| 57 | * If Dynamic Thermal Shutdown is enabled then PMC logic shuts down the |
| 58 | * thermal sensor when CPU is in a C-state and DTS Temp <= LTT. |
| 59 | */ |
| 60 | pch_thermal_configuration(); |
| 61 | |
Subrata Banik | a0d9ad3 | 2022-01-03 18:07:13 +0000 | [diff] [blame] | 62 | /* we should disable Heci1 based on the config */ |
| 63 | if (CONFIG(DISABLE_HECI1_AT_PRE_BOOT)) |
Subrata Banik | be3e911 | 2022-01-28 03:12:35 +0530 | [diff] [blame] | 64 | heci1_disable(); |
Patrick Rudolph | 5199e82 | 2019-09-26 14:00:14 +0200 | [diff] [blame] | 65 | |
| 66 | /* Hide p2sb device as the OS must not change BAR0. */ |
| 67 | p2sb_hide(); |
Subrata Banik | 112ffd7 | 2022-02-06 18:39:54 +0530 | [diff] [blame] | 68 | |
| 69 | pmc_clear_pmcon_sts(); |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 70 | } |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 71 | |
Subrata Banik | c51df93 | 2018-05-08 11:58:01 +0530 | [diff] [blame] | 72 | static void soc_lockdown(struct device *dev) |
Rizwan Qureshi | e64f794 | 2015-11-19 16:01:54 +0530 | [diff] [blame] | 73 | { |
Barnali Sarkar | 0818a2a | 2017-08-17 11:52:39 +0530 | [diff] [blame] | 74 | struct soc_intel_skylake_config *config; |
Rizwan Qureshi | e64f794 | 2015-11-19 16:01:54 +0530 | [diff] [blame] | 75 | u8 reg8; |
Barnali Sarkar | 0818a2a | 2017-08-17 11:52:39 +0530 | [diff] [blame] | 76 | |
Kyösti Mälkki | 8950cfb | 2019-07-13 22:16:25 +0300 | [diff] [blame] | 77 | config = config_of(dev); |
Rizwan Qureshi | e64f794 | 2015-11-19 16:01:54 +0530 | [diff] [blame] | 78 | |
| 79 | /* Global SMI Lock */ |
| 80 | if (config->LockDownConfigGlobalSmi == 0) { |
Rizwan Qureshi | e64f794 | 2015-11-19 16:01:54 +0530 | [diff] [blame] | 81 | reg8 = pci_read_config8(dev, GEN_PMCON_A); |
| 82 | reg8 |= SMI_LOCK; |
| 83 | pci_write_config8(dev, GEN_PMCON_A, reg8); |
| 84 | } |
Michael Niewöhner | 48fb573 | 2019-09-22 21:56:17 +0200 | [diff] [blame] | 85 | |
Michael Niewöhner | 348f2a6 | 2020-08-05 21:38:59 +0200 | [diff] [blame] | 86 | /* |
| 87 | * Lock chipset memory registers to protect SMM. |
| 88 | * When SkipMpInit=0, this is done by FSP. |
| 89 | */ |
| 90 | if (!CONFIG(USE_INTEL_FSP_MP_INIT)) |
| 91 | cpu_lt_lock_memory(); |
Rizwan Qureshi | e64f794 | 2015-11-19 16:01:54 +0530 | [diff] [blame] | 92 | } |
| 93 | |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 94 | static void soc_finalize(void *unused) |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 95 | { |
Subrata Banik | c51df93 | 2018-05-08 11:58:01 +0530 | [diff] [blame] | 96 | struct device *dev; |
| 97 | |
| 98 | dev = PCH_DEV_PMC; |
| 99 | |
| 100 | /* Check if PMC is enabled, else return */ |
Kyösti Mälkki | 8950cfb | 2019-07-13 22:16:25 +0300 | [diff] [blame] | 101 | if (dev == NULL) |
Subrata Banik | c51df93 | 2018-05-08 11:58:01 +0530 | [diff] [blame] | 102 | return; |
| 103 | |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 104 | printk(BIOS_DEBUG, "Finalizing chipset.\n"); |
Rizwan Qureshi | e64f794 | 2015-11-19 16:01:54 +0530 | [diff] [blame] | 105 | |
Subrata Banik | c51df93 | 2018-05-08 11:58:01 +0530 | [diff] [blame] | 106 | pch_finalize_script(dev); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 107 | |
Subrata Banik | c51df93 | 2018-05-08 11:58:01 +0530 | [diff] [blame] | 108 | soc_lockdown(dev); |
Kyösti Mälkki | b658548 | 2020-06-01 15:11:14 +0300 | [diff] [blame] | 109 | apm_control(APM_CNT_FINALIZE); |
Duncan Laurie | 6f0e6fa | 2016-02-09 09:40:39 -0800 | [diff] [blame] | 110 | |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 111 | /* Indicate finalize step with post code */ |
lilacious | 40cb3fe | 2023-06-21 23:24:14 +0200 | [diff] [blame] | 112 | post_code(POSTCODE_OS_BOOT); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 115 | BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL); |
| 116 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL); |