hfi_intf.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022 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. /**
  12. * struct hfi_mem
  13. * @len: length of memory
  14. * @kva: kernel virtual address
  15. * @iova: IO virtual address
  16. * @reserved: reserved field
  17. */
  18. struct hfi_mem {
  19. uint64_t len;
  20. uintptr_t kva;
  21. uint32_t iova;
  22. uint32_t reserved;
  23. };
  24. /**
  25. * struct hfi_mem_info
  26. * @qtbl: qtable hfi memory
  27. * @cmd_q: command queue hfi memory for host to firmware communication
  28. * @msg_q: message queue hfi memory for firmware to host communication
  29. * @dbg_q: debug queue hfi memory for firmware debug information
  30. * @sfr_buf: buffer for subsystem failure reason[SFR]
  31. * @sec_heap: secondary heap hfi memory for firmware
  32. * @qdss: qdss mapped memory for fw
  33. * @io_mem: io memory info
  34. * @io_mem2: 2nd io memory info
  35. * @fw_uncached: FW uncached region info
  36. */
  37. struct hfi_mem_info {
  38. struct hfi_mem qtbl;
  39. struct hfi_mem cmd_q;
  40. struct hfi_mem msg_q;
  41. struct hfi_mem dbg_q;
  42. struct hfi_mem sfr_buf;
  43. struct hfi_mem sec_heap;
  44. struct hfi_mem shmem;
  45. struct hfi_mem qdss;
  46. struct hfi_mem io_mem;
  47. struct hfi_mem io_mem2;
  48. struct hfi_mem fw_uncached;
  49. };
  50. /**
  51. * struct hfi_ops
  52. * @irq_raise: called to raise H2ICP interrupt
  53. * @irq_enable: called to enable interrupts from ICP
  54. * @iface_addr: called to get interface registers base address
  55. */
  56. struct hfi_ops {
  57. void (*irq_raise)(void *data);
  58. void (*irq_enable)(void *data);
  59. void __iomem *(*iface_addr)(void *data);
  60. };
  61. /**
  62. * struct hfi_mini_dump_info
  63. * @cmd_q: cmd queue
  64. * @msg_q: msg queue
  65. * @msg_q_state: msg queue state
  66. * @cmd_q_state: cmd queue state
  67. */
  68. struct hfi_mini_dump_info {
  69. uint32_t cmd_q[HFI_CMD_Q_MINI_DUMP_SIZE_IN_BYTES];
  70. uint32_t msg_q[HFI_MSG_Q_MINI_DUMP_SIZE_IN_BYTES];
  71. bool msg_q_state;
  72. bool cmd_q_state;
  73. };
  74. /**
  75. * hfi_write_cmd() - function for hfi write
  76. * @cmd_ptr: pointer to command data for hfi write
  77. *
  78. * Returns success(zero)/failure(non zero)
  79. */
  80. int hfi_write_cmd(void *cmd_ptr);
  81. /**
  82. * hfi_read_message() - function for hfi read
  83. * @pmsg: buffer to place read message for hfi queue
  84. * @q_id: queue id
  85. * @words_read: total number of words read from the queue
  86. * returned as output to the caller
  87. *
  88. * Returns success(zero)/failure(non zero)
  89. */
  90. int hfi_read_message(uint32_t *pmsg, uint8_t q_id, uint32_t *words_read);
  91. /**
  92. * hfi_init() - function initialize hfi after firmware download
  93. * @hfi_mem: hfi memory info
  94. * @hfi_ops: processor-specific hfi ops
  95. * @priv: device private data
  96. * @event_driven_mode: event mode
  97. *
  98. * Returns success(zero)/failure(non zero)
  99. */
  100. int cam_hfi_init(struct hfi_mem_info *hfi_mem, const struct hfi_ops *hfi_ops,
  101. void *priv, uint8_t event_driven_mode);
  102. /**
  103. * hfi_get_hw_caps() - hardware capabilities from firmware
  104. * @query_caps: holds query information from hfi
  105. *
  106. * Returns success(zero)/failure(non zero)
  107. */
  108. int hfi_get_hw_caps(void *query_caps);
  109. /**
  110. * hfi_send_system_cmd() - send hfi system command to firmware
  111. * @type: type of system command
  112. * @data: command data
  113. * @size: size of command data
  114. */
  115. void hfi_send_system_cmd(uint32_t type, uint64_t data, uint32_t size);
  116. /**
  117. * cam_hfi_deinit() - cleanup HFI
  118. */
  119. void cam_hfi_deinit(void);
  120. /**
  121. * hfi_set_debug_level() - set debug level
  122. * @icp_dbg_type: 1 for debug_q & 2 for qdss
  123. * @lvl: FW debug message level
  124. */
  125. int hfi_set_debug_level(u64 icp_dbg_type, uint32_t lvl);
  126. /**
  127. * hfi_set_fw_dump_levels() - set firmware hang dump/ramdump levels
  128. * @hang_dump_lvl : level of firmware hang dump
  129. * @ram_dump_lvl : level of firmware ram dump
  130. */
  131. int hfi_set_fw_dump_levels(uint32_t hang_dump_lvl, uint32_t ram_dump_lvl);
  132. /**
  133. * hfi_send_freq_info() - set firmware dump level
  134. * @freq: icp freq
  135. */
  136. int hfi_send_freq_info(int32_t freq);
  137. /**
  138. * hfi_enable_dev_pc() - Enable interframe pc
  139. * Host sends a command to firmware to enable interframe
  140. * power collapse for ICP's controlled hardware.
  141. *
  142. * @enable: flag to enable/disable
  143. * @core_info: Core information to firmware
  144. */
  145. int hfi_enable_dev_pc(bool enable, uint32_t core_info);
  146. /**
  147. * hfi_cmd_ubwc_config_ext() - UBWC configuration to firmware
  148. * @ubwc_ipe_cfg: UBWC ipe fetch/write configuration params
  149. * @ubwc_bps_cfg: UBWC bps fetch/write configuration params
  150. */
  151. int hfi_cmd_ubwc_config_ext(uint32_t *ubwc_ipe_cfg,
  152. uint32_t *ubwc_bps_cfg);
  153. /**
  154. * hfi_cmd_ubwc_config() - UBWC configuration to firmware
  155. * for older targets
  156. * @ubwc_cfg: UBWC configuration parameters
  157. */
  158. int hfi_cmd_ubwc_config(uint32_t *ubwc_cfg);
  159. /**
  160. * cam_hfi_resume() - function to resume
  161. * @hfi_mem: hfi memory info
  162. *
  163. * Returns success(zero)/failure(non zero)
  164. */
  165. int cam_hfi_resume(struct hfi_mem_info *hfi_mem);
  166. /**
  167. * cam_hfi_queue_dump() - utility function to dump hfi queues
  168. * @dump_queue_data: if set dumps queue contents
  169. *
  170. */
  171. void cam_hfi_queue_dump(bool dump_queue_data);
  172. /**
  173. * cam_hfi_mini_dump() - utility function for mini dump
  174. */
  175. void cam_hfi_mini_dump(struct hfi_mini_dump_info *dst);
  176. #endif /* _HFI_INTF_H_ */