hfi_intf.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 _HFI_INTF_H_
  7. #define _HFI_INTF_H_
  8. #include <linux/types.h>
  9. #define HFI_CMD_Q_MINI_DUMP_SIZE_IN_BYTES 4096
  10. #define HFI_MSG_Q_MINI_DUMP_SIZE_IN_BYTES 4096
  11. #define HFI_NUM_MAX 2
  12. #define HFI_HANDLE_INIT_VALUE HFI_NUM_MAX
  13. #define HFI_CLIENT_NAME_LEN 32
  14. /**
  15. * struct hfi_mem
  16. * @len: length of memory
  17. * @kva: kernel virtual address
  18. * @iova: IO virtual address
  19. * @reserved: reserved field
  20. */
  21. struct hfi_mem {
  22. uint64_t len;
  23. uintptr_t kva;
  24. uint32_t iova;
  25. uint32_t reserved;
  26. };
  27. /**
  28. * struct hfi_mem_info
  29. * @qtbl: qtable hfi memory
  30. * @cmd_q: command queue hfi memory for host to firmware communication
  31. * @msg_q: message queue hfi memory for firmware to host communication
  32. * @dbg_q: debug queue hfi memory for firmware debug information
  33. * @sfr_buf: buffer for subsystem failure reason[SFR]
  34. * @sec_heap: secondary heap hfi memory for firmware
  35. * @qdss: qdss mapped memory for fw
  36. * @io_mem: io memory info
  37. * @io_mem2: 2nd io memory info
  38. * @fw_uncached: FW uncached region info
  39. * @global_sync: Global sync mem for IPC
  40. * @device_mem: device memory
  41. */
  42. struct hfi_mem_info {
  43. struct hfi_mem qtbl;
  44. struct hfi_mem cmd_q;
  45. struct hfi_mem msg_q;
  46. struct hfi_mem dbg_q;
  47. struct hfi_mem sfr_buf;
  48. struct hfi_mem sec_heap;
  49. struct hfi_mem shmem;
  50. struct hfi_mem qdss;
  51. struct hfi_mem io_mem;
  52. struct hfi_mem io_mem2;
  53. struct hfi_mem fw_uncached;
  54. struct hfi_mem device_mem;
  55. };
  56. /**
  57. * struct hfi_ops
  58. * @irq_raise: called to raise H2ICP interrupt
  59. * @irq_enable: called to enable interrupts from ICP
  60. * @iface_addr: called to get interface registers base address
  61. */
  62. struct hfi_ops {
  63. void (*irq_raise)(void *data);
  64. void (*irq_enable)(void *data);
  65. void __iomem *(*iface_addr)(void *data);
  66. };
  67. /**
  68. * struct hfi_mini_dump_info
  69. * @cmd_q: cmd queue
  70. * @msg_q: msg queue
  71. * @msg_q_state: msg queue state
  72. * @cmd_q_state: cmd queue state
  73. * @dbg_q_state: dbg queue state
  74. */
  75. struct hfi_mini_dump_info {
  76. uint32_t cmd_q[HFI_CMD_Q_MINI_DUMP_SIZE_IN_BYTES];
  77. uint32_t msg_q[HFI_MSG_Q_MINI_DUMP_SIZE_IN_BYTES];
  78. bool msg_q_state;
  79. bool cmd_q_state;
  80. bool dbg_q_state;
  81. };
  82. /**
  83. * hfi_write_cmd() - function for hfi write
  84. * @client_handle: client handle
  85. * @cmd_ptr: pointer to command data for hfi write
  86. *
  87. * Returns success(zero)/failure(non zero)
  88. */
  89. int hfi_write_cmd(int client_handle, void *cmd_ptr);
  90. /**
  91. * hfi_read_message() - function for hfi read
  92. * @client_handle: client handle
  93. * @pmsg: buffer to place read message for hfi queue
  94. * @q_id: Queue to read from
  95. * @buf_words_size: size in words of the input buffer
  96. * @words_read: total number of words read from the queue
  97. * returned as output to the caller
  98. *
  99. * Returns success(zero)/failure(non zero)
  100. */
  101. int hfi_read_message(int client_handle, uint32_t *pmsg, uint8_t q_id,
  102. size_t buf_words_size, uint32_t *words_read);
  103. /**
  104. * hfi_init() - function initialize hfi after firmware download
  105. * @client_handle: client handle
  106. * @hfi_mem: hfi memory info
  107. * @hfi_ops: processor-specific hfi ops
  108. * @priv: device private data
  109. * @event_driven_mode: event mode
  110. *
  111. * Returns success(zero)/failure(non zero)
  112. */
  113. int cam_hfi_init(int client_handle, struct hfi_mem_info *hfi_mem,
  114. const struct hfi_ops *hfi_ops, void *priv, uint8_t event_driven_modem);
  115. /**
  116. * cam_hfi_register() - function to register user as hfi client and retrieve handle
  117. * @client_handle: client handle to be retrieved
  118. * @client_name: Name of the client to be registered
  119. *
  120. * Returns success(zero)/failure(non zero)
  121. */
  122. int cam_hfi_register(int *client_handle, const char *client_name);
  123. /**
  124. * cam_hfi_unregister() - function to unregister hfi client
  125. * @client_handle: client handle
  126. *
  127. * Returns success(zero)/failure(non zero)
  128. */
  129. int cam_hfi_unregister(int *client_handle);
  130. /**
  131. * hfi_get_hw_caps() - hardware capabilities from firmware
  132. * @query_caps: holds query information from hfi
  133. *
  134. * Returns success(zero)/failure(non zero)
  135. */
  136. int hfi_get_hw_caps(void *query_caps);
  137. /**
  138. * hfi_get_hw_caps_v2() - hardware capabilities from firmware, used for v2 query cap
  139. * @client_handle: client handle
  140. * @query_caps: holds query information from hfi
  141. *
  142. * Returns success(zero)/failure(non zero)
  143. */
  144. int hfi_get_hw_caps_v2(int client_handle, void *query_caps);
  145. /**
  146. * hfi_send_system_cmd() - send hfi system command to firmware
  147. * @client_handle: client handle
  148. * @type: type of system command
  149. * @data: command data
  150. * @size: size of command data
  151. *
  152. * Returns success(zero)/failure(non zero)
  153. */
  154. int hfi_send_system_cmd(int client_handle, uint32_t type, uint64_t data, uint32_t size);
  155. /**
  156. * cam_hfi_deinit() - cleanup HFI
  157. * @client_handle: client handle to be retrieved
  158. */
  159. void cam_hfi_deinit(int client_handle);
  160. /**
  161. * hfi_set_debug_level() - set debug level
  162. * @client_handle: client handle to be retrieved
  163. * @icp_dbg_type: 1 for debug_q & 2 for qdss
  164. * @lvl: FW debug message level
  165. *
  166. * Returns success(zero)/failure(non zero)
  167. */
  168. int hfi_set_debug_level(int client_handle, u64 icp_dbg_type, uint32_t lvl);
  169. /**
  170. * hfi_set_fw_dump_levels() - set firmware hang dump/ramdump levels
  171. * @client_handle: client handle to be retrieved
  172. * @hang_dump_lvl : level of firmware hang dump
  173. * @ram_dump_lvl : level of firmware ram dump
  174. *
  175. * Returns success(zero)/failure(non zero)
  176. */
  177. int hfi_set_fw_dump_levels(int client_handle,
  178. uint32_t hang_dump_lvl, uint32_t ram_dump_lvl);
  179. /**
  180. * hfi_send_freq_info() - set firmware dump level
  181. * @client_handle: client handle to be retrieved
  182. * @freq: icp freq
  183. *
  184. * Returns success(zero)/failure(non zero)
  185. */
  186. int hfi_send_freq_info(int client_handle, int32_t freq);
  187. /**
  188. * hfi_cmd_ubwc_config_ext() - UBWC configuration to firmware
  189. * @client_handle: client handle to be retrieved
  190. * @ubwc_ipe_cfg: UBWC ipe fetch/write configuration params
  191. * @ubwc_bps_cfg: UBWC bps fetch/write configuration params
  192. * @ubwc_ofe_cfg: UBWC ofe fetch/write configuration params
  193. *
  194. * Returns success(zero)/failure(non zero)
  195. */
  196. int hfi_cmd_ubwc_config_ext(int client_handle, uint32_t *ubwc_ipe_cfg,
  197. uint32_t *ubwc_bps_cfg, uint32_t *ubwc_ofe_cfg);
  198. /**
  199. * hfi_cmd_ubwc_config() - UBWC configuration to firmware
  200. * for older targets
  201. * @client_handle: client handle to be retrieved
  202. * @ubwc_cfg: UBWC configuration parameters
  203. *
  204. * Returns success(zero)/failure(non zero)
  205. */
  206. int hfi_cmd_ubwc_config(int client_handle, uint32_t *ubwc_cfg);
  207. /**
  208. * cam_hfi_resume() - function to resume
  209. * @client_handle: client handle to be retrieved
  210. *
  211. * Returns success(zero)/failure(non zero)
  212. */
  213. int cam_hfi_resume(int client_handle);
  214. /**
  215. * cam_hfi_queue_dump() - utility function to dump hfi queues
  216. * @client_handle: client handle to be retrieved
  217. * @dump_queue_data: if set dumps queue contents
  218. */
  219. void cam_hfi_queue_dump(int client_handle, bool dump_queue_data);
  220. /**
  221. * cam_hfi_mini_dump() - utility function for mini dump
  222. * @client_handle: client handle to be retrieved
  223. * @dst: memory destination
  224. */
  225. void cam_hfi_mini_dump(int client_handle, struct hfi_mini_dump_info *dst);
  226. #endif /* _HFI_INTF_H_ */