reset-controller.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_RESET_CONTROLLER_H_
  3. #define _LINUX_RESET_CONTROLLER_H_
  4. #include <linux/list.h>
  5. struct reset_controller_dev;
  6. /**
  7. * struct reset_control_ops - reset controller driver callbacks
  8. *
  9. * @reset: for self-deasserting resets, does all necessary
  10. * things to reset the device
  11. * @assert: manually assert the reset line, if supported
  12. * @deassert: manually deassert the reset line, if supported
  13. * @status: return the status of the reset line, if supported
  14. */
  15. struct reset_control_ops {
  16. int (*reset)(struct reset_controller_dev *rcdev, unsigned long id);
  17. int (*assert)(struct reset_controller_dev *rcdev, unsigned long id);
  18. int (*deassert)(struct reset_controller_dev *rcdev, unsigned long id);
  19. int (*status)(struct reset_controller_dev *rcdev, unsigned long id);
  20. };
  21. struct module;
  22. struct device_node;
  23. struct of_phandle_args;
  24. /**
  25. * struct reset_control_lookup - represents a single lookup entry
  26. *
  27. * @list: internal list of all reset lookup entries
  28. * @provider: name of the reset controller device controlling this reset line
  29. * @index: ID of the reset controller in the reset controller device
  30. * @dev_id: name of the device associated with this reset line
  31. * @con_id: name of the reset line (can be NULL)
  32. */
  33. struct reset_control_lookup {
  34. struct list_head list;
  35. const char *provider;
  36. unsigned int index;
  37. const char *dev_id;
  38. const char *con_id;
  39. };
  40. #define RESET_LOOKUP(_provider, _index, _dev_id, _con_id) \
  41. { \
  42. .provider = _provider, \
  43. .index = _index, \
  44. .dev_id = _dev_id, \
  45. .con_id = _con_id, \
  46. }
  47. /**
  48. * struct reset_controller_dev - reset controller entity that might
  49. * provide multiple reset controls
  50. * @ops: a pointer to device specific struct reset_control_ops
  51. * @owner: kernel module of the reset controller driver
  52. * @list: internal list of reset controller devices
  53. * @reset_control_head: head of internal list of requested reset controls
  54. * @dev: corresponding driver model device struct
  55. * @of_node: corresponding device tree node as phandle target
  56. * @of_reset_n_cells: number of cells in reset line specifiers
  57. * @of_xlate: translation function to translate from specifier as found in the
  58. * device tree to id as given to the reset control ops, defaults
  59. * to :c:func:`of_reset_simple_xlate`.
  60. * @nr_resets: number of reset controls in this reset controller device
  61. */
  62. struct reset_controller_dev {
  63. const struct reset_control_ops *ops;
  64. struct module *owner;
  65. struct list_head list;
  66. struct list_head reset_control_head;
  67. struct device *dev;
  68. struct device_node *of_node;
  69. int of_reset_n_cells;
  70. int (*of_xlate)(struct reset_controller_dev *rcdev,
  71. const struct of_phandle_args *reset_spec);
  72. unsigned int nr_resets;
  73. };
  74. int reset_controller_register(struct reset_controller_dev *rcdev);
  75. void reset_controller_unregister(struct reset_controller_dev *rcdev);
  76. struct device;
  77. int devm_reset_controller_register(struct device *dev,
  78. struct reset_controller_dev *rcdev);
  79. void reset_controller_add_lookup(struct reset_control_lookup *lookup,
  80. unsigned int num_entries);
  81. #endif