| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 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 - reset controller driver callbacks |
| 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 |
| 16 | * @status: return the status of the reset line, if supported |
| 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); |
| 22 | int (*status)(struct reset_controller_dev *rcdev, unsigned long id); |
| 23 | }; |
| 24 | |
| 25 | struct module; |
| 26 | struct device_node; |
| 27 | struct of_phandle_args; |
| 28 | |
| 29 | /** |
| 30 | * struct reset_controller_dev - reset controller entity that might |
| 31 | * provide multiple reset controls |
| 32 | * @ops: a pointer to device specific struct reset_control_ops |
| 33 | * @owner: kernel module of the reset controller driver |
| 34 | * @list: internal list of reset controller devices |
| 35 | * @reset_control_head: head of internal list of requested reset controls |
| 36 | * @dev: corresponding driver model device struct |
| 37 | * @of_node: corresponding device tree node as phandle target |
| 38 | * @of_args: for reset-gpios controllers: corresponding phandle args with |
| 39 | * of_node and GPIO number complementing of_node; either this or |
| 40 | * of_node should be present |
| 41 | * @of_reset_n_cells: number of cells in reset line specifiers |
| 42 | * @of_xlate: translation function to translate from specifier as found in the |
| 43 | * device tree to id as given to the reset control ops, defaults |
| 44 | * to :c:func:`of_reset_simple_xlate`. |
| 45 | * @nr_resets: number of reset controls in this reset controller device |
| 46 | */ |
| 47 | struct reset_controller_dev { |
| 48 | const struct reset_control_ops *ops; |
| 49 | struct module *owner; |
| 50 | struct list_head list; |
| 51 | struct list_head reset_control_head; |
| 52 | struct device *dev; |
| 53 | struct device_node *of_node; |
| 54 | const struct of_phandle_args *of_args; |
| 55 | int of_reset_n_cells; |
| 56 | int (*of_xlate)(struct reset_controller_dev *rcdev, |
| 57 | const struct of_phandle_args *reset_spec); |
| 58 | unsigned int nr_resets; |
| 59 | }; |
| 60 | |
| 61 | #if IS_ENABLED(CONFIG_RESET_CONTROLLER) |
| 62 | int reset_controller_register(struct reset_controller_dev *rcdev); |
| 63 | void reset_controller_unregister(struct reset_controller_dev *rcdev); |
| 64 | |
| 65 | struct device; |
| 66 | int devm_reset_controller_register(struct device *dev, |
| 67 | struct reset_controller_dev *rcdev); |
| 68 | #else |
| 69 | static inline int reset_controller_register(struct reset_controller_dev *rcdev) |
| 70 | { |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | static inline void reset_controller_unregister(struct reset_controller_dev *rcdev) |
| 75 | { |
| 76 | } |
| 77 | |
| 78 | static inline int devm_reset_controller_register(struct device *dev, |
| 79 | struct reset_controller_dev *rcdev) |
| 80 | { |
| 81 | return 0; |
| 82 | } |
| 83 | #endif |
| 84 | |
| 85 | #endif |
| 86 | |