[PATCH/RFC 06/10] iommu/ipmmu-vmsa: Also use IOMMU_OF_DECLARE()
From: Magnus Damm
Date: Tue Dec 15 2015 - 08:04:32 EST
From: Magnus Damm <damm+renesas@xxxxxxxxxxxxx>
Hook up IOMMU_OF_DECLARE() support. The default case
has the use_of_iommu feature disabled so the init
order remains unchanged for the default case.
Signed-off-by: Magnus Damm <damm+renesas@xxxxxxxxxxxxx>
---
drivers/iommu/ipmmu-vmsa.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
--- 0016/drivers/iommu/ipmmu-vmsa.c
+++ work/drivers/iommu/ipmmu-vmsa.c 2015-12-15 21:19:31.090513000 +0900
@@ -18,6 +18,8 @@
#include <linux/iommu.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_iommu.h>
+#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/sizes.h>
#include <linux/slab.h>
@@ -36,6 +38,7 @@ struct ipmmu_features {
bool has_cache_leaf_nodes;
bool setup_imbuscr;
bool twobit_imttbcr_sl0;
+ bool use_of_iommu;
};
struct ipmmu_vmsa_device {
@@ -891,6 +894,7 @@ static const struct ipmmu_features ipmmu
.has_cache_leaf_nodes = false,
.setup_imbuscr = true,
.twobit_imttbcr_sl0 = false,
+ .use_of_iommu = false,
};
static const struct of_device_id ipmmu_of_ids[] = {
@@ -1015,15 +1019,21 @@ static struct platform_driver ipmmu_driv
static int __init ipmmu_init(void)
{
+ static bool setup_done;
int ret;
+ if (setup_done)
+ return 0;
+
ret = platform_driver_register(&ipmmu_driver);
if (ret < 0)
return ret;
+#ifdef CONFIG_ARM
if (!iommu_present(&platform_bus_type))
bus_set_iommu(&platform_bus_type, &ipmmu_ops);
-
+#endif
+ setup_done = true;
return 0;
}
@@ -1035,6 +1045,29 @@ static void __exit ipmmu_exit(void)
subsys_initcall(ipmmu_init);
module_exit(ipmmu_exit);
+static int __init ipmmu_vmsa_iommu_of_setup(struct device_node *np)
+{
+ const struct of_device_id *match;
+ const struct ipmmu_features *feature;
+ static const struct iommu_ops *ops = &ipmmu_ops;
+
+ ipmmu_init();
+
+ match = of_match_node(ipmmu_of_ids, np);
+ if (match) {
+ feature = match->data;
+ if (feature->use_of_iommu) {
+ of_iommu_set_ops(np, (struct iommu_ops *)ops);
+ if (!iommu_present(&platform_bus_type))
+ bus_set_iommu(&platform_bus_type, ops);
+ }
+ }
+ return 0;
+}
+
+IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "renesas,ipmmu-vmsa",
+ ipmmu_vmsa_iommu_of_setup);
+
MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>");
MODULE_LICENSE("GPL v2");
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/