blob: 0a4cea620752bc9618c1552ac42376ea4f829f99 [file] [log] [blame]
Andrey Petrov2e410752020-03-20 12:08:32 -07001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
3
4#include <arch/ioapic.h>
5#include <cbfs.h>
6#include <console/console.h>
7#include <cpu/x86/lapic.h>
8#include <device/pci.h>
9#include <fsp/api.h>
Andrey Petrov4e48ac02020-04-30 14:08:19 -070010#include <intelblocks/p2sb.h>
Andrey Petrov8670e822020-03-30 12:25:06 -070011#include <soc/cpu.h>
Andrey Petrov2e410752020-03-20 12:08:32 -070012#include <soc/ramstage.h>
13#include <soc/pm.h>
14
15/* C620 IOAPIC has 120 redirection entries */
16#define C620_IOAPIC_REDIR_ENTRIES 120
17
18static void pci_domain_set_resources(struct device *dev)
19{
20 assign_resources(dev->link_list);
21}
22
23void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd)
24{
25 /* not implemented yet */
26}
27
28static struct device_operations pci_domain_ops = {
29 .read_resources = &pci_domain_read_resources,
30 .set_resources = &pci_domain_set_resources,
31 .scan_bus = &pci_domain_scan_bus,
32};
33
Andrey Petrov2e410752020-03-20 12:08:32 -070034static struct device_operations cpu_bus_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020035 .read_resources = noop_read_resources,
36 .set_resources = noop_set_resources,
Andrey Petrov8670e822020-03-30 12:25:06 -070037 .init = cpx_init_cpus,
Andrey Petrov2e410752020-03-20 12:08:32 -070038};
39
40static void chip_enable_dev(struct device *dev)
41{
42 /* Set the operations if it is a special bus type */
43 if (dev->path.type == DEVICE_PATH_DOMAIN) {
44 dev->ops = &pci_domain_ops;
45 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
46 dev->ops = &cpu_bus_ops;
47 }
48}
49
50static void pch_enable_ioapic(const struct device *dev)
51{
52 uint32_t reg32;
53
54 set_ioapic_id((void *)IO_APIC_ADDR, 2);
55
56 /* affirm full set of redirection table entries ("write once") */
57 reg32 = io_apic_read((void *)IO_APIC_ADDR, 1);
58
59 reg32 &= ~0x00ff0000;
60 reg32 |= (C620_IOAPIC_REDIR_ENTRIES - 1) << 16;
61
62 io_apic_write((void *)IO_APIC_ADDR, 1, reg32);
63
64 /*
65 * Select Boot Configuration register (0x03) and
66 * use Processor System Bus (0x01) to deliver interrupts.
67 */
68 io_apic_write((void *)IO_APIC_ADDR, 3, 1);
69}
70
71struct pci_operations soc_pci_ops = {
72 .set_subsystem = pci_dev_set_subsystem,
73};
74
75static void chip_final(void *data)
76{
Andrey Petrov4e48ac02020-04-30 14:08:19 -070077 p2sb_hide();
Andrey Petrov2e410752020-03-20 12:08:32 -070078}
79
80static void chip_init(void *data)
81{
82 printk(BIOS_DEBUG, "coreboot: calling fsp_silicon_init\n");
83 fsp_silicon_init(false);
84 pch_enable_ioapic(NULL);
85 setup_lapic();
Andrey Petrov4e48ac02020-04-30 14:08:19 -070086 p2sb_unhide();
Andrey Petrov2e410752020-03-20 12:08:32 -070087}
88
89struct chip_operations soc_intel_xeon_sp_cpx_ops = {
90 CHIP_NAME("Intel Cooperlake-SP")
91 .enable_dev = chip_enable_dev,
92 .init = chip_init,
93 .final = chip_final
94};