blob: 5672f65ce63222e6a9efa7851e617a27d08d9335 [file] [log] [blame]
Felix Held926887c2023-10-13 21:19:53 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2
Felix Helde549ee02024-02-12 22:28:17 +01003#include <acpi/acpigen_pci.h>
Felix Held474c5d62024-01-09 16:56:56 +01004#include <amdblocks/ioapic.h>
Felix Held926887c2023-10-13 21:19:53 +02005#include <amdblocks/data_fabric.h>
6#include <amdblocks/root_complex.h>
7#include <amdblocks/smn.h>
8#include <arch/ioapic.h>
9#include <console/console.h>
10#include <device/device.h>
11#include <types.h>
12
Felix Held2f58bbd2023-12-07 22:04:13 +010013#include <vendorcode/amd/opensil/genoa_poc/opensil.h>
14
Felix Held926887c2023-10-13 21:19:53 +020015#define IOHC_IOAPIC_BASE_ADDR_LO 0x2f0
16
Felix Held30f36c32024-01-30 15:15:31 +010017void read_soc_memmap_resources(struct device *domain, unsigned long *idx)
Felix Held2f58bbd2023-12-07 22:04:13 +010018{
Felix Heldfbda3232024-01-30 15:33:34 +010019 add_opensil_memmap(domain, idx);
Felix Held2f58bbd2023-12-07 22:04:13 +010020}
21
Felix Held926887c2023-10-13 21:19:53 +020022static void genoa_domain_set_resources(struct device *domain)
23{
Arthur Heymans7fcd4d52023-08-24 15:12:19 +020024 if (domain->downstream->bridge_ctrl & PCI_BRIDGE_CTL_VGA) {
Felix Held926887c2023-10-13 21:19:53 +020025 printk(BIOS_DEBUG, "Setting VGA decoding for domain 0x%x\n",
26 domain->path.domain.domain);
27 const union df_vga_en vga_en = {
28 .ve = 1,
29 .dst_fabric_id = get_iohc_fabric_id(domain),
30 };
31 data_fabric_broadcast_write32(DF_VGA_EN, vga_en.raw);
32 }
33
34 pci_domain_set_resources(domain);
35
36 /* Enable IOAPIC memory decoding */
37 struct resource *res = probe_resource(domain, IOMMU_IOAPIC_IDX);
38 if (res) {
39 const uint32_t iohc_misc_base = get_iohc_misc_smn_base(domain);
40 uint32_t ioapic_base = smn_read32(iohc_misc_base | IOHC_IOAPIC_BASE_ADDR_LO);
41 ioapic_base |= (1 << 0);
42 smn_write32(iohc_misc_base | IOHC_IOAPIC_BASE_ADDR_LO, ioapic_base);
43 }
44}
45
Felix Held020d4b62023-12-12 18:45:06 +010046static const char *genoa_domain_acpi_name(const struct device *domain)
47{
48 const char *domain_acpi_names[4] = {
49 "S0B0",
50 "S0B1",
51 "S0B2",
52 "S0B3",
53 };
54
55 if (domain->path.domain.domain < ARRAY_SIZE(domain_acpi_names))
56 return domain_acpi_names[domain->path.domain.domain];
57
58 return NULL;
59}
60
Felix Held926887c2023-10-13 21:19:53 +020061struct device_operations genoa_pci_domain_ops = {
Felix Held30f36c32024-01-30 15:15:31 +010062 .read_resources = amd_pci_domain_read_resources,
Felix Held0fe86432023-12-12 19:59:14 +010063 .set_resources = genoa_domain_set_resources,
64 .scan_bus = amd_pci_domain_scan_bus,
Felix Held416cc662024-01-31 12:17:58 +010065 .init = amd_pci_domain_init,
Felix Held020d4b62023-12-12 18:45:06 +010066 .acpi_name = genoa_domain_acpi_name,
Felix Helde549ee02024-02-12 22:28:17 +010067 .acpi_fill_ssdt = pci_domain_fill_ssdt,
Felix Held926887c2023-10-13 21:19:53 +020068};