soc/intel/common/irq: Add function to return IRQ for PCI devfn

The IRQ for a single device may be required elsewhere, therefore provide
get_pci_devfn_irq.

BUG=b:130217151, b:171580862, b:176858827

Change-Id: Ibebd821767a2698c9e60b09eeeff3bb596359728
Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55826
Reviewed-by: Furquan Shaikh <furquan@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/soc/intel/common/block/irq/irq.c b/src/soc/intel/common/block/irq/irq.c
index b3f5c73..f0892a9 100644
--- a/src/soc/intel/common/block/irq/irq.c
+++ b/src/soc/intel/common/block/irq/irq.c
@@ -21,7 +21,6 @@
 
 #define IDX2PIN(i)		(enum pci_pin)((i) + PCI_INT_A)
 #define PIN2IDX(p)		(size_t)((p) - PCI_INT_A)
-#define INVALID_IRQ		-1
 
 struct pin_info {
 	enum pin_state {
@@ -429,3 +428,17 @@
 
 	return true;
 }
+
+int get_pci_devfn_irq(unsigned int devfn)
+{
+	const struct pci_irq_entry *entry = cached_entries;
+
+	while (entry) {
+		if (entry->devfn == devfn)
+			return entry->irq;
+
+		entry = entry->next;
+	}
+
+	return INVALID_IRQ;
+}