]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - drivers/clk/mediatek/clk-gate.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
[mirror_ubuntu-jammy-kernel.git] / drivers / clk / mediatek / clk-gate.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (c) 2014 MediaTek Inc.
4 * Author: James Liao <jamesjj.liao@mediatek.com>
5 */
6
7 #ifndef __DRV_CLK_GATE_H
8 #define __DRV_CLK_GATE_H
9
10 #include <linux/regmap.h>
11 #include <linux/clk-provider.h>
12
13 struct clk;
14
15 struct mtk_clk_gate {
16 struct clk_hw hw;
17 struct regmap *regmap;
18 int set_ofs;
19 int clr_ofs;
20 int sta_ofs;
21 u8 bit;
22 };
23
24 static inline struct mtk_clk_gate *to_mtk_clk_gate(struct clk_hw *hw)
25 {
26 return container_of(hw, struct mtk_clk_gate, hw);
27 }
28
29 extern const struct clk_ops mtk_clk_gate_ops_setclr;
30 extern const struct clk_ops mtk_clk_gate_ops_setclr_inv;
31 extern const struct clk_ops mtk_clk_gate_ops_no_setclr;
32 extern const struct clk_ops mtk_clk_gate_ops_no_setclr_inv;
33
34 struct clk *mtk_clk_register_gate(
35 const char *name,
36 const char *parent_name,
37 struct regmap *regmap,
38 int set_ofs,
39 int clr_ofs,
40 int sta_ofs,
41 u8 bit,
42 const struct clk_ops *ops,
43 unsigned long flags,
44 struct device *dev);
45
46 #define GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, \
47 _ops, _flags) { \
48 .id = _id, \
49 .name = _name, \
50 .parent_name = _parent, \
51 .regs = _regs, \
52 .shift = _shift, \
53 .ops = _ops, \
54 .flags = _flags, \
55 }
56
57 #define GATE_MTK(_id, _name, _parent, _regs, _shift, _ops) \
58 GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0)
59
60 #endif /* __DRV_CLK_GATE_H */