]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/iommu/of_iommu.c
iommu: provide early initialisation hook for IOMMU drivers
[karo-tx-linux.git] / drivers / iommu / of_iommu.c
index e550ccb7634e91d312cd9377ff499499d37e38ed..89b903406968c3d50b675bd378ee9e4d57741657 100644 (file)
@@ -22,6 +22,9 @@
 #include <linux/of.h>
 #include <linux/of_iommu.h>
 
+static const struct of_device_id __iommu_of_table_sentinel
+       __used __section(__iommu_of_table_end);
+
 /**
  * of_get_dma_window - Parse *dma-window property and returns 0 if found.
  *
@@ -89,3 +92,17 @@ int of_get_dma_window(struct device_node *dn, const char *prefix, int index,
        return 0;
 }
 EXPORT_SYMBOL_GPL(of_get_dma_window);
+
+void __init of_iommu_init(void)
+{
+       struct device_node *np;
+       const struct of_device_id *match, *matches = &__iommu_of_table;
+
+       for_each_matching_node_and_match(np, matches, &match) {
+               const of_iommu_init_fn init_fn = match->data;
+
+               if (init_fn(np))
+                       pr_err("Failed to initialise IOMMU %s\n",
+                               of_node_full_name(np));
+       }
+}