Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[cascardo/linux.git] / drivers / irqchip / irq-gic-v3-its-pci-msi.c
index aee60ed..aee1c60 100644 (file)
@@ -15,6 +15,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <linux/acpi_iort.h>
 #include <linux/msi.h>
 #include <linux/of.h>
 #include <linux/of_irq.h>
@@ -106,34 +107,91 @@ static struct of_device_id its_device_id[] = {
        {},
 };
 
-static int __init its_pci_msi_init(void)
+static int __init its_pci_msi_init_one(struct fwnode_handle *handle,
+                                      const char *name)
 {
-       struct device_node *np;
        struct irq_domain *parent;
 
+       parent = irq_find_matching_fwnode(handle, DOMAIN_BUS_NEXUS);
+       if (!parent || !msi_get_domain_info(parent)) {
+               pr_err("%s: Unable to locate ITS domain\n", name);
+               return -ENXIO;
+       }
+
+       if (!pci_msi_create_irq_domain(handle, &its_pci_msi_domain_info,
+                                      parent)) {
+               pr_err("%s: Unable to create PCI domain\n", name);
+               return -ENOMEM;
+       }
+
+       return 0;
+}
+
+static int __init its_pci_of_msi_init(void)
+{
+       struct device_node *np;
+
        for (np = of_find_matching_node(NULL, its_device_id); np;
             np = of_find_matching_node(np, its_device_id)) {
                if (!of_property_read_bool(np, "msi-controller"))
                        continue;
 
-               parent = irq_find_matching_host(np, DOMAIN_BUS_NEXUS);
-               if (!parent || !msi_get_domain_info(parent)) {
-                       pr_err("%s: unable to locate ITS domain\n",
-                              np->full_name);
-                       continue;
-               }
-
-               if (!pci_msi_create_irq_domain(of_node_to_fwnode(np),
-                                              &its_pci_msi_domain_info,
-                                              parent)) {
-                       pr_err("%s: unable to create PCI domain\n",
-                              np->full_name);
+               if (its_pci_msi_init_one(of_node_to_fwnode(np), np->full_name))
                        continue;
-               }
 
                pr_info("PCI/MSI: %s domain created\n", np->full_name);
        }
 
        return 0;
 }
+
+#ifdef CONFIG_ACPI
+
+static int __init
+its_pci_msi_parse_madt(struct acpi_subtable_header *header,
+                      const unsigned long end)
+{
+       struct acpi_madt_generic_translator *its_entry;
+       struct fwnode_handle *dom_handle;
+       const char *node_name;
+       int err = -ENXIO;
+
+       its_entry = (struct acpi_madt_generic_translator *)header;
+       node_name = kasprintf(GFP_KERNEL, "ITS@0x%lx",
+                             (long)its_entry->base_address);
+       dom_handle = iort_find_domain_token(its_entry->translation_id);
+       if (!dom_handle) {
+               pr_err("%s: Unable to locate ITS domain handle\n", node_name);
+               goto out;
+       }
+
+       err = its_pci_msi_init_one(dom_handle, node_name);
+       if (!err)
+               pr_info("PCI/MSI: %s domain created\n", node_name);
+
+out:
+       kfree(node_name);
+       return err;
+}
+
+static int __init its_pci_acpi_msi_init(void)
+{
+       acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR,
+                             its_pci_msi_parse_madt, 0);
+       return 0;
+}
+#else
+static int __init its_pci_acpi_msi_init(void)
+{
+       return 0;
+}
+#endif
+
+static int __init its_pci_msi_init(void)
+{
+       its_pci_of_msi_init();
+       its_pci_acpi_msi_init();
+
+       return 0;
+}
 early_initcall(its_pci_msi_init);