| 1 |
|
| 2 |
|
| 3 |
#include <device/mmio.h> |
| 4 |
#include <device/device.h> |
| 5 |
#include <device/pci_ops.h> |
| 6 |
#include <intelblocks/fast_spi.h> |
| 7 |
#include <intelblocks/gspi.h> |
| 8 |
#include <intelblocks/lpc_lib.h> |
| 9 |
#include <intelblocks/p2sb.h> |
| 10 |
#include <intelblocks/pcr.h> |
| 11 |
#include <intelblocks/pmclib.h> |
| 12 |
#include <intelblocks/rtc.h> |
| 13 |
#include <intelblocks/systemagent.h> |
| 14 |
#include <intelblocks/tco.h> |
| 15 |
#include <intelblocks/uart.h> |
| 16 |
#include <intelpch/espi.h> |
| 17 |
#include <soc/bootblock.h> |
| 18 |
#include <soc/iomap.h> |
| 19 |
#include <soc/p2sb.h> |
| 20 |
#include <soc/pci_devs.h> |
| 21 |
#include <soc/pcr_ids.h> |
| 22 |
#include <soc/pm.h> |
| 23 |
|
| 24 |
#define PCR_PSF8_TO_SHDW_PMC_REG_BASE 0xA00 |
| 25 |
#define PCR_PSFX_TO_SHDW_BAR0 0 |
| 26 |
#define PCR_PSFX_TO_SHDW_BAR1 0x4 |
| 27 |
#define PCR_PSFX_TO_SHDW_BAR2 0x8 |
| 28 |
#define PCR_PSFX_TO_SHDW_BAR3 0xC |
| 29 |
#define PCR_PSFX_TO_SHDW_BAR4 0x10 |
| 30 |
#define PCR_PSFX_TO_SHDW_PCIEN_IOEN 0x01 |
| 31 |
#define PCR_PSFX_T0_SHDW_PCIEN 0x1C |
| 32 |
|
| 33 |
#define PCR_DMI_ACPIBA 0x27B4 |
| 34 |
#define PCR_DMI_ACPIBDID 0x27B8 |
| 35 |
#define PCR_DMI_PMBASEA 0x27AC |
| 36 |
#define PCR_DMI_PMBASEC 0x27B0 |
| 37 |
|
| 38 |
static void soc_die_config_pwrmbase(void) |
| 39 |
{ |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
pci_and_config16(PCI_DEV_PMC, PCI_COMMAND, ~(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER)); |
| 45 |
|
| 46 |
|
| 47 |
pci_write_config32(PCI_DEV_PMC, PWRMBASE, PCH_PWRM_BASE_ADDRESS); |
| 48 |
|
| 49 |
|
| 50 |
pci_or_config16(PCI_DEV_PMC, PCI_COMMAND, (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER)); |
| 51 |
|
| 52 |
|
| 53 |
setbits32((void *)PCH_PWRM_BASE_ADDRESS + ACTL, PWRM_EN); |
| 54 |
} |
| 55 |
|
| 56 |
static void soc_die_early_iorange_init(void) |
| 57 |
{ |
| 58 |
uint16_t io_enables = LPC_IOE_LPT_EN | LPC_IOE_FDD_EN | |
| 59 |
LPC_IOE_LGE_200 | LPC_IOE_HGE_208 | |
| 60 |
LPC_IOE_KBC_60_64 | LPC_IOE_EC_62_66 | |
| 61 |
LPC_IOE_SUPERIO_2E_2F | LPC_IOE_EC_4E_4F; |
| 62 |
|
| 63 |
|
| 64 |
if (CONFIG(DRIVERS_UART_8250IO)) |
| 65 |
lpc_io_setup_comm_a_b(); |
| 66 |
|
| 67 |
|
| 68 |
lpc_enable_fixed_io_ranges(io_enables); |
| 69 |
|
| 70 |
|
| 71 |
pch_enable_lpc(); |
| 72 |
} |
| 73 |
|
| 74 |
static void soc_die_early_ip_init(void) |
| 75 |
{ |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
p2sb_enable_bar(); |
| 81 |
p2sb_configure_hpet(); |
| 82 |
|
| 83 |
fast_spi_early_init(SPI_BASE_ADDRESS); |
| 84 |
gspi_early_bar_init(); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
soc_die_config_pwrmbase(); |
| 91 |
} |
| 92 |
|
| 93 |
static void soc_die_early_sa_init(void) |
| 94 |
{ |
| 95 |
const struct sa_mmio_descriptor soc_fixed_pci_resources[] = { |
| 96 |
{ MCHBAR, MCH_BASE_ADDRESS, MCH_BASE_SIZE, "MCHBAR" }, |
| 97 |
}; |
| 98 |
|
| 99 |
bootblock_systemagent_early_init(); |
| 100 |
|
| 101 |
|
| 102 |
sa_set_pci_bar(soc_fixed_pci_resources, ARRAY_SIZE(soc_fixed_pci_resources)); |
| 103 |
} |
| 104 |
|
| 105 |
void bootblock_soc_die_early_init(void) |
| 106 |
{ |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
soc_die_early_sa_init(); |
| 112 |
|
| 113 |
soc_die_early_ip_init(); |
| 114 |
|
| 115 |
fast_spi_cache_bios_region(); |
| 116 |
soc_die_early_iorange_init(); |
| 117 |
if (CONFIG(INTEL_LPSS_UART_FOR_CONSOLE)) |
| 118 |
uart_bootblock_init(); |
| 119 |
} |
| 120 |
|
| 121 |
static void soc_die_config_acpibase(void) |
| 122 |
{ |
| 123 |
uint32_t pmc_reg_value; |
| 124 |
uint32_t pmc_base_reg = PCR_PSF8_TO_SHDW_PMC_REG_BASE; |
| 125 |
|
| 126 |
pmc_reg_value = pcr_read32(PID_PSF8, pmc_base_reg + PCR_PSFX_TO_SHDW_BAR4); |
| 127 |
|
| 128 |
if (pmc_reg_value != 0xffffffff) { |
| 129 |
|
| 130 |
pcr_rmw32(PID_PSF8, pmc_base_reg + PCR_PSFX_T0_SHDW_PCIEN, |
| 131 |
~PCR_PSFX_TO_SHDW_PCIEN_IOEN, 0); |
| 132 |
|
| 133 |
pcr_write32(PID_PSF8, pmc_base_reg + PCR_PSFX_TO_SHDW_BAR4, |
| 134 |
ACPI_BASE_ADDRESS); |
| 135 |
|
| 136 |
pcr_rmw32(PID_PSF8, pmc_base_reg + PCR_PSFX_T0_SHDW_PCIEN, |
| 137 |
~0, PCR_PSFX_TO_SHDW_PCIEN_IOEN); |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
void bootblock_soc_die_init(void) |
| 142 |
{ |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
soc_die_config_acpibase(); |
| 148 |
|
| 149 |
|
| 150 |
pmc_gpe_init(); |
| 151 |
|
| 152 |
enable_rtc_upper_bank(); |
| 153 |
|
| 154 |
|
| 155 |
tco_configure(); |
| 156 |
} |