summaryrefslogtreecommitdiff
path: root/src/soc/amd/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc/amd/common')
-rw-r--r--src/soc/amd/common/block/include/amdblocks/amd_pci_util.h1
-rw-r--r--src/soc/amd/common/block/pci/pci_routing_info.c35
2 files changed, 35 insertions, 1 deletions
diff --git a/src/soc/amd/common/block/include/amdblocks/amd_pci_util.h b/src/soc/amd/common/block/include/amdblocks/amd_pci_util.h
index b9cd1406c9..83922c9468 100644
--- a/src/soc/amd/common/block/include/amdblocks/amd_pci_util.h
+++ b/src/soc/amd/common/block/include/amdblocks/amd_pci_util.h
@@ -51,7 +51,6 @@ struct pci_routing_info {
uint8_t irq;
} __packed;
-/* Implemented by the SoC */
void populate_pirq_data(void);
/* Implemented by the SoC */
diff --git a/src/soc/amd/common/block/pci/pci_routing_info.c b/src/soc/amd/common/block/pci/pci_routing_info.c
index e0a696442e..ac7255348e 100644
--- a/src/soc/amd/common/block/pci/pci_routing_info.c
+++ b/src/soc/amd/common/block/pci/pci_routing_info.c
@@ -3,6 +3,7 @@
#include <amdblocks/amd_pci_util.h>
#include <console/console.h>
#include <device/pci_def.h>
+#include <stdlib.h>
#include <types.h>
enum pcie_swizzle_pin {
@@ -55,3 +56,37 @@ unsigned int pci_calculate_irq(const struct pci_routing_info *routing_info,
return irq;
}
+
+void populate_pirq_data(void)
+{
+ const struct pci_routing_info *routing_table, *routing_entry;
+ size_t entries = 0;
+ struct pirq_struct *pirq;
+ unsigned int irq;
+
+ routing_table = get_pci_routing_table(&entries);
+
+ if (!routing_table || !entries)
+ return;
+
+ pirq = calloc(entries, sizeof(*pirq));
+
+ if (!pirq) {
+ printk(BIOS_ERR, "%s: Allocation failed\n", __func__);
+ return;
+ }
+
+ for (size_t i = 0; i < entries; ++i) {
+ routing_entry = &routing_table[i];
+
+ pirq[i].devfn = routing_entry->devfn;
+ for (size_t j = 0; j < 4; ++j) {
+ irq = pci_calculate_irq(routing_entry, j);
+
+ pirq[i].PIN[j] = irq % 8;
+ }
+ }
+
+ pirq_data_ptr = pirq;
+ pirq_data_size = entries;
+}