1 /* SPDX-License-Identifier: GPL-2.0 */
3 // Spreadtrum pll clock driver
5 // Copyright (C) 2015~2017 Spreadtrum, Inc.
6 // Author: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
18 struct clk_bit_field
{
40 * struct sprd_pll - definition of adjustable pll clock
42 * @reg: registers used to set the configuration of pll clock,
43 * reg[0] shows how many registers this pll clock uses.
44 * @itable: pll ibias table, itable[0] means how many items this
46 * @udelay delay time after setting rate
47 * @factors used to calculate the pll clock rate
48 * @fvco: fvco threshold rate
54 const struct clk_bit_field
*factors
;
61 struct sprd_clk_common common
;
64 #define SPRD_PLL_HW_INIT_FN(_struct, _name, _parent, _reg, \
65 _regs_num, _itable, _factors, \
66 _udelay, _k1, _k2, _fflag, \
68 struct sprd_pll _struct = { \
69 .regs_num = _regs_num, \
71 .factors = _factors, \
80 .hw.init = _fn(_name, _parent, \
85 #define SPRD_PLL_WITH_ITABLE_K_FVCO(_struct, _name, _parent, _reg, \
86 _regs_num, _itable, _factors, \
87 _udelay, _k1, _k2, _fflag, _fvco) \
88 SPRD_PLL_HW_INIT_FN(_struct, _name, _parent, _reg, _regs_num, \
89 _itable, _factors, _udelay, _k1, _k2, \
90 _fflag, _fvco, CLK_HW_INIT)
92 #define SPRD_PLL_WITH_ITABLE_K(_struct, _name, _parent, _reg, \
93 _regs_num, _itable, _factors, \
95 SPRD_PLL_WITH_ITABLE_K_FVCO(_struct, _name, _parent, _reg, \
96 _regs_num, _itable, _factors, \
97 _udelay, _k1, _k2, 0, 0)
99 #define SPRD_PLL_WITH_ITABLE_1K(_struct, _name, _parent, _reg, \
100 _regs_num, _itable, _factors, _udelay) \
101 SPRD_PLL_WITH_ITABLE_K_FVCO(_struct, _name, _parent, _reg, \
102 _regs_num, _itable, _factors, \
103 _udelay, 1000, 1000, 0, 0)
105 #define SPRD_PLL_FW_NAME(_struct, _name, _parent, _reg, _regs_num, \
106 _itable, _factors, _udelay, _k1, _k2, \
108 SPRD_PLL_HW_INIT_FN(_struct, _name, _parent, _reg, _regs_num, \
109 _itable, _factors, _udelay, _k1, _k2, \
110 _fflag, _fvco, CLK_HW_INIT_FW_NAME)
112 #define SPRD_PLL_HW(_struct, _name, _parent, _reg, _regs_num, _itable, \
113 _factors, _udelay, _k1, _k2, _fflag, _fvco) \
114 SPRD_PLL_HW_INIT_FN(_struct, _name, _parent, _reg, _regs_num, \
115 _itable, _factors, _udelay, _k1, _k2, \
116 _fflag, _fvco, CLK_HW_INIT_HW)
118 static inline struct sprd_pll
*hw_to_sprd_pll(struct clk_hw
*hw
)
120 struct sprd_clk_common
*common
= hw_to_sprd_clk_common(hw
);
122 return container_of(common
, struct sprd_pll
, common
);
125 extern const struct clk_ops sprd_pll_ops
;
127 #endif /* _SPRD_PLL_H_ */