Commit 8ed55c81 authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Joerg Roedel

iommu/exynos: Init from dt-specific callback instead of initcall

This patch introduces IOMMU_OF_DECLARE-based initialization to the
driver, which replaces subsys_initcall-based procedure.
exynos_iommu_of_setup ensures that each sysmmu controller is probed
before its master device.
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Tested-by: default avatarJavier Martinez Canillas <javier.martinez@collabora.co.uk>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 622015e4
...@@ -13,16 +13,21 @@ ...@@ -13,16 +13,21 @@
#endif #endif
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/dma-mapping.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/iommu.h> #include <linux/iommu.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/of.h>
#include <linux/of_iommu.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <asm/dma-iommu.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
typedef u32 sysmmu_iova_t; typedef u32 sysmmu_iova_t;
...@@ -1141,7 +1146,7 @@ static void exynos_iommu_remove_device(struct device *dev) ...@@ -1141,7 +1146,7 @@ static void exynos_iommu_remove_device(struct device *dev)
iommu_group_remove_device(dev); iommu_group_remove_device(dev);
} }
static const struct iommu_ops exynos_iommu_ops = { static struct iommu_ops exynos_iommu_ops = {
.domain_alloc = exynos_iommu_domain_alloc, .domain_alloc = exynos_iommu_domain_alloc,
.domain_free = exynos_iommu_domain_free, .domain_free = exynos_iommu_domain_free,
.attach_dev = exynos_iommu_attach_device, .attach_dev = exynos_iommu_attach_device,
...@@ -1155,17 +1160,12 @@ static const struct iommu_ops exynos_iommu_ops = { ...@@ -1155,17 +1160,12 @@ static const struct iommu_ops exynos_iommu_ops = {
.pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE, .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,
}; };
static bool init_done;
static int __init exynos_iommu_init(void) static int __init exynos_iommu_init(void)
{ {
struct device_node *np;
int ret; int ret;
np = of_find_matching_node(NULL, sysmmu_of_match);
if (!np)
return 0;
of_node_put(np);
lv2table_kmem_cache = kmem_cache_create("exynos-iommu-lv2table", lv2table_kmem_cache = kmem_cache_create("exynos-iommu-lv2table",
LV2TABLE_SIZE, LV2TABLE_SIZE, 0, NULL); LV2TABLE_SIZE, LV2TABLE_SIZE, 0, NULL);
if (!lv2table_kmem_cache) { if (!lv2table_kmem_cache) {
...@@ -1194,6 +1194,8 @@ static int __init exynos_iommu_init(void) ...@@ -1194,6 +1194,8 @@ static int __init exynos_iommu_init(void)
goto err_set_iommu; goto err_set_iommu;
} }
init_done = true;
return 0; return 0;
err_set_iommu: err_set_iommu:
kmem_cache_free(lv2table_kmem_cache, zero_lv2_table); kmem_cache_free(lv2table_kmem_cache, zero_lv2_table);
...@@ -1203,4 +1205,21 @@ static int __init exynos_iommu_init(void) ...@@ -1203,4 +1205,21 @@ static int __init exynos_iommu_init(void)
kmem_cache_destroy(lv2table_kmem_cache); kmem_cache_destroy(lv2table_kmem_cache);
return ret; return ret;
} }
subsys_initcall(exynos_iommu_init);
static int __init exynos_iommu_of_setup(struct device_node *np)
{
struct platform_device *pdev;
if (!init_done)
exynos_iommu_init();
pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root);
if (IS_ERR(pdev))
return PTR_ERR(pdev);
of_iommu_set_ops(np, &exynos_iommu_ops);
return 0;
}
IOMMU_OF_DECLARE(exynos_iommu_of, "samsung,exynos-sysmmu",
exynos_iommu_of_setup);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment