Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_RESET_CONTROLLER_H_
0003 #define _LINUX_RESET_CONTROLLER_H_
0004 
0005 #include <linux/list.h>
0006 
0007 struct reset_controller_dev;
0008 
0009 /**
0010  * struct reset_control_ops - reset controller driver callbacks
0011  *
0012  * @reset: for self-deasserting resets, does all necessary
0013  *         things to reset the device
0014  * @assert: manually assert the reset line, if supported
0015  * @deassert: manually deassert the reset line, if supported
0016  * @status: return the status of the reset line, if supported
0017  */
0018 struct reset_control_ops {
0019     int (*reset)(struct reset_controller_dev *rcdev, unsigned long id);
0020     int (*assert)(struct reset_controller_dev *rcdev, unsigned long id);
0021     int (*deassert)(struct reset_controller_dev *rcdev, unsigned long id);
0022     int (*status)(struct reset_controller_dev *rcdev, unsigned long id);
0023 };
0024 
0025 struct module;
0026 struct device_node;
0027 struct of_phandle_args;
0028 
0029 /**
0030  * struct reset_control_lookup - represents a single lookup entry
0031  *
0032  * @list: internal list of all reset lookup entries
0033  * @provider: name of the reset controller device controlling this reset line
0034  * @index: ID of the reset controller in the reset controller device
0035  * @dev_id: name of the device associated with this reset line
0036  * @con_id: name of the reset line (can be NULL)
0037  */
0038 struct reset_control_lookup {
0039     struct list_head list;
0040     const char *provider;
0041     unsigned int index;
0042     const char *dev_id;
0043     const char *con_id;
0044 };
0045 
0046 #define RESET_LOOKUP(_provider, _index, _dev_id, _con_id)       \
0047     {                               \
0048         .provider = _provider,                  \
0049         .index = _index,                    \
0050         .dev_id = _dev_id,                  \
0051         .con_id = _con_id,                  \
0052     }
0053 
0054 /**
0055  * struct reset_controller_dev - reset controller entity that might
0056  *                               provide multiple reset controls
0057  * @ops: a pointer to device specific struct reset_control_ops
0058  * @owner: kernel module of the reset controller driver
0059  * @list: internal list of reset controller devices
0060  * @reset_control_head: head of internal list of requested reset controls
0061  * @dev: corresponding driver model device struct
0062  * @of_node: corresponding device tree node as phandle target
0063  * @of_reset_n_cells: number of cells in reset line specifiers
0064  * @of_xlate: translation function to translate from specifier as found in the
0065  *            device tree to id as given to the reset control ops, defaults
0066  *            to :c:func:`of_reset_simple_xlate`.
0067  * @nr_resets: number of reset controls in this reset controller device
0068  */
0069 struct reset_controller_dev {
0070     const struct reset_control_ops *ops;
0071     struct module *owner;
0072     struct list_head list;
0073     struct list_head reset_control_head;
0074     struct device *dev;
0075     struct device_node *of_node;
0076     int of_reset_n_cells;
0077     int (*of_xlate)(struct reset_controller_dev *rcdev,
0078             const struct of_phandle_args *reset_spec);
0079     unsigned int nr_resets;
0080 };
0081 
0082 #if IS_ENABLED(CONFIG_RESET_CONTROLLER)
0083 int reset_controller_register(struct reset_controller_dev *rcdev);
0084 void reset_controller_unregister(struct reset_controller_dev *rcdev);
0085 
0086 struct device;
0087 int devm_reset_controller_register(struct device *dev,
0088                    struct reset_controller_dev *rcdev);
0089 
0090 void reset_controller_add_lookup(struct reset_control_lookup *lookup,
0091                  unsigned int num_entries);
0092 #else
0093 static inline int reset_controller_register(struct reset_controller_dev *rcdev)
0094 {
0095     return 0;
0096 }
0097 
0098 static inline void reset_controller_unregister(struct reset_controller_dev *rcdev)
0099 {
0100 }
0101 
0102 static inline int devm_reset_controller_register(struct device *dev,
0103                          struct reset_controller_dev *rcdev)
0104 {
0105     return 0;
0106 }
0107 
0108 static inline void reset_controller_add_lookup(struct reset_control_lookup *lookup,
0109                            unsigned int num_entries)
0110 {
0111 }
0112 #endif
0113 
0114 #endif