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"
28 struct clk_div_table
*table
;
31 #define _SUNXI_CCU_DIV_TABLE_FLAGS(_shift, _width, _table, _flags) \
39 #define _SUNXI_CCU_DIV_FLAGS(_shift, _width, _flags) \
40 _SUNXI_CCU_DIV_TABLE_FLAGS(_shift, _width, NULL, _flags)
42 #define _SUNXI_CCU_DIV_TABLE(_shift, _width, _table) \
43 _SUNXI_CCU_DIV_TABLE_FLAGS(_shift, _width, _table, 0)
45 #define _SUNXI_CCU_DIV(_shift, _width) \
46 _SUNXI_CCU_DIV_TABLE_FLAGS(_shift, _width, NULL, 0)
52 struct ccu_mux_internal mux
;
53 struct ccu_common common
;
56 #define SUNXI_CCU_DIV_TABLE_WITH_GATE(_struct, _name, _parent, _reg, \
58 _table, _gate, _flags) \
59 struct ccu_div _struct = { \
60 .div = _SUNXI_CCU_DIV_TABLE(_shift, _width, \
65 .hw.init = CLK_HW_INIT(_name, \
73 #define SUNXI_CCU_DIV_TABLE(_struct, _name, _parent, _reg, \
76 SUNXI_CCU_DIV_TABLE_WITH_GATE(_struct, _name, _parent, _reg, \
77 _shift, _width, _table, 0, \
80 #define SUNXI_CCU_M_WITH_MUX_GATE(_struct, _name, _parents, _reg, \
81 _mshift, _mwidth, _muxshift, _muxwidth, \
83 struct ccu_div _struct = { \
85 .div = _SUNXI_CCU_DIV(_mshift, _mwidth), \
86 .mux = SUNXI_CLK_MUX(_muxshift, _muxwidth), \
89 .hw.init = CLK_HW_INIT_PARENTS(_name, \
96 #define SUNXI_CCU_M_WITH_MUX(_struct, _name, _parents, _reg, \
97 _mshift, _mwidth, _muxshift, _muxwidth, \
99 SUNXI_CCU_M_WITH_MUX_GATE(_struct, _name, _parents, _reg, \
100 _mshift, _mwidth, _muxshift, _muxwidth, \
104 #define SUNXI_CCU_M_WITH_GATE(_struct, _name, _parent, _reg, \
105 _mshift, _mwidth, _gate, \
107 struct ccu_div _struct = { \
109 .div = _SUNXI_CCU_DIV(_mshift, _mwidth), \
112 .hw.init = CLK_HW_INIT(_name, \
119 #define SUNXI_CCU_M(_struct, _name, _parent, _reg, _mshift, _mwidth, \
121 SUNXI_CCU_M_WITH_GATE(_struct, _name, _parent, _reg, \
122 _mshift, _mwidth, 0, _flags)
124 static inline struct ccu_div
*hw_to_ccu_div(struct clk_hw
*hw
)
126 struct ccu_common
*common
= hw_to_ccu_common(hw
);
128 return container_of(common
, struct ccu_div
, common
);
131 extern const struct clk_ops ccu_div_ops
;
133 #endif /* _CCU_DIV_H_ */