1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2016 Maxime Ripard. All rights reserved.
9 #include <linux/clk-provider.h>
11 #include "ccu_common.h"
18 * struct ccu_nm - Definition of an N-M clock
20 * Clocks based on the formula parent * N / M
26 struct ccu_mult_internal n
;
27 struct ccu_div_internal m
;
28 struct ccu_frac_internal frac
;
29 struct ccu_sdm_internal sdm
;
31 unsigned int fixed_post_div
;
32 unsigned int min_rate
;
33 unsigned int max_rate
;
35 struct ccu_common common
;
38 #define SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(_struct, _name, _parent, _reg, \
41 _sdm_table, _sdm_en, \
42 _sdm_reg, _sdm_reg_en, \
43 _gate, _lock, _flags) \
44 struct ccu_nm _struct = { \
47 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
48 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
49 .sdm = _SUNXI_CCU_SDM(_sdm_table, _sdm_en, \
50 _sdm_reg, _sdm_reg_en),\
53 .features = CCU_FEATURE_SIGMA_DELTA_MOD, \
54 .hw.init = CLK_HW_INIT(_name, \
61 #define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(_struct, _name, _parent, _reg, \
64 _frac_en, _frac_sel, \
65 _frac_rate_0, _frac_rate_1, \
66 _gate, _lock, _flags) \
67 struct ccu_nm _struct = { \
70 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
71 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
72 .frac = _SUNXI_CCU_FRAC(_frac_en, _frac_sel, \
77 .features = CCU_FEATURE_FRACTIONAL, \
78 .hw.init = CLK_HW_INIT(_name, \
85 #define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN(_struct, _name, _parent, \
89 _frac_en, _frac_sel, \
90 _frac_rate_0, _frac_rate_1,\
91 _gate, _lock, _flags) \
92 struct ccu_nm _struct = { \
95 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
96 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
97 .frac = _SUNXI_CCU_FRAC(_frac_en, _frac_sel, \
100 .min_rate = _min_rate, \
103 .features = CCU_FEATURE_FRACTIONAL, \
104 .hw.init = CLK_HW_INIT(_name, \
111 #define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK_MIN_MAX(_struct, _name, \
113 _min_rate, _max_rate, \
116 _frac_en, _frac_sel, \
119 _gate, _lock, _flags) \
120 struct ccu_nm _struct = { \
123 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
124 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
125 .frac = _SUNXI_CCU_FRAC(_frac_en, _frac_sel, \
128 .min_rate = _min_rate, \
129 .max_rate = _max_rate, \
132 .features = CCU_FEATURE_FRACTIONAL, \
133 .hw.init = CLK_HW_INIT(_name, \
140 #define SUNXI_CCU_NM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
143 _gate, _lock, _flags) \
144 struct ccu_nm _struct = { \
147 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
148 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
151 .hw.init = CLK_HW_INIT(_name, \
158 static inline struct ccu_nm
*hw_to_ccu_nm(struct clk_hw
*hw
)
160 struct ccu_common
*common
= hw_to_ccu_common(hw
);
162 return container_of(common
, struct ccu_nm
, common
);
165 extern const struct clk_ops ccu_nm_ops
;
167 #endif /* _CCU_NM_H_ */