| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
/* |
| 3 |
* Copyright (c) 2014 MediaTek Inc. |
| 4 |
* Author: James Liao <[email protected]> |
| 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 |
extern const struct clk_ops mtk_clk_gate_hwv_ops_setclr; |
| 23 |
extern const struct clk_ops mtk_clk_gate_hwv_ops_setclr_inv; |
| 24 |
|
| 25 |
struct mtk_gate_regs { |
| 26 |
u32 sta_ofs; |
| 27 |
u32 clr_ofs; |
| 28 |
u32 set_ofs; |
| 29 |
}; |
| 30 |
|
| 31 |
struct mtk_gate { |
| 32 |
int id; |
| 33 |
const char *name; |
| 34 |
const char *parent_name; |
| 35 |
const struct mtk_gate_regs *regs; |
| 36 |
const struct mtk_gate_regs *hwv_regs; |
| 37 |
int shift; |
| 38 |
const struct clk_ops *ops; |
| 39 |
unsigned long flags; |
| 40 |
}; |
| 41 |
|
| 42 |
#define GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, \ |
| 43 |
_ops, _flags) { \ |
| 44 |
.id = _id, \ |
| 45 |
.name = _name, \ |
| 46 |
.parent_name = _parent, \ |
| 47 |
.regs = _regs, \ |
| 48 |
.shift = _shift, \ |
| 49 |
.ops = _ops, \ |
| 50 |
.flags = _flags, \ |
| 51 |
} |
| 52 |
|
| 53 |
#define GATE_MTK(_id, _name, _parent, _regs, _shift, _ops) \ |
| 54 |
GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0) |
| 55 |
|
| 56 |
int mtk_clk_register_gates(struct device *dev, struct device_node *node, |
| 57 |
const struct mtk_gate *clks, int num, |
| 58 |
struct clk_hw_onecell_data *clk_data); |
| 59 |
|
| 60 |
void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num, |
| 61 |
struct clk_hw_onecell_data *clk_data); |
| 62 |
|
| 63 |
#endif /* __DRV_CLK_GATE_H */ |