ccu-rst.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2021 BAIKAL ELECTRONICS, JSC
  4. *
  5. * Baikal-T1 CCU Resets interface driver
  6. */
  7. #ifndef __CLK_BT1_CCU_RST_H__
  8. #define __CLK_BT1_CCU_RST_H__
  9. #include <linux/of.h>
  10. #include <linux/regmap.h>
  11. #include <linux/reset-controller.h>
  12. struct ccu_rst_info;
  13. /*
  14. * enum ccu_rst_type - CCU Reset types
  15. * @CCU_RST_TRIG: Self-deasserted reset signal.
  16. * @CCU_RST_DIR: Directly controlled reset signal.
  17. */
  18. enum ccu_rst_type {
  19. CCU_RST_TRIG,
  20. CCU_RST_DIR,
  21. };
  22. /*
  23. * struct ccu_rst_init_data - CCU Resets initialization data
  24. * @sys_regs: Baikal-T1 System Controller registers map.
  25. * @np: Pointer to the node with the System CCU block.
  26. */
  27. struct ccu_rst_init_data {
  28. struct regmap *sys_regs;
  29. struct device_node *np;
  30. };
  31. /*
  32. * struct ccu_rst - CCU Reset descriptor
  33. * @rcdev: Reset controller descriptor.
  34. * @sys_regs: Baikal-T1 System Controller registers map.
  35. * @rsts_info: Reset flag info (base address and mask).
  36. */
  37. struct ccu_rst {
  38. struct reset_controller_dev rcdev;
  39. struct regmap *sys_regs;
  40. const struct ccu_rst_info *rsts_info;
  41. };
  42. #define to_ccu_rst(_rcdev) container_of(_rcdev, struct ccu_rst, rcdev)
  43. #ifdef CONFIG_CLK_BT1_CCU_RST
  44. struct ccu_rst *ccu_rst_hw_register(const struct ccu_rst_init_data *init);
  45. void ccu_rst_hw_unregister(struct ccu_rst *rst);
  46. #else
  47. static inline
  48. struct ccu_rst *ccu_rst_hw_register(const struct ccu_rst_init_data *init)
  49. {
  50. return NULL;
  51. }
  52. static inline void ccu_rst_hw_unregister(struct ccu_rst *rst) {}
  53. #endif
  54. #endif /* __CLK_BT1_CCU_RST_H__ */