aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk-gate.c
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@linaro.org>2013-06-08 10:47:19 -0400
committerMike Turquette <mturquette@linaro.org>2013-06-15 23:23:53 -0400
commit045779942c04646a222289989e6a5b617dfdedf7 (patch)
treee66048660ffc624543a0a36e526ce685e8d3e132 /drivers/clk/clk-gate.c
parentd57dfe7508af2b528e26d84792edec1e7d919682 (diff)
clk: gate: add CLK_GATE_HIWORD_MASK
In Rockchip Cortex-A9 based chips, they don't use paradigm of reading-changing-writing the register contents. Instead they use a hiword mask to indicate the changed bits. When b1 should be set as gate, it also needs to indicate the change by setting hiword mask (b1 << 16). The patch adds gate flag for this usage. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/clk-gate.c')
-rw-r--r--drivers/clk/clk-gate.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c
index 15114febfd92..790306e921c8 100644
--- a/drivers/clk/clk-gate.c
+++ b/drivers/clk/clk-gate.c
@@ -53,12 +53,18 @@ static void clk_gate_endisable(struct clk_hw *hw, int enable)
53 if (gate->lock) 53 if (gate->lock)
54 spin_lock_irqsave(gate->lock, flags); 54 spin_lock_irqsave(gate->lock, flags);
55 55
56 reg = readl(gate->reg); 56 if (gate->flags & CLK_GATE_HIWORD_MASK) {
57 57 reg = BIT(gate->bit_idx + 16);
58 if (set) 58 if (set)
59 reg |= BIT(gate->bit_idx); 59 reg |= BIT(gate->bit_idx);
60 else 60 } else {
61 reg &= ~BIT(gate->bit_idx); 61 reg = readl(gate->reg);
62
63 if (set)
64 reg |= BIT(gate->bit_idx);
65 else
66 reg &= ~BIT(gate->bit_idx);
67 }
62 68
63 writel(reg, gate->reg); 69 writel(reg, gate->reg);
64 70
@@ -121,6 +127,13 @@ struct clk *clk_register_gate(struct device *dev, const char *name,
121 struct clk *clk; 127 struct clk *clk;
122 struct clk_init_data init; 128 struct clk_init_data init;
123 129
130 if (clk_gate_flags & CLK_GATE_HIWORD_MASK) {
131 if (bit_idx > 16) {
132 pr_err("gate bit exceeds LOWORD field\n");
133 return ERR_PTR(-EINVAL);
134 }
135 }
136
124 /* allocate the gate */ 137 /* allocate the gate */
125 gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL); 138 gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL);
126 if (!gate) { 139 if (!gate) {