diff options
author | David Daney <david.daney@cavium.com> | 2015-10-08 18:10:49 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2015-10-16 08:07:12 -0400 |
commit | b6eec9b717d4dcb39ef024b8a3b619a32468b01e (patch) | |
tree | 938c3d37100f02ef76c4d197abc5cc662d3fa923 /drivers/pci/msi.c | |
parent | 8db02d8b4089fa8098a170738e8ae7939aa8ae7a (diff) |
PCI/MSI: Add helper function pci_msi_domain_get_msi_rid().
Add pci_msi_domain_get_msi_rid() to return the MSI requester id (RID).
Initially needed by gic-v3 based systems. It will be used by follow on
patch to drivers/irqchip/irq-gic-v3-its-pci-msi.c
Initially supports mapping the RID via OF device tree. In the future,
this could be extended to use ACPI _IORT tables as well.
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'drivers/pci/msi.c')
-rw-r--r-- | drivers/pci/msi.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index ddd59fe786f8..5ab5c4f8dcb0 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/irqdomain.h> | 22 | #include <linux/irqdomain.h> |
23 | #include <linux/of_irq.h> | ||
23 | 24 | ||
24 | #include "pci.h" | 25 | #include "pci.h" |
25 | 26 | ||
@@ -1327,4 +1328,35 @@ struct irq_domain *pci_msi_create_default_irq_domain(struct fwnode_handle *fwnod | |||
1327 | 1328 | ||
1328 | return domain; | 1329 | return domain; |
1329 | } | 1330 | } |
1331 | |||
1332 | static int get_msi_id_cb(struct pci_dev *pdev, u16 alias, void *data) | ||
1333 | { | ||
1334 | u32 *pa = data; | ||
1335 | |||
1336 | *pa = alias; | ||
1337 | return 0; | ||
1338 | } | ||
1339 | /** | ||
1340 | * pci_msi_domain_get_msi_rid - Get the MSI requester id (RID) | ||
1341 | * @domain: The interrupt domain | ||
1342 | * @pdev: The PCI device. | ||
1343 | * | ||
1344 | * The RID for a device is formed from the alias, with a firmware | ||
1345 | * supplied mapping applied | ||
1346 | * | ||
1347 | * Returns: The RID. | ||
1348 | */ | ||
1349 | u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev) | ||
1350 | { | ||
1351 | struct device_node *of_node; | ||
1352 | u32 rid = 0; | ||
1353 | |||
1354 | pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid); | ||
1355 | |||
1356 | of_node = irq_domain_get_of_node(domain); | ||
1357 | if (of_node) | ||
1358 | rid = of_msi_map_rid(&pdev->dev, of_node, rid); | ||
1359 | |||
1360 | return rid; | ||
1361 | } | ||
1330 | #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */ | 1362 | #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */ |