• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/types.h>
11 
12 struct clk;
13 struct clk_hw_onecell_data;
14 struct clk_ops;
15 struct device;
16 struct device_node;
17 
18 extern const struct clk_ops mtk_clk_gate_ops_setclr;
19 extern const struct clk_ops mtk_clk_gate_ops_setclr_inv;
20 extern const struct clk_ops mtk_clk_gate_ops_no_setclr;
21 extern const struct clk_ops mtk_clk_gate_ops_no_setclr_inv;
22 
23 struct mtk_gate_regs {
24 	u32 sta_ofs;
25 	u32 clr_ofs;
26 	u32 set_ofs;
27 };
28 
29 struct mtk_gate {
30 	int id;
31 	const char *name;
32 	const char *parent_name;
33 	const struct mtk_gate_regs *regs;
34 	int shift;
35 	const struct clk_ops *ops;
36 	unsigned long flags;
37 };
38 
39 #define GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift,	\
40 			_ops, _flags) {				\
41 		.id = _id,					\
42 		.name = _name,					\
43 		.parent_name = _parent,				\
44 		.regs = _regs,					\
45 		.shift = _shift,				\
46 		.ops = _ops,					\
47 		.flags = _flags,				\
48 	}
49 
50 #define GATE_MTK(_id, _name, _parent, _regs, _shift, _ops)		\
51 	GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0)
52 
53 int mtk_clk_register_gates(struct device_node *node,
54 			   const struct mtk_gate *clks, int num,
55 			   struct clk_hw_onecell_data *clk_data);
56 
57 int mtk_clk_register_gates_with_dev(struct device_node *node,
58 				    const struct mtk_gate *clks, int num,
59 				    struct clk_hw_onecell_data *clk_data,
60 				    struct device *dev);
61 
62 void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num,
63 			      struct clk_hw_onecell_data *clk_data);
64 
65 #endif /* __DRV_CLK_GATE_H */
66