Debian Codegraph @

src/soc/intel/skylake/bootblock/pch.c

raw symbols SCIP
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 <static.h>
22 #include "../chip.h"
23
24 #define PCR_DMI_ACPIBA 0x27B4
25 #define PCR_DMI_ACPIBDID 0x27B8
26 #define PCR_DMI_PMBASEA 0x27AC
27 #define PCR_DMI_PMBASEC 0x27B0
28
29 void bootblock_pch_early_init(void)
30 {
31 /*
32 * Perform P2SB configuration before any another controller initialization as the
33 * controller might want to perform PCR settings.
34 */
35 p2sb_enable_bar();
36 p2sb_configure_hpet();
37
38 fast_spi_early_init(SPI_BASE_ADDRESS);
39 }
40
41 static void soc_config_acpibase(void)
42 {
43 uint32_t reg32;
44
45 /* Disable ABASE in PMC Device first before changing Base Address */
46 reg32 = pci_read_config32(PCH_DEV_PMC, ACTL);
47 pci_write_config32(PCH_DEV_PMC, ACTL, reg32 & ~ACPI_EN);
48
49 /* Program ACPI Base */
50 pci_write_config32(PCH_DEV_PMC, ABASE, ACPI_BASE_ADDRESS);
51
52 /* Enable ACPI in PMC */
53 pci_write_config32(PCH_DEV_PMC, ACTL, reg32 | ACPI_EN);
54
55 /*
56 * Program "ACPI Base Address" PCR[DMI] + 27B4h[23:18, 15:2, 0]
57 * to [0x3F, PMC PCI Offset 40h bit[15:2], 1]
58 */
59 reg32 = ((0x3f << 18) | ACPI_BASE_ADDRESS | 1);
60 pcr_write32(PID_DMI, PCR_DMI_ACPIBA, reg32);
61 if (CONFIG(SKYLAKE_SOC_PCH_H))
62 pcr_write32(PID_DMI, PCR_DMI_ACPIBDID, 0x23a8);
63 else
64 pcr_write32(PID_DMI, PCR_DMI_ACPIBDID, 0x23a0);
65 }
66
67 static void soc_config_pwrmbase(void)
68 {
69 uint32_t reg32;
70
71 /* Disable PWRMBASE in PMC Device first before changing Base address */
72 reg32 = pci_read_config32(PCH_DEV_PMC, ACTL);
73 pci_write_config32(PCH_DEV_PMC, ACTL, reg32 & ~PWRM_EN);
74
75 /* Program PWRM Base */
76 pci_write_config32(PCH_DEV_PMC, PWRMBASE, PCH_PWRM_BASE_ADDRESS);
77
78 /* Enable PWRM in PMC */
79 pci_write_config32(PCH_DEV_PMC, ACTL, reg32 | PWRM_EN);
80
81 /*
82 * Program "PM Base Address Memory Range Base" PCR[DMI] + 27ACh[15:0]
83 * to the same value programmed in PMC PCI Offset 48h bit[31:16],
84 * this has an implication of making sure the PWRMBASE to be
85 * 64KB aligned.
86 *
87 * Program "PM Base Address Memory Range Limit" PCR[DMI] + 27ACh[31:16]
88 * to the value programmed in PMC PCI Offset 48h bit[31:16], this has an
89 * implication of making sure the memory allocated to PWRMBASE to be
90 * 64KB in size.
91 */
92 pcr_write32(PID_DMI, PCR_DMI_PMBASEA,
93 ((PCH_PWRM_BASE_ADDRESS & 0xFFFF0000) |
94 (PCH_PWRM_BASE_ADDRESS >> 16)));
95 if (CONFIG(SKYLAKE_SOC_PCH_H))
96 pcr_write32(PID_DMI, PCR_DMI_PMBASEC, 0x800023a8);
97 else
98 pcr_write32(PID_DMI, PCR_DMI_PMBASEC, 0x800023a0);
99 }
100
101 void pch_early_iorange_init(void)
102 {
103 uint16_t io_enables = LPC_IOE_SUPERIO_2E_2F | LPC_IOE_KBC_60_64 |
104 LPC_IOE_EC_62_66;
105
106 const config_t *config = config_of_soc();
107
108 if (config->lpc_ioe) {
109 io_enables = config->lpc_ioe & 0x3f0f;
110 lpc_set_fixed_io_ranges(config->lpc_iod, 0x1377);
111 } else {
112 /* IO Decode Range */
113 if (CONFIG(DRIVERS_UART_8250IO))
114 lpc_io_setup_comm_a_b();
115 }
116
117 /* IO Decode Enable */
118 lpc_enable_fixed_io_ranges(io_enables);
119
120 /* Program generic IO Decode Range */
121 pch_enable_lpc();
122 }
123
124 void bootblock_pch_init(void)
125 {
126 /*
127 * Enabling ABASE for accessing PM1_STS, PM1_EN, PM1_CNT,
128 * GPE0_STS, GPE0_EN registers.
129 */
130 soc_config_acpibase();
131
132 /*
133 * Enabling PWRM Base for accessing
134 * Global Reset Cause Register.
135 */
136 soc_config_pwrmbase();
137
138 /* Set up GPE configuration */
139 pmc_gpe_init();
140
141 enable_rtc_upper_bank();
142
143 gspi_early_bar_init();
144 }