hfi_intf.h 7.0 KB

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