Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 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 | /** |
Randy Dunlap | f430c7e | 2019-10-22 20:57:06 -0700 | [diff] [blame] | 10 | * struct reset_control_ops - reset controller driver callbacks |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 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 |
Dinh Nguyen | 729de41 | 2014-10-10 10:21:14 -0500 | [diff] [blame] | 16 | * @status: return the status of the reset line, if supported |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 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); |
Dinh Nguyen | 729de41 | 2014-10-10 10:21:14 -0500 | [diff] [blame] | 22 | int (*status)(struct reset_controller_dev *rcdev, unsigned long id); |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | struct module; |
| 26 | struct device_node; |
Stephen Boyd | d0d44dd | 2014-01-15 10:47:21 -0800 | [diff] [blame] | 27 | struct of_phandle_args; |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 28 | |
| 29 | /** |
Bartosz Golaszewski | 6691dff | 2018-02-28 14:08:57 +0100 | [diff] [blame] | 30 | * struct reset_control_lookup - represents a single lookup entry |
| 31 | * |
| 32 | * @list: internal list of all reset lookup entries |
Bartosz Golaszewski | e2749bb | 2018-03-23 14:04:48 +0100 | [diff] [blame] | 33 | * @provider: name of the reset controller device controlling this reset line |
Bartosz Golaszewski | 6691dff | 2018-02-28 14:08:57 +0100 | [diff] [blame] | 34 | * @index: ID of the reset controller in the reset controller device |
| 35 | * @dev_id: name of the device associated with this reset line |
Philipp Zabel | ed713ce | 2019-10-22 16:11:54 +0200 | [diff] [blame] | 36 | * @con_id: name of the reset line (can be NULL) |
Bartosz Golaszewski | 6691dff | 2018-02-28 14:08:57 +0100 | [diff] [blame] | 37 | */ |
| 38 | struct reset_control_lookup { |
| 39 | struct list_head list; |
Bartosz Golaszewski | e2749bb | 2018-03-23 14:04:48 +0100 | [diff] [blame] | 40 | const char *provider; |
Bartosz Golaszewski | 6691dff | 2018-02-28 14:08:57 +0100 | [diff] [blame] | 41 | unsigned int index; |
| 42 | const char *dev_id; |
| 43 | const char *con_id; |
| 44 | }; |
| 45 | |
Bartosz Golaszewski | e2749bb | 2018-03-23 14:04:48 +0100 | [diff] [blame] | 46 | #define RESET_LOOKUP(_provider, _index, _dev_id, _con_id) \ |
Bartosz Golaszewski | 6691dff | 2018-02-28 14:08:57 +0100 | [diff] [blame] | 47 | { \ |
Bartosz Golaszewski | e2749bb | 2018-03-23 14:04:48 +0100 | [diff] [blame] | 48 | .provider = _provider, \ |
| 49 | .index = _index, \ |
Bartosz Golaszewski | 6691dff | 2018-02-28 14:08:57 +0100 | [diff] [blame] | 50 | .dev_id = _dev_id, \ |
| 51 | .con_id = _con_id, \ |
Bartosz Golaszewski | 6691dff | 2018-02-28 14:08:57 +0100 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | /** |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 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 |
Hans de Goede | c15ddec | 2016-02-23 18:46:25 +0100 | [diff] [blame] | 60 | * @reset_control_head: head of internal list of requested reset controls |
Bartosz Golaszewski | e2749bb | 2018-03-23 14:04:48 +0100 | [diff] [blame] | 61 | * @dev: corresponding driver model device struct |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 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 |
Philipp Zabel | a48108c | 2019-10-22 16:51:37 +0200 | [diff] [blame] | 65 | * device tree to id as given to the reset control ops, defaults |
| 66 | * to :c:func:`of_reset_simple_xlate`. |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 67 | * @nr_resets: number of reset controls in this reset controller device |
| 68 | */ |
| 69 | struct reset_controller_dev { |
Maxime Ripard | 203d4f3 | 2016-01-14 16:24:45 +0100 | [diff] [blame] | 70 | const struct reset_control_ops *ops; |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 71 | struct module *owner; |
| 72 | struct list_head list; |
Hans de Goede | c15ddec | 2016-02-23 18:46:25 +0100 | [diff] [blame] | 73 | struct list_head reset_control_head; |
Bartosz Golaszewski | e2749bb | 2018-03-23 14:04:48 +0100 | [diff] [blame] | 74 | struct device *dev; |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 75 | 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 | |
| 82 | int reset_controller_register(struct reset_controller_dev *rcdev); |
| 83 | void reset_controller_unregister(struct reset_controller_dev *rcdev); |
| 84 | |
Masahiro Yamada | 8d5b5d5 | 2016-05-01 19:36:57 +0900 | [diff] [blame] | 85 | struct device; |
| 86 | int devm_reset_controller_register(struct device *dev, |
| 87 | struct reset_controller_dev *rcdev); |
| 88 | |
Bartosz Golaszewski | e2749bb | 2018-03-23 14:04:48 +0100 | [diff] [blame] | 89 | void reset_controller_add_lookup(struct reset_control_lookup *lookup, |
Bartosz Golaszewski | 6691dff | 2018-02-28 14:08:57 +0100 | [diff] [blame] | 90 | unsigned int num_entries); |
| 91 | |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 92 | #endif |