[COMMON] iommu/exynos: runtime suspend/resume callback
authorJanghyuck Kim <janghyuck.kim@samsung.com>
Mon, 25 Apr 2016 09:27:20 +0000 (18:27 +0900)
committerSangwook Ju <sw.ju@samsung.com>
Mon, 14 May 2018 10:45:18 +0000 (19:45 +0900)
Sysmmu operation is implicitly enabled and disabled when master device
turned on the power and off the power.

This patch replaces runtime pm suspend/resume callback of platform bus
with exynos_iommu_runtime_suspend/resume that added sysmmu handling.

Change-Id: I5e5e1f5fb485a9943c84c0e6a379b8720de57094
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
drivers/iommu/exynos-iommu.c

index aba7bfc69d25f18016a31ee1295ed56788730523..ef9794fa5d69e6c4ac38c838461ed394afc019f8 100644 (file)
@@ -426,7 +426,35 @@ static int exynos_sysmmu_resume(struct device *dev)
 }
 #endif
 
+int exynos_iommu_runtime_suspend(struct device *sysmmu)
+{
+       unsigned long flags;
+       struct sysmmu_drvdata *drvdata = dev_get_drvdata(sysmmu);
+
+       spin_lock_irqsave(&drvdata->lock, flags);
+       if (put_sysmmu_runtime_active(drvdata) && is_sysmmu_active(drvdata))
+               __sysmmu_disable_nocount(drvdata);
+       spin_unlock_irqrestore(&drvdata->lock, flags);
+
+       return 0;
+}
+
+int exynos_iommu_runtime_resume(struct device *sysmmu)
+{
+       unsigned long flags;
+       struct sysmmu_drvdata *drvdata = dev_get_drvdata(sysmmu);
+
+       spin_lock_irqsave(&drvdata->lock, flags);
+       if (get_sysmmu_runtime_active(drvdata) && is_sysmmu_active(drvdata))
+               __sysmmu_enable_nocount(drvdata);
+       spin_unlock_irqrestore(&drvdata->lock, flags);
+
+       return 0;
+}
+
 static const struct dev_pm_ops sysmmu_pm_ops = {
+       SET_RUNTIME_PM_OPS(exynos_iommu_runtime_suspend,
+                               exynos_iommu_runtime_resume, NULL)
        SET_LATE_SYSTEM_SLEEP_PM_OPS(exynos_sysmmu_suspend, exynos_sysmmu_resume)
 };