blob: 3e9922f6e95524c504afd5083f231ff4950e12b2 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Jonathan Zhang8f895492020-01-16 11:16:45 -08002
3#include <bootblock_common.h>
Jonathan Zhang8f895492020-01-16 11:16:45 -08004#include <console/console.h>
Johnny Lin34473ea2020-03-18 10:23:26 +08005#include <cpu/x86/mtrr.h>
Jeremy Compostella63d5fc62024-02-01 14:30:48 -08006#include <device/pci.h>
Arthur Heymans087fe9f2020-10-28 14:10:37 +01007#include <fsp/util.h>
Jeremy Compostella63d5fc62024-02-01 14:30:48 -08008#include <FsptUpd.h>
9#include <intelblocks/fast_spi.h>
10#include <intelblocks/lpc_lib.h>
11#include <intelblocks/tco.h>
12#include <security/intel/cbnt/cbnt.h>
13#include <soc/bootblock.h>
14#include <soc/iomap.h>
15#include <soc/pci_devs.h>
Jonathan Zhang8f895492020-01-16 11:16:45 -080016
Li, Jincheng969f04f2023-03-01 18:25:49 +080017#if (CONFIG(PLATFORM_USES_FSP2_4))
18const FSPT_UPD temp_ram_init_params = {
19 .FspUpdHeader = {
20 .Signature = FSPT_UPD_SIGNATURE,
21 .Revision = 2,
22 .Reserved = {0},
23 },
24 .FsptArchUpd = {
25 .Revision = 2,
26 .Length = 32,
27 .FspDebugHandler = 0,
28 .Reserved1 = {0},
29 },
30 .FsptCoreUpd = {
31 .MicrocodeRegionBase = 0,
32 .MicrocodeRegionLength = 0,
33 .CodeRegionBase = (UINT64)CACHE_ROM_BASE,
34 .CodeRegionLength = (UINT64)CACHE_ROM_SIZE,
35 },
36 .FsptConfig = {
37 .FsptPort80RouteDisable = 0,
38 .ReservedTempRamInitUpd = {0},
39 },
40 .UpdTerminator = 0x55AA,
41};
42#else
Jonathan Zhang8f895492020-01-16 11:16:45 -080043const FSPT_UPD temp_ram_init_params = {
44 .FspUpdHeader = {
45 .Signature = FSPT_UPD_SIGNATURE,
46 .Revision = 1,
47 .Reserved = {0},
48 },
49 .FsptCoreUpd = {
50 .MicrocodeRegionBase = (UINT32)CONFIG_CPU_MICROCODE_CBFS_LOC,
51 .MicrocodeRegionLength = (UINT32)CONFIG_CPU_MICROCODE_CBFS_LEN,
Johnny Lin34473ea2020-03-18 10:23:26 +080052 .CodeRegionBase = (UINT32)CACHE_ROM_BASE,
53 .CodeRegionLength = (UINT32)CACHE_ROM_SIZE,
Jonathan Zhang8f895492020-01-16 11:16:45 -080054 .Reserved1 = {0},
55 },
56 .FsptConfig = {
Jonathan Zhang641642e2020-05-26 13:42:28 -070057 .FsptPort80RouteDisable = 0,
Jonathan Zhang8f895492020-01-16 11:16:45 -080058 .ReservedTempRamInitUpd = {0},
59 },
60 .UnusedUpdSpace0 = {0},
61 .UpdTerminator = 0x55AA,
62};
Li, Jincheng969f04f2023-03-01 18:25:49 +080063#endif //(!CONFIG(PLATFORM_USES_FSP2_4))
Jonathan Zhang8f895492020-01-16 11:16:45 -080064
Arthur Heymans02dec122020-11-18 12:27:28 +010065static uint64_t assembly_timestamp;
66static uint64_t bootblock_timestamp;
67
Jonathan Zhang8f895492020-01-16 11:16:45 -080068asmlinkage void bootblock_c_entry(uint64_t base_timestamp)
69{
Arthur Heymans02dec122020-11-18 12:27:28 +010070 /*
71 * FSP-T does not respect its own API and trashes registers
72 * coreboot uses to store its initial timestamp.
73 */
74 assembly_timestamp = base_timestamp;
75 bootblock_timestamp = timestamp_get();
Jonathan Zhang8f895492020-01-16 11:16:45 -080076 fast_spi_cache_bios_region();
77
Arthur Heymans02dec122020-11-18 12:27:28 +010078 bootblock_main_with_basetime(MIN(assembly_timestamp, bootblock_timestamp));
Jonathan Zhang8f895492020-01-16 11:16:45 -080079}
80
81void bootblock_soc_early_init(void)
82{
83 fast_spi_early_init(SPI_BASE_ADDRESS);
Johnny Linebb7f542020-02-19 15:52:45 +080084 pch_enable_lpc();
Andrey Petrov335384d2020-03-22 22:27:44 -070085
86 /* Set up P2SB BAR. This is needed for PCR to work */
Nico Huberf4f365f2021-10-14 18:16:39 +020087 uint8_t p2sb_cmd = pci_s_read_config8(PCH_DEV_P2SB, PCI_COMMAND);
88 pci_s_write_config8(PCH_DEV_P2SB, PCI_COMMAND, p2sb_cmd | PCI_COMMAND_MEMORY);
89 pci_s_write_config32(PCH_DEV_P2SB, PCI_BASE_ADDRESS_0, CONFIG_PCR_BASE_ADDRESS);
Jonathan Zhang8f895492020-01-16 11:16:45 -080090}
91
92void bootblock_soc_init(void)
93{
Arthur Heymans02dec122020-11-18 12:27:28 +010094 if (assembly_timestamp > bootblock_timestamp)
95 printk(BIOS_WARNING, "Invalid initial timestamp detected\n");
96
Arthur Heymans087fe9f2020-10-28 14:10:37 +010097 if (CONFIG(FSP_CAR))
98 report_fspt_output();
Arthur Heymansee55d712021-05-12 16:22:05 +020099
100 if (CONFIG(INTEL_CBNT_LOGGING))
101 intel_cbnt_log_registers();
102
Rocky Phagurac62c98a2020-05-23 20:29:00 -0700103 bootblock_pch_init();
Johnny Lin6b1e7dd2022-01-24 15:18:57 +0800104
105 /* Programming TCO_BASE_ADDRESS and TCO Timer Halt */
106 tco_configure();
Naresh Solanki08135332022-12-05 11:42:10 +0100107
108 report_platform_info();
Jonathan Zhang8f895492020-01-16 11:16:45 -0800109}