reset.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-11-26 GuEe-GUI first version
  9. */
  10. #ifndef __RESET_H__
  11. #define __RESET_H__
  12. #include <rthw.h>
  13. #include <rtthread.h>
  14. #include <drivers/ofw.h>
  15. #define RT_RESET_CONTROLLER_OBJ_NAME "RSTC"
  16. struct rt_reset_control_ops;
  17. struct rt_reset_controller
  18. {
  19. struct rt_object parent;
  20. rt_list_t rstc_nodes;
  21. const char *name;
  22. const struct rt_reset_control_ops *ops;
  23. struct rt_ofw_node *ofw_node;
  24. void *priv;
  25. struct rt_spinlock spinlock;
  26. };
  27. struct rt_reset_control
  28. {
  29. rt_list_t list;
  30. struct rt_reset_controller *rstcer;
  31. int id;
  32. const char *con_id;
  33. rt_bool_t is_array;
  34. void *priv;
  35. };
  36. struct rt_reset_control_ops
  37. {
  38. /*
  39. * rt_ofw_cell_args return:
  40. * args[0] = rstc.id
  41. */
  42. rt_err_t (*ofw_parse)(struct rt_reset_control *rstc, struct rt_ofw_cell_args *args);
  43. /* API */
  44. rt_err_t (*reset)(struct rt_reset_control *rstc);
  45. rt_err_t (*assert)(struct rt_reset_control *rstc);
  46. rt_err_t (*deassert)(struct rt_reset_control *rstc);
  47. int (*status)(struct rt_reset_control *rstc);
  48. };
  49. rt_err_t rt_reset_controller_register(struct rt_reset_controller *rstcer);
  50. rt_err_t rt_reset_controller_unregister(struct rt_reset_controller *rstcer);
  51. rt_err_t rt_reset_control_reset(struct rt_reset_control *rstc);
  52. rt_err_t rt_reset_control_assert(struct rt_reset_control *rstc);
  53. rt_err_t rt_reset_control_deassert(struct rt_reset_control *rstc);
  54. int rt_reset_control_status(struct rt_reset_control *rstc);
  55. rt_ssize_t rt_reset_control_get_count(struct rt_device *dev);
  56. struct rt_reset_control *rt_reset_control_get_array(struct rt_device *dev);
  57. struct rt_reset_control *rt_reset_control_get_by_index(struct rt_device *dev, int index);
  58. struct rt_reset_control *rt_reset_control_get_by_name(struct rt_device *dev, const char *name);
  59. void rt_reset_control_put(struct rt_reset_control *rstc);
  60. struct rt_reset_control *rt_ofw_get_reset_control_array(struct rt_ofw_node *np);
  61. struct rt_reset_control *rt_ofw_get_reset_control_by_index(struct rt_ofw_node *np, int index);
  62. struct rt_reset_control *rt_ofw_get_reset_control_by_name(struct rt_ofw_node *np, const char *name);
  63. #endif /* __RESET_H__ */