blob: ec35814e0bbbc11b4c2459846d6e3e8b0d318686 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Philipp Zabel61fc4132012-11-19 17:23:13 +01002#ifndef _LINUX_RESET_CONTROLLER_H_
3#define _LINUX_RESET_CONTROLLER_H_
4
5#include <linux/list.h>
6
7struct reset_controller_dev;
8
9/**
Randy Dunlapf430c7e2019-10-22 20:57:06 -070010 * struct reset_control_ops - reset controller driver callbacks
Philipp Zabel61fc4132012-11-19 17:23:13 +010011 *
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
Dinh Nguyen729de412014-10-10 10:21:14 -050016 * @status: return the status of the reset line, if supported
Philipp Zabel61fc4132012-11-19 17:23:13 +010017 */
18struct 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);
Dinh Nguyen729de412014-10-10 10:21:14 -050022 int (*status)(struct reset_controller_dev *rcdev, unsigned long id);
Philipp Zabel61fc4132012-11-19 17:23:13 +010023};
24
25struct module;
26struct device_node;
Stephen Boydd0d44dd2014-01-15 10:47:21 -080027struct of_phandle_args;
Philipp Zabel61fc4132012-11-19 17:23:13 +010028
29/**
Bartosz Golaszewski6691dff2018-02-28 14:08:57 +010030 * struct reset_control_lookup - represents a single lookup entry
31 *
32 * @list: internal list of all reset lookup entries
Bartosz Golaszewskie2749bb2018-03-23 14:04:48 +010033 * @provider: name of the reset controller device controlling this reset line
Bartosz Golaszewski6691dff2018-02-28 14:08:57 +010034 * @index: ID of the reset controller in the reset controller device
35 * @dev_id: name of the device associated with this reset line
Philipp Zabeled713ce2019-10-22 16:11:54 +020036 * @con_id: name of the reset line (can be NULL)
Bartosz Golaszewski6691dff2018-02-28 14:08:57 +010037 */
38struct reset_control_lookup {
39 struct list_head list;
Bartosz Golaszewskie2749bb2018-03-23 14:04:48 +010040 const char *provider;
Bartosz Golaszewski6691dff2018-02-28 14:08:57 +010041 unsigned int index;
42 const char *dev_id;
43 const char *con_id;
44};
45
Bartosz Golaszewskie2749bb2018-03-23 14:04:48 +010046#define RESET_LOOKUP(_provider, _index, _dev_id, _con_id) \
Bartosz Golaszewski6691dff2018-02-28 14:08:57 +010047 { \
Bartosz Golaszewskie2749bb2018-03-23 14:04:48 +010048 .provider = _provider, \
49 .index = _index, \
Bartosz Golaszewski6691dff2018-02-28 14:08:57 +010050 .dev_id = _dev_id, \
51 .con_id = _con_id, \
Bartosz Golaszewski6691dff2018-02-28 14:08:57 +010052 }
53
54/**
Philipp Zabel61fc4132012-11-19 17:23:13 +010055 * 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
Hans de Goedec15ddec2016-02-23 18:46:25 +010060 * @reset_control_head: head of internal list of requested reset controls
Bartosz Golaszewskie2749bb2018-03-23 14:04:48 +010061 * @dev: corresponding driver model device struct
Philipp Zabel61fc4132012-11-19 17:23:13 +010062 * @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
Philipp Zabela48108c2019-10-22 16:51:37 +020065 * device tree to id as given to the reset control ops, defaults
66 * to :c:func:`of_reset_simple_xlate`.
Philipp Zabel61fc4132012-11-19 17:23:13 +010067 * @nr_resets: number of reset controls in this reset controller device
68 */
69struct reset_controller_dev {
Maxime Ripard203d4f32016-01-14 16:24:45 +010070 const struct reset_control_ops *ops;
Philipp Zabel61fc4132012-11-19 17:23:13 +010071 struct module *owner;
72 struct list_head list;
Hans de Goedec15ddec2016-02-23 18:46:25 +010073 struct list_head reset_control_head;
Bartosz Golaszewskie2749bb2018-03-23 14:04:48 +010074 struct device *dev;
Philipp Zabel61fc4132012-11-19 17:23:13 +010075 struct device_node *of_node;
76 int of_reset_n_cells;
77 int (*of_xlate)(struct reset_controller_dev *rcdev,
78 const struct of_phandle_args *reset_spec);
79 unsigned int nr_resets;
80};
81
82int reset_controller_register(struct reset_controller_dev *rcdev);
83void reset_controller_unregister(struct reset_controller_dev *rcdev);
84
Masahiro Yamada8d5b5d52016-05-01 19:36:57 +090085struct device;
86int devm_reset_controller_register(struct device *dev,
87 struct reset_controller_dev *rcdev);
88
Bartosz Golaszewskie2749bb2018-03-23 14:04:48 +010089void reset_controller_add_lookup(struct reset_control_lookup *lookup,
Bartosz Golaszewski6691dff2018-02-28 14:08:57 +010090 unsigned int num_entries);
91
Philipp Zabel61fc4132012-11-19 17:23:13 +010092#endif