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"
25 * struct ccu_nm - Definition of an N-M clock
27 * Clocks based on the formula parent * N / M
33 struct ccu_mult_internal n
;
34 struct ccu_div_internal m
;
35 struct ccu_frac_internal frac
;
37 struct ccu_common common
;
40 #define SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(_struct, _name, _parent, _reg, \
43 _frac_en, _frac_sel, \
44 _frac_rate_0, _frac_rate_1, \
45 _gate, _lock, _flags) \
46 struct ccu_nm _struct = { \
49 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
50 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
51 .frac = _SUNXI_CCU_FRAC(_frac_en, _frac_sel, \
56 .features = CCU_FEATURE_FRACTIONAL, \
57 .hw.init = CLK_HW_INIT(_name, \
64 #define SUNXI_CCU_NM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
67 _gate, _lock, _flags) \
68 struct ccu_nm _struct = { \
71 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
72 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
75 .hw.init = CLK_HW_INIT(_name, \
82 static inline struct ccu_nm
*hw_to_ccu_nm(struct clk_hw
*hw
)
84 struct ccu_common
*common
= hw_to_ccu_common(hw
);
86 return container_of(common
, struct ccu_nm
, common
);
89 extern const struct clk_ops ccu_nm_ops
;
91 #endif /* _CCU_NM_H_ */