Felix Held | 926887c | 2023-10-13 21:19:53 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Felix Held | e549ee0 | 2024-02-12 22:28:17 +0100 | [diff] [blame] | 3 | #include <acpi/acpigen_pci.h> |
Felix Held | 474c5d6 | 2024-01-09 16:56:56 +0100 | [diff] [blame] | 4 | #include <amdblocks/ioapic.h> |
Felix Held | 926887c | 2023-10-13 21:19:53 +0200 | [diff] [blame] | 5 | #include <amdblocks/data_fabric.h> |
Felix Held | df9a040 | 2024-03-22 16:23:23 +0100 | [diff] [blame] | 6 | #include <amdblocks/memmap.h> |
Felix Held | 926887c | 2023-10-13 21:19:53 +0200 | [diff] [blame] | 7 | #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 Held | 2f58bbd | 2023-12-07 22:04:13 +0100 | [diff] [blame] | 14 | #include <vendorcode/amd/opensil/genoa_poc/opensil.h> |
| 15 | |
Felix Held | 926887c | 2023-10-13 21:19:53 +0200 | [diff] [blame] | 16 | #define IOHC_IOAPIC_BASE_ADDR_LO 0x2f0 |
| 17 | |
Felix Held | 30f36c3 | 2024-01-30 15:15:31 +0100 | [diff] [blame] | 18 | void read_soc_memmap_resources(struct device *domain, unsigned long *idx) |
Felix Held | 2f58bbd | 2023-12-07 22:04:13 +0100 | [diff] [blame] | 19 | { |
Felix Held | 556373e | 2024-03-22 16:16:18 +0100 | [diff] [blame^] | 20 | read_lower_soc_memmap_resources(domain, idx); |
Felix Held | df9a040 | 2024-03-22 16:23:23 +0100 | [diff] [blame] | 21 | |
Felix Held | fbda323 | 2024-01-30 15:33:34 +0100 | [diff] [blame] | 22 | add_opensil_memmap(domain, idx); |
Felix Held | 2f58bbd | 2023-12-07 22:04:13 +0100 | [diff] [blame] | 23 | } |
| 24 | |
Felix Held | 926887c | 2023-10-13 21:19:53 +0200 | [diff] [blame] | 25 | static void genoa_domain_set_resources(struct device *domain) |
| 26 | { |
Arthur Heymans | 7fcd4d5 | 2023-08-24 15:12:19 +0200 | [diff] [blame] | 27 | if (domain->downstream->bridge_ctrl & PCI_BRIDGE_CTL_VGA) { |
Felix Held | 926887c | 2023-10-13 21:19:53 +0200 | [diff] [blame] | 28 | 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 Held | 020d4b6 | 2023-12-12 18:45:06 +0100 | [diff] [blame] | 49 | static 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 Held | 926887c | 2023-10-13 21:19:53 +0200 | [diff] [blame] | 64 | struct device_operations genoa_pci_domain_ops = { |
Felix Held | 30f36c3 | 2024-01-30 15:15:31 +0100 | [diff] [blame] | 65 | .read_resources = amd_pci_domain_read_resources, |
Felix Held | 0fe8643 | 2023-12-12 19:59:14 +0100 | [diff] [blame] | 66 | .set_resources = genoa_domain_set_resources, |
| 67 | .scan_bus = amd_pci_domain_scan_bus, |
Felix Held | 416cc66 | 2024-01-31 12:17:58 +0100 | [diff] [blame] | 68 | .init = amd_pci_domain_init, |
Felix Held | 020d4b6 | 2023-12-12 18:45:06 +0100 | [diff] [blame] | 69 | .acpi_name = genoa_domain_acpi_name, |
Felix Held | e549ee0 | 2024-02-12 22:28:17 +0100 | [diff] [blame] | 70 | .acpi_fill_ssdt = pci_domain_fill_ssdt, |
Felix Held | 926887c | 2023-10-13 21:19:53 +0200 | [diff] [blame] | 71 | }; |