Andrey Petrov | 2e41075 | 2020-03-20 12:08:32 -0700 | [diff] [blame] | 1 | /* 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 Petrov | 4e48ac0 | 2020-04-30 14:08:19 -0700 | [diff] [blame^] | 10 | #include <intelblocks/p2sb.h> |
Andrey Petrov | 8670e82 | 2020-03-30 12:25:06 -0700 | [diff] [blame] | 11 | #include <soc/cpu.h> |
Andrey Petrov | 2e41075 | 2020-03-20 12:08:32 -0700 | [diff] [blame] | 12 | #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 | |
| 18 | static void pci_domain_set_resources(struct device *dev) |
| 19 | { |
| 20 | assign_resources(dev->link_list); |
| 21 | } |
| 22 | |
| 23 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd) |
| 24 | { |
| 25 | /* not implemented yet */ |
| 26 | } |
| 27 | |
| 28 | static 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 Petrov | 2e41075 | 2020-03-20 12:08:32 -0700 | [diff] [blame] | 34 | static struct device_operations cpu_bus_ops = { |
Nico Huber | 2f8ba69 | 2020-04-05 14:05:24 +0200 | [diff] [blame] | 35 | .read_resources = noop_read_resources, |
| 36 | .set_resources = noop_set_resources, |
Andrey Petrov | 8670e82 | 2020-03-30 12:25:06 -0700 | [diff] [blame] | 37 | .init = cpx_init_cpus, |
Andrey Petrov | 2e41075 | 2020-03-20 12:08:32 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | static 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 | |
| 50 | static 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 | |
| 71 | struct pci_operations soc_pci_ops = { |
| 72 | .set_subsystem = pci_dev_set_subsystem, |
| 73 | }; |
| 74 | |
| 75 | static void chip_final(void *data) |
| 76 | { |
Andrey Petrov | 4e48ac0 | 2020-04-30 14:08:19 -0700 | [diff] [blame^] | 77 | p2sb_hide(); |
Andrey Petrov | 2e41075 | 2020-03-20 12:08:32 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | static 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 Petrov | 4e48ac0 | 2020-04-30 14:08:19 -0700 | [diff] [blame^] | 86 | p2sb_unhide(); |
Andrey Petrov | 2e41075 | 2020-03-20 12:08:32 -0700 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | struct 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 | }; |