hfi_intf.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. * @hwmutex: HWMutex 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 global_sync;
  55. struct hfi_mem hwmutex;
  56. };
  57. /**
  58. * struct hfi_ops
  59. * @irq_raise: called to raise H2ICP interrupt
  60. * @irq_enable: called to enable interrupts from ICP
  61. * @iface_addr: called to get interface registers base address
  62. */
  63. struct hfi_ops {
  64. void (*irq_raise)(void *data);
  65. void (*irq_enable)(void *data);
  66. void __iomem *(*iface_addr)(void *data);
  67. };
  68. /**
  69. * struct hfi_mini_dump_info
  70. * @cmd_q: cmd queue
  71. * @msg_q: msg queue
  72. * @msg_q_state: msg queue state
  73. * @cmd_q_state: cmd 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. };
  81. /**
  82. * hfi_write_cmd() - function for hfi write
  83. * @client_handle: client handle
  84. * @cmd_ptr: pointer to command data for hfi write
  85. *
  86. * Returns success(zero)/failure(non zero)
  87. */
  88. int hfi_write_cmd(int client_handle, void *cmd_ptr);
  89. /**
  90. * hfi_read_message() - function for hfi read
  91. * @client_handle: client handle
  92. * @pmsg: buffer to place read message for hfi queue
  93. * @q_id: queue id
  94. * @words_read: total number of words read from the queue
  95. * returned as output to the caller
  96. *
  97. * Returns success(zero)/failure(non zero)
  98. */
  99. int hfi_read_message(int client_handle, uint32_t *pmsg, uint8_t q_id, uint32_t *words_read);
  100. /**
  101. * hfi_init() - function initialize hfi after firmware download
  102. * @client_handle: client handle
  103. * @hfi_mem: hfi memory info
  104. * @hfi_ops: processor-specific hfi ops
  105. * @priv: device private data
  106. * @event_driven_mode: event mode
  107. *
  108. * Returns success(zero)/failure(non zero)
  109. */
  110. int cam_hfi_init(int client_handle, struct hfi_mem_info *hfi_mem,
  111. const struct hfi_ops *hfi_ops, void *priv, uint8_t event_driven_modem);
  112. /**
  113. * cam_hfi_register() - function to register user as hfi client and retrieve handle
  114. * @client_handle: client handle to be retrieved
  115. * @client_name: Name of the client to be registered
  116. *
  117. * Returns success(zero)/failure(non zero)
  118. */
  119. int cam_hfi_register(int *client_handle, const char *client_name);
  120. /**
  121. * cam_hfi_unregister() - function to unregister hfi client
  122. * @client_handle: client handle
  123. *
  124. * Returns success(zero)/failure(non zero)
  125. */
  126. int cam_hfi_unregister(int *client_handle);
  127. /**
  128. * hfi_get_hw_caps() - hardware capabilities from firmware
  129. * @query_caps: holds query information from hfi
  130. *
  131. * Returns success(zero)/failure(non zero)
  132. */
  133. int hfi_get_hw_caps(void *query_caps);
  134. /**
  135. * hfi_get_hw_caps_v2() - hardware capabilities from firmware, used for v2 query cap
  136. * @client_handle: client handle
  137. * @query_caps: holds query information from hfi
  138. *
  139. * Returns success(zero)/failure(non zero)
  140. */
  141. int hfi_get_hw_caps_v2(int client_handle, void *query_caps);
  142. /**
  143. * hfi_send_system_cmd() - send hfi system command to firmware
  144. * @client_handle: client handle
  145. * @type: type of system command
  146. * @data: command data
  147. * @size: size of command data
  148. *
  149. * Returns success(zero)/failure(non zero)
  150. */
  151. int hfi_send_system_cmd(int client_handle, uint32_t type, uint64_t data, uint32_t size);
  152. /**
  153. * cam_hfi_deinit() - cleanup HFI
  154. * @client_handle: client handle to be retrieved
  155. */
  156. void cam_hfi_deinit(int client_handle);
  157. /**
  158. * hfi_set_debug_level() - set debug level
  159. * @client_handle: client handle to be retrieved
  160. * @icp_dbg_type: 1 for debug_q & 2 for qdss
  161. * @lvl: FW debug message level
  162. *
  163. * Returns success(zero)/failure(non zero)
  164. */
  165. int hfi_set_debug_level(int client_handle, u64 icp_dbg_type, uint32_t lvl);
  166. /**
  167. * hfi_set_fw_dump_levels() - set firmware hang dump/ramdump levels
  168. * @client_handle: client handle to be retrieved
  169. * @hang_dump_lvl : level of firmware hang dump
  170. * @ram_dump_lvl : level of firmware ram dump
  171. *
  172. * Returns success(zero)/failure(non zero)
  173. */
  174. int hfi_set_fw_dump_levels(int client_handle,
  175. uint32_t hang_dump_lvl, uint32_t ram_dump_lvl);
  176. /**
  177. * hfi_send_freq_info() - set firmware dump level
  178. * @client_handle: client handle to be retrieved
  179. * @freq: icp freq
  180. *
  181. * Returns success(zero)/failure(non zero)
  182. */
  183. int hfi_send_freq_info(int client_handle, int32_t freq);
  184. /**
  185. * hfi_cmd_ubwc_config_ext() - UBWC configuration to firmware
  186. * @client_handle: client handle to be retrieved
  187. * @ubwc_ipe_cfg: UBWC ipe fetch/write configuration params
  188. * @ubwc_bps_cfg: UBWC bps fetch/write configuration params
  189. * @ubwc_ofe_cfg: UBWC ofe fetch/write configuration params
  190. *
  191. * Returns success(zero)/failure(non zero)
  192. */
  193. int hfi_cmd_ubwc_config_ext(int client_handle, uint32_t *ubwc_ipe_cfg,
  194. uint32_t *ubwc_bps_cfg, uint32_t *ubwc_ofe_cfg);
  195. /**
  196. * hfi_cmd_ubwc_config() - UBWC configuration to firmware
  197. * for older targets
  198. * @client_handle: client handle to be retrieved
  199. * @ubwc_cfg: UBWC configuration parameters
  200. *
  201. * Returns success(zero)/failure(non zero)
  202. */
  203. int hfi_cmd_ubwc_config(int client_handle, uint32_t *ubwc_cfg);
  204. /**
  205. * cam_hfi_resume() - function to resume
  206. * @client_handle: client handle to be retrieved
  207. *
  208. * Returns success(zero)/failure(non zero)
  209. */
  210. int cam_hfi_resume(int client_handle);
  211. /**
  212. * cam_hfi_queue_dump() - utility function to dump hfi queues
  213. * @client_handle: client handle to be retrieved
  214. * @dump_queue_data: if set dumps queue contents
  215. */
  216. void cam_hfi_queue_dump(int client_handle, bool dump_queue_data);
  217. /**
  218. * cam_hfi_mini_dump() - utility function for mini dump
  219. * @client_handle: client handle to be retrieved
  220. * @dst: memory destination
  221. */
  222. void cam_hfi_mini_dump(int client_handle, struct hfi_mini_dump_info *dst);
  223. #endif /* _HFI_INTF_H_ */