diff options
author | Shawn Guo <shawn.guo@freescale.com> | 2014-04-19 01:01:30 -0400 |
---|---|---|
committer | Nicolin Chen <Guangyu.Chen@freescale.com> | 2014-04-22 23:14:18 -0400 |
commit | b0293bafbb378183279eb74442506194db7b2c89 (patch) | |
tree | 85651af05c20180fe472e277150e657befae5dca | |
parent | 0ac36559f00dace422fbc766de3e06cf2a343fdf (diff) |
ARM: imx: define struct clk_gate2 on our own
The imx clk-gate2 driver implements an i.MX specific gate clock, which
has two bits controlling the gate states. While this is a completely
separate gate driver from the common clk-gate one, it reuses the common
clk_gate structure. Such reusing makes the extending of clk_gate2
clumsy. Let's define struct clk_gate2 on our own to make the driver
independent of the common clk-gate one, and ease the clk_gate2 extending
at a later time.
Signed-off-by: Shawn Guo <shawn.guo@freescale.com>
Signed-off-by: Nicolin Chen <Guangyu.Chen@freescale.com>
-rw-r--r-- | arch/arm/mach-imx/clk-gate2.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/arch/arm/mach-imx/clk-gate2.c b/arch/arm/mach-imx/clk-gate2.c index dcdc1a1d8a1b..a7857a9dd866 100644 --- a/arch/arm/mach-imx/clk-gate2.c +++ b/arch/arm/mach-imx/clk-gate2.c | |||
@@ -28,11 +28,19 @@ | |||
28 | * parent - fixed parent. No clk_set_parent support | 28 | * parent - fixed parent. No clk_set_parent support |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw) | 31 | struct clk_gate2 { |
32 | struct clk_hw hw; | ||
33 | void __iomem *reg; | ||
34 | u8 bit_idx; | ||
35 | u8 flags; | ||
36 | spinlock_t *lock; | ||
37 | }; | ||
38 | |||
39 | #define to_clk_gate2(_hw) container_of(_hw, struct clk_gate2, hw) | ||
32 | 40 | ||
33 | static int clk_gate2_enable(struct clk_hw *hw) | 41 | static int clk_gate2_enable(struct clk_hw *hw) |
34 | { | 42 | { |
35 | struct clk_gate *gate = to_clk_gate(hw); | 43 | struct clk_gate2 *gate = to_clk_gate2(hw); |
36 | u32 reg; | 44 | u32 reg; |
37 | unsigned long flags = 0; | 45 | unsigned long flags = 0; |
38 | 46 | ||
@@ -51,7 +59,7 @@ static int clk_gate2_enable(struct clk_hw *hw) | |||
51 | 59 | ||
52 | static void clk_gate2_disable(struct clk_hw *hw) | 60 | static void clk_gate2_disable(struct clk_hw *hw) |
53 | { | 61 | { |
54 | struct clk_gate *gate = to_clk_gate(hw); | 62 | struct clk_gate2 *gate = to_clk_gate2(hw); |
55 | u32 reg; | 63 | u32 reg; |
56 | unsigned long flags = 0; | 64 | unsigned long flags = 0; |
57 | 65 | ||
@@ -69,7 +77,7 @@ static void clk_gate2_disable(struct clk_hw *hw) | |||
69 | static int clk_gate2_is_enabled(struct clk_hw *hw) | 77 | static int clk_gate2_is_enabled(struct clk_hw *hw) |
70 | { | 78 | { |
71 | u32 reg; | 79 | u32 reg; |
72 | struct clk_gate *gate = to_clk_gate(hw); | 80 | struct clk_gate2 *gate = to_clk_gate2(hw); |
73 | 81 | ||
74 | reg = readl(gate->reg); | 82 | reg = readl(gate->reg); |
75 | 83 | ||
@@ -90,15 +98,15 @@ struct clk *clk_register_gate2(struct device *dev, const char *name, | |||
90 | void __iomem *reg, u8 bit_idx, | 98 | void __iomem *reg, u8 bit_idx, |
91 | u8 clk_gate2_flags, spinlock_t *lock) | 99 | u8 clk_gate2_flags, spinlock_t *lock) |
92 | { | 100 | { |
93 | struct clk_gate *gate; | 101 | struct clk_gate2 *gate; |
94 | struct clk *clk; | 102 | struct clk *clk; |
95 | struct clk_init_data init; | 103 | struct clk_init_data init; |
96 | 104 | ||
97 | gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL); | 105 | gate = kzalloc(sizeof(struct clk_gate2), GFP_KERNEL); |
98 | if (!gate) | 106 | if (!gate) |
99 | return ERR_PTR(-ENOMEM); | 107 | return ERR_PTR(-ENOMEM); |
100 | 108 | ||
101 | /* struct clk_gate assignments */ | 109 | /* struct clk_gate2 assignments */ |
102 | gate->reg = reg; | 110 | gate->reg = reg; |
103 | gate->bit_idx = bit_idx; | 111 | gate->bit_idx = bit_idx; |
104 | gate->flags = clk_gate2_flags; | 112 | gate->flags = clk_gate2_flags; |