hfi_intf.h 4.9 KB

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