aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoachim Eastwood <manabian@gmail.com>2015-10-24 12:55:23 -0400
committerStephen Boyd <sboyd@codeaurora.org>2015-10-26 15:36:56 -0400
commit2a9a06f98f26654d3b07482319ea0be276689f0b (patch)
tree72a89b76df2c69c926c7421a4794d41da8b7786f
parentbe68bf883170b3e4123fc4ff3745e38fb45a573e (diff)
clk: lpc18xx-ccu: fix potential system hang when disabling unused clocks
CCU branch clock register must only be accessed while the base (parent) clock is running. Access with a disabled base clock will cause the system to hang. Fix this issue by adding code that check if the parent clock is running in the is_enabled clk_ops callback. This hang would occur when disabling unused clocks after AMBA runtime pm had already disabled some of the clocks. Signed-off-by: Joachim Eastwood <manabian@gmail.com> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
-rw-r--r--drivers/clk/nxp/clk-lpc18xx-ccu.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/clk/nxp/clk-lpc18xx-ccu.c b/drivers/clk/nxp/clk-lpc18xx-ccu.c
index eeaee97da110..13aabbb3acbe 100644
--- a/drivers/clk/nxp/clk-lpc18xx-ccu.c
+++ b/drivers/clk/nxp/clk-lpc18xx-ccu.c
@@ -179,9 +179,22 @@ static void lpc18xx_ccu_gate_disable(struct clk_hw *hw)
179 179
180static int lpc18xx_ccu_gate_is_enabled(struct clk_hw *hw) 180static int lpc18xx_ccu_gate_is_enabled(struct clk_hw *hw)
181{ 181{
182 struct clk_gate *gate = to_clk_gate(hw); 182 const struct clk_hw *parent;
183
184 /*
185 * The branch clock registers are only accessible
186 * if the base (parent) clock is enabled. Register
187 * access with a disabled base clock will hang the
188 * system.
189 */
190 parent = clk_hw_get_parent(hw);
191 if (!parent)
192 return 0;
193
194 if (!clk_hw_is_enabled(parent))
195 return 0;
183 196
184 return clk_readl(gate->reg) & LPC18XX_CCU_RUN; 197 return clk_gate_ops.is_enabled(hw);
185} 198}
186 199
187static const struct clk_ops lpc18xx_ccu_gate_ops = { 200static const struct clk_ops lpc18xx_ccu_gate_ops = {