Skip to content

Commit

Permalink
ARM: imx: define struct clk_gate2 on our own
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shawn Guo committed May 12, 2014
1 parent 1e56f89 commit 54ee147
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions arch/arm/mach-imx/clk-gate2.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@
* parent - fixed parent. No clk_set_parent support
*/

#define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw)
struct clk_gate2 {
struct clk_hw hw;
void __iomem *reg;
u8 bit_idx;
u8 flags;
spinlock_t *lock;
};

#define to_clk_gate2(_hw) container_of(_hw, struct clk_gate2, hw)

static int clk_gate2_enable(struct clk_hw *hw)
{
struct clk_gate *gate = to_clk_gate(hw);
struct clk_gate2 *gate = to_clk_gate2(hw);
u32 reg;
unsigned long flags = 0;

Expand All @@ -50,7 +58,7 @@ static int clk_gate2_enable(struct clk_hw *hw)

static void clk_gate2_disable(struct clk_hw *hw)
{
struct clk_gate *gate = to_clk_gate(hw);
struct clk_gate2 *gate = to_clk_gate2(hw);
u32 reg;
unsigned long flags = 0;

Expand All @@ -68,7 +76,7 @@ static void clk_gate2_disable(struct clk_hw *hw)
static int clk_gate2_is_enabled(struct clk_hw *hw)
{
u32 reg;
struct clk_gate *gate = to_clk_gate(hw);
struct clk_gate2 *gate = to_clk_gate2(hw);

reg = readl(gate->reg);

Expand All @@ -89,15 +97,15 @@ struct clk *clk_register_gate2(struct device *dev, const char *name,
void __iomem *reg, u8 bit_idx,
u8 clk_gate2_flags, spinlock_t *lock)
{
struct clk_gate *gate;
struct clk_gate2 *gate;
struct clk *clk;
struct clk_init_data init;

gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL);
gate = kzalloc(sizeof(struct clk_gate2), GFP_KERNEL);
if (!gate)
return ERR_PTR(-ENOMEM);

/* struct clk_gate assignments */
/* struct clk_gate2 assignments */
gate->reg = reg;
gate->bit_idx = bit_idx;
gate->flags = clk_gate2_flags;
Expand Down

0 comments on commit 54ee147

Please sign in to comment.