blob: 5f1dedf4979bd6c77dd0031182bd33120f966cdd [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 Petrov8670e822020-03-30 12:25:06 -070010#include <soc/cpu.h>
Andrey Petrov2e410752020-03-20 12:08:32 -070011#include <soc/ramstage.h>
12#include <soc/pm.h>
13
14/* C620 IOAPIC has 120 redirection entries */
15#define C620_IOAPIC_REDIR_ENTRIES 120
16
17static void pci_domain_set_resources(struct device *dev)
18{
19 assign_resources(dev->link_list);
20}
21
22void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd)
23{
24 /* not implemented yet */
25}
26
27static struct device_operations pci_domain_ops = {
28 .read_resources = &pci_domain_read_resources,
29 .set_resources = &pci_domain_set_resources,
30 .scan_bus = &pci_domain_scan_bus,
31};
32
Andrey Petrov2e410752020-03-20 12:08:32 -070033static struct device_operations cpu_bus_ops = {
34 .read_resources = DEVICE_NOOP,
35 .set_resources = DEVICE_NOOP,
Andrey Petrov8670e822020-03-30 12:25:06 -070036 .init = cpx_init_cpus,
Andrey Petrov2e410752020-03-20 12:08:32 -070037};
38
39static void chip_enable_dev(struct device *dev)
40{
41 /* Set the operations if it is a special bus type */
42 if (dev->path.type == DEVICE_PATH_DOMAIN) {
43 dev->ops = &pci_domain_ops;
44 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
45 dev->ops = &cpu_bus_ops;
46 }
47}
48
49static void pch_enable_ioapic(const struct device *dev)
50{
51 uint32_t reg32;
52
53 set_ioapic_id((void *)IO_APIC_ADDR, 2);
54
55 /* affirm full set of redirection table entries ("write once") */
56 reg32 = io_apic_read((void *)IO_APIC_ADDR, 1);
57
58 reg32 &= ~0x00ff0000;
59 reg32 |= (C620_IOAPIC_REDIR_ENTRIES - 1) << 16;
60
61 io_apic_write((void *)IO_APIC_ADDR, 1, reg32);
62
63 /*
64 * Select Boot Configuration register (0x03) and
65 * use Processor System Bus (0x01) to deliver interrupts.
66 */
67 io_apic_write((void *)IO_APIC_ADDR, 3, 1);
68}
69
70struct pci_operations soc_pci_ops = {
71 .set_subsystem = pci_dev_set_subsystem,
72};
73
74static void chip_final(void *data)
75{
76 /* nothing implemented yet */
77}
78
79static void chip_init(void *data)
80{
81 printk(BIOS_DEBUG, "coreboot: calling fsp_silicon_init\n");
82 fsp_silicon_init(false);
83 pch_enable_ioapic(NULL);
84 setup_lapic();
85}
86
87struct chip_operations soc_intel_xeon_sp_cpx_ops = {
88 CHIP_NAME("Intel Cooperlake-SP")
89 .enable_dev = chip_enable_dev,
90 .init = chip_init,
91 .final = chip_final
92};