1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 #include <acpi/acpigen.h>
5 #include <acpi/acpigen_pci.h>
6 #include <amdblocks/amd_pci_util.h>
7 #include <arch/ioapic.h>
8 #include <device/device.h>
10 /* GNB IO-APIC is located after the FCH IO-APIC */
11 #define FCH_IOAPIC_INTERRUPTS 24
12 #define GNB_GSI_BASE FCH_IOAPIC_INTERRUPTS
14 static void acpigen_write_PRT_GSI(const struct pci_routing_info
*routing_info
)
18 acpigen_write_package(4); /* Package - APIC Routing */
19 for (unsigned int i
= 0; i
< 4; ++i
) {
20 irq
= pci_calculate_irq(routing_info
, i
);
22 acpigen_write_PRT_GSI_entry(
23 0, /* There is only one device attached to the bridge */
27 acpigen_pop_len(); /* Package - APIC Routing */
30 static void acpigen_write_PRT_PIC(const struct pci_routing_info
*routing_info
)
33 char link_template
[] = "\\_SB.INTX";
35 acpigen_write_package(4); /* Package - PIC Routing */
36 for (unsigned int i
= 0; i
< 4; ++i
) {
37 irq
= pci_calculate_irq(routing_info
, i
);
39 link_template
[8] = 'A' + (irq
% 8);
41 acpigen_write_PRT_source_entry(
42 0, /* There is only one device attached to the bridge */
44 link_template
/* Source */,
45 0 /* Source Index */);
47 acpigen_pop_len(); /* Package - PIC Routing */
51 * This method writes a PCI _PRT table that uses the GNB IO-APIC / PIC :
52 * Method (_PRT, 0, NotSerialized) // _PRT: PCI Routing Table
56 * Return (Package (0x04)
93 * Return (Package (0x04)
130 void acpigen_write_pci_GNB_PRT(const struct device
*dev
)
132 const struct pci_routing_info
*routing_info
=
133 get_pci_routing_info(dev
->path
.pci
.devfn
);
138 acpigen_write_method("_PRT", 0);
142 acpigen_emit_namestring("PICM");
144 /* Return (Package{...}) */
145 acpigen_emit_byte(RETURN_OP
);
146 acpigen_write_PRT_GSI(routing_info
);
149 acpigen_write_else();
151 /* Return (Package{...}) */
152 acpigen_emit_byte(RETURN_OP
);
153 acpigen_write_PRT_PIC(routing_info
);
155 acpigen_pop_len(); /* End Else */
157 acpigen_pop_len(); /* Method */
161 * This method writes a PCI _PRT table that uses the FCH IO-APIC / PIC :
162 * Name (_PRT, Package (0x04)
197 void acpigen_write_pci_FCH_PRT(const struct device
*dev
)
199 const struct pci_routing_info
*routing_info
=
200 get_pci_routing_info(dev
->path
.pci
.devfn
);
205 acpigen_write_name("_PRT");
206 acpigen_write_PRT_PIC(routing_info
);