From d20adc2e942b56ed0793147be8f63e1f27d1a8bb Mon Sep 17 00:00:00 2001 From: Janghyuck Kim Date: Thu, 21 Apr 2016 19:19:53 +0900 Subject: [PATCH] [COMMON] iommu/exynos: add initialization This is the starting point for exynos iommu driver. It registers sysmmu driver and iommu api to platform_bus_type. Change-Id: Iae165ce448ab4334ca956c5c2aaaa6bbe4997d7a Signed-off-by: Janghyuck Kim --- drivers/iommu/exynos-iommu.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 1d5e93032757..6552a37a3a9e 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -27,6 +27,8 @@ #include "exynos-iommu.h" +static struct kmem_cache *lv2table_kmem_cache; + static int __init exynos_sysmmu_probe(struct platform_device *pdev) { /* Dummy */ @@ -122,4 +124,37 @@ static struct iommu_ops exynos_iommu_ops = { .of_xlate = exynos_iommu_of_xlate, }; +static int __init exynos_iommu_init(void) +{ + int ret; + + lv2table_kmem_cache = kmem_cache_create("exynos-iommu-lv2table", + LV2TABLE_SIZE, LV2TABLE_SIZE, 0, NULL); + if (!lv2table_kmem_cache) { + pr_err("%s: Failed to create kmem cache\n", __func__); + return -ENOMEM; + } + + ret = platform_driver_register(&exynos_sysmmu_driver); + if (ret) { + pr_err("%s: Failed to register driver\n", __func__); + goto err_reg_driver; + } + + ret = bus_set_iommu(&platform_bus_type, &exynos_iommu_ops); + if (ret) { + pr_err("%s: Failed to register exynos-iommu driver.\n", + __func__); + goto err_set_iommu; + } + + return 0; +err_set_iommu: + platform_driver_unregister(&exynos_sysmmu_driver); +err_reg_driver: + kmem_cache_destroy(lv2table_kmem_cache); + return ret; +} +core_initcall(exynos_iommu_init); + IOMMU_OF_DECLARE(exynos_iommu_of, "samsung,exynos-sysmmu", NULL); -- 2.20.1