2 * Copyright (c) 2016 Maxime Ripard. All rights reserved.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
17 #include <linux/clk-provider.h>
19 #include "ccu_common.h"
26 * struct ccu_nm - Definition of an N-M clock
28 * Clocks based on the formula parent * N / M
34 struct ccu_mult_internal n
;
35 struct ccu_div_internal m
;
36 struct ccu_frac_internal frac
;
37 struct ccu_sdm_internal sdm
;
39 unsigned int fixed_post_div
;
40 unsigned int min_rate
;
42 struct ccu_common common
;
45 #define SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(_struct, _name, _parent, _reg, \
48 _sdm_table, _sdm_en, \
49 _sdm_reg, _sdm_reg_en, \
50 _gate, _lock, _flags) \
51 struct ccu_nm _struct = { \
54 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
55 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
56 .sdm = _SUNXI_CCU_SDM(_sdm_table, _sdm_en, \
57 _sdm_reg, _sdm_reg_en),\
60 .features = CCU_FEATURE_SIGMA_DELTA_MOD, \
61 .hw.init = CLK_HW_INIT(_name, \
68 #define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(_struct, _name, _parent, _reg, \
71 _frac_en, _frac_sel, \
72 _frac_rate_0, _frac_rate_1, \
73 _gate, _lock, _flags) \
74 struct ccu_nm _struct = { \
77 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
78 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
79 .frac = _SUNXI_CCU_FRAC(_frac_en, _frac_sel, \
84 .features = CCU_FEATURE_FRACTIONAL, \
85 .hw.init = CLK_HW_INIT(_name, \
92 #define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN(_struct, _name, _parent, \
96 _frac_en, _frac_sel, \
97 _frac_rate_0, _frac_rate_1,\
98 _gate, _lock, _flags) \
99 struct ccu_nm _struct = { \
102 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
103 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
104 .frac = _SUNXI_CCU_FRAC(_frac_en, _frac_sel, \
107 .min_rate = _min_rate, \
110 .features = CCU_FEATURE_FRACTIONAL, \
111 .hw.init = CLK_HW_INIT(_name, \
118 #define SUNXI_CCU_NM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
121 _gate, _lock, _flags) \
122 struct ccu_nm _struct = { \
125 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
126 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
129 .hw.init = CLK_HW_INIT(_name, \
136 static inline struct ccu_nm
*hw_to_ccu_nm(struct clk_hw
*hw
)
138 struct ccu_common
*common
= hw_to_ccu_common(hw
);
140 return container_of(common
, struct ccu_nm
, common
);
143 extern const struct clk_ops ccu_nm_ops
;
145 #endif /* _CCU_NM_H_ */