0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _OWL_GATE_H_
0012 #define _OWL_GATE_H_
0013
0014 #include "owl-common.h"
0015
0016 struct owl_gate_hw {
0017 u32 reg;
0018 u8 bit_idx;
0019 u8 gate_flags;
0020 };
0021
0022 struct owl_gate {
0023 struct owl_gate_hw gate_hw;
0024 struct owl_clk_common common;
0025 };
0026
0027 #define OWL_GATE_HW(_reg, _bit_idx, _gate_flags) \
0028 { \
0029 .reg = _reg, \
0030 .bit_idx = _bit_idx, \
0031 .gate_flags = _gate_flags, \
0032 }
0033
0034 #define OWL_GATE(_struct, _name, _parent, _reg, \
0035 _bit_idx, _gate_flags, _flags) \
0036 struct owl_gate _struct = { \
0037 .gate_hw = OWL_GATE_HW(_reg, _bit_idx, _gate_flags), \
0038 .common = { \
0039 .regmap = NULL, \
0040 .hw.init = CLK_HW_INIT(_name, \
0041 _parent, \
0042 &owl_gate_ops, \
0043 _flags), \
0044 } \
0045 } \
0046
0047 #define OWL_GATE_NO_PARENT(_struct, _name, _reg, \
0048 _bit_idx, _gate_flags, _flags) \
0049 struct owl_gate _struct = { \
0050 .gate_hw = OWL_GATE_HW(_reg, _bit_idx, _gate_flags), \
0051 .common = { \
0052 .regmap = NULL, \
0053 .hw.init = CLK_HW_INIT_NO_PARENT(_name, \
0054 &owl_gate_ops, \
0055 _flags), \
0056 }, \
0057 } \
0058
0059 static inline struct owl_gate *hw_to_owl_gate(const struct clk_hw *hw)
0060 {
0061 struct owl_clk_common *common = hw_to_owl_clk_common(hw);
0062
0063 return container_of(common, struct owl_gate, common);
0064 }
0065
0066 void owl_gate_set(const struct owl_clk_common *common,
0067 const struct owl_gate_hw *gate_hw, bool enable);
0068 int owl_gate_clk_is_enabled(const struct owl_clk_common *common,
0069 const struct owl_gate_hw *gate_hw);
0070
0071 extern const struct clk_ops owl_gate_ops;
0072
0073 #endif