xref: /openbmc/linux/drivers/clk/mediatek/clk-gate.h (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
11802d0beSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
29741b1a6SJames Liao /*
39741b1a6SJames Liao  * Copyright (c) 2014 MediaTek Inc.
49741b1a6SJames Liao  * Author: James Liao <jamesjj.liao@mediatek.com>
59741b1a6SJames Liao  */
69741b1a6SJames Liao 
79741b1a6SJames Liao #ifndef __DRV_CLK_GATE_H
89741b1a6SJames Liao #define __DRV_CLK_GATE_H
99741b1a6SJames Liao 
10625afe4fSChen-Yu Tsai #include <linux/types.h>
11625afe4fSChen-Yu Tsai 
12625afe4fSChen-Yu Tsai struct clk;
13609cc5e1SChen-Yu Tsai struct clk_hw_onecell_data;
14625afe4fSChen-Yu Tsai struct clk_ops;
15625afe4fSChen-Yu Tsai struct device;
16625afe4fSChen-Yu Tsai struct device_node;
179741b1a6SJames Liao 
189741b1a6SJames Liao extern const struct clk_ops mtk_clk_gate_ops_setclr;
199741b1a6SJames Liao extern const struct clk_ops mtk_clk_gate_ops_setclr_inv;
20e9862118SShunli Wang extern const struct clk_ops mtk_clk_gate_ops_no_setclr;
21e9862118SShunli Wang extern const struct clk_ops mtk_clk_gate_ops_no_setclr_inv;
229741b1a6SJames Liao 
2319b8d438SChen-Yu Tsai struct mtk_gate_regs {
2419b8d438SChen-Yu Tsai 	u32 sta_ofs;
2519b8d438SChen-Yu Tsai 	u32 clr_ofs;
2619b8d438SChen-Yu Tsai 	u32 set_ofs;
2719b8d438SChen-Yu Tsai };
2819b8d438SChen-Yu Tsai 
2919b8d438SChen-Yu Tsai struct mtk_gate {
3019b8d438SChen-Yu Tsai 	int id;
3119b8d438SChen-Yu Tsai 	const char *name;
3219b8d438SChen-Yu Tsai 	const char *parent_name;
3319b8d438SChen-Yu Tsai 	const struct mtk_gate_regs *regs;
3419b8d438SChen-Yu Tsai 	int shift;
3519b8d438SChen-Yu Tsai 	const struct clk_ops *ops;
3619b8d438SChen-Yu Tsai 	unsigned long flags;
3719b8d438SChen-Yu Tsai };
3819b8d438SChen-Yu Tsai 
39acddfc2cSWeiyi Lu #define GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift,	\
40acddfc2cSWeiyi Lu 			_ops, _flags) {				\
41acddfc2cSWeiyi Lu 		.id = _id,					\
42acddfc2cSWeiyi Lu 		.name = _name,					\
43acddfc2cSWeiyi Lu 		.parent_name = _parent,				\
44acddfc2cSWeiyi Lu 		.regs = _regs,					\
45acddfc2cSWeiyi Lu 		.shift = _shift,				\
46acddfc2cSWeiyi Lu 		.ops = _ops,					\
47acddfc2cSWeiyi Lu 		.flags = _flags,				\
48acddfc2cSWeiyi Lu 	}
49acddfc2cSWeiyi Lu 
50acddfc2cSWeiyi Lu #define GATE_MTK(_id, _name, _parent, _regs, _shift, _ops)		\
51acddfc2cSWeiyi Lu 	GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0)
52acddfc2cSWeiyi Lu 
53*20498d52SAngeloGioacchino Del Regno int mtk_clk_register_gates(struct device *dev, struct device_node *node,
5419b8d438SChen-Yu Tsai 			   const struct mtk_gate *clks, int num,
55609cc5e1SChen-Yu Tsai 			   struct clk_hw_onecell_data *clk_data);
5619b8d438SChen-Yu Tsai 
5744dd1414SChen-Yu Tsai void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num,
58609cc5e1SChen-Yu Tsai 			      struct clk_hw_onecell_data *clk_data);
5944dd1414SChen-Yu Tsai 
609741b1a6SJames Liao #endif /* __DRV_CLK_GATE_H */
61