Commit 875e8f6b authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by Geert Uytterhoeven

clk: renesas: rcar-gen3: Add spinlock

Protect the CPG register read-modify-write sequence with a spinlock.
Signed-off-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
parent 8cb8f16c
...@@ -30,14 +30,19 @@ ...@@ -30,14 +30,19 @@
#define CPG_RCKCR_CKSEL BIT(15) /* RCLK Clock Source Select */ #define CPG_RCKCR_CKSEL BIT(15) /* RCLK Clock Source Select */
static spinlock_t cpg_lock;
static void cpg_reg_modify(void __iomem *reg, u32 clear, u32 set) static void cpg_reg_modify(void __iomem *reg, u32 clear, u32 set)
{ {
unsigned long flags;
u32 val; u32 val;
spin_lock_irqsave(&cpg_lock, flags);
val = readl(reg); val = readl(reg);
val &= ~clear; val &= ~clear;
val |= set; val |= set;
writel(val, reg); writel(val, reg);
spin_unlock_irqrestore(&cpg_lock, flags);
}; };
struct cpg_simple_notifier { struct cpg_simple_notifier {
...@@ -615,5 +620,8 @@ int __init rcar_gen3_cpg_init(const struct rcar_gen3_cpg_pll_config *config, ...@@ -615,5 +620,8 @@ int __init rcar_gen3_cpg_init(const struct rcar_gen3_cpg_pll_config *config,
if (attr) if (attr)
cpg_quirks = (uintptr_t)attr->data; cpg_quirks = (uintptr_t)attr->data;
pr_debug("%s: mode = 0x%x quirks = 0x%x\n", __func__, mode, cpg_quirks); pr_debug("%s: mode = 0x%x quirks = 0x%x\n", __func__, mode, cpg_quirks);
spin_lock_init(&cpg_lock);
return 0; return 0;
} }
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