hal_reset.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016 Maxime Ripard. All rights reserved.
  4. */
  5. #ifndef _HAL_RESET_H_
  6. #define _HAL_RESET_H_
  7. #include <aw_list.h>
  8. #include <sunxi_hal_common.h>
  9. #include <platform_rst.h>
  10. typedef enum {
  11. HAL_SUNXI_RESET = 0,
  12. HAL_SUNXI_R_RESET,
  13. HAL_SUNXI_RESET_NUMBER,
  14. } hal_reset_type_t;
  15. typedef u32 hal_reset_id_t;
  16. struct reset_control_dev;
  17. /**
  18. * struct reset_control_ops - reset controller driver callbacks
  19. *
  20. * @reset: for self-deasserting resets, does all necessary
  21. * things to reset the device
  22. * @assert: manually assert the reset line, if supported
  23. * @deassert: manually deassert the reset line, if supported
  24. * @status: return the status of the reset line, if supported
  25. */
  26. struct reset_control_ops {
  27. int (*reset)(struct reset_control_dev *rcdev, hal_reset_id_t id);
  28. int (*assert)(struct reset_control_dev *rcdev, hal_reset_id_t id);
  29. int (*deassert)(struct reset_control_dev *rcdev, hal_reset_id_t id);
  30. int (*status)(struct reset_control_dev *rcdev, hal_reset_id_t id);
  31. };
  32. /**
  33. * struct reset_control - reset controller entity that might
  34. * provide multiple reset controls
  35. * @ops: a pointer to device specific struct reset_control_ops
  36. * @owner: kernel module of the reset controller driver
  37. * @list: internal list of reset controller devices
  38. * @reset_control_head: head of internal list of requested reset controls
  39. * @dev: corresponding driver model device struct
  40. * @of_node: corresponding device tree node as phandle target
  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
  44. * @nr_resets: number of reset controls in this reset controller device
  45. */
  46. struct reset_control_dev {
  47. const struct reset_control_ops *ops;
  48. hal_reset_type_t type;
  49. u32 nr_resets;
  50. struct list_head node;
  51. };
  52. struct reset_control {
  53. struct reset_control_dev *rcdev;
  54. u32 enable_count;
  55. hal_reset_id_t id;
  56. };
  57. int reset_control_register(struct reset_control_dev *rcdev); //for reset system
  58. int reset_control_unregister(struct reset_control *reset); //for reset system
  59. struct reset_control *hal_reset_control_get(hal_reset_type_t type, hal_reset_id_t id);
  60. int hal_reset_control_put(struct reset_control *reset);
  61. int hal_reset_control_set(struct reset_control *reset); //for other module
  62. int hal_reset_control_deassert(struct reset_control *reset); //for other module
  63. int hal_reset_control_assert(struct reset_control *reset); //for other_module
  64. int hal_reset_control_reset(struct reset_control *reset); //for other_module
  65. int hal_reset_control_status(struct reset_control *reset); //for other_module
  66. #endif