blob: cb2503ae401ab00cabc930fc7f03b59d7f4c8383 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Mariusz Szafranskia4041332017-08-02 17:28:17 +02002
Kyösti Mälkki6fcee752021-02-14 15:06:50 +02003#include <assert.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02004#include <bootblock_common.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02005#include <device/pci.h>
Kyösti Mälkki6fcee752021-02-14 15:06:50 +02006#include <device/pci_ops.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02007#include <FsptUpd.h>
8#include <intelblocks/fast_spi.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02009#include <soc/bootblock.h>
Kyösti Mälkki6fcee752021-02-14 15:06:50 +020010#include <soc/pci_devs.h>
11#include <soc/systemagent.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020012#include <spi-generic.h>
Kyösti Mälkki6fcee752021-02-14 15:06:50 +020013#include <stdint.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020014#include <console/console.h>
15
16const FSPT_UPD temp_ram_init_params = {
17 .FspUpdHeader = {
18 .Signature = 0x545F445055564E44ULL,
19 .Revision = 1,
20 .Reserved = {0},
21 },
22 .FsptCoreUpd = {
Subrata Banik24ab1c52019-11-25 11:57:28 +053023 /*
24 * It is a requirement for firmware to have Firmware Interface Table
25 * (FIT), which contains pointers to each microcode update.
26 * The microcode update is loaded for all logical processors before
27 * cpu reset vector.
28 *
29 * All SoC since Gen-4 has above mechanism in place to load microcode
30 * even before hitting CPU reset vector. Hence skipping FSP-T loading
31 * microcode after CPU reset by passing '0' value to
32 * FSPT_UPD.MicrocodeRegionBase and FSPT_UPD.MicrocodeRegionLength.
33 */
34 .MicrocodeRegionBase = 0,
35 .MicrocodeRegionLength = 0,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020036 .CodeRegionBase =
Arthur Heymans62c0b612019-02-05 21:10:01 +010037 (UINT32)(0x100000000ULL - CONFIG_ROM_SIZE),
38 .CodeRegionLength = (UINT32)CONFIG_ROM_SIZE,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020039 .Reserved1 = {0},
40 },
41 .FsptConfig = {
42 .PcdFsptPort80RouteDisable = 0,
43 .ReservedTempRamInitUpd = {0},
44 },
45 .UnusedUpdSpace0 = {0},
46 .UpdTerminator = 0x55AA,
47};
48
49asmlinkage void bootblock_c_entry(uint64_t base_timestamp)
50{
51 /* Call lib/bootblock.c main */
Kyösti Mälkki101ef0b2019-08-18 06:58:42 +030052 bootblock_main_with_basetime(base_timestamp);
Mariusz Szafranskia4041332017-08-02 17:28:17 +020053};
54
Kyösti Mälkki6fcee752021-02-14 15:06:50 +020055static void sanity_check_pci_mmconf(void)
56{
57 u32 pciexbar, base = 0, length = 0;
58
59 pciexbar = pci_io_read_config32(PCH_SA_DEV, PCIEXBAR);
60 assert(pciexbar & (1 << 0));
61
62 switch (pciexbar & MASK_PCIEXBAR_LENGTH) {
63 case MASK_PCIEXBAR_LENGTH_256M:
64 base = pciexbar & MASK_PCIEXBAR_256M;
65 length = 256;
66 break;
67 case MASK_PCIEXBAR_LENGTH_128M:
68 base = pciexbar & MASK_PCIEXBAR_128M;
69 length = 128;
70 break;
71 case MASK_PCIEXBAR_LENGTH_64M:
72 base = pciexbar & MASK_PCIEXBAR_64M;
73 length = 64;
74 break;
75 }
76
Shelley Chen4e9bb332021-10-20 15:43:45 -070077 assert(base == CONFIG_ECAM_MMCONF_BASE_ADDRESS);
78 assert(length == CONFIG_ECAM_MMCONF_BUS_NUMBER);
Kyösti Mälkki6fcee752021-02-14 15:06:50 +020079}
80
Mariusz Szafranskia4041332017-08-02 17:28:17 +020081void bootblock_soc_early_init(void)
82{
83
Julius Wernercd49cce2019-03-05 16:53:33 -080084#if (CONFIG(CONSOLE_SERIAL))
Mariusz Szafranskia4041332017-08-02 17:28:17 +020085 early_uart_init();
86#endif
87};
88
89void bootblock_soc_init(void)
90{
Kyösti Mälkki6fcee752021-02-14 15:06:50 +020091 sanity_check_pci_mmconf();
92
Julius Wernercd49cce2019-03-05 16:53:33 -080093 if (CONFIG(BOOTBLOCK_CONSOLE))
Mariusz Szafranskia4041332017-08-02 17:28:17 +020094 printk(BIOS_DEBUG, "FSP TempRamInit successful...\n");
95};