Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <chunyan.zhang@unisoc.com>
Link: https://lkml.kernel.org/r/20200527053638.31439-2-zhang.lyra@gmail.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Chunyan Zhang and committed by
Stephen Boyd
8b4f6b8d c2f30986

+16
+7
drivers/clk/sprd/gate.c
··· 94 94 { 95 95 struct sprd_gate *sg = hw_to_sprd_gate(hw); 96 96 struct sprd_clk_common *common = &sg->common; 97 + struct clk_hw *parent; 97 98 unsigned int reg; 99 + 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 + } 98 105 99 106 regmap_read(common->regmap, common->reg, &reg); 100 107
+9
drivers/clk/sprd/gate.h
··· 19 19 struct sprd_clk_common common; 20 20 }; 21 21 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 + 22 31 #define SPRD_SC_GATE_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, \ 23 32 _sc_offset, _enable_mask, _flags, \ 24 33 _gate_flags, _udelay, _ops, _fn) \