Debian Codegraph @

src/soc/intel/pantherlake/chip.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <device/device.h>
4 #include <device/pci.h>
5 #include <fsp/api.h>
6 #include <fsp/util.h>
7 #include <gpio.h>
8 #include <intelblocks/acpi.h>
9 #include <intelblocks/cfg.h>
10 #include <intelblocks/cse.h>
11 #include <intelblocks/irq.h>
12 #include <intelblocks/itss.h>
13 #include <intelblocks/p2sb.h>
14 #include <intelblocks/pcie_rp.h>
15 #include <intelblocks/systemagent.h>
16 #include <intelblocks/tcss.h>
17 #include <intelblocks/xdci.h>
18 #include <soc/intel/common/reset.h>
19 #include <soc/intel/common/vbt.h>
20 #include <soc/iomap.h>
21 #include <soc/p2sb.h>
22 #include <soc/pci_devs.h>
23 #include <soc/pcie.h>
24 #include <soc/ramstage.h>
25 #include <soc/soc_chip.h>
26 #include <soc/tcss.h>
27 #include <static.h>
28
29 #if CONFIG(HAVE_ACPI_TABLES)
30 const char *soc_acpi_name(const struct device *dev)
31 {
32 if (dev->path.type == DEVICE_PATH_DOMAIN)
33 return "PCI0";
34
35 if (dev->path.type == DEVICE_PATH_USB) {
36 switch (dev->path.usb.port_type) {
37 case 0:
38 /* Root Hub */
39 return "RHUB";
40 case 2:
41 /* USB2 ports */
42 switch (dev->path.usb.port_id) {
43 case 0: return "HS01";
44 case 1: return "HS02";
45 case 2: return "HS03";
46 case 3: return "HS04";
47 case 4: return "HS05";
48 case 5: return "HS06";
49 case 6: return "HS07";
50 case 7: return "HS08";
51 }
52 break;
53 case 3:
54 /* USB3 ports */
55 switch (dev->path.usb.port_id) {
56 case 0: return "SS01";
57 case 1: return "SS02";
58 case 2: return "SS03";
59 case 3: return "SS04";
60 }
61 break;
62 }
63 printk(BIOS_ERR, "Missing ACPI Name for USB port_type=0x%x\n",
64 dev->path.usb.port_type);
65 return NULL;
66 }
67 if (dev->path.type != DEVICE_PATH_PCI) {
68 printk(BIOS_ERR, "Missing ACPI Name for USB path_type=0x%x\n",
69 dev->path.type);
70 return NULL;
71 }
72
73 switch (dev->path.pci.devfn) {
74 case PCI_DEVFN_ROOT: return "MCHC";
75 case PCI_DEVFN_IGD: return "GFX0";
76 case PCI_DEVFN_TCSS_XHCI: return "TXHC";
77 case PCI_DEVFN_TCSS_XDCI: return "TXDC";
78 case PCI_DEVFN_TCSS_DMA0: return "TDM0";
79 case PCI_DEVFN_TCSS_DMA1: return "TDM1";
80 case PCI_DEVFN_TBT0: return "TRP0";
81 case PCI_DEVFN_TBT1: return "TRP1";
82 case PCI_DEVFN_TBT2: return "TRP2";
83 case PCI_DEVFN_TBT3: return "TRP3";
84 case PCI_DEVFN_THC0: return "THC0";
85 case PCI_DEVFN_THC1: return "THC1";
86 case PCI_DEVFN_NPU: return "NPU";
87 case PCI_DEVFN_IPU: return "IPU0";
88 case PCI_DEVFN_ISH: return "ISHB";
89 case PCI_DEVFN_GSPI2: return "SPI2";
90 case PCI_DEVFN_XHCI: return "XHCI";
91 case PCI_DEVFN_SRAM: return "SRAM";
92 case PCI_DEVFN_I2C0: return "I2C0";
93 case PCI_DEVFN_I2C1: return "I2C1";
94 case PCI_DEVFN_I2C2: return "I2C2";
95 case PCI_DEVFN_I2C3: return "I2C3";
96 case PCI_DEVFN_I2C4: return "I2C4";
97 case PCI_DEVFN_I2C5: return "I2C5";
98 case PCI_DEVFN_CSE: return "HECI";
99 case PCI_DEVFN_PCIE1: return "RP01";
100 case PCI_DEVFN_PCIE2: return "RP02";
101 case PCI_DEVFN_PCIE3: return "RP03";
102 case PCI_DEVFN_PCIE4: return "RP04";
103 case PCI_DEVFN_PCIE5: return "RP05";
104 case PCI_DEVFN_PCIE6: return "RP06";
105 #if CONFIG(SOC_INTEL_PANTHERLAKE)
106 case PCI_DEVFN_PCIE7: return "RP07";
107 case PCI_DEVFN_PCIE8: return "RP08";
108 case PCI_DEVFN_PCIE9: return "RP09";
109 case PCI_DEVFN_PCIE10: return "RP10";
110 case PCI_DEVFN_PCIE11: return "RP11";
111 case PCI_DEVFN_PCIE12: return "RP12";
112 #endif
113 case PCI_DEVFN_PMC: return "PMC";
114 case PCI_DEVFN_UART0: return "UAR0";
115 case PCI_DEVFN_UART1: return "UAR1";
116 case PCI_DEVFN_UART2: return "UAR2";
117 case PCI_DEVFN_GSPI0: return "SPI0";
118 case PCI_DEVFN_GSPI1: return "SPI1";
119 /* Keeping ACPI device name coherent with ec.asl */
120 case PCI_DEVFN_ESPI: return "LPCB";
121 case PCI_DEVFN_SPI: return "FSPI";
122 case PCI_DEVFN_HDA: return "HDAS";
123 case PCI_DEVFN_SMBUS: return "SBUS";
124 case PCI_DEVFN_GBE: return "GLAN";
125 }
126 printk(BIOS_ERR, "Missing ACPI Name for PCI: 00:%02x.%01x\n",
127 PCI_SLOT(dev->path.pci.devfn), PCI_FUNC(dev->path.pci.devfn));
128 return NULL;
129 }
130 #endif
131
132 #if CONFIG(SOC_INTEL_STORE_ISH_FW_VERSION)
133 /* SoC override API to identify if ISH Firmware existed inside CSE FPT */
134 bool soc_is_ish_partition_enabled(void)
135 {
136 struct device *ish = pcidev_path_on_root(PCI_DEVFN_ISH);
137 uint16_t ish_pci_id = ish ? pci_read_config16(ish, PCI_DEVICE_ID) : 0xFFFF;
138
139 if (ish_pci_id == 0xFFFF)
140 return false;
141
142 return true;
143 }
144 #endif
145
146 /* SoC routine to fill GPIO PM mask and value for GPIO_MISCCFG register */
147 static void soc_fill_gpio_pm_configuration(void)
148 {
149 uint8_t value[TOTAL_GPIO_COMM];
150 const struct soc_intel_pantherlake_config *config = config_of_soc();
151
152 if (config->gpio_override_pm)
153 memcpy(value, config->gpio_pm, sizeof(value));
154 else
155 memset(value, MISCCFG_GPIO_PM_CONFIG_BITS, sizeof(value));
156
157 gpio_pm_configure(value, TOTAL_GPIO_COMM);
158 }
159
160 /* Enable tracehub in device tree */
161 static void soc_enable_tracehub(void)
162 {
163 struct device *dev;
164
165 dev = pcidev_path_on_root(PCI_DEVFN_NPK);
166 if (dev) {
167 dev->enabled = 1;
168 printk(BIOS_DEBUG, "Tracehub is enabled.\n");
169 }
170 }
171
172 void soc_init_pre_device(void *chip_info)
173 {
174 struct soc_intel_pantherlake_config *config = config_of_soc();
175 if (config == NULL) {
176 printk(BIOS_ERR, "Error: Configuration could not be retrieved.\n");
177 return;
178 }
179 /* Validate TBT image authentication */
180 config->tbt_authentication = p2sb2_sbi_read(PID_IOM,
181 IOM_CSME_IMR_TBT_STATUS) & TBT_VALID_AUTHENTICATION;
182
183 if (CONFIG(SOC_INTEL_COMMON_BLOCK_TRACEHUB))
184 soc_enable_tracehub();
185
186 /* Perform silicon specific init. */
187 fsp_silicon_init();
188
189 /* Display FIRMWARE_VERSION_INFO_HOB */
190 fsp_display_fvi_version_hob();
191
192 soc_fill_gpio_pm_configuration();
193
194 /* Swap enabled PCI ports in device tree if needed. */
195 pcie_rp_update_devicetree(get_pcie_rp_table());
196
197 /* Swap enabled TBT root ports in device tree if needed. */
198 pcie_rp_update_devicetree(get_tbt_pcie_rp_table());
199
200 /*
201 * Earlier when coreboot used to send EOP at late as possible caused
202 * issue of delayed response from CSE since CSE was busy loading payload.
203 * To resolve the issue, EOP should be sent earlier than current sequence
204 * in the boot sequence at BS_DEV_INIT.
205 *
206 * Intel CSE team recommends to send EOP close to FW init (between FSP-S
207 * exit and current boot sequence) to reduce message response time from
208 * CSE hence moving sending EOP to earlier stage.
209 */
210 if (CONFIG(SOC_INTEL_CSE_SEND_EOP_EARLY) || CONFIG(SOC_INTEL_CSE_SEND_EOP_ASYNC)) {
211 printk(BIOS_INFO, "Sending EOP early from SoC\n");
212 cse_send_end_of_post();
213 }
214 }
215
216 static void cpu_fill_ssdt(const struct device *dev)
217 {
218 if (!generate_pin_irq_map())
219 printk(BIOS_ERR, "Failed to generate ACPI _PRT table!\n");
220
221 generate_cpu_entries(dev);
222 }
223
224 static void cpu_set_north_irqs(struct device *dev)
225 {
226 irq_program_non_pch();
227 }
228
229 static struct device_operations pci_domain_ops = {
230 .read_resources = &pci_domain_read_resources,
231 .set_resources = &pci_domain_set_resources,
232 .scan_bus = &pci_host_bridge_scan_bus,
233 #if CONFIG(HAVE_ACPI_TABLES)
234 .acpi_name = &soc_acpi_name,
235 .acpi_fill_ssdt = ssdt_set_above_4g_pci,
236 #endif
237 };
238
239 static struct device_operations cpu_bus_ops = {
240 .read_resources = noop_read_resources,
241 .set_resources = noop_set_resources,
242 .enable_resources = cpu_set_north_irqs,
243 #if CONFIG(HAVE_ACPI_TABLES)
244 .acpi_fill_ssdt = cpu_fill_ssdt,
245 #endif
246 };
247
248 static void soc_enable(struct device *dev)
249 {
250 struct device_operations *soc_p2sb_ops = (struct device_operations *)&p2sb_ops;
251 struct device_operations *soc_p2sb2_ops = (struct device_operations *)&p2sb2_ops;
252
253 /*
254 * Set the operations if it is a special bus type or a hidden PCI
255 * device.
256 */
257 if (dev->path.type == DEVICE_PATH_DOMAIN)
258 dev->ops = &pci_domain_ops;
259 else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER)
260 dev->ops = &cpu_bus_ops;
261 else if (dev->path.type == DEVICE_PATH_PCI &&
262 dev->path.pci.devfn == PCI_DEVFN_PMC)
263 dev->ops = &pmc_ops;
264 else if (dev->path.type == DEVICE_PATH_PCI &&
265 dev->path.pci.devfn == PCI_DEVFN_P2SB)
266 dev->ops = soc_p2sb_ops;
267 else if (dev->path.type == DEVICE_PATH_PCI &&
268 dev->path.pci.devfn == PCI_DEVFN_P2SB2)
269 dev->ops = soc_p2sb2_ops;
270 else if (dev->path.type == DEVICE_PATH_GPIO)
271 block_gpio_enable(dev);
272 }
273
274 static void soc_init_final_device(void *chip_info)
275 {
276 efi_return_status_t reset_status = fsp_get_pch_reset_status();
277
278 if (reset_status == FSP_SUCCESS)
279 return;
280
281 /* Handle any pending reset request from previously executed FSP APIs */
282 fsp_handle_reset(reset_status);
283
284 /* Control shouldn't return here */
285 fsp_die_with_post_code(reset_status, POSTCODE_HW_INIT_FAILURE,
286 "Failed to handle the FSP reset request with error");
287 }
288
289 struct chip_operations soc_intel_pantherlake_ops = {
290 .name = "Intel Pantherlake",
291 .enable_dev = &soc_enable,
292 .init = &soc_init_pre_device,
293 .final = &soc_init_final_device,
294 };