1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_RESET_CONTROLLER_H_
3 #define _LINUX_RESET_CONTROLLER_H_
5 #include <linux/list.h>
7 struct reset_controller_dev;
10 * struct reset_control_ops - reset controller driver callbacks
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
16 * @status: return the status of the reset line, if supported
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);
22 int (*status)(struct reset_controller_dev *rcdev, unsigned long id);
27 struct of_phandle_args;
30 * struct reset_control_lookup - represents a single lookup entry
32 * @list: internal list of all reset lookup entries
33 * @provider: name of the reset controller device controlling this reset line
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)
38 struct reset_control_lookup {
39 struct list_head list;
46 #define RESET_LOOKUP(_provider, _index, _dev_id, _con_id) \
48 .provider = _provider, \
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
60 * @reset_control_head: head of internal list of requested reset controls
61 * @dev: corresponding driver model device struct
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, defaults
66 * to :c:func:`of_reset_simple_xlate`.
67 * @nr_resets: number of reset controls in this reset controller device
69 struct reset_controller_dev {
70 const struct reset_control_ops *ops;
72 struct list_head list;
73 struct list_head reset_control_head;
75 struct device_node *of_node;
77 int (*of_xlate)(struct reset_controller_dev *rcdev,
78 const struct of_phandle_args *reset_spec);
79 unsigned int nr_resets;
82 int reset_controller_register(struct reset_controller_dev *rcdev);
83 void reset_controller_unregister(struct reset_controller_dev *rcdev);
86 int devm_reset_controller_register(struct device *dev,
87 struct reset_controller_dev *rcdev);
89 void reset_controller_add_lookup(struct reset_control_lookup *lookup,
90 unsigned int num_entries);