blob: a3076a8035c6d631a9b98ce39589c3036f859654 [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>
Subrata Banik1366e442020-09-29 13:55:50 +05308#include <intelblocks/lpc_lib.h>
Andrey Petrov4e48ac02020-04-30 14:08:19 -07009#include <intelblocks/p2sb.h>
Jonathan Zhang3172f982020-05-28 17:53:48 -070010#include <soc/acpi.h>
Marc Jones1f500842020-10-15 14:32:51 -060011#include <soc/chip_common.h>
Andrey Petrov8670e822020-03-30 12:25:06 -070012#include <soc/cpu.h>
Arthur Heymans3d802532020-11-12 21:17:56 +010013#include <soc/pch.h>
Andrey Petrov2e410752020-03-20 12:08:32 -070014#include <soc/ramstage.h>
Arthur Heymans0f91e9c2020-10-16 13:15:50 +020015#include <soc/p2sb.h>
Jonathan Zhang7919d612020-04-02 17:27:54 -070016#include <soc/soc_util.h>
Marc Jones5851f9d2020-11-02 15:30:10 -070017#include <soc/util.h>
Arthur Heymans0f91e9c2020-10-16 13:15:50 +020018#include <soc/pci_devs.h>
Jonathan Zhang7919d612020-04-02 17:27:54 -070019
Marc Jonesb9365ef2020-10-11 15:00:36 -060020/* UPD parameters to be initialized before SiliconInit */
Andrey Petrov2e410752020-03-20 12:08:32 -070021void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd)
22{
Marc Jonesb9365ef2020-10-11 15:00:36 -060023 mainboard_silicon_init_params(silupd);
Andrey Petrov2e410752020-03-20 12:08:32 -070024}
25
Jonathan Zhang1ba42a92020-09-21 17:14:44 -070026#if CONFIG(HAVE_ACPI_TABLES)
27static const char *soc_acpi_name(const struct device *dev)
28{
29 if (dev->path.type == DEVICE_PATH_DOMAIN)
30 return "PC00";
31 return NULL;
32}
33#endif
34
Andrey Petrov2e410752020-03-20 12:08:32 -070035static struct device_operations pci_domain_ops = {
36 .read_resources = &pci_domain_read_resources,
Marc Jones1f500842020-10-15 14:32:51 -060037 .set_resources = &xeonsp_pci_domain_set_resources,
38 .scan_bus = &xeonsp_pci_domain_scan_bus,
Jonathan Zhang1ba42a92020-09-21 17:14:44 -070039#if CONFIG(HAVE_ACPI_TABLES)
Jonathan Zhang3172f982020-05-28 17:53:48 -070040 .write_acpi_tables = &northbridge_write_acpi_tables,
Jonathan Zhang1ba42a92020-09-21 17:14:44 -070041 .acpi_name = soc_acpi_name
42#endif
Andrey Petrov2e410752020-03-20 12:08:32 -070043};
44
Andrey Petrov2e410752020-03-20 12:08:32 -070045static struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020046 .read_resources = noop_read_resources,
47 .set_resources = noop_set_resources,
Andrey Petrov8670e822020-03-30 12:25:06 -070048 .init = cpx_init_cpus,
Jonathan Zhangc1105952020-06-03 15:55:28 -070049 .acpi_fill_ssdt = generate_cpu_entries,
Andrey Petrov2e410752020-03-20 12:08:32 -070050};
51
Andrey Petrov2e410752020-03-20 12:08:32 -070052struct pci_operations soc_pci_ops = {
53 .set_subsystem = pci_dev_set_subsystem,
54};
55
Jonathan Zhang7919d612020-04-02 17:27:54 -070056static void chip_enable_dev(struct device *dev)
57{
58 /* Set the operations if it is a special bus type */
59 if (dev->path.type == DEVICE_PATH_DOMAIN) {
60 dev->ops = &pci_domain_ops;
61 attach_iio_stacks(dev);
62 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
63 dev->ops = &cpu_bus_ops;
64 }
65}
66
Andrey Petrov2e410752020-03-20 12:08:32 -070067static void chip_final(void *data)
68{
Arthur Heymans0f91e9c2020-10-16 13:15:50 +020069 /* Lock SBI */
70 pci_or_config32(PCH_DEV_P2SB, P2SBC, SBILOCK);
Arthur Heymans19185532020-10-27 17:40:22 +010071
72 /* LOCK PAM */
73 pci_or_config32(pcidev_path_on_root(PCI_DEVFN(0, 0)), 0x80, 1 << 0);
74
75 /*
76 * LOCK SMRAM
77 * According to the CedarIsland FSP Integration Guide this needs to
78 * be done with legacy 0xCF8/0xCFC IO ops.
79 */
80 uint8_t reg8 = pci_io_read_config8(PCI_DEV(0, 0, 0), 0x88);
81 pci_io_write_config8(PCI_DEV(0, 0, 0), 0x88, reg8 | (1 << 4));
82
Andrey Petrov4e48ac02020-04-30 14:08:19 -070083 p2sb_hide();
Jonathan Zhangbea19802020-04-13 19:34:53 -070084
85 set_bios_init_completion();
Andrey Petrov2e410752020-03-20 12:08:32 -070086}
87
88static void chip_init(void *data)
89{
90 printk(BIOS_DEBUG, "coreboot: calling fsp_silicon_init\n");
91 fsp_silicon_init(false);
Arthur Heymans3d802532020-11-12 21:17:56 +010092 override_hpet_ioapic_bdf();
Subrata Banik1366e442020-09-29 13:55:50 +053093 pch_enable_ioapic();
Arthur Heymans83463072020-12-16 11:30:40 +010094 pch_lock_dmictl();
Andrey Petrov2e410752020-03-20 12:08:32 -070095 setup_lapic();
Andrey Petrov4e48ac02020-04-30 14:08:19 -070096 p2sb_unhide();
Andrey Petrov2e410752020-03-20 12:08:32 -070097}
98
99struct chip_operations soc_intel_xeon_sp_cpx_ops = {
100 CHIP_NAME("Intel Cooperlake-SP")
101 .enable_dev = chip_enable_dev,
102 .init = chip_init,
Jonathan Zhang7919d612020-04-02 17:27:54 -0700103 .final = chip_final,
Andrey Petrov2e410752020-03-20 12:08:32 -0700104};