1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2016 Maxime Ripard. All rights reserved.
4  */
5 
6 #ifndef _HAL_RESET_H_
7 #define _HAL_RESET_H_
8 
9 #include <aw_list.h>
10 #include <sunxi_hal_common.h>
11 #include <platform_rst.h>
12 
13 typedef enum {
14     HAL_SUNXI_RESET = 0,
15     HAL_SUNXI_R_RESET,
16     HAL_SUNXI_RESET_NUMBER,
17 } hal_reset_type_t;
18 
19 typedef u32 hal_reset_id_t;
20 
21 struct reset_control_dev;
22 
23 /**
24  * struct reset_control_ops - reset controller driver callbacks
25  *
26  * @reset: for self-deasserting resets, does all necessary
27  *         things to reset the device
28  * @assert: manually assert the reset line, if supported
29  * @deassert: manually deassert the reset line, if supported
30  * @status: return the status of the reset line, if supported
31  */
32 struct reset_control_ops {
33     int (*reset)(struct reset_control_dev *rcdev, hal_reset_id_t id);
34     int (*assert)(struct reset_control_dev *rcdev, hal_reset_id_t id);
35     int (*deassert)(struct reset_control_dev *rcdev, hal_reset_id_t id);
36     int (*status)(struct reset_control_dev *rcdev, hal_reset_id_t id);
37 };
38 /**
39  * struct reset_control - reset controller entity that might
40  *                               provide multiple reset controls
41  * @ops: a pointer to device specific struct reset_control_ops
42  * @owner: kernel module of the reset controller driver
43  * @list: internal list of reset controller devices
44  * @reset_control_head: head of internal list of requested reset controls
45  * @dev: corresponding driver model device struct
46  * @of_node: corresponding device tree node as phandle target
47  * @of_reset_n_cells: number of cells in reset line specifiers
48  * @of_xlate: translation function to translate from specifier as found in the
49  *            device tree to id as given to the reset control ops
50  * @nr_resets: number of reset controls in this reset controller device
51  */
52 struct reset_control_dev {
53     const struct reset_control_ops *ops;
54     hal_reset_type_t type;
55     u32 nr_resets;
56     struct list_head node;
57 };
58 
59 struct reset_control {
60     struct reset_control_dev *rcdev;
61     u32 enable_count;
62     hal_reset_id_t id;
63 };
64 
65 int reset_control_register(struct reset_control_dev *rcdev); //for reset system
66 
67 int reset_control_unregister(struct reset_control *reset); //for reset system
68 
69 struct reset_control *hal_reset_control_get(hal_reset_type_t type, hal_reset_id_t id);
70 
71 int hal_reset_control_put(struct reset_control *reset);
72 
73 int hal_reset_control_set(struct reset_control *reset); //for other module
74 
75 int hal_reset_control_deassert(struct reset_control *reset); //for other module
76 
77 int hal_reset_control_assert(struct reset_control *reset); //for other_module
78 
79 int hal_reset_control_reset(struct reset_control *reset);  //for other_module
80 
81 int hal_reset_control_status(struct reset_control *reset); //for other_module
82 
83 #endif
84