Commit b398af21 authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Joerg Roedel

iommu/exynos: Simplify master clock operations

All clock API function can be called on NULL clock, so simplify code avoid
checking of master clock presence.
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 5e3435eb
...@@ -333,8 +333,7 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id) ...@@ -333,8 +333,7 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id)
spin_lock(&data->lock); spin_lock(&data->lock);
if (!IS_ERR(data->clk_master)) clk_enable(data->clk_master);
clk_enable(data->clk_master);
itype = (enum exynos_sysmmu_inttype) itype = (enum exynos_sysmmu_inttype)
__ffs(__raw_readl(data->sfrbase + REG_INT_STATUS)); __ffs(__raw_readl(data->sfrbase + REG_INT_STATUS));
...@@ -366,8 +365,7 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id) ...@@ -366,8 +365,7 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id)
sysmmu_unblock(data->sfrbase); sysmmu_unblock(data->sfrbase);
if (!IS_ERR(data->clk_master)) clk_disable(data->clk_master);
clk_disable(data->clk_master);
spin_unlock(&data->lock); spin_unlock(&data->lock);
...@@ -376,15 +374,13 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id) ...@@ -376,15 +374,13 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id)
static void __sysmmu_disable_nocount(struct sysmmu_drvdata *data) static void __sysmmu_disable_nocount(struct sysmmu_drvdata *data)
{ {
if (!IS_ERR(data->clk_master)) clk_enable(data->clk_master);
clk_enable(data->clk_master);
__raw_writel(CTRL_DISABLE, data->sfrbase + REG_MMU_CTRL); __raw_writel(CTRL_DISABLE, data->sfrbase + REG_MMU_CTRL);
__raw_writel(0, data->sfrbase + REG_MMU_CFG); __raw_writel(0, data->sfrbase + REG_MMU_CFG);
clk_disable(data->clk); clk_disable(data->clk);
if (!IS_ERR(data->clk_master)) clk_disable(data->clk_master);
clk_disable(data->clk_master);
} }
static bool __sysmmu_disable(struct sysmmu_drvdata *data) static bool __sysmmu_disable(struct sysmmu_drvdata *data)
...@@ -437,8 +433,7 @@ static void __sysmmu_init_config(struct sysmmu_drvdata *data) ...@@ -437,8 +433,7 @@ static void __sysmmu_init_config(struct sysmmu_drvdata *data)
static void __sysmmu_enable_nocount(struct sysmmu_drvdata *data) static void __sysmmu_enable_nocount(struct sysmmu_drvdata *data)
{ {
if (!IS_ERR(data->clk_master)) clk_enable(data->clk_master);
clk_enable(data->clk_master);
clk_enable(data->clk); clk_enable(data->clk);
__raw_writel(CTRL_BLOCK, data->sfrbase + REG_MMU_CTRL); __raw_writel(CTRL_BLOCK, data->sfrbase + REG_MMU_CTRL);
...@@ -449,8 +444,7 @@ static void __sysmmu_enable_nocount(struct sysmmu_drvdata *data) ...@@ -449,8 +444,7 @@ static void __sysmmu_enable_nocount(struct sysmmu_drvdata *data)
__raw_writel(CTRL_ENABLE, data->sfrbase + REG_MMU_CTRL); __raw_writel(CTRL_ENABLE, data->sfrbase + REG_MMU_CTRL);
if (!IS_ERR(data->clk_master)) clk_disable(data->clk_master);
clk_disable(data->clk_master);
} }
static int __sysmmu_enable(struct sysmmu_drvdata *data, phys_addr_t pgtable, static int __sysmmu_enable(struct sysmmu_drvdata *data, phys_addr_t pgtable,
...@@ -493,16 +487,14 @@ static void sysmmu_tlb_invalidate_flpdcache(struct sysmmu_drvdata *data, ...@@ -493,16 +487,14 @@ static void sysmmu_tlb_invalidate_flpdcache(struct sysmmu_drvdata *data,
{ {
unsigned long flags; unsigned long flags;
if (!IS_ERR(data->clk_master)) clk_enable(data->clk_master);
clk_enable(data->clk_master);
spin_lock_irqsave(&data->lock, flags); spin_lock_irqsave(&data->lock, flags);
if (is_sysmmu_active(data)) if (is_sysmmu_active(data))
__sysmmu_tlb_invalidate_flpdcache(data, iova); __sysmmu_tlb_invalidate_flpdcache(data, iova);
spin_unlock_irqrestore(&data->lock, flags); spin_unlock_irqrestore(&data->lock, flags);
if (!IS_ERR(data->clk_master)) clk_disable(data->clk_master);
clk_disable(data->clk_master);
} }
static void sysmmu_tlb_invalidate_entry(struct sysmmu_drvdata *data, static void sysmmu_tlb_invalidate_entry(struct sysmmu_drvdata *data,
...@@ -514,8 +506,7 @@ static void sysmmu_tlb_invalidate_entry(struct sysmmu_drvdata *data, ...@@ -514,8 +506,7 @@ static void sysmmu_tlb_invalidate_entry(struct sysmmu_drvdata *data,
if (is_sysmmu_active(data)) { if (is_sysmmu_active(data)) {
unsigned int num_inv = 1; unsigned int num_inv = 1;
if (!IS_ERR(data->clk_master)) clk_enable(data->clk_master);
clk_enable(data->clk_master);
/* /*
* L2TLB invalidation required * L2TLB invalidation required
...@@ -535,8 +526,7 @@ static void sysmmu_tlb_invalidate_entry(struct sysmmu_drvdata *data, ...@@ -535,8 +526,7 @@ static void sysmmu_tlb_invalidate_entry(struct sysmmu_drvdata *data,
data->sfrbase, iova, num_inv); data->sfrbase, iova, num_inv);
sysmmu_unblock(data->sfrbase); sysmmu_unblock(data->sfrbase);
} }
if (!IS_ERR(data->clk_master)) clk_disable(data->clk_master);
clk_disable(data->clk_master);
} else { } else {
dev_dbg(data->master, dev_dbg(data->master,
"disabled. Skipping TLB invalidation @ %#x\n", iova); "disabled. Skipping TLB invalidation @ %#x\n", iova);
...@@ -593,6 +583,8 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev) ...@@ -593,6 +583,8 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev)
dev_err(dev, "Failed to prepare master's clk\n"); dev_err(dev, "Failed to prepare master's clk\n");
return ret; return ret;
} }
} else {
data->clk_master = NULL;
} }
data->sysmmu = dev; data->sysmmu = dev;
......
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