Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 2 | |
| 3 | #include <bootblock_common.h> |
| 4 | #include <device/pci.h> |
| 5 | #include <FsptUpd.h> |
| 6 | #include <intelblocks/fast_spi.h> |
| 7 | #include <soc/iomap.h> |
| 8 | #include <console/console.h> |
Johnny Lin | 34473ea | 2020-03-18 10:23:26 +0800 | [diff] [blame] | 9 | #include <cpu/x86/mtrr.h> |
Johnny Lin | ebb7f54 | 2020-02-19 15:52:45 +0800 | [diff] [blame] | 10 | #include <intelblocks/lpc_lib.h> |
Arthur Heymans | ee55d71 | 2021-05-12 16:22:05 +0200 | [diff] [blame] | 11 | #include <security/intel/cbnt/cbnt.h> |
Andrey Petrov | 335384d | 2020-03-22 22:27:44 -0700 | [diff] [blame] | 12 | #include <soc/pci_devs.h> |
Rocky Phagura | c62c98a | 2020-05-23 20:29:00 -0700 | [diff] [blame] | 13 | #include <soc/bootblock.h> |
Arthur Heymans | 087fe9f | 2020-10-28 14:10:37 +0100 | [diff] [blame] | 14 | #include <fsp/util.h> |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 15 | |
| 16 | const FSPT_UPD temp_ram_init_params = { |
| 17 | .FspUpdHeader = { |
| 18 | .Signature = FSPT_UPD_SIGNATURE, |
| 19 | .Revision = 1, |
| 20 | .Reserved = {0}, |
| 21 | }, |
| 22 | .FsptCoreUpd = { |
| 23 | .MicrocodeRegionBase = (UINT32)CONFIG_CPU_MICROCODE_CBFS_LOC, |
| 24 | .MicrocodeRegionLength = (UINT32)CONFIG_CPU_MICROCODE_CBFS_LEN, |
Johnny Lin | 34473ea | 2020-03-18 10:23:26 +0800 | [diff] [blame] | 25 | .CodeRegionBase = (UINT32)CACHE_ROM_BASE, |
| 26 | .CodeRegionLength = (UINT32)CACHE_ROM_SIZE, |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 27 | .Reserved1 = {0}, |
| 28 | }, |
| 29 | .FsptConfig = { |
Jonathan Zhang | 641642e | 2020-05-26 13:42:28 -0700 | [diff] [blame] | 30 | .FsptPort80RouteDisable = 0, |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 31 | .ReservedTempRamInitUpd = {0}, |
| 32 | }, |
| 33 | .UnusedUpdSpace0 = {0}, |
| 34 | .UpdTerminator = 0x55AA, |
| 35 | }; |
| 36 | |
Arthur Heymans | 02dec12 | 2020-11-18 12:27:28 +0100 | [diff] [blame] | 37 | static uint64_t assembly_timestamp; |
| 38 | static uint64_t bootblock_timestamp; |
| 39 | |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 40 | asmlinkage void bootblock_c_entry(uint64_t base_timestamp) |
| 41 | { |
Arthur Heymans | 02dec12 | 2020-11-18 12:27:28 +0100 | [diff] [blame] | 42 | /* |
| 43 | * FSP-T does not respect its own API and trashes registers |
| 44 | * coreboot uses to store its initial timestamp. |
| 45 | */ |
| 46 | assembly_timestamp = base_timestamp; |
| 47 | bootblock_timestamp = timestamp_get(); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 48 | fast_spi_cache_bios_region(); |
| 49 | |
Arthur Heymans | 02dec12 | 2020-11-18 12:27:28 +0100 | [diff] [blame] | 50 | bootblock_main_with_basetime(MIN(assembly_timestamp, bootblock_timestamp)); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void bootblock_soc_early_init(void) |
| 54 | { |
| 55 | fast_spi_early_init(SPI_BASE_ADDRESS); |
Johnny Lin | ebb7f54 | 2020-02-19 15:52:45 +0800 | [diff] [blame] | 56 | pch_enable_lpc(); |
Andrey Petrov | 335384d | 2020-03-22 22:27:44 -0700 | [diff] [blame] | 57 | |
| 58 | /* Set up P2SB BAR. This is needed for PCR to work */ |
Nico Huber | f4f365f | 2021-10-14 18:16:39 +0200 | [diff] [blame] | 59 | uint8_t p2sb_cmd = pci_s_read_config8(PCH_DEV_P2SB, PCI_COMMAND); |
| 60 | pci_s_write_config8(PCH_DEV_P2SB, PCI_COMMAND, p2sb_cmd | PCI_COMMAND_MEMORY); |
| 61 | pci_s_write_config32(PCH_DEV_P2SB, PCI_BASE_ADDRESS_0, CONFIG_PCR_BASE_ADDRESS); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | void bootblock_soc_init(void) |
| 65 | { |
Arthur Heymans | 02dec12 | 2020-11-18 12:27:28 +0100 | [diff] [blame] | 66 | if (assembly_timestamp > bootblock_timestamp) |
| 67 | printk(BIOS_WARNING, "Invalid initial timestamp detected\n"); |
| 68 | |
Arthur Heymans | 087fe9f | 2020-10-28 14:10:37 +0100 | [diff] [blame] | 69 | if (CONFIG(FSP_CAR)) |
| 70 | report_fspt_output(); |
Arthur Heymans | ee55d71 | 2021-05-12 16:22:05 +0200 | [diff] [blame] | 71 | |
| 72 | if (CONFIG(INTEL_CBNT_LOGGING)) |
| 73 | intel_cbnt_log_registers(); |
| 74 | |
Rocky Phagura | c62c98a | 2020-05-23 20:29:00 -0700 | [diff] [blame] | 75 | bootblock_pch_init(); |
Jonathan Zhang | 8f89549 | 2020-01-16 11:16:45 -0800 | [diff] [blame] | 76 | } |