cam_cpas_hw_intf.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CAM_CPAS_HW_INTF_H_
  6. #define _CAM_CPAS_HW_INTF_H_
  7. #include <linux/platform_device.h>
  8. #include "cam_cpas_api.h"
  9. #include "cam_hw.h"
  10. #include "cam_hw_intf.h"
  11. #include "cam_debug_util.h"
  12. /* Number of times to retry while polling */
  13. #define CAM_CPAS_POLL_RETRY_CNT 5
  14. /* Minimum usecs to sleep while polling */
  15. #define CAM_CPAS_POLL_MIN_USECS 200
  16. /* Maximum usecs to sleep while polling */
  17. #define CAM_CPAS_POLL_MAX_USECS 250
  18. /* Number of times to retry while polling */
  19. #define CAM_CPAS_POLL_QH_RETRY_CNT 50
  20. /**
  21. * enum cam_cpas_hw_type - Enum for CPAS HW type
  22. */
  23. enum cam_cpas_hw_type {
  24. CAM_HW_CPASTOP,
  25. CAM_HW_CAMSSTOP,
  26. };
  27. /**
  28. * enum cam_cpas_hw_cmd_process - Enum for CPAS HW process command type
  29. */
  30. enum cam_cpas_hw_cmd_process {
  31. CAM_CPAS_HW_CMD_REGISTER_CLIENT,
  32. CAM_CPAS_HW_CMD_UNREGISTER_CLIENT,
  33. CAM_CPAS_HW_CMD_REG_WRITE,
  34. CAM_CPAS_HW_CMD_REG_READ,
  35. CAM_CPAS_HW_CMD_AHB_VOTE,
  36. CAM_CPAS_HW_CMD_AXI_VOTE,
  37. CAM_CPAS_HW_CMD_LOG_VOTE,
  38. CAM_CPAS_HW_CMD_SELECT_QOS,
  39. CAM_CPAS_HW_CMD_LOG_EVENT,
  40. CAM_CPAS_HW_CMD_INVALID,
  41. };
  42. /**
  43. * struct cam_cpas_hw_cmd_reg_read_write : CPAS cmd struct for reg read, write
  44. *
  45. * @client_handle: Client handle
  46. * @reg_base: Register base type
  47. * @offset: Register offset
  48. * @value: Register value
  49. * @mb: Whether to do operation with memory barrier
  50. *
  51. */
  52. struct cam_cpas_hw_cmd_reg_read_write {
  53. uint32_t client_handle;
  54. enum cam_cpas_reg_base reg_base;
  55. uint32_t offset;
  56. uint32_t value;
  57. bool mb;
  58. };
  59. /**
  60. * struct cam_cpas_hw_cmd_ahb_vote : CPAS cmd struct for AHB vote
  61. *
  62. * @client_handle: Client handle
  63. * @ahb_vote: AHB voting info
  64. *
  65. */
  66. struct cam_cpas_hw_cmd_ahb_vote {
  67. uint32_t client_handle;
  68. struct cam_ahb_vote *ahb_vote;
  69. };
  70. /**
  71. * struct cam_cpas_hw_cmd_axi_vote : CPAS cmd struct for AXI vote
  72. *
  73. * @client_handle: Client handle
  74. * @axi_vote: axi bandwidth vote
  75. *
  76. */
  77. struct cam_cpas_hw_cmd_axi_vote {
  78. uint32_t client_handle;
  79. struct cam_axi_vote *axi_vote;
  80. };
  81. /**
  82. * struct cam_cpas_hw_cmd_start : CPAS cmd struct for start
  83. *
  84. * @client_handle: Client handle
  85. *
  86. */
  87. struct cam_cpas_hw_cmd_start {
  88. uint32_t client_handle;
  89. struct cam_ahb_vote *ahb_vote;
  90. struct cam_axi_vote *axi_vote;
  91. };
  92. /**
  93. * struct cam_cpas_hw_cmd_stop : CPAS cmd struct for stop
  94. *
  95. * @client_handle: Client handle
  96. *
  97. */
  98. struct cam_cpas_hw_cmd_stop {
  99. uint32_t client_handle;
  100. };
  101. /**
  102. * struct cam_cpas_hw_cmd_notify_event : CPAS cmd struct for notify event
  103. *
  104. * @identifier_string: Identifier string passed by caller
  105. * @identifier_value: Identifier value passed by caller
  106. *
  107. */
  108. struct cam_cpas_hw_cmd_notify_event {
  109. const char *identifier_string;
  110. int32_t identifier_value;
  111. };
  112. /**
  113. * struct cam_cpas_hw_caps : CPAS HW capabilities
  114. *
  115. * @camera_family: Camera family type
  116. * @camera_version: Camera version
  117. * @cpas_version: CPAS version
  118. * @camera_capability: Camera hw capabilities
  119. * @fuse_info: Fuse information
  120. *
  121. */
  122. struct cam_cpas_hw_caps {
  123. uint32_t camera_family;
  124. struct cam_hw_version camera_version;
  125. struct cam_hw_version cpas_version;
  126. uint32_t camera_capability;
  127. struct cam_cpas_fuse_info fuse_info;
  128. };
  129. int cam_cpas_hw_probe(struct platform_device *pdev,
  130. struct cam_hw_intf **hw_intf);
  131. int cam_cpas_hw_remove(struct cam_hw_intf *cpas_hw_intf);
  132. /**
  133. * @brief : API to register CPAS hw to platform framework.
  134. * @return struct platform_device pointer on on success, or ERR_PTR() on error.
  135. */
  136. int cam_cpas_dev_init_module(void);
  137. /**
  138. * @brief : API to remove CPAS interface from platform framework.
  139. */
  140. void cam_cpas_dev_exit_module(void);
  141. #endif /* _CAM_CPAS_HW_INTF_H_ */