xref: /linux/drivers/clk/sunxi-ng/ccu_gate.h (revision b7019ac550eb3916f34d79db583e9b7ea2524afa)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2016 Maxime Ripard. All rights reserved.
4  */
5 
6 #ifndef _CCU_GATE_H_
7 #define _CCU_GATE_H_
8 
9 #include <linux/clk-provider.h>
10 
11 #include "ccu_common.h"
12 
13 struct ccu_gate {
14 	u32			enable;
15 
16 	struct ccu_common	common;
17 };
18 
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 		}							\
29 	}
30 
31 static inline struct ccu_gate *hw_to_ccu_gate(struct clk_hw *hw)
32 {
33 	struct ccu_common *common = hw_to_ccu_common(hw);
34 
35 	return container_of(common, struct ccu_gate, common);
36 }
37 
38 void ccu_gate_helper_disable(struct ccu_common *common, u32 gate);
39 int ccu_gate_helper_enable(struct ccu_common *common, u32 gate);
40 int ccu_gate_helper_is_enabled(struct ccu_common *common, u32 gate);
41 
42 extern const struct clk_ops ccu_gate_ops;
43 
44 #endif /* _CCU_GATE_H_ */
45