summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk-gate.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-12-07 10:34:31 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-03-15 09:53:30 +0100
commit87eebfe9662506ca1d699150a27f6d524ac79a51 (patch)
tree5fb0451d104d144c359afef23f576dc22fe7a6c9 /drivers/clk/clk-gate.c
parentd34aca4c09615870b694820dc21049bd1e77030e (diff)
downloadbarebox-87eebfe9662506ca1d699150a27f6d524ac79a51.tar.gz
barebox-87eebfe9662506ca1d699150a27f6d524ac79a51.tar.xz
clk: Add is_enabled callback
This allows us to better detect whether a clk is enabled or not. - If we can ask a clk, ask it. If it's enabled, go on and ask parents - If we can't ask it, but it can be enabled, depend on the enable_count. if it's positive, go on and ask parents - If we can't ask it and it cannot be enabled, assume it is enabled and ask parents. This makes the CLK_ALWAYS_ENABLED unnecessary, since the fixed clk now always returns 1 in its is_enabled callback. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/clk/clk-gate.c')
-rw-r--r--drivers/clk/clk-gate.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c
index cf1bb1af62..a455094b69 100644
--- a/drivers/clk/clk-gate.c
+++ b/drivers/clk/clk-gate.c
@@ -49,9 +49,23 @@ static void clk_gate_disable(struct clk *clk)
writel(val, g->reg);
}
+static int clk_gate_is_enabled(struct clk *clk)
+{
+ struct clk_gate *g = container_of(clk, struct clk_gate, clk);
+ u32 val;
+
+ val = readl(g->reg);
+
+ if (val & (1 << g->shift))
+ return 1;
+ else
+ return 0;
+}
+
struct clk_ops clk_gate_ops = {
.enable = clk_gate_enable,
.disable = clk_gate_disable,
+ .is_enabled = clk_gate_is_enabled,
};
struct clk *clk_gate(const char *name, const char *parent, void __iomem *reg,