1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #include <acpi/acpigen_pci.h>
3 #include <arch/ioapic.h>
4 #include <console/console.h>
5 #include <console/debug.h>
6 #include <cpu/x86/lapic.h>
7 #include <device/pci.h>
8 #include <device/pci_ids.h>
9 #include <device/pci_def.h>
10 #include <device/pciexp.h>
11 #include <intelblocks/acpi.h>
12 #include <intelblocks/gpio.h>
13 #include <intelblocks/lpc_lib.h>
14 #include <intelblocks/p2sb.h>
15 #include <intelblocks/pcr.h>
16 #include <intelblocks/tco.h>
18 #include <soc/chip_common.h>
19 #include <soc/crashlog.h>
23 #include <soc/soc_pch.h>
24 #include <soc/pci_devs.h>
25 #include <soc/ramstage.h>
26 #include <soc/soc_util.h>
30 __weak
void mainboard_silicon_init_params(FSPS_UPD
*params
)
34 /* UPD parameters to be initialized before SiliconInit */
35 void platform_fsp_silicon_init_params_cb(FSPS_UPD
*silupd
)
37 mainboard_silicon_init_params(silupd
);
40 static struct device_operations cpu_bus_ops
= {
41 .read_resources
= noop_read_resources
,
42 .set_resources
= noop_set_resources
,
43 .init
= mp_cpu_bus_init
,
44 .acpi_fill_ssdt
= generate_cpu_entries
,
47 struct pci_operations soc_pci_ops
= {
48 .set_subsystem
= pci_dev_set_subsystem
,
51 static void chip_enable_dev(struct device
*dev
)
53 /* Set the operations if it is a special bus type */
54 if (dev
->path
.type
== DEVICE_PATH_DOMAIN
) {
55 /* domain ops are assigned at their creation */
56 } else if (dev
->path
.type
== DEVICE_PATH_CPU_CLUSTER
) {
57 dev
->ops
= &cpu_bus_ops
;
58 } else if (dev
->path
.type
== DEVICE_PATH_GPIO
) {
59 block_gpio_enable(dev
);
63 static void set_pcu_locks(void)
65 struct device
*dev
= NULL
;
67 while ((dev
= dev_find_device(PCI_VID_INTEL
, PCU_CR0_DEVID
, dev
))) {
68 printk(BIOS_SPEW
, "%s: locking registers\n", dev_path(dev
));
69 pci_or_config32(dev
, PCU_CR0_P_STATE_LIMITS
, P_STATE_LIMITS_LOCK
);
70 pci_or_config32(dev
, PCU_CR0_PACKAGE_RAPL_LIMIT_UPR
,
71 PKG_PWR_LIM_LOCK_UPR
);
72 pci_or_config32(dev
, PCU_CR0_TURBO_ACTIVATION_RATIO
,
73 TURBO_ACTIVATION_RATIO_LOCK
);
77 while ((dev
= dev_find_device(PCI_VID_INTEL
, PCU_CR2_DEVID
, dev
))) {
78 printk(BIOS_SPEW
, "%s: locking registers\n", dev_path(dev
));
79 pci_or_config32(dev
, PCU_CR2_DRAM_POWER_INFO_UPR
,
80 DRAM_POWER_INFO_LOCK_UPR
);
81 pci_or_config32(dev
, PCU_CR2_DRAM_PLANE_POWER_LIMIT_UPR
,
86 while ((dev
= dev_find_device(PCI_VID_INTEL
, PCU_CR3_DEVID
, dev
))) {
87 printk(BIOS_SPEW
, "%s: locking registers\n", dev_path(dev
));
88 pci_or_config32(dev
, PCU_CR3_CONFIG_TDP_CONTROL
, TDP_LOCK
);
92 while ((dev
= dev_find_device(PCI_VID_INTEL
, PCU_CR6_DEVID
, dev
))) {
93 printk(BIOS_SPEW
, "%s: locking registers\n", dev_path(dev
));
94 pci_or_config32(dev
, PCU_CR6_PLATFORM_RAPL_LIMIT_CFG_UPR
,
95 PLT_PWR_LIM_LOCK_UPR
);
96 pci_or_config32(dev
, PCU_CR6_PLATFORM_POWER_INFO_CFG_UPR
,
97 PLT_PWR_INFO_LOCK_UPR
);
101 static void chip_final(void *data
)
104 pci_or_config32(PCH_DEV_P2SB
, P2SBC
, SBILOCK
);
107 pci_or_config32(pcidev_path_on_root(PCI_DEVFN(0, 0)), 0x80, 1 << 0);
114 /* Accessing xHCI CSR needs to be done after PCI enumeration. */
116 mainboard_override_usb_oc();
118 /* Disable CPU Crashlog to avoid conflict between CPU Crashlog and BMC ACD. */
119 disable_cpu_crashlog();
121 set_bios_init_completion();
124 static void chip_init(void *data
)
126 printk(BIOS_DEBUG
, "coreboot: calling fsp_silicon_init\n");
131 override_hpet_ioapic_bdf();
136 mainboard_override_fsp_gpio();
140 struct chip_operations soc_intel_xeon_sp_spr_ops
= {
141 .name
= "Intel SapphireRapids-SP",
142 .enable_dev
= chip_enable_dev
,
147 void lock_gpio(bool lock
)
150 pcr_write32(gpio_get_pad_portid(GPPC_B0
), PAD_CFG_LOCK_B
, 0xffffffff);
151 pcr_write32(gpio_get_pad_portid(GPP_D0
), PAD_CFG_LOCK_D
, 0xffffffff);
153 pcr_write32(gpio_get_pad_portid(GPPC_B0
), PAD_CFG_LOCK_B
, 0);
154 pcr_write32(gpio_get_pad_portid(GPP_D0
), PAD_CFG_LOCK_D
, 0);
158 /* Root Complex Event Collector */
159 static void rcec_init(struct device
*dev
)
161 /* Set up RCEC EA extended capability, section 7.9.10 of PCIe 5.0 spec */
162 const unsigned int rcecea_cap
=
163 pciexp_find_extended_cap(dev
, PCIE_EXT_CAP_RCECEA_ID
, 0);
167 pci_devfn_t ecrc_bdf
= PCI_BDF(dev
);
168 uint32_t ecrc_bus
= (ecrc_bdf
>> 20) & 0xFFF;
169 uint32_t ecrc_dev
= (ecrc_bdf
>> 15) & 0x1F;
172 * Find all CXL devices, and match them with RCEC.
173 * With CXL 1.1, the bus# of CXL device (RCiEP) is 1 bigger than
178 for (i
= 0; i
< pds
.num_pds
; i
++) {
179 if (pds
.pds
[i
].pd_type
== PD_TYPE_PROCESSOR
)
181 ep_bus
= PCI_BDF(pds
.pds
[i
].dev
) >> 20;
182 if (ep_bus
== ecrc_bus
+ 1)
185 if (i
== pds
.num_pds
)
188 printk(BIOS_DEBUG
, "ep_bus: %x, ecrc_dev: %x\n", ep_bus
, ecrc_dev
);
189 u32 rcecea_bitmap
= 0x1 << ecrc_dev
;
190 u32 rcecea_busnum
= (ep_bus
<< 8) | (ep_bus
<< 16);
191 pci_write_config32(dev
, rcecea_cap
+ PCI_RCECEA_BITMAP
, rcecea_bitmap
);
192 pci_write_config32(dev
, rcecea_cap
+ PCI_RCECEA_BUSNUM
, rcecea_busnum
);
195 #define SPR_IEH 0x0b23
197 static const unsigned short rcec_ids
[] = {
202 static struct device_operations rcec_ops
= {
203 .read_resources
= pci_dev_read_resources
,
204 .set_resources
= pci_dev_set_resources
,
205 .enable_resources
= pci_dev_enable_resources
,
207 .ops_pci
= &soc_pci_ops
,
210 static const struct pci_driver rcec_driver __pci_driver
= {
212 .vendor
= PCI_VID_INTEL
,