Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
61fc4131 PZ |
2 | #ifndef _LINUX_RESET_CONTROLLER_H_ |
3 | #define _LINUX_RESET_CONTROLLER_H_ | |
4 | ||
5 | #include <linux/list.h> | |
6 | ||
7 | struct reset_controller_dev; | |
8 | ||
9 | /** | |
10 | * struct reset_control_ops | |
11 | * | |
12 | * @reset: for self-deasserting resets, does all necessary | |
13 | * things to reset the device | |
14 | * @assert: manually assert the reset line, if supported | |
15 | * @deassert: manually deassert the reset line, if supported | |
729de41b | 16 | * @status: return the status of the reset line, if supported |
61fc4131 PZ |
17 | */ |
18 | struct reset_control_ops { | |
19 | int (*reset)(struct reset_controller_dev *rcdev, unsigned long id); | |
20 | int (*assert)(struct reset_controller_dev *rcdev, unsigned long id); | |
21 | int (*deassert)(struct reset_controller_dev *rcdev, unsigned long id); | |
729de41b | 22 | int (*status)(struct reset_controller_dev *rcdev, unsigned long id); |
61fc4131 PZ |
23 | }; |
24 | ||
25 | struct module; | |
26 | struct device_node; | |
d0d44dd4 | 27 | struct of_phandle_args; |
61fc4131 | 28 | |
6691dffa BG |
29 | /** |
30 | * struct reset_control_lookup - represents a single lookup entry | |
31 | * | |
32 | * @list: internal list of all reset lookup entries | |
e2749bb9 | 33 | * @provider: name of the reset controller device controlling this reset line |
6691dffa BG |
34 | * @index: ID of the reset controller in the reset controller device |
35 | * @dev_id: name of the device associated with this reset line | |
36 | * @con_id name of the reset line (can be NULL) | |
37 | */ | |
38 | struct reset_control_lookup { | |
39 | struct list_head list; | |
e2749bb9 | 40 | const char *provider; |
6691dffa BG |
41 | unsigned int index; |
42 | const char *dev_id; | |
43 | const char *con_id; | |
44 | }; | |
45 | ||
e2749bb9 | 46 | #define RESET_LOOKUP(_provider, _index, _dev_id, _con_id) \ |
6691dffa | 47 | { \ |
e2749bb9 BG |
48 | .provider = _provider, \ |
49 | .index = _index, \ | |
6691dffa BG |
50 | .dev_id = _dev_id, \ |
51 | .con_id = _con_id, \ | |
6691dffa BG |
52 | } |
53 | ||
61fc4131 PZ |
54 | /** |
55 | * struct reset_controller_dev - reset controller entity that might | |
56 | * provide multiple reset controls | |
57 | * @ops: a pointer to device specific struct reset_control_ops | |
58 | * @owner: kernel module of the reset controller driver | |
59 | * @list: internal list of reset controller devices | |
c15ddec2 | 60 | * @reset_control_head: head of internal list of requested reset controls |
e2749bb9 | 61 | * @dev: corresponding driver model device struct |
61fc4131 PZ |
62 | * @of_node: corresponding device tree node as phandle target |
63 | * @of_reset_n_cells: number of cells in reset line specifiers | |
64 | * @of_xlate: translation function to translate from specifier as found in the | |
65 | * device tree to id as given to the reset control ops | |
66 | * @nr_resets: number of reset controls in this reset controller device | |
67 | */ | |
68 | struct reset_controller_dev { | |
203d4f34 | 69 | const struct reset_control_ops *ops; |
61fc4131 PZ |
70 | struct module *owner; |
71 | struct list_head list; | |
c15ddec2 | 72 | struct list_head reset_control_head; |
e2749bb9 | 73 | struct device *dev; |
61fc4131 PZ |
74 | struct device_node *of_node; |
75 | int of_reset_n_cells; | |
76 | int (*of_xlate)(struct reset_controller_dev *rcdev, | |
77 | const struct of_phandle_args *reset_spec); | |
78 | unsigned int nr_resets; | |
79 | }; | |
80 | ||
81 | int reset_controller_register(struct reset_controller_dev *rcdev); | |
82 | void reset_controller_unregister(struct reset_controller_dev *rcdev); | |
83 | ||
8d5b5d5c MY |
84 | struct device; |
85 | int devm_reset_controller_register(struct device *dev, | |
86 | struct reset_controller_dev *rcdev); | |
87 | ||
e2749bb9 | 88 | void reset_controller_add_lookup(struct reset_control_lookup *lookup, |
6691dffa BG |
89 | unsigned int num_entries); |
90 | ||
61fc4131 | 91 | #endif |