hfi_intf.h 4.3 KB

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