blob: 778d277a0ce3079d8c099e57fee3c05252ea8e5e [file] [log] [blame]
Andrey Petrov2e410752020-03-20 12:08:32 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Andrey Petrov2e410752020-03-20 12:08:32 -07002
3#include <arch/ioapic.h>
Andrey Petrov2e410752020-03-20 12:08:32 -07004#include <console/console.h>
Marc Jones8b522db2020-10-12 11:58:46 -06005#include <console/debug.h>
Andrey Petrov2e410752020-03-20 12:08:32 -07006#include <cpu/x86/lapic.h>
7#include <device/pci.h>
Michael Niewöhner8913b782020-12-11 22:13:44 +01008#include <intelblocks/gpio.h>
Subrata Banik1366e442020-09-29 13:55:50 +05309#include <intelblocks/lpc_lib.h>
Andrey Petrov4e48ac02020-04-30 14:08:19 -070010#include <intelblocks/p2sb.h>
Jonathan Zhang3172f982020-05-28 17:53:48 -070011#include <soc/acpi.h>
Marc Jones1f500842020-10-15 14:32:51 -060012#include <soc/chip_common.h>
Andrey Petrov8670e822020-03-30 12:25:06 -070013#include <soc/cpu.h>
Arthur Heymans3d802532020-11-12 21:17:56 +010014#include <soc/pch.h>
Andrey Petrov2e410752020-03-20 12:08:32 -070015#include <soc/ramstage.h>
Arthur Heymans0f91e9c2020-10-16 13:15:50 +020016#include <soc/p2sb.h>
Jonathan Zhang7919d612020-04-02 17:27:54 -070017#include <soc/soc_util.h>
Marc Jones5851f9d2020-11-02 15:30:10 -070018#include <soc/util.h>
Arthur Heymans0f91e9c2020-10-16 13:15:50 +020019#include <soc/pci_devs.h>
Jonathan Zhang7919d612020-04-02 17:27:54 -070020
Marc Jonesb9365ef2020-10-11 15:00:36 -060021/* UPD parameters to be initialized before SiliconInit */
Andrey Petrov2e410752020-03-20 12:08:32 -070022void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd)
23{
Marc Jonesb9365ef2020-10-11 15:00:36 -060024 mainboard_silicon_init_params(silupd);
Andrey Petrov2e410752020-03-20 12:08:32 -070025}
26
Jonathan Zhang1ba42a92020-09-21 17:14:44 -070027#if CONFIG(HAVE_ACPI_TABLES)
28static const char *soc_acpi_name(const struct device *dev)
29{
30 if (dev->path.type == DEVICE_PATH_DOMAIN)
31 return "PC00";
32 return NULL;
33}
34#endif
35
Andrey Petrov2e410752020-03-20 12:08:32 -070036static struct device_operations pci_domain_ops = {
37 .read_resources = &pci_domain_read_resources,
Marc Jones1f500842020-10-15 14:32:51 -060038 .set_resources = &xeonsp_pci_domain_set_resources,
39 .scan_bus = &xeonsp_pci_domain_scan_bus,
Jonathan Zhang1ba42a92020-09-21 17:14:44 -070040#if CONFIG(HAVE_ACPI_TABLES)
Jonathan Zhang3172f982020-05-28 17:53:48 -070041 .write_acpi_tables = &northbridge_write_acpi_tables,
Jonathan Zhang1ba42a92020-09-21 17:14:44 -070042 .acpi_name = soc_acpi_name
43#endif
Andrey Petrov2e410752020-03-20 12:08:32 -070044};
45
Andrey Petrov2e410752020-03-20 12:08:32 -070046static struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020047 .read_resources = noop_read_resources,
48 .set_resources = noop_set_resources,
Andrey Petrov8670e822020-03-30 12:25:06 -070049 .init = cpx_init_cpus,
Jonathan Zhangc1105952020-06-03 15:55:28 -070050 .acpi_fill_ssdt = generate_cpu_entries,
Andrey Petrov2e410752020-03-20 12:08:32 -070051};
52
Andrey Petrov2e410752020-03-20 12:08:32 -070053struct pci_operations soc_pci_ops = {
54 .set_subsystem = pci_dev_set_subsystem,
55};
56
Jonathan Zhang7919d612020-04-02 17:27:54 -070057static void chip_enable_dev(struct device *dev)
58{
59 /* Set the operations if it is a special bus type */
60 if (dev->path.type == DEVICE_PATH_DOMAIN) {
61 dev->ops = &pci_domain_ops;
62 attach_iio_stacks(dev);
63 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
64 dev->ops = &cpu_bus_ops;
Michael Niewöhner8913b782020-12-11 22:13:44 +010065 } else if (dev->path.type == DEVICE_PATH_GPIO) {
66 block_gpio_enable(dev);
Jonathan Zhang7919d612020-04-02 17:27:54 -070067 }
68}
69
Andrey Petrov2e410752020-03-20 12:08:32 -070070static void chip_final(void *data)
71{
Arthur Heymans0f91e9c2020-10-16 13:15:50 +020072 /* Lock SBI */
73 pci_or_config32(PCH_DEV_P2SB, P2SBC, SBILOCK);
Arthur Heymans19185532020-10-27 17:40:22 +010074
75 /* LOCK PAM */
76 pci_or_config32(pcidev_path_on_root(PCI_DEVFN(0, 0)), 0x80, 1 << 0);
77
78 /*
79 * LOCK SMRAM
80 * According to the CedarIsland FSP Integration Guide this needs to
81 * be done with legacy 0xCF8/0xCFC IO ops.
82 */
83 uint8_t reg8 = pci_io_read_config8(PCI_DEV(0, 0, 0), 0x88);
84 pci_io_write_config8(PCI_DEV(0, 0, 0), 0x88, reg8 | (1 << 4));
85
Andrey Petrov4e48ac02020-04-30 14:08:19 -070086 p2sb_hide();
Jonathan Zhangbea19802020-04-13 19:34:53 -070087
88 set_bios_init_completion();
Andrey Petrov2e410752020-03-20 12:08:32 -070089}
90
91static void chip_init(void *data)
92{
93 printk(BIOS_DEBUG, "coreboot: calling fsp_silicon_init\n");
94 fsp_silicon_init(false);
Arthur Heymans3d802532020-11-12 21:17:56 +010095 override_hpet_ioapic_bdf();
Subrata Banik1366e442020-09-29 13:55:50 +053096 pch_enable_ioapic();
Arthur Heymans83463072020-12-16 11:30:40 +010097 pch_lock_dmictl();
Andrey Petrov2e410752020-03-20 12:08:32 -070098 setup_lapic();
Andrey Petrov4e48ac02020-04-30 14:08:19 -070099 p2sb_unhide();
Andrey Petrov2e410752020-03-20 12:08:32 -0700100}
101
102struct chip_operations soc_intel_xeon_sp_cpx_ops = {
103 CHIP_NAME("Intel Cooperlake-SP")
104 .enable_dev = chip_enable_dev,
105 .init = chip_init,
Jonathan Zhang7919d612020-04-02 17:27:54 -0700106 .final = chip_final,
Andrey Petrov2e410752020-03-20 12:08:32 -0700107};