| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <device/mmio.h> |
| 5 |
#include <device/device.h> |
| 6 |
#include <device/pci_ops.h> |
| 7 |
#include <gpio.h> |
| 8 |
#include <intelblocks/fast_spi.h> |
| 9 |
#include <intelblocks/gspi.h> |
| 10 |
#include <intelblocks/lpc_lib.h> |
| 11 |
#include <intelblocks/p2sb.h> |
| 12 |
#include <intelblocks/pcr.h> |
| 13 |
#include <intelblocks/pmclib.h> |
| 14 |
#include <intelblocks/rtc.h> |
| 15 |
#include <soc/bootblock.h> |
| 16 |
#include <soc/iomap.h> |
| 17 |
#include <soc/lpc.h> |
| 18 |
#include <soc/p2sb.h> |
| 19 |
#include <soc/pch.h> |
| 20 |
#include <soc/pci_devs.h> |
| 21 |
#include <soc/pcr_ids.h> |
| 22 |
#include <soc/pm.h> |
| 23 |
|
| 24 |
#define PCR_PSF3_TO_SHDW_PMC_REG_BASE_CNP_LP 0x1400 |
| 25 |
#define PCR_PSF3_TO_SHDW_PMC_REG_BASE_CNP_H 0x0980 |
| 26 |
|
| 27 |
#define PCR_PSFX_TO_SHDW_BAR0 0 |
| 28 |
#define PCR_PSFX_TO_SHDW_BAR1 0x4 |
| 29 |
#define PCR_PSFX_TO_SHDW_BAR2 0x8 |
| 30 |
#define PCR_PSFX_TO_SHDW_BAR3 0xC |
| 31 |
#define PCR_PSFX_TO_SHDW_BAR4 0x10 |
| 32 |
#define PCR_PSFX_TO_SHDW_PCIEN_IOEN 0x01 |
| 33 |
#define PCR_PSFX_T0_SHDW_PCIEN 0x1C |
| 34 |
|
| 35 |
static uint32_t get_pmc_reg_base(void) |
| 36 |
{ |
| 37 |
if (CONFIG(SOC_INTEL_CANNONLAKE_PCH_H)) |
| 38 |
return PCR_PSF3_TO_SHDW_PMC_REG_BASE_CNP_H; |
| 39 |
else |
| 40 |
return PCR_PSF3_TO_SHDW_PMC_REG_BASE_CNP_LP; |
| 41 |
} |
| 42 |
|
| 43 |
static void soc_config_pwrmbase(void) |
| 44 |
{ |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
pci_and_config16(PCH_DEV_PMC, PCI_COMMAND, ~(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER)); |
| 50 |
|
| 51 |
|
| 52 |
pci_write_config32(PCH_DEV_PMC, PWRMBASE, PCH_PWRM_BASE_ADDRESS); |
| 53 |
|
| 54 |
|
| 55 |
pci_or_config16(PCH_DEV_PMC, PCI_COMMAND, (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER)); |
| 56 |
|
| 57 |
|
| 58 |
setbits32((void *)PCH_PWRM_BASE_ADDRESS + ACTL, PWRM_EN); |
| 59 |
} |
| 60 |
|
| 61 |
void bootblock_pch_early_init(void) |
| 62 |
{ |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
p2sb_enable_bar(); |
| 68 |
p2sb_configure_hpet(); |
| 69 |
|
| 70 |
fast_spi_early_init(SPI_BASE_ADDRESS); |
| 71 |
gspi_early_bar_init(); |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
soc_config_pwrmbase(); |
| 78 |
} |
| 79 |
|
| 80 |
static void soc_config_acpibase(void) |
| 81 |
{ |
| 82 |
uint32_t pmc_reg_value; |
| 83 |
uint32_t pmc_base_reg; |
| 84 |
|
| 85 |
pmc_base_reg = get_pmc_reg_base(); |
| 86 |
if (!pmc_base_reg) |
| 87 |
die_with_post_code(POSTCODE_HW_INIT_FAILURE, |
| 88 |
"Invalid PMC base address\n"); |
| 89 |
|
| 90 |
pmc_reg_value = pcr_read32(PID_PSF3, pmc_base_reg + |
| 91 |
PCR_PSFX_TO_SHDW_BAR4); |
| 92 |
|
| 93 |
if (pmc_reg_value != 0xFFFFFFFF) |
| 94 |
{ |
| 95 |
|
| 96 |
pcr_rmw32(PID_PSF3, pmc_base_reg + |
| 97 |
PCR_PSFX_T0_SHDW_PCIEN, |
| 98 |
~PCR_PSFX_TO_SHDW_PCIEN_IOEN, 0); |
| 99 |
|
| 100 |
pcr_write32(PID_PSF3, pmc_base_reg + |
| 101 |
PCR_PSFX_TO_SHDW_BAR4, |
| 102 |
ACPI_BASE_ADDRESS); |
| 103 |
|
| 104 |
pcr_rmw32(PID_PSF3, pmc_base_reg + |
| 105 |
PCR_PSFX_T0_SHDW_PCIEN, |
| 106 |
~0, PCR_PSFX_TO_SHDW_PCIEN_IOEN); |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
void pch_early_iorange_init(void) |
| 111 |
{ |
| 112 |
uint16_t io_enables = LPC_IOE_EC_4E_4F | LPC_IOE_SUPERIO_2E_2F | LPC_IOE_KBC_60_64 | |
| 113 |
LPC_IOE_EC_62_66 | LPC_IOE_LGE_200; |
| 114 |
|
| 115 |
|
| 116 |
if (CONFIG(DRIVERS_UART_8250IO)) |
| 117 |
lpc_io_setup_comm_a_b(); |
| 118 |
|
| 119 |
|
| 120 |
lpc_enable_fixed_io_ranges(io_enables); |
| 121 |
|
| 122 |
|
| 123 |
pch_enable_lpc(); |
| 124 |
} |
| 125 |
|
| 126 |
void bootblock_pch_init(void) |
| 127 |
{ |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
gpi_clear_int_cfg(); |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
soc_config_acpibase(); |
| 139 |
|
| 140 |
|
| 141 |
pmc_gpe_init(); |
| 142 |
|
| 143 |
enable_rtc_upper_bank(); |
| 144 |
|
| 145 |
|
| 146 |
soc_gpio_pm_configuration(); |
| 147 |
} |