Skip to content

Commit 8b4f6b8

Browse files
Chunyan Zhangbebarino
authored andcommitted
clk: sprd: check its parent status before reading gate clock
Some clocks only can be accessed if their parent is enabled. mipi_csi_xx clocks on SC9863A are an examples. We have to ensure the parent clock is enabled when reading those clocks. Signed-off-by: Chunyan Zhang <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent c2f3098 commit 8b4f6b8

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/clk/sprd/gate.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,15 @@ static int sprd_gate_is_enabled(struct clk_hw *hw)
9494
{
9595
struct sprd_gate *sg = hw_to_sprd_gate(hw);
9696
struct sprd_clk_common *common = &sg->common;
97+
struct clk_hw *parent;
9798
unsigned int reg;
9899

100+
if (sg->flags & SPRD_GATE_NON_AON) {
101+
parent = clk_hw_get_parent(hw);
102+
if (!parent || !clk_hw_is_enabled(parent))
103+
return 0;
104+
}
105+
99106
regmap_read(common->regmap, common->reg, &reg);
100107

101108
if (sg->flags & CLK_GATE_SET_TO_DISABLE)

drivers/clk/sprd/gate.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ struct sprd_gate {
1919
struct sprd_clk_common common;
2020
};
2121

22+
/*
23+
* sprd_gate->flags is used for:
24+
* CLK_GATE_SET_TO_DISABLE BIT(0)
25+
* CLK_GATE_HIWORD_MASK BIT(1)
26+
* CLK_GATE_BIG_ENDIAN BIT(2)
27+
* so we define new flags from BIT(3)
28+
*/
29+
#define SPRD_GATE_NON_AON BIT(3) /* not alway powered on, check before read */
30+
2231
#define SPRD_SC_GATE_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, \
2332
_sc_offset, _enable_mask, _flags, \
2433
_gate_flags, _udelay, _ops, _fn) \

0 commit comments

Comments
 (0)