adreno_a6xx_hfi.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __ADRENO_A6XX_HFI_H
  7. #define __ADRENO_A6XX_HFI_H
  8. #include "adreno_hfi.h"
  9. /**
  10. * struct a6xx_hfi - HFI control structure
  11. * @seqnum: atomic counter that is incremented for each message sent. The
  12. * value of the counter is used as sequence number for HFI message
  13. * @bw_table: HFI BW table buffer
  14. * @acd_table: HFI table for ACD data
  15. */
  16. struct a6xx_hfi {
  17. /** @irq: HFI interrupt line */
  18. int irq;
  19. atomic_t seqnum;
  20. /** @hfi_mem: Memory descriptor for the hfi memory */
  21. struct kgsl_memdesc *hfi_mem;
  22. struct hfi_bwtable_cmd bw_table;
  23. struct hfi_acd_table_cmd acd_table;
  24. /** @dcvs_table: HFI table for gpu dcvs levels */
  25. struct hfi_dcvstable_cmd dcvs_table;
  26. };
  27. struct a6xx_gmu_device;
  28. /* a6xx_hfi_irq_handler - IRQ handler for HFI interripts */
  29. irqreturn_t a6xx_hfi_irq_handler(int irq, void *data);
  30. /**
  31. * a6xx_hfi_start - Send the various HFIs during device boot up
  32. * @adreno_dev: Pointer to the adreno device
  33. *
  34. * Return: 0 on success or negative error on failure
  35. */
  36. int a6xx_hfi_start(struct adreno_device *adreno_dev);
  37. /**
  38. * a6xx_hfi_start - Send the various HFIs during device boot up
  39. * @adreno_dev: Pointer to the adreno device
  40. *
  41. * Return: 0 on success or negative error on failure
  42. */
  43. void a6xx_hfi_stop(struct adreno_device *adreno_dev);
  44. /**
  45. * a6xx_hfi_init - Initialize hfi resources
  46. * @adreno_dev: Pointer to the adreno device
  47. *
  48. * This function allocates and sets up hfi queues
  49. * when a process creates the very first kgsl instance
  50. *
  51. * Return: 0 on success or negative error on failure
  52. */
  53. int a6xx_hfi_init(struct adreno_device *adreno_dev);
  54. /* Helper function to get to a6xx hfi struct from adreno device */
  55. struct a6xx_hfi *to_a6xx_hfi(struct adreno_device *adreno_dev);
  56. /**
  57. * a6xx_hfi_queue_write - Write a command to hfi queue
  58. * @adreno_dev: Pointer to the adreno device
  59. * @queue_idx: destination queue id
  60. * @msg: Data to be written to the queue
  61. * @size_bytes: Size of the command in bytes
  62. *
  63. * Return: 0 on success or negative error on failure
  64. */
  65. int a6xx_hfi_queue_write(struct adreno_device *adreno_dev, u32 queue_idx,
  66. u32 *msg, u32 size_bytes);
  67. /**
  68. * a6xx_hfi_queue_read - Read data from hfi queue
  69. * @gmu: Pointer to the a6xx gmu device
  70. * @queue_idx: queue id to read from
  71. * @output: Pointer to read the data into
  72. * @max_size: Number of bytes to read from the queue
  73. *
  74. * Return: 0 on success or negative error on failure
  75. */
  76. int a6xx_hfi_queue_read(struct a6xx_gmu_device *gmu, u32 queue_idx,
  77. u32 *output, u32 max_size);
  78. /**
  79. * a6xx_receive_ack_cmd - Process ack type packets
  80. * @gmu: Pointer to the a6xx gmu device
  81. * @rcvd: Pointer to the data read from hfi queue
  82. * @ret_cmd: Container for the hfi packet for which this ack is received
  83. *
  84. * Return: 0 on success or negative error on failure
  85. */
  86. int a6xx_receive_ack_cmd(struct a6xx_gmu_device *gmu, void *rcvd,
  87. struct pending_cmd *ret_cmd);
  88. /**
  89. * a6xx_hfi_send_feature_ctrl - Enable gmu feature via hfi
  90. * @adreno_dev: Pointer to the adreno device
  91. * @feature: feature to be enabled or disabled
  92. * enable: Set 1 to enable or 0 to disable a feature
  93. * @data: payload for the send feature hfi packet
  94. *
  95. * Return: 0 on success or negative error on failure
  96. */
  97. int a6xx_hfi_send_feature_ctrl(struct adreno_device *adreno_dev,
  98. u32 feature, u32 enable, u32 data);
  99. /**
  100. * a6xx_hfi_send_set_value - Send gmu set_values via hfi
  101. * @adreno_dev: Pointer to the adreno device
  102. * @type: GMU set_value type
  103. * @subtype: GMU set_value subtype
  104. * @data: Value to set
  105. *
  106. * Return: 0 on success or negative error on failure
  107. */
  108. int a6xx_hfi_send_set_value(struct adreno_device *adreno_dev,
  109. u32 type, u32 subtype, u32 data);
  110. /**
  111. * a6xx_hfi_send_core_fw_start - Send the core fw start hfi
  112. * @adreno_dev: Pointer to the adreno device
  113. *
  114. * Return: 0 on success or negative error on failure
  115. */
  116. int a6xx_hfi_send_core_fw_start(struct adreno_device *adreno_dev);
  117. /**
  118. * a6xx_hfi_send_acd_feature_ctrl - Send the acd table and acd feature
  119. * @adreno_dev: Pointer to the adreno device
  120. *
  121. * Return: 0 on success or negative error on failure
  122. */
  123. int a6xx_hfi_send_acd_feature_ctrl(struct adreno_device *adreno_dev);
  124. /**
  125. * a6xx_hfi_send_lm_feature_ctrl - Send the lm feature hfi packet
  126. * @adreno_dev: Pointer to the adreno device
  127. *
  128. * Return: 0 on success or negative error on failure
  129. */
  130. int a6xx_hfi_send_lm_feature_ctrl(struct adreno_device *adreno_dev);
  131. /**
  132. * a6xx_hfi_send_generic_req - Send a generic hfi packet
  133. * @adreno_dev: Pointer to the adreno device
  134. * @cmd: Pointer to the hfi packet header and data
  135. * @size_bytes: Size of the command in bytes
  136. *
  137. * Return: 0 on success or negative error on failure
  138. */
  139. int a6xx_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes);
  140. /**
  141. * a6xx_hfi_send_bcl_feature_ctrl - Send the bcl feature hfi packet
  142. * @adreno_dev: Pointer to the adreno device
  143. *
  144. * Return: 0 on success or negative error on failure
  145. */
  146. int a6xx_hfi_send_bcl_feature_ctrl(struct adreno_device *adreno_dev);
  147. /*
  148. * a6xx_hfi_process_queue - Check hfi queue for messages from gmu
  149. * @gmu: Pointer to the a6xx gmu device
  150. * @queue_idx: queue id to be processed
  151. * @ret_cmd: Container for data needed for waiting for the ack
  152. *
  153. * Return: 0 on success or negative error on failure
  154. */
  155. int a6xx_hfi_process_queue(struct a6xx_gmu_device *gmu,
  156. u32 queue_idx, struct pending_cmd *ret_cmd);
  157. /**
  158. * a6xx_hfi_cmdq_write - Write a command to command queue
  159. * @adreno_dev: Pointer to the adreno device
  160. * @msg: Data to be written to the queue
  161. * @size_bytes: Size of the command in bytes
  162. *
  163. * Return: 0 on success or negative error on failure
  164. */
  165. int a6xx_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes);
  166. void adreno_a6xx_receive_err_req(struct a6xx_gmu_device *gmu, void *rcvd);
  167. void adreno_a6xx_receive_debug_req(struct a6xx_gmu_device *gmu, void *rcvd);
  168. #endif