coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pch.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/mmio.h>
5 #include <device/device.h>
6 #include <device/pci_ops.h>
7 #include <intelblocks/fast_spi.h>
8 #include <intelblocks/gpio.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/gpio.h>
17 #include <soc/iomap.h>
18 #include <soc/lpc.h>
19 #include <soc/p2sb.h>
20 #include <soc/pch.h>
21 #include <soc/pci_devs.h>
22 #include <soc/pcr_ids.h>
23 #include <soc/pm.h>
24 
25 #define PCR_PSF3_TO_SHDW_PMC_REG_BASE_CNP_LP 0x1400
26 #define PCR_PSF3_TO_SHDW_PMC_REG_BASE_CNP_H 0x0980
27 
28 #define PCR_PSFX_TO_SHDW_BAR0 0
29 #define PCR_PSFX_TO_SHDW_BAR1 0x4
30 #define PCR_PSFX_TO_SHDW_BAR2 0x8
31 #define PCR_PSFX_TO_SHDW_BAR3 0xC
32 #define PCR_PSFX_TO_SHDW_BAR4 0x10
33 #define PCR_PSFX_TO_SHDW_PCIEN_IOEN 0x01
34 #define PCR_PSFX_T0_SHDW_PCIEN 0x1C
35 
37 {
38  if (CONFIG(SOC_INTEL_CANNONLAKE_PCH_H))
40  else
42 }
43 
44 static void soc_config_pwrmbase(void)
45 {
46  /*
47  * Assign Resources to PWRMBASE
48  * Clear BIT 1-2 Command Register
49  */
51 
52  /* Program PWRM Base */
54 
55  /* Enable Bus Master and MMIO Space */
57 
58  /* Enable PWRM in PMC */
60 }
61 
63 {
64  /*
65  * Perform P2SB configuration before any another controller initialization as the
66  * controller might want to perform PCR settings.
67  */
70 
73 
74  /*
75  * Enabling PWRM Base for accessing
76  * Global Reset Cause Register.
77  */
79 }
80 
81 static void soc_config_acpibase(void)
82 {
83  uint32_t pmc_reg_value;
84  uint32_t pmc_base_reg;
85 
86  pmc_base_reg = get_pmc_reg_base();
87  if (!pmc_base_reg)
89  "Invalid PMC base address\n");
90 
91  pmc_reg_value = pcr_read32(PID_PSF3, pmc_base_reg +
93 
94  if (pmc_reg_value != 0xFFFFFFFF)
95  {
96  /* Disable Io Space before changing the address */
97  pcr_rmw32(PID_PSF3, pmc_base_reg +
100  /* Program ABASE in PSF3 PMC space BAR4*/
101  pcr_write32(PID_PSF3, pmc_base_reg +
104  /* Enable IO Space */
105  pcr_rmw32(PID_PSF3, pmc_base_reg +
108  }
109 }
110 
112 {
115 
116  /* IO Decode Range */
117  if (CONFIG(DRIVERS_UART_8250IO))
119 
120  /* IO Decode Enable */
121  lpc_enable_fixed_io_ranges(io_enables);
122 
123  /* Program generic IO Decode Range */
124  pch_enable_lpc();
125 }
126 
128 {
129  /*
130  * Clear the GPI interrupt status and enable registers. These
131  * registers do not get reset to default state when booting from S5.
132  */
134 
135  /*
136  * Enabling ABASE for accessing PM1_STS, PM1_EN, PM1_CNT,
137  * GPE0_STS, GPE0_EN registers.
138  */
140 
141  /* Set up GPE configuration */
142  pmc_gpe_init();
143 
145 
146  /* GPIO community PM configuration */
148 }
#define PID_PSF3
Definition: pcr_ids.h:29
#define SPI_BASE_ADDRESS
Definition: iomap.h:8
void p2sb_enable_bar(void)
Definition: p2sb.c:19
void p2sb_configure_hpet(void)
Definition: p2sb.c:29
void pcr_write32(uint8_t pid, uint16_t offset, uint32_t indata)
Definition: pcr.c:124
void pcr_rmw32(uint8_t pid, uint16_t offset, uint32_t anddata, uint32_t ordata)
Definition: pcr.c:154
uint32_t pcr_read32(uint8_t pid, uint16_t offset)
Definition: pcr.c:89
#define die_with_post_code(value, fmt,...)
Definition: console.h:21
@ CONFIG
Definition: dsi_common.h:201
void fast_spi_early_init(uintptr_t spi_base_address)
Definition: fast_spi.c:378
void soc_gpio_pm_configuration(void)
Definition: gpio_common.c:11
void gspi_early_bar_init(void)
#define setbits32(addr, set)
Definition: mmio.h:21
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline void pci_and_config16(const struct device *dev, u16 reg, u16 andmask)
Definition: pci_ops.h:147
static __always_inline void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
Definition: pci_ops.h:180
#define PCH_PWRM_BASE_ADDRESS
Definition: iomap.h:70
#define ACPI_BASE_ADDRESS
Definition: iomap.h:99
#define PWRMBASE
Definition: pmc.h:10
#define PWRM_EN
Definition: pmc.h:145
#define ACTL
Definition: pmc.h:144
#define LPC_IOE_EC_62_66
Definition: lpc_lib.h:18
#define LPC_IOE_LGE_200
Definition: lpc_lib.h:21
#define LPC_IOE_EC_4E_4F
Definition: lpc_lib.h:16
#define LPC_IOE_SUPERIO_2E_2F
Definition: lpc_lib.h:17
#define LPC_IOE_KBC_60_64
Definition: lpc_lib.h:19
uint16_t lpc_enable_fixed_io_ranges(uint16_t io_enables)
Definition: lpc_lib.c:21
void lpc_io_setup_comm_a_b(void)
Definition: lpc_lib.c:249
#define PCI_COMMAND_MASTER
Definition: pci_def.h:13
#define PCI_COMMAND_MEMORY
Definition: pci_def.h:12
#define PCI_COMMAND
Definition: pci_def.h:10
#define POST_HW_INIT_FAILURE
Hardware initialization failure.
Definition: post_codes.h:353
void bootblock_pch_init(void)
Definition: pch.c:114
void bootblock_pch_early_init(void)
Definition: pch.c:59
void pch_early_iorange_init(void)
Definition: pch.c:98
#define PCH_DEV_PMC
Definition: pci_devs.h:236
static void pch_enable_lpc(void)
Definition: early_pch.c:51
#define PCR_PSFX_T0_SHDW_PCIEN
Definition: pch.c:34
#define PCR_PSF3_TO_SHDW_PMC_REG_BASE_CNP_LP
Definition: pch.c:25
#define PCR_PSF3_TO_SHDW_PMC_REG_BASE_CNP_H
Definition: pch.c:26
static void soc_config_pwrmbase(void)
Definition: pch.c:44
static uint32_t get_pmc_reg_base(void)
Definition: pch.c:36
#define PCR_PSFX_TO_SHDW_BAR4
Definition: pch.c:32
static void soc_config_acpibase(void)
Definition: pch.c:81
#define PCR_PSFX_TO_SHDW_PCIEN_IOEN
Definition: pch.c:33
void gpi_clear_int_cfg(void)
Definition: gpio.c:820
void pmc_gpe_init(void)
Definition: pmclib.c:535
void enable_rtc_upper_bank(void)
Definition: rtc.c:18
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14