Commit 32e8dec8 authored by Shawn Guo's avatar Shawn Guo Committed by Greg Kroah-Hartman

ARM: imx: fix .is_enabled() of shared gate clock

commit 9e1ac462 upstream.

Commit 63288b72 ("ARM: imx: fix shared gate clock") attempted to fix
an issue with particular enable/disable sequence from two shared gate
clocks.  But unfortunately, while it partially fixed the issue, it also
did something wrong in .is_enabled() function hook.  In case of shared
gate, the function shouldn't really query the hardware state via
share_count, because the function is trying to query the enabling state
of the clock in question, not the hardware state which is shared by
multiple clocks.

Fix the issue by returning the enable_count of the clock itself which is
maintained by clock core, in case it's a clock sharing hardware gate
with others.  As the result, the initialization of share_count per
hardware state is not needed now.  So remove it.
Reported-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Fixes: 63288b72 ("ARM: imx: fix shared gate clock")
Signed-off-by: default avatarShawn Guo <shawn.guo@freescale.com>
Tested-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fb69ff7f
...@@ -97,7 +97,7 @@ static int clk_gate2_is_enabled(struct clk_hw *hw) ...@@ -97,7 +97,7 @@ static int clk_gate2_is_enabled(struct clk_hw *hw)
struct clk_gate2 *gate = to_clk_gate2(hw); struct clk_gate2 *gate = to_clk_gate2(hw);
if (gate->share_count) if (gate->share_count)
return !!(*gate->share_count); return !!__clk_get_enable_count(hw->clk);
else else
return clk_gate2_reg_is_enabled(gate->reg, gate->bit_idx); return clk_gate2_reg_is_enabled(gate->reg, gate->bit_idx);
} }
...@@ -127,10 +127,6 @@ struct clk *clk_register_gate2(struct device *dev, const char *name, ...@@ -127,10 +127,6 @@ struct clk *clk_register_gate2(struct device *dev, const char *name,
gate->bit_idx = bit_idx; gate->bit_idx = bit_idx;
gate->flags = clk_gate2_flags; gate->flags = clk_gate2_flags;
gate->lock = lock; gate->lock = lock;
/* Initialize share_count per hardware state */
if (share_count)
*share_count = clk_gate2_reg_is_enabled(reg, bit_idx) ? 1 : 0;
gate->share_count = share_count; gate->share_count = share_count;
init.name = name; init.name = name;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment