blob: 43e436a00a5ae474a5c723e0fed1ce3bbc840a82 [file] [log] [blame]
Felix Held926887c2023-10-13 21:19:53 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <amdblocks/data_fabric.h>
4#include <amdblocks/root_complex.h>
5#include <amdblocks/smn.h>
6#include <arch/ioapic.h>
7#include <console/console.h>
8#include <device/device.h>
9#include <types.h>
10
11#define IOHC_IOAPIC_BASE_ADDR_LO 0x2f0
12
13static void genoa_domain_set_resources(struct device *domain)
14{
15 if (domain->link_list->bridge_ctrl & PCI_BRIDGE_CTL_VGA) {
16 printk(BIOS_DEBUG, "Setting VGA decoding for domain 0x%x\n",
17 domain->path.domain.domain);
18 const union df_vga_en vga_en = {
19 .ve = 1,
20 .dst_fabric_id = get_iohc_fabric_id(domain),
21 };
22 data_fabric_broadcast_write32(DF_VGA_EN, vga_en.raw);
23 }
24
25 pci_domain_set_resources(domain);
26
27 /* Enable IOAPIC memory decoding */
28 struct resource *res = probe_resource(domain, IOMMU_IOAPIC_IDX);
29 if (res) {
30 const uint32_t iohc_misc_base = get_iohc_misc_smn_base(domain);
31 uint32_t ioapic_base = smn_read32(iohc_misc_base | IOHC_IOAPIC_BASE_ADDR_LO);
32 ioapic_base |= (1 << 0);
33 smn_write32(iohc_misc_base | IOHC_IOAPIC_BASE_ADDR_LO, ioapic_base);
34 }
35}
36
37struct device_operations genoa_pci_domain_ops = {
38 .read_resources = amd_pci_domain_read_resources,
39 .set_resources = genoa_domain_set_resources,
40 .scan_bus = amd_pci_domain_scan_bus,
41};