13 #include <linux/module.h>
14 #include <linux/slab.h>
17 #include <linux/string.h>
29 #define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw)
31 static int clk_gate2_enable(
struct clk_hw *
hw)
35 unsigned long flags = 0;
40 reg =
readl(gate->reg);
41 reg |= 3 << gate->bit_idx;
45 spin_unlock_irqrestore(gate->lock, flags);
50 static void clk_gate2_disable(
struct clk_hw *
hw)
54 unsigned long flags = 0;
59 reg =
readl(gate->reg);
60 reg &= ~(3 << gate->bit_idx);
64 spin_unlock_irqrestore(gate->lock, flags);
67 static int clk_gate2_is_enabled(
struct clk_hw *hw)
72 reg =
readl(gate->reg);
74 if (((reg >> gate->bit_idx) & 3) == 3)
80 static struct clk_ops clk_gate2_ops = {
81 .enable = clk_gate2_enable,
82 .disable = clk_gate2_disable,
83 .is_enabled = clk_gate2_is_enabled,
87 const char *parent_name,
unsigned long flags,
91 struct clk_gate *gate;
93 struct clk_init_data init;
95 gate = kzalloc(
sizeof(
struct clk_gate),
GFP_KERNEL);
101 gate->bit_idx = bit_idx;
102 gate->flags = clk_gate2_flags;
106 init.ops = &clk_gate2_ops;
108 init.parent_names = parent_name ? &parent_name :
NULL;
109 init.num_parents = parent_name ? 1 : 0;
111 gate->hw.init = &
init;