Merge tag 'trace-v5.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux/fpc-iii.git] / drivers / clk / sunxi-ng / ccu_gate.h
blobc386689a952b89304e878bfa844a099605207e69
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (c) 2016 Maxime Ripard. All rights reserved.
4 */
6 #ifndef _CCU_GATE_H_
7 #define _CCU_GATE_H_
9 #include <linux/clk-provider.h>
11 #include "ccu_common.h"
13 struct ccu_gate {
14 u32 enable;
16 struct ccu_common common;
19 #define SUNXI_CCU_GATE(_struct, _name, _parent, _reg, _gate, _flags) \
20 struct ccu_gate _struct = { \
21 .enable = _gate, \
22 .common = { \
23 .reg = _reg, \
24 .hw.init = CLK_HW_INIT(_name, \
25 _parent, \
26 &ccu_gate_ops, \
27 _flags), \
28 } \
31 #define SUNXI_CCU_GATE_HW(_struct, _name, _parent, _reg, _gate, _flags) \
32 struct ccu_gate _struct = { \
33 .enable = _gate, \
34 .common = { \
35 .reg = _reg, \
36 .hw.init = CLK_HW_INIT_HW(_name, \
37 _parent, \
38 &ccu_gate_ops, \
39 _flags), \
40 } \
43 #define SUNXI_CCU_GATE_FW(_struct, _name, _parent, _reg, _gate, _flags) \
44 struct ccu_gate _struct = { \
45 .enable = _gate, \
46 .common = { \
47 .reg = _reg, \
48 .hw.init = CLK_HW_INIT_FW_NAME(_name, \
49 _parent, \
50 &ccu_gate_ops, \
51 _flags), \
52 } \
56 * The following two 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 = { \
61 .enable = _gate, \
62 .common = { \
63 .reg = _reg, \
64 .hw.init = CLK_HW_INIT_HWS(_name, \
65 _parent, \
66 &ccu_gate_ops, \
67 _flags), \
68 } \
71 #define SUNXI_CCU_GATE_DATA(_struct, _name, _data, _reg, _gate, _flags) \
72 struct ccu_gate _struct = { \
73 .enable = _gate, \
74 .common = { \
75 .reg = _reg, \
76 .hw.init = \
77 CLK_HW_INIT_PARENTS_DATA(_name, \
78 _data, \
79 &ccu_gate_ops, \
80 _flags), \
81 } \
84 static inline struct ccu_gate *hw_to_ccu_gate(struct clk_hw *hw)
86 struct ccu_common *common = hw_to_ccu_common(hw);
88 return container_of(common, struct ccu_gate, common);
91 void ccu_gate_helper_disable(struct ccu_common *common, u32 gate);
92 int ccu_gate_helper_enable(struct ccu_common *common, u32 gate);
93 int ccu_gate_helper_is_enabled(struct ccu_common *common, u32 gate);
95 extern const struct clk_ops ccu_gate_ops;
97 #endif /* _CCU_GATE_H_ */