| 1 |
|
| 2 |
|
| 3 |
#include <bootblock_common.h> |
| 4 |
#include <cpu/x86/pae.h> |
| 5 |
#include <device/pci.h> |
| 6 |
#include <device/pci_ops.h> |
| 7 |
#include <gpio.h> |
| 8 |
#include <intelblocks/cpulib.h> |
| 9 |
#include <intelblocks/fast_spi.h> |
| 10 |
#include <intelblocks/lpc_lib.h> |
| 11 |
#include <intelblocks/p2sb.h> |
| 12 |
#include <intelblocks/pcr.h> |
| 13 |
#include <intelblocks/rtc.h> |
| 14 |
#include <intelblocks/systemagent.h> |
| 15 |
#include <intelblocks/pmclib.h> |
| 16 |
#include <intelblocks/tco.h> |
| 17 |
#include <intelblocks/uart.h> |
| 18 |
#include <soc/iomap.h> |
| 19 |
#include <soc/cpu.h> |
| 20 |
#include <soc/loader.h> |
| 21 |
#include <soc/gpio.h> |
| 22 |
#include <soc/measured_boot.h> |
| 23 |
#include <soc/soc_chip.h> |
| 24 |
#include <soc/systemagent.h> |
| 25 |
#include <soc/pci_devs.h> |
| 26 |
#include <soc/pm.h> |
| 27 |
#include <spi-generic.h> |
| 28 |
#include <static.h> |
| 29 |
|
| 30 |
static const struct pad_config tpm_spi_configs[] = { |
| 31 |
#if CONFIG(SOC_INTEL_GEMINILAKE) |
| 32 |
PAD_CFG_NF(GPIO_81, NATIVE, DEEP, NF3), |
| 33 |
#else |
| 34 |
PAD_CFG_NF(GPIO_106, NATIVE, DEEP, NF3), |
| 35 |
#endif |
| 36 |
}; |
| 37 |
|
| 38 |
static void tpm_enable(void) |
| 39 |
{ |
| 40 |
|
| 41 |
gpio_configure_pads(tpm_spi_configs, ARRAY_SIZE(tpm_spi_configs)); |
| 42 |
} |
| 43 |
|
| 44 |
asmlinkage void bootblock_c_entry(uint64_t base_timestamp) |
| 45 |
{ |
| 46 |
pci_devfn_t dev; |
| 47 |
bool ibb_exists; |
| 48 |
struct boot_policy_manifest bpm_info; |
| 49 |
|
| 50 |
bootblock_systemagent_early_init(); |
| 51 |
|
| 52 |
p2sb_enable_bar(); |
| 53 |
p2sb_configure_hpet(); |
| 54 |
|
| 55 |
|
| 56 |
dev = PCH_DEV_PMC; |
| 57 |
pci_write_config16(dev, PCI_BASE_ADDRESS_4, ACPI_BASE_ADDRESS); |
| 58 |
pci_write_config16(dev, PCI_COMMAND, |
| 59 |
PCI_COMMAND_IO | PCI_COMMAND_MASTER); |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
if (CONFIG(IFWI_MEASURED_BOOT)) |
| 66 |
ibb_exists = fetch_pre_rbp_data(&bpm_info); |
| 67 |
|
| 68 |
enable_rtc_upper_bank(); |
| 69 |
|
| 70 |
if (CONFIG(IFWI_IBBM_LOAD)) { |
| 71 |
load_ibb(CONFIG_IBBM_ROM_ADDR, CONFIG_IBBM_ROM_SIZE); |
| 72 |
flush_l1d_to_l2(); |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
if (CONFIG(IFWI_MEASURED_BOOT) && ibb_exists) |
| 80 |
fetch_post_rbp_data(&bpm_info); |
| 81 |
|
| 82 |
|
| 83 |
bootblock_main_with_basetime(base_timestamp); |
| 84 |
} |
| 85 |
|
| 86 |
static void enable_pmcbar(void) |
| 87 |
{ |
| 88 |
pci_devfn_t pmc = PCH_DEV_PMC; |
| 89 |
|
| 90 |
|
| 91 |
pci_write_config32(pmc, PCI_BASE_ADDRESS_0, PCH_PWRM_BASE_ADDRESS); |
| 92 |
pci_write_config32(pmc, PCI_BASE_ADDRESS_1, 0); |
| 93 |
pci_write_config32(pmc, PCI_BASE_ADDRESS_2, PMC_BAR1); |
| 94 |
pci_write_config32(pmc, PCI_BASE_ADDRESS_3, 0); |
| 95 |
pci_write_config16(pmc, PCI_BASE_ADDRESS_4, ACPI_BASE_ADDRESS); |
| 96 |
pci_write_config16(pmc, PCI_COMMAND, |
| 97 |
PCI_COMMAND_IO | PCI_COMMAND_MEMORY | |
| 98 |
PCI_COMMAND_MASTER); |
| 99 |
} |
| 100 |
|
| 101 |
void bootblock_soc_early_init(void) |
| 102 |
{ |
| 103 |
enable_pmcbar(); |
| 104 |
|
| 105 |
|
| 106 |
pmc_global_reset_enable(0); |
| 107 |
|
| 108 |
|
| 109 |
if (CONFIG(INTEL_LPSS_UART_FOR_CONSOLE)) |
| 110 |
uart_bootblock_init(); |
| 111 |
|
| 112 |
uint16_t io_enables = LPC_IOE_SUPERIO_2E_2F | LPC_IOE_KBC_60_64 | |
| 113 |
LPC_IOE_EC_62_66; |
| 114 |
|
| 115 |
const config_t *config = config_of_soc(); |
| 116 |
|
| 117 |
|
| 118 |
if (config->lpc_ioe) { |
| 119 |
io_enables = config->lpc_ioe & 0x3f0f; |
| 120 |
lpc_set_fixed_io_ranges(config->lpc_iod, 0x1377); |
| 121 |
} else { |
| 122 |
|
| 123 |
if (CONFIG(DRIVERS_UART_8250IO)) |
| 124 |
lpc_io_setup_comm_a_b(); |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
lpc_enable_fixed_io_ranges(io_enables); |
| 129 |
|
| 130 |
|
| 131 |
pch_enable_lpc(); |
| 132 |
|
| 133 |
if (CONFIG(TPM_ON_FAST_SPI)) |
| 134 |
tpm_enable(); |
| 135 |
|
| 136 |
enable_pm_timer_emulation(); |
| 137 |
|
| 138 |
fast_spi_early_init(SPI_BASE_ADDRESS); |
| 139 |
|
| 140 |
fast_spi_cache_bios_region(); |
| 141 |
|
| 142 |
|
| 143 |
pmc_gpe_init(); |
| 144 |
|
| 145 |
|
| 146 |
tco_configure(); |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
if (CONFIG(PAGING_IN_CACHE_AS_RAM)) { |
| 152 |
paging_set_nxe(1); |
| 153 |
paging_set_default_pat(); |
| 154 |
paging_enable_for_car("pdpt", "pt"); |
| 155 |
} |
| 156 |
} |