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 45 #define GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, \ 46 _ops, _flags) { \ 47 .id = _id, \ 48 .name = _name, \ 49 .parent_name = _parent, \ 50 .regs = _regs, \ 51 .shift = _shift, \ 52 .ops = _ops, \ 53 .flags = _flags, \ 54 } 55 56 #define GATE_MTK(_id, _name, _parent, _regs, _shift, _ops) \ 57 GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0) 58 59 #endif /* __DRV_CLK_GATE_H */ 60