Raul E Rangel | 7b84b02 | 2021-05-04 15:38:03 -0600 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <amdblocks/amd_pci_util.h> |
| 4 | #include <console/console.h> |
| 5 | #include <device/pci_def.h> |
| 6 | #include <fsp/util.h> |
| 7 | #include <FspGuids.h> |
| 8 | #include <types.h> |
| 9 | |
| 10 | const struct pci_routing_info *get_pci_routing_table(size_t *entries) |
| 11 | { |
| 12 | static const struct pci_routing_info *routing_table; |
| 13 | static size_t routing_table_entries; |
| 14 | |
| 15 | size_t hob_size = 0; |
| 16 | |
| 17 | if (routing_table) { |
| 18 | *entries = routing_table_entries; |
| 19 | return routing_table; |
| 20 | } |
| 21 | |
| 22 | routing_table = fsp_find_extension_hob_by_guid(AMD_FSP_PCIE_DEVFUNC_REMAP_HOB_GUID.b, |
| 23 | &hob_size); |
| 24 | |
| 25 | if (routing_table == NULL || hob_size == 0) { |
| 26 | printk(BIOS_ERR, "Couldn't find PCIe routing HOB.\n"); |
| 27 | return NULL; |
| 28 | } |
| 29 | |
| 30 | routing_table_entries = hob_size / sizeof(struct pci_routing_info); |
| 31 | |
| 32 | for (size_t i = 0; i < routing_table_entries; ++i) { |
| 33 | printk(BIOS_DEBUG, "%02x.%x: group: %u, swizzle: %u, irq: %u\n", |
| 34 | PCI_SLOT(routing_table[i].devfn), PCI_FUNC(routing_table[i].devfn), |
| 35 | routing_table[i].group, routing_table[i].swizzle, routing_table[i].irq); |
| 36 | } |
| 37 | |
| 38 | *entries = routing_table_entries; |
| 39 | |
| 40 | return routing_table; |
| 41 | } |