of/platform: Assign MSI domain to platform device
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 28 Jul 2015 13:46:15 +0000 (14:46 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 29 Jul 2015 22:14:37 +0000 (00:14 +0200)
As for PCI, we're able to populate the msi_domain field at probe time,
provided that the device tree has an "msi-parent" property.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Cc: Yijing Wang <wangyijing@huawei.com>
Cc: Ma Jun <majun258@huawei.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Duc Dang <dhdang@apm.com>
Cc: Hanjun Guo <hanjun.guo@linaro.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Link: http://lkml.kernel.org/r/1438091186-10244-9-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
drivers/of/irq.c
drivers/of/platform.c
include/linux/irqdomain.h
include/linux/of_irq.h

index 3cf7a01f557f4fbe924479e379d599d03016f07f..2956d725649f25ffd7d115097a36a711867b052a 100644 (file)
@@ -18,6 +18,7 @@
  * driver.
  */
 
+#include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/list.h>
 #include <linux/module.h>
@@ -576,3 +577,23 @@ err:
                kfree(desc);
        }
 }
+
+/**
+ * of_msi_configure - Set the msi_domain field of a device
+ * @dev: device structure to associate with an MSI irq domain
+ * @np: device node for that device
+ */
+void of_msi_configure(struct device *dev, struct device_node *np)
+{
+       struct device_node *msi_np;
+       struct irq_domain *d;
+
+       msi_np = of_parse_phandle(np, "msi-parent", 0);
+       if (!msi_np)
+               return;
+
+       d = irq_find_matching_host(msi_np, DOMAIN_BUS_PLATFORM_MSI);
+       if (!d)
+               d = irq_find_host(msi_np);
+       dev_set_msi_domain(dev, d);
+}
index ddf8e42c9367d36132a2cd068fc441e9e29eea87..8a002d6151f2662851e22e240b5eb9957da974ee 100644 (file)
@@ -184,6 +184,7 @@ static struct platform_device *of_platform_device_create_pdata(
        dev->dev.bus = &platform_bus_type;
        dev->dev.platform_data = platform_data;
        of_dma_configure(&dev->dev, dev->dev.of_node);
+       of_msi_configure(&dev->dev, dev->dev.of_node);
 
        if (of_device_add(dev) != 0) {
                of_dma_deconfigure(&dev->dev);
index 25e9e6696a65c6bac8f8d52a2155ff4f3ac77a54..b4a74f73a0c3adb2fb24147597fa817b76965128 100644 (file)
@@ -55,6 +55,7 @@ struct irq_data;
 enum irq_domain_bus_token {
        DOMAIN_BUS_ANY          = 0,
        DOMAIN_BUS_PCI_MSI,
+       DOMAIN_BUS_PLATFORM_MSI,
 };
 
 /**
index d884929a77479782f9486ac486d0bad444bfcef8..4bcbd586a67296081fadb219ee96f32d7fcb65b2 100644 (file)
@@ -74,6 +74,7 @@ static inline int of_irq_to_resource_table(struct device_node *dev,
  */
 extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
 extern struct device_node *of_irq_find_parent(struct device_node *child);
+extern void of_msi_configure(struct device *dev, struct device_node *np);
 
 #else /* !CONFIG_OF */
 static inline unsigned int irq_of_parse_and_map(struct device_node *dev,