adreno_gen7_hfi.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __ADRENO_GEN7_HFI_H
  7. #define __ADRENO_GEN7_HFI_H
  8. #include "adreno_hfi.h"
  9. /**
  10. * struct gen7_hfi - HFI control structure
  11. */
  12. struct gen7_hfi {
  13. /** @irq: HFI interrupt line */
  14. int irq;
  15. /** @seqnum: atomic counter that is incremented for each message sent.
  16. * The value of the counter is used as sequence number for HFI message.
  17. */
  18. atomic_t seqnum;
  19. /** @hfi_mem: Memory descriptor for the hfi memory */
  20. struct kgsl_memdesc *hfi_mem;
  21. /** @bw_table: HFI BW table buffer */
  22. struct hfi_bwtable_cmd bw_table;
  23. /** @acd_table: HFI table for ACD data */
  24. struct hfi_acd_table_cmd acd_table;
  25. /** @cmdq_lock: Spinlock for accessing the cmdq */
  26. spinlock_t cmdq_lock;
  27. /**
  28. * @wb_set_record_bitmask: Bitmask to enable or disable the recording
  29. * of messages in the GMU scratch.
  30. */
  31. unsigned long wb_set_record_bitmask[BITS_TO_LONGS(HFI_MAX_ID)];
  32. };
  33. struct gen7_gmu_device;
  34. /* gen7_hfi_irq_handler - IRQ handler for HFI interripts */
  35. irqreturn_t gen7_hfi_irq_handler(int irq, void *data);
  36. /**
  37. * gen7_hfi_start - Send the various HFIs during device boot up
  38. * @adreno_dev: Pointer to the adreno device
  39. *
  40. * Return: 0 on success or negative error on failure
  41. */
  42. int gen7_hfi_start(struct adreno_device *adreno_dev);
  43. /**
  44. * gen7_hfi_start - Send the various HFIs during device boot up
  45. * @adreno_dev: Pointer to the adreno device
  46. *
  47. * Return: 0 on success or negative error on failure
  48. */
  49. void gen7_hfi_stop(struct adreno_device *adreno_dev);
  50. /**
  51. * gen7_hfi_init - Initialize hfi resources
  52. * @adreno_dev: Pointer to the adreno device
  53. *
  54. * This function allocates and sets up hfi queues
  55. * when a process creates the very first kgsl instance
  56. *
  57. * Return: 0 on success or negative error on failure
  58. */
  59. int gen7_hfi_init(struct adreno_device *adreno_dev);
  60. /* Helper function to get to gen7 hfi struct from adreno device */
  61. struct gen7_hfi *to_gen7_hfi(struct adreno_device *adreno_dev);
  62. /**
  63. * gen7_hfi_queue_write - Write a command to hfi queue
  64. * @adreno_dev: Pointer to the adreno device
  65. * @queue_idx: destination queue id
  66. * @msg: Data to be written to the queue
  67. * @size_bytes: Size of the command in bytes
  68. *
  69. * Return: 0 on success or negative error on failure
  70. */
  71. int gen7_hfi_queue_write(struct adreno_device *adreno_dev, u32 queue_idx,
  72. u32 *msg, u32 size_bytes);
  73. /**
  74. * gen7_hfi_queue_read - Read data from hfi queue
  75. * @gmu: Pointer to the gen7 gmu device
  76. * @queue_idx: queue id to read from
  77. * @output: Pointer to read the data into
  78. * @max_size: Number of bytes to read from the queue
  79. *
  80. * Return: 0 on success or negative error on failure
  81. */
  82. int gen7_hfi_queue_read(struct gen7_gmu_device *gmu, u32 queue_idx,
  83. u32 *output, u32 max_size);
  84. /**
  85. * gen7_receive_ack_cmd - Process ack type packets
  86. * @gmu: Pointer to the gen7 gmu device
  87. * @rcvd: Pointer to the data read from hfi queue
  88. * @ret_cmd: Container for the hfi packet for which this ack is received
  89. *
  90. * Return: 0 on success or negative error on failure
  91. */
  92. int gen7_receive_ack_cmd(struct gen7_gmu_device *gmu, void *rcvd,
  93. struct pending_cmd *ret_cmd);
  94. /**
  95. * gen7_hfi_send_feature_ctrl - Enable gmu feature via hfi
  96. * @adreno_dev: Pointer to the adreno device
  97. * @feature: feature to be enabled or disabled
  98. * enable: Set 1 to enable or 0 to disable a feature
  99. * @data: payload for the send feature hfi packet
  100. *
  101. * Return: 0 on success or negative error on failure
  102. */
  103. int gen7_hfi_send_feature_ctrl(struct adreno_device *adreno_dev,
  104. u32 feature, u32 enable, u32 data);
  105. /**
  106. * gen7_hfi_send_get_value - Send gmu get_values via hfi
  107. * @adreno_dev: Pointer to the adreno device
  108. * @type: GMU get_value type
  109. * @subtype: GMU get_value subtype
  110. *
  111. * Return: 0 on success or negative error on failure
  112. */
  113. int gen7_hfi_send_get_value(struct adreno_device *adreno_dev, u32 type, u32 subtype);
  114. /**
  115. * gen7_hfi_send_set_value - Send gmu set_values via hfi
  116. * @adreno_dev: Pointer to the adreno device
  117. * @type: GMU set_value type
  118. * @subtype: GMU set_value subtype
  119. * @data: Value to set
  120. *
  121. * Return: 0 on success or negative error on failure
  122. */
  123. int gen7_hfi_send_set_value(struct adreno_device *adreno_dev,
  124. u32 type, u32 subtype, u32 data);
  125. /**
  126. * gen7_hfi_send_core_fw_start - Send the core fw start hfi
  127. * @adreno_dev: Pointer to the adreno device
  128. *
  129. * Return: 0 on success or negative error on failure
  130. */
  131. int gen7_hfi_send_core_fw_start(struct adreno_device *adreno_dev);
  132. /**
  133. * gen7_hfi_send_acd_feature_ctrl - Send the acd table and acd feature
  134. * @adreno_dev: Pointer to the adreno device
  135. *
  136. * Return: 0 on success or negative error on failure
  137. */
  138. int gen7_hfi_send_acd_feature_ctrl(struct adreno_device *adreno_dev);
  139. /**
  140. * gen7_hfi_send_generic_req - Send a generic hfi packet
  141. * @adreno_dev: Pointer to the adreno device
  142. * @cmd: Pointer to the hfi packet header and data
  143. * @size_bytes: Size of the packet in bytes
  144. *
  145. * Return: 0 on success or negative error on failure
  146. */
  147. int gen7_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes);
  148. /**
  149. * gen7_hfi_send_generic_req_v5 - Send a generic hfi packet with additional error handling
  150. * @adreno_dev: Pointer to the adreno device
  151. * @cmd: Pointer to the hfi packet header and data
  152. * @ret_cmd: Ack for the command we just sent
  153. * @size_bytes: Size of the packet in bytes
  154. *
  155. * Return: 0 on success or negative error on failure
  156. */
  157. int gen7_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd,
  158. struct pending_cmd *ret_cmd, u32 size_bytes);
  159. /**
  160. * gen7_hfi_send_bcl_feature_ctrl - Send the bcl feature hfi packet
  161. * @adreno_dev: Pointer to the adreno device
  162. *
  163. * Return: 0 on success or negative error on failure
  164. */
  165. int gen7_hfi_send_bcl_feature_ctrl(struct adreno_device *adreno_dev);
  166. /**
  167. * gen7_hfi_send_clx_feature_ctrl - Send the clx feature hfi packet
  168. * @adreno_dev: Pointer to the adreno device
  169. *
  170. * Return: 0 on success or negative error on failure
  171. */
  172. int gen7_hfi_send_clx_feature_ctrl(struct adreno_device *adreno_dev);
  173. /**
  174. * gen7_hfi_send_ifpc_feature_ctrl - Send the ipfc feature hfi packet
  175. * @adreno_dev: Pointer to the adreno device
  176. *
  177. * Return: 0 on success or negative error on failure
  178. */
  179. int gen7_hfi_send_ifpc_feature_ctrl(struct adreno_device *adreno_dev);
  180. /**
  181. * gen7_hfi_send_gpu_perf_table - Send the gpu perf table hfi packet
  182. * @adreno_dev: Pointer to the adreno device
  183. *
  184. * Return: 0 on success or negative error on failure
  185. */
  186. int gen7_hfi_send_gpu_perf_table(struct adreno_device *adreno_dev);
  187. /*
  188. * gen7_hfi_process_queue - Check hfi queue for messages from gmu
  189. * @gmu: Pointer to the gen7 gmu device
  190. * @queue_idx: queue id to be processed
  191. * @ret_cmd: Container for data needed for waiting for the ack
  192. *
  193. * Return: 0 on success or negative error on failure
  194. */
  195. int gen7_hfi_process_queue(struct gen7_gmu_device *gmu,
  196. u32 queue_idx, struct pending_cmd *ret_cmd);
  197. /**
  198. * gen7_hfi_cmdq_write - Write a command to command queue
  199. * @adreno_dev: Pointer to the adreno device
  200. * @msg: Data to be written to the queue
  201. * @size_bytes: Size of the command in bytes
  202. *
  203. * This function takes the cmdq lock before writing data to the queue
  204. * Return: 0 on success or negative error on failure
  205. */
  206. int gen7_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes);
  207. void adreno_gen7_receive_err_req(struct gen7_gmu_device *gmu, void *rcvd);
  208. void adreno_gen7_receive_debug_req(struct gen7_gmu_device *gmu, void *rcvd);
  209. #endif