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"
16 struct ccu_common common;
19 #define SUNXI_CCU_GATE(_struct, _name, _parent, _reg, _gate, _flags) \
20 struct ccu_gate _struct = { \
24 .hw.init = CLK_HW_INIT(_name, \
31 #define SUNXI_CCU_GATE_HW(_struct, _name, _parent, _reg, _gate, _flags) \
32 struct ccu_gate _struct = { \
36 .hw.init = CLK_HW_INIT_HW(_name, \
43 #define SUNXI_CCU_GATE_FW(_struct, _name, _parent, _reg, _gate, _flags) \
44 struct ccu_gate _struct = { \
48 .hw.init = CLK_HW_INIT_FW_NAME(_name, \
56 * The following macros allow the re-use of the data structure
57 * holding the parent info.
59 #define SUNXI_CCU_GATE_HWS(_struct, _name, _parent, _reg, _gate, _flags) \
60 struct ccu_gate _struct = { \
64 .hw.init = CLK_HW_INIT_HWS(_name, \
71 #define SUNXI_CCU_GATE_HWS_WITH_PREDIV(_struct, _name, _parent, _reg, \
72 _gate, _prediv, _flags) \
73 struct ccu_gate _struct = { \
78 .features = CCU_FEATURE_ALL_PREDIV, \
79 .hw.init = CLK_HW_INIT_HWS(_name, \
86 #define SUNXI_CCU_GATE_DATA(_struct, _name, _data, _reg, _gate, _flags) \
87 struct ccu_gate _struct = { \
92 CLK_HW_INIT_PARENTS_DATA(_name, \
99 #define SUNXI_CCU_GATE_DATA_WITH_PREDIV(_struct, _name, _parent, _reg, \
100 _gate, _prediv, _flags) \
101 struct ccu_gate _struct = { \
106 .features = CCU_FEATURE_ALL_PREDIV, \
107 .hw.init = CLK_HW_INIT_PARENTS_DATA(_name, \
114 static inline struct ccu_gate *hw_to_ccu_gate(struct clk_hw *hw)
116 struct ccu_common *common = hw_to_ccu_common(hw);
118 return container_of(common, struct ccu_gate, common);
121 void ccu_gate_helper_disable(struct ccu_common *common, u32 gate);
122 int ccu_gate_helper_enable(struct ccu_common *common, u32 gate);
123 int ccu_gate_helper_is_enabled(struct ccu_common *common, u32 gate);
125 extern const struct clk_ops ccu_gate_ops;
127 #endif /* _CCU_GATE_H_ */