xref: /linux/drivers/clk/baikal-t1/ccu-rst.h (revision be239684b18e1cdcafcf8c7face4a2f562c745ad)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2021 BAIKAL ELECTRONICS, JSC
4  *
5  * Baikal-T1 CCU Resets interface driver
6  */
7 #ifndef __CLK_BT1_CCU_RST_H__
8 #define __CLK_BT1_CCU_RST_H__
9 
10 #include <linux/of.h>
11 #include <linux/regmap.h>
12 #include <linux/reset-controller.h>
13 
14 struct ccu_rst_info;
15 
16 /*
17  * enum ccu_rst_type - CCU Reset types
18  * @CCU_RST_TRIG: Self-deasserted reset signal.
19  * @CCU_RST_DIR: Directly controlled reset signal.
20  */
21 enum ccu_rst_type {
22 	CCU_RST_TRIG,
23 	CCU_RST_DIR,
24 };
25 
26 /*
27  * struct ccu_rst_init_data - CCU Resets initialization data
28  * @sys_regs: Baikal-T1 System Controller registers map.
29  * @np: Pointer to the node with the System CCU block.
30  */
31 struct ccu_rst_init_data {
32 	struct regmap *sys_regs;
33 	struct device_node *np;
34 };
35 
36 /*
37  * struct ccu_rst - CCU Reset descriptor
38  * @rcdev: Reset controller descriptor.
39  * @sys_regs: Baikal-T1 System Controller registers map.
40  * @rsts_info: Reset flag info (base address and mask).
41  */
42 struct ccu_rst {
43 	struct reset_controller_dev rcdev;
44 	struct regmap *sys_regs;
45 	const struct ccu_rst_info *rsts_info;
46 };
47 #define to_ccu_rst(_rcdev) container_of(_rcdev, struct ccu_rst, rcdev)
48 
49 #ifdef CONFIG_CLK_BT1_CCU_RST
50 
51 struct ccu_rst *ccu_rst_hw_register(const struct ccu_rst_init_data *init);
52 
53 void ccu_rst_hw_unregister(struct ccu_rst *rst);
54 
55 #else
56 
57 static inline
58 struct ccu_rst *ccu_rst_hw_register(const struct ccu_rst_init_data *init)
59 {
60 	return NULL;
61 }
62 
63 static inline void ccu_rst_hw_unregister(struct ccu_rst *rst) {}
64 
65 #endif
66 
67 #endif /* __CLK_BT1_CCU_RST_H__ */
68