blob: 88f386c2c188ae02091cd6946df134d225a3042c [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>
Felix Helddf9a0402024-03-22 16:23:23 +01006#include <amdblocks/memmap.h>
Felix Held926887c2023-10-13 21:19:53 +02007#include <amdblocks/root_complex.h>
8#include <amdblocks/smn.h>
9#include <arch/ioapic.h>
10#include <console/console.h>
11#include <device/device.h>
12#include <types.h>
13
Felix Held2f58bbd2023-12-07 22:04:13 +010014#include <vendorcode/amd/opensil/genoa_poc/opensil.h>
15
Felix Held926887c2023-10-13 21:19:53 +020016#define IOHC_IOAPIC_BASE_ADDR_LO 0x2f0
17
Felix Held30f36c32024-01-30 15:15:31 +010018void read_soc_memmap_resources(struct device *domain, unsigned long *idx)
Felix Held2f58bbd2023-12-07 22:04:13 +010019{
Felix Held556373e2024-03-22 16:16:18 +010020 read_lower_soc_memmap_resources(domain, idx);
Felix Helddf9a0402024-03-22 16:23:23 +010021
Felix Heldfbda3232024-01-30 15:33:34 +010022 add_opensil_memmap(domain, idx);
Felix Held2f58bbd2023-12-07 22:04:13 +010023}
24
Felix Held926887c2023-10-13 21:19:53 +020025static void genoa_domain_set_resources(struct device *domain)
26{
Arthur Heymans7fcd4d52023-08-24 15:12:19 +020027 if (domain->downstream->bridge_ctrl & PCI_BRIDGE_CTL_VGA) {
Felix Held926887c2023-10-13 21:19:53 +020028 printk(BIOS_DEBUG, "Setting VGA decoding for domain 0x%x\n",
29 domain->path.domain.domain);
30 const union df_vga_en vga_en = {
31 .ve = 1,
32 .dst_fabric_id = get_iohc_fabric_id(domain),
33 };
34 data_fabric_broadcast_write32(DF_VGA_EN, vga_en.raw);
35 }
36
37 pci_domain_set_resources(domain);
38
39 /* Enable IOAPIC memory decoding */
40 struct resource *res = probe_resource(domain, IOMMU_IOAPIC_IDX);
41 if (res) {
42 const uint32_t iohc_misc_base = get_iohc_misc_smn_base(domain);
43 uint32_t ioapic_base = smn_read32(iohc_misc_base | IOHC_IOAPIC_BASE_ADDR_LO);
44 ioapic_base |= (1 << 0);
45 smn_write32(iohc_misc_base | IOHC_IOAPIC_BASE_ADDR_LO, ioapic_base);
46 }
47}
48
Felix Held020d4b62023-12-12 18:45:06 +010049static const char *genoa_domain_acpi_name(const struct device *domain)
50{
51 const char *domain_acpi_names[4] = {
52 "S0B0",
53 "S0B1",
54 "S0B2",
55 "S0B3",
56 };
57
58 if (domain->path.domain.domain < ARRAY_SIZE(domain_acpi_names))
59 return domain_acpi_names[domain->path.domain.domain];
60
61 return NULL;
62}
63
Felix Held926887c2023-10-13 21:19:53 +020064struct device_operations genoa_pci_domain_ops = {
Felix Held30f36c32024-01-30 15:15:31 +010065 .read_resources = amd_pci_domain_read_resources,
Felix Held0fe86432023-12-12 19:59:14 +010066 .set_resources = genoa_domain_set_resources,
67 .scan_bus = amd_pci_domain_scan_bus,
Felix Held416cc662024-01-31 12:17:58 +010068 .init = amd_pci_domain_init,
Felix Held020d4b62023-12-12 18:45:06 +010069 .acpi_name = genoa_domain_acpi_name,
Felix Helde549ee02024-02-12 22:28:17 +010070 .acpi_fill_ssdt = pci_domain_fill_ssdt,
Felix Held926887c2023-10-13 21:19:53 +020071};