]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/clk/sunxi-ng/ccu_gate.h
iommu/amd: Lock dev_data in attach/detach code paths
[linux.git] / drivers / clk / sunxi-ng / ccu_gate.h
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 #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                 }                                                       \
41         }
42
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                 }                                                       \
53         }
54
55 /*
56  * The following two macros allow the re-use of the data structure
57  * holding the parent info.
58  */
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                 }                                                       \
69         }
70
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                 }                                                       \
82         }
83
84 static inline struct ccu_gate *hw_to_ccu_gate(struct clk_hw *hw)
85 {
86         struct ccu_common *common = hw_to_ccu_common(hw);
87
88         return container_of(common, struct ccu_gate, common);
89 }
90
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);
94
95 extern const struct clk_ops ccu_gate_ops;
96
97 #endif /* _CCU_GATE_H_ */