1 /* SPDX-License-Identifier: GPL-2.0+ */
3 // OWL pll clock driver
5 // Copyright (c) 2014 Actions Semi Inc.
6 // Author: David Liu <liuwei@actions-semi.com>
8 // Copyright (c) 2018 Linaro Ltd.
9 // Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
14 #include "owl-common.h"
16 #define OWL_PLL_DEF_DELAY 50
18 /* last entry should have rate = 0 */
19 struct clk_pll_table
{
33 const struct clk_pll_table
*table
;
37 struct owl_pll_hw pll_hw
;
38 struct owl_clk_common common
;
41 #define OWL_PLL_HW(_reg, _bfreq, _bit_idx, _shift, \
42 _width, _min_mul, _max_mul, _delay, _table) \
46 .bit_idx = _bit_idx, \
49 .min_mul = _min_mul, \
50 .max_mul = _max_mul, \
55 #define OWL_PLL(_struct, _name, _parent, _reg, _bfreq, _bit_idx, \
56 _shift, _width, _min_mul, _max_mul, _table, _flags) \
57 struct owl_pll _struct = { \
58 .pll_hw = OWL_PLL_HW(_reg, _bfreq, _bit_idx, _shift, \
59 _width, _min_mul, _max_mul, \
60 OWL_PLL_DEF_DELAY, _table), \
63 .hw.init = CLK_HW_INIT(_name, \
70 #define OWL_PLL_NO_PARENT(_struct, _name, _reg, _bfreq, _bit_idx, \
71 _shift, _width, _min_mul, _max_mul, _table, _flags) \
72 struct owl_pll _struct = { \
73 .pll_hw = OWL_PLL_HW(_reg, _bfreq, _bit_idx, _shift, \
74 _width, _min_mul, _max_mul, \
75 OWL_PLL_DEF_DELAY, _table), \
78 .hw.init = CLK_HW_INIT_NO_PARENT(_name, \
84 #define OWL_PLL_NO_PARENT_DELAY(_struct, _name, _reg, _bfreq, _bit_idx, \
85 _shift, _width, _min_mul, _max_mul, _delay, _table, \
87 struct owl_pll _struct = { \
88 .pll_hw = OWL_PLL_HW(_reg, _bfreq, _bit_idx, _shift, \
89 _width, _min_mul, _max_mul, \
93 .hw.init = CLK_HW_INIT_NO_PARENT(_name, \
99 #define mul_mask(m) ((1 << ((m)->width)) - 1)
101 static inline struct owl_pll
*hw_to_owl_pll(const struct clk_hw
*hw
)
103 struct owl_clk_common
*common
= hw_to_owl_clk_common(hw
);
105 return container_of(common
, struct owl_pll
, common
);
108 extern const struct clk_ops owl_pll_ops
;
110 #endif /* _OWL_PLL_H_ */