Merge tag 'extcon-next-for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux/fpc-iii.git] / drivers / clk / sprd / gate.h
blobdc352ea55e1fa464b52e76d93f862b0b821550de
1 /* SPDX-License-Identifier: GPL-2.0 */
2 //
3 // Spreadtrum gate clock driver
4 //
5 // Copyright (C) 2017 Spreadtrum, Inc.
6 // Author: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
8 #ifndef _SPRD_GATE_H_
9 #define _SPRD_GATE_H_
11 #include "common.h"
13 struct sprd_gate {
14 u32 enable_mask;
15 u16 flags;
16 u16 sc_offset;
18 struct sprd_clk_common common;
21 #define SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset, \
22 _enable_mask, _flags, _gate_flags, _ops) \
23 struct sprd_gate _struct = { \
24 .enable_mask = _enable_mask, \
25 .sc_offset = _sc_offset, \
26 .flags = _gate_flags, \
27 .common = { \
28 .regmap = NULL, \
29 .reg = _reg, \
30 .hw.init = CLK_HW_INIT(_name, \
31 _parent, \
32 _ops, \
33 _flags), \
34 } \
37 #define SPRD_GATE_CLK(_struct, _name, _parent, _reg, \
38 _enable_mask, _flags, _gate_flags) \
39 SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, 0, \
40 _enable_mask, _flags, _gate_flags, \
41 &sprd_gate_ops)
43 #define SPRD_SC_GATE_CLK(_struct, _name, _parent, _reg, _sc_offset, \
44 _enable_mask, _flags, _gate_flags) \
45 SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset, \
46 _enable_mask, _flags, _gate_flags, \
47 &sprd_sc_gate_ops)
49 static inline struct sprd_gate *hw_to_sprd_gate(const struct clk_hw *hw)
51 struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
53 return container_of(common, struct sprd_gate, common);
56 extern const struct clk_ops sprd_gate_ops;
57 extern const struct clk_ops sprd_sc_gate_ops;
59 #endif /* _SPRD_GATE_H_ */