Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
[firefly-linux-kernel-4.4.55.git] / drivers / of / of_pci_irq.c
index ee3293d4b66bd0a05290d8a7372e748f6718e107..8736bc7676c5d84b78cd42462fda90982ca079d9 100644 (file)
@@ -2,7 +2,6 @@
 #include <linux/of_pci.h>
 #include <linux/of_irq.h>
 #include <linux/export.h>
-#include <asm/prom.h>
 
 /**
  * of_irq_parse_pci - Resolve the interrupt for a PCI device
@@ -85,9 +84,37 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
                pdev = ppdev;
        }
 
+       out_irq->np = ppnode;
+       out_irq->args_count = 1;
+       out_irq->args[0] = lspec;
        lspec_be = cpu_to_be32(lspec);
        laddr[0] = cpu_to_be32((pdev->bus->number << 16) | (pdev->devfn << 8));
-       laddr[1]  = laddr[2] = cpu_to_be32(0);
-       return of_irq_parse_raw(ppnode, &lspec_be, 1, laddr, out_irq);
+       laddr[1] = laddr[2] = cpu_to_be32(0);
+       return of_irq_parse_raw(laddr, out_irq);
 }
 EXPORT_SYMBOL_GPL(of_irq_parse_pci);
+
+/**
+ * of_irq_parse_and_map_pci() - Decode a PCI irq from the device tree and map to a virq
+ * @dev: The pci device needing an irq
+ * @slot: PCI slot number; passed when used as map_irq callback. Unused
+ * @pin: PCI irq pin number; passed when used as map_irq callback. Unused
+ *
+ * @slot and @pin are unused, but included in the function so that this
+ * function can be used directly as the map_irq callback to pci_fixup_irqs().
+ */
+int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
+{
+       struct of_phandle_args oirq;
+       int ret;
+
+       ret = of_irq_parse_pci(dev, &oirq);
+       if (ret) {
+               dev_err(&dev->dev, "of_irq_parse_pci() failed with rc=%d\n", ret);
+               return 0; /* Proper return code 0 == NO_IRQ */
+       }
+
+       return irq_create_of_mapping(&oirq);
+}
+EXPORT_SYMBOL_GPL(of_irq_parse_and_map_pci);
+