Skip to content

Commit 187e5cd

Browse files
Xiaolong Zhangbebarino
authored andcommitted
clk: sprd: add gate for pll clocks
Some sprd's gate clocks are used to the switch of pll, which need to wait a certain time for stable after being enabled. Signed-off-by: Xiaolong Zhang <[email protected]> Signed-off-by: Chunyan Zhang <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent bb6d3fb commit 187e5cd

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

drivers/clk/sprd/gate.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ static int sprd_sc_gate_enable(struct clk_hw *hw)
7979

8080
return 0;
8181
}
82+
83+
static int sprd_pll_sc_gate_prepare(struct clk_hw *hw)
84+
{
85+
struct sprd_gate *sg = hw_to_sprd_gate(hw);
86+
87+
clk_sc_gate_toggle(sg, true);
88+
udelay(sg->udelay);
89+
90+
return 0;
91+
}
92+
8293
static int sprd_gate_is_enabled(struct clk_hw *hw)
8394
{
8495
struct sprd_gate *sg = hw_to_sprd_gate(hw);
@@ -109,3 +120,9 @@ const struct clk_ops sprd_sc_gate_ops = {
109120
};
110121
EXPORT_SYMBOL_GPL(sprd_sc_gate_ops);
111122

123+
const struct clk_ops sprd_pll_sc_gate_ops = {
124+
.unprepare = sprd_sc_gate_disable,
125+
.prepare = sprd_pll_sc_gate_prepare,
126+
.is_enabled = sprd_gate_is_enabled,
127+
};
128+
EXPORT_SYMBOL_GPL(sprd_pll_sc_gate_ops);

drivers/clk/sprd/gate.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ struct sprd_gate {
1414
u32 enable_mask;
1515
u16 flags;
1616
u16 sc_offset;
17+
u16 udelay;
1718

1819
struct sprd_clk_common common;
1920
};
2021

21-
#define SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset, \
22-
_enable_mask, _flags, _gate_flags, _ops) \
22+
#define SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg, \
23+
_sc_offset, _enable_mask, _flags, \
24+
_gate_flags, _udelay, _ops) \
2325
struct sprd_gate _struct = { \
2426
.enable_mask = _enable_mask, \
2527
.sc_offset = _sc_offset, \
2628
.flags = _gate_flags, \
29+
.udelay = _udelay, \
2730
.common = { \
2831
.regmap = NULL, \
2932
.reg = _reg, \
@@ -34,6 +37,12 @@ struct sprd_gate {
3437
} \
3538
}
3639

40+
#define SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset, \
41+
_enable_mask, _flags, _gate_flags, _ops) \
42+
SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg, \
43+
_sc_offset, _enable_mask, _flags, \
44+
_gate_flags, 0, _ops)
45+
3746
#define SPRD_GATE_CLK(_struct, _name, _parent, _reg, \
3847
_enable_mask, _flags, _gate_flags) \
3948
SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, 0, \
@@ -46,6 +55,13 @@ struct sprd_gate {
4655
_enable_mask, _flags, _gate_flags, \
4756
&sprd_sc_gate_ops)
4857

58+
#define SPRD_PLL_SC_GATE_CLK(_struct, _name, _parent, _reg, _sc_offset, \
59+
_enable_mask, _flags, _gate_flags, _udelay) \
60+
SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg, \
61+
_sc_offset, _enable_mask, _flags, \
62+
_gate_flags, _udelay, \
63+
&sprd_pll_sc_gate_ops)
64+
4965
static inline struct sprd_gate *hw_to_sprd_gate(const struct clk_hw *hw)
5066
{
5167
struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
@@ -55,5 +71,6 @@ static inline struct sprd_gate *hw_to_sprd_gate(const struct clk_hw *hw)
5571

5672
extern const struct clk_ops sprd_gate_ops;
5773
extern const struct clk_ops sprd_sc_gate_ops;
74+
extern const struct clk_ops sprd_pll_sc_gate_ops;
5875

5976
#endif /* _SPRD_GATE_H_ */

0 commit comments

Comments
 (0)