cam_cpas_hw_intf.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _CAM_CPAS_HW_INTF_H_
  7. #define _CAM_CPAS_HW_INTF_H_
  8. #include <linux/platform_device.h>
  9. #include "cam_cpas_api.h"
  10. #include "cam_hw.h"
  11. #include "cam_hw_intf.h"
  12. #include "cam_debug_util.h"
  13. /* Number of times to retry while polling */
  14. #define CAM_CPAS_POLL_RETRY_CNT 5
  15. /* Minimum usecs to sleep while polling */
  16. #define CAM_CPAS_POLL_MIN_USECS 200
  17. /* Maximum usecs to sleep while polling */
  18. #define CAM_CPAS_POLL_MAX_USECS 250
  19. /* Number of times to retry while polling */
  20. #define CAM_CPAS_POLL_QH_RETRY_CNT 50
  21. /* Number of CPAS hw caps registers */
  22. #define CAM_CPAS_MAX_CAPS_REGS 2
  23. /**
  24. * enum cam_cpas_hw_type - Enum for CPAS HW type
  25. */
  26. enum cam_cpas_hw_type {
  27. CAM_HW_CPASTOP,
  28. CAM_HW_CAMSSTOP,
  29. };
  30. /**
  31. * enum cam_cpas_reg_base - Enum for register base identifier. These
  32. * are the identifiers used in generic register
  33. * write/read APIs provided by cpas driver.
  34. */
  35. enum cam_cpas_reg_base {
  36. CAM_CPAS_REG_CPASTOP,
  37. CAM_CPAS_REG_CAMNOC,
  38. CAM_CPAS_REG_CAMSS,
  39. CAM_CPAS_REG_RPMH,
  40. CAM_CPAS_REG_CESTA,
  41. CAM_CPAS_REG_CAMNOC_RT,
  42. CAM_CPAS_REG_CAMNOC_NRT,
  43. CAM_CPAS_REG_MAX
  44. };
  45. /**
  46. * enum cam_cpas_hw_cmd_process - Enum for CPAS HW process command type
  47. */
  48. enum cam_cpas_hw_cmd_process {
  49. CAM_CPAS_HW_CMD_REGISTER_CLIENT,
  50. CAM_CPAS_HW_CMD_UNREGISTER_CLIENT,
  51. CAM_CPAS_HW_CMD_REG_WRITE,
  52. CAM_CPAS_HW_CMD_REG_READ,
  53. CAM_CPAS_HW_CMD_AHB_VOTE,
  54. CAM_CPAS_HW_CMD_AXI_VOTE,
  55. CAM_CPAS_HW_CMD_LOG_VOTE,
  56. CAM_CPAS_HW_CMD_SELECT_QOS,
  57. CAM_CPAS_HW_CMD_LOG_EVENT,
  58. CAM_CPAS_HW_CMD_GET_SCID,
  59. CAM_CPAS_HW_CMD_ACTIVATE_LLC,
  60. CAM_CPAS_HW_CMD_DEACTIVATE_LLC,
  61. CAM_CPAS_HW_CMD_CONFIGURE_STALING_LLC,
  62. CAM_CPAS_HW_CMD_NOTIF_STALL_INC_LLC,
  63. CAM_CPAS_HW_CMD_DUMP_BUFF_FILL_INFO,
  64. CAM_CPAS_HW_CMD_CSID_INPUT_CORE_INFO_UPDATE,
  65. CAM_CPAS_HW_CMD_CSID_PROCESS_RESUME,
  66. CAM_CPAS_HW_CMD_ENABLE_DISABLE_DOMAIN_ID_CLK,
  67. CAM_CPAS_HW_CMD_TPG_MUX_SEL,
  68. CAM_CPAS_HW_CMD_DUMP_STATE_MONITOR_INFO,
  69. CAM_CPAS_HW_CMD_INVALID,
  70. };
  71. /**
  72. * struct cam_cpas_hw_cmd_csid_input_core_info_update : CPAS cmd struct for updating acquired
  73. * csid core info to cpas
  74. *
  75. * @csid_idx: CSID core index
  76. * @sfe_idx: SFE core index corresponding to CSID core
  77. * @set_port: Indicates whether to set or reset port for given client
  78. *
  79. */
  80. struct cam_cpas_hw_cmd_csid_input_core_info_update {
  81. int csid_idx;
  82. int sfe_idx;
  83. bool set_port;
  84. };
  85. /**
  86. * struct cam_cpas_hw_cmd_reg_read_write : CPAS cmd struct for reg read, write
  87. *
  88. * @client_handle: Client handle
  89. * @reg_base: Register base type
  90. * @offset: Register offset
  91. * @value: Register value
  92. * @mb: Whether to do operation with memory barrier
  93. *
  94. */
  95. struct cam_cpas_hw_cmd_reg_read_write {
  96. uint32_t client_handle;
  97. enum cam_cpas_reg_base reg_base;
  98. uint32_t offset;
  99. uint32_t value;
  100. bool mb;
  101. };
  102. /**
  103. * struct cam_cpas_hw_cmd_ahb_vote : CPAS cmd struct for AHB vote
  104. *
  105. * @client_handle: Client handle
  106. * @ahb_vote: AHB voting info
  107. *
  108. */
  109. struct cam_cpas_hw_cmd_ahb_vote {
  110. uint32_t client_handle;
  111. struct cam_ahb_vote *ahb_vote;
  112. };
  113. /**
  114. * struct cam_cpas_hw_cmd_axi_vote : CPAS cmd struct for AXI vote
  115. *
  116. * @client_handle: Client handle
  117. * @axi_vote: axi bandwidth vote
  118. *
  119. */
  120. struct cam_cpas_hw_cmd_axi_vote {
  121. uint32_t client_handle;
  122. struct cam_axi_vote *axi_vote;
  123. };
  124. /**
  125. * struct cam_cpas_hw_cmd_start : CPAS cmd struct for start
  126. *
  127. * @client_handle: Client handle
  128. *
  129. */
  130. struct cam_cpas_hw_cmd_start {
  131. uint32_t client_handle;
  132. struct cam_ahb_vote *ahb_vote;
  133. struct cam_axi_vote *axi_vote;
  134. };
  135. /**
  136. * struct cam_cpas_hw_cmd_stop : CPAS cmd struct for stop
  137. *
  138. * @client_handle: Client handle
  139. *
  140. */
  141. struct cam_cpas_hw_cmd_stop {
  142. uint32_t client_handle;
  143. };
  144. /**
  145. * struct cam_cpas_hw_cmd_notify_event : CPAS cmd struct for notify event
  146. *
  147. * @identifier_string: Identifier string passed by caller
  148. * @identifier_value: Identifier value passed by caller
  149. *
  150. */
  151. struct cam_cpas_hw_cmd_notify_event {
  152. const char *identifier_string;
  153. int32_t identifier_value;
  154. };
  155. /**
  156. * struct cam_cpas_hw_caps : CPAS HW capabilities
  157. *
  158. * @camera_family: Camera family type
  159. * @camera_version: Camera version
  160. * @cpas_version: CPAS version
  161. * @camera_capability: array of camera hw capabilities
  162. * @num_capability_reg: Number of camera hw capabilities registers
  163. * @fuse_info: Fuse information
  164. *
  165. */
  166. struct cam_cpas_hw_caps {
  167. uint32_t camera_family;
  168. struct cam_hw_version camera_version;
  169. struct cam_hw_version cpas_version;
  170. uint32_t camera_capability[CAM_CPAS_MAX_CAPS_REGS];
  171. uint32_t num_capability_reg;
  172. struct cam_cpas_fuse_info fuse_info;
  173. };
  174. int cam_cpas_hw_probe(struct platform_device *pdev,
  175. struct cam_hw_intf **hw_intf);
  176. int cam_cpas_hw_remove(struct cam_hw_intf *cpas_hw_intf);
  177. /**
  178. * @brief : API to register CPAS hw to platform framework.
  179. * @return struct platform_device pointer on on success, or ERR_PTR() on error.
  180. */
  181. int cam_cpas_dev_init_module(void);
  182. /**
  183. * @brief : API to remove CPAS interface from platform framework.
  184. */
  185. void cam_cpas_dev_exit_module(void);
  186. /**
  187. * @brief : API to select TPG mux select.
  188. */
  189. int cam_cpas_enable_tpg_mux_sel(uint32_t tpg_mux_sel);
  190. #endif /* _CAM_CPAS_HW_INTF_H_ */