blob: 5e3c368c0f824b6151983d51228d88c873e56b5c [file] [log] [blame]
Raul E Rangel7b84b022021-05-04 15:38:03 -06001/* 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
10const 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;
Raul E Rangel7b84b022021-05-04 15:38:03 -060014 size_t hob_size = 0;
Nikolai Vyssotski177a4022021-06-04 10:35:15 -050015 const struct {
16 uint32_t num_of_entries;
17 struct pci_routing_info routing_table[];
18 } __packed *routing_hob;
Raul E Rangel7b84b022021-05-04 15:38:03 -060019
20 if (routing_table) {
21 *entries = routing_table_entries;
22 return routing_table;
23 }
24
Nikolai Vyssotski177a4022021-06-04 10:35:15 -050025 routing_hob = fsp_find_extension_hob_by_guid(AMD_FSP_PCIE_DEVFUNC_REMAP_HOB_GUID.b,
Raul E Rangel7b84b022021-05-04 15:38:03 -060026 &hob_size);
27
Nikolai Vyssotski177a4022021-06-04 10:35:15 -050028 if (routing_hob == NULL || hob_size == 0 || routing_hob->num_of_entries == 0) {
Julius Wernere9665952022-01-21 17:06:20 -080029 printk(BIOS_ERR, "Couldn't find valid PCIe interrupt routing HOB.\n");
Raul E Rangel7b84b022021-05-04 15:38:03 -060030 return NULL;
31 }
32
Nikolai Vyssotski177a4022021-06-04 10:35:15 -050033 routing_table = routing_hob->routing_table;
34 routing_table_entries = routing_hob->num_of_entries;
Raul E Rangel7b84b022021-05-04 15:38:03 -060035
36 for (size_t i = 0; i < routing_table_entries; ++i) {
37 printk(BIOS_DEBUG, "%02x.%x: group: %u, swizzle: %u, irq: %u\n",
38 PCI_SLOT(routing_table[i].devfn), PCI_FUNC(routing_table[i].devfn),
39 routing_table[i].group, routing_table[i].swizzle, routing_table[i].irq);
40 }
41
42 *entries = routing_table_entries;
43
44 return routing_table;
45}