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 #include <device/pci_ops.h>
3 #include <device/device.h>
4 #include <device/pci_def.h>
5 #include <intelblocks/fast_spi.h>
6 #include <intelblocks/gspi.h>
7 #include <intelblocks/itss.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 <soc/bootblock.h>
14 #include <soc/iomap.h>
15 #include <soc/p2sb.h>
16 #include <soc/pch.h>
17 #include <soc/pci_devs.h>
18 #include <soc/pcr_ids.h>
19 #include <soc/pm.h>
20 #include <soc/pmc.h>
21 #include "../chip.h"
22 
23 #define PCR_DMI_ACPIBA 0x27B4
24 #define PCR_DMI_ACPIBDID 0x27B8
25 #define PCR_DMI_PMBASEA 0x27AC
26 #define PCR_DMI_PMBASEC 0x27B0
27 
29 {
30  /*
31  * Perform P2SB configuration before any another controller initialization as the
32  * controller might want to perform PCR settings.
33  */
36 
38 }
39 
40 static void soc_config_acpibase(void)
41 {
42  uint32_t reg32;
43 
44  /* Disable ABASE in PMC Device first before changing Base Address */
47 
48  /* Program ACPI Base */
50 
51  /* Enable ACPI in PMC */
53 
54  /*
55  * Program "ACPI Base Address" PCR[DMI] + 27B4h[23:18, 15:2, 0]
56  * to [0x3F, PMC PCI Offset 40h bit[15:2], 1]
57  */
58  reg32 = ((0x3f << 18) | ACPI_BASE_ADDRESS | 1);
60  if (CONFIG(SKYLAKE_SOC_PCH_H))
62  else
64 }
65 
66 static void soc_config_pwrmbase(void)
67 {
68  uint32_t reg32;
69 
70  /* Disable PWRMBASE in PMC Device first before changing Base address */
73 
74  /* Program PWRM Base */
76 
77  /* Enable PWRM in PMC */
79 
80  /*
81  * Program "PM Base Address Memory Range Base" PCR[DMI] + 27ACh[15:0]
82  * to the same value programmed in PMC PCI Offset 48h bit[31:16],
83  * this has an implication of making sure the PWRMBASE to be
84  * 64KB aligned.
85  *
86  * Program "PM Base Address Memory Range Limit" PCR[DMI] + 27ACh[31:16]
87  * to the value programmed in PMC PCI Offset 48h bit[31:16], this has an
88  * implication of making sure the memory allocated to PWRMBASE to be
89  * 64KB in size.
90  */
92  ((PCH_PWRM_BASE_ADDRESS & 0xFFFF0000) |
93  (PCH_PWRM_BASE_ADDRESS >> 16)));
94  if (CONFIG(SKYLAKE_SOC_PCH_H))
95  pcr_write32(PID_DMI, PCR_DMI_PMBASEC, 0x800023a8);
96  else
97  pcr_write32(PID_DMI, PCR_DMI_PMBASEC, 0x800023a0);
98 }
99 
101 {
104 
105  const config_t *config = config_of_soc();
106 
107  if (config->lpc_ioe) {
108  io_enables = config->lpc_ioe & 0x3f0f;
109  lpc_set_fixed_io_ranges(config->lpc_iod, 0x1377);
110  } else {
111  /* IO Decode Range */
112  if (CONFIG(DRIVERS_UART_8250IO))
114  }
115 
116  /* IO Decode Enable */
117  lpc_enable_fixed_io_ranges(io_enables);
118 
119  /* Program generic IO Decode Range */
120  pch_enable_lpc();
121 }
122 
124 {
125  /*
126  * Enabling ABASE for accessing PM1_STS, PM1_EN, PM1_CNT,
127  * GPE0_STS, GPE0_EN registers.
128  */
130 
131  /*
132  * Enabling PWRM Base for accessing
133  * Global Reset Cause Register.
134  */
136 
137  /* Set up GPE configuration */
138  pmc_gpe_init();
139 
141 
143 }
#define PID_DMI
Definition: pcr_ids.h:23
#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
@ CONFIG
Definition: dsi_common.h:201
void fast_spi_early_init(uintptr_t spi_base_address)
Definition: fast_spi.c:378
void gspi_early_bar_init(void)
#define config_of_soc()
Definition: device.h:394
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
#define PCH_PWRM_BASE_ADDRESS
Definition: iomap.h:70
#define ACPI_BASE_ADDRESS
Definition: iomap.h:99
#define ACPI_EN
Definition: pmc.h:146
#define ABASE
Definition: pmc.h:11
#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
uint16_t lpc_set_fixed_io_ranges(uint16_t io_ranges, uint16_t mask)
Definition: lpc_lib.c:39
#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
enum board_config config
Definition: memory.c:448
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
void pmc_gpe_init(void)
Definition: pmclib.c:535
void enable_rtc_upper_bank(void)
Definition: rtc.c:18
static void soc_config_pwrmbase(void)
Definition: pch.c:66
#define PCR_DMI_ACPIBDID
Definition: pch.c:24
#define PCR_DMI_PMBASEA
Definition: pch.c:25
#define PCR_DMI_ACPIBA
Definition: pch.c:23
#define PCR_DMI_PMBASEC
Definition: pch.c:26
static void soc_config_acpibase(void)
Definition: pch.c:40
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14