[COMMON] iommu/exynos: add initialization
authorJanghyuck Kim <janghyuck.kim@samsung.com>
Thu, 21 Apr 2016 10:19:53 +0000 (19:19 +0900)
committerSangwook Ju <sw.ju@samsung.com>
Mon, 14 May 2018 10:45:17 +0000 (19:45 +0900)
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 <janghyuck.kim@samsung.com>
drivers/iommu/exynos-iommu.c

index 1d5e93032757fe073d0ae4b89c3ce9171768d4e0..6552a37a3a9ef69ee12dc969c82c08a65dcd0606 100644 (file)
@@ -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);