hfi_intf.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2019, 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. * @icp_base: icp base address
  32. */
  33. struct hfi_mem_info {
  34. struct hfi_mem qtbl;
  35. struct hfi_mem cmd_q;
  36. struct hfi_mem msg_q;
  37. struct hfi_mem dbg_q;
  38. struct hfi_mem sfr_buf;
  39. struct hfi_mem sec_heap;
  40. struct hfi_mem shmem;
  41. struct hfi_mem qdss;
  42. struct hfi_mem io_mem;
  43. void __iomem *icp_base;
  44. };
  45. /**
  46. * hfi_write_cmd() - function for hfi write
  47. * @cmd_ptr: pointer to command data for hfi write
  48. *
  49. * Returns success(zero)/failure(non zero)
  50. */
  51. int hfi_write_cmd(void *cmd_ptr);
  52. /**
  53. * hfi_read_message() - function for hfi read
  54. * @pmsg: buffer to place read message for hfi queue
  55. * @q_id: queue id
  56. * @words_read: total number of words read from the queue
  57. * returned as output to the caller
  58. *
  59. * Returns success(zero)/failure(non zero)
  60. */
  61. int hfi_read_message(uint32_t *pmsg, uint8_t q_id, uint32_t *words_read);
  62. /**
  63. * hfi_init() - function initialize hfi after firmware download
  64. * @event_driven_mode: event mode
  65. * @hfi_mem: hfi memory info
  66. * @icp_base: icp base address
  67. * @debug: debug flag
  68. *
  69. * Returns success(zero)/failure(non zero)
  70. */
  71. int cam_hfi_init(uint8_t event_driven_mode, struct hfi_mem_info *hfi_mem,
  72. void *__iomem icp_base, bool debug);
  73. /**
  74. * hfi_get_hw_caps() - hardware capabilities from firmware
  75. * @query_caps: holds query information from hfi
  76. *
  77. * Returns success(zero)/failure(non zero)
  78. */
  79. int hfi_get_hw_caps(void *query_caps);
  80. /**
  81. * hfi_send_system_cmd() - send hfi system command to firmware
  82. * @type: type of system command
  83. * @data: command data
  84. * @size: size of command data
  85. */
  86. void hfi_send_system_cmd(uint32_t type, uint64_t data, uint32_t size);
  87. /**
  88. * cam_hfi_enable_cpu() - enable A5 CPU
  89. * @icp_base: icp base address
  90. */
  91. void cam_hfi_enable_cpu(void __iomem *icp_base);
  92. /**
  93. * cam_hfi_disable_cpu() - disable A5 CPU
  94. * @icp_base: icp base address
  95. */
  96. void cam_hfi_disable_cpu(void __iomem *icp_base);
  97. /**
  98. * cam_hfi_deinit() - cleanup HFI
  99. */
  100. void cam_hfi_deinit(void __iomem *icp_base);
  101. /**
  102. * hfi_set_debug_level() - set debug level
  103. * @a5_dbg_type: 1 for debug_q & 2 for qdss
  104. * @lvl: FW debug message level
  105. */
  106. int hfi_set_debug_level(u64 a5_dbg_type, uint32_t lvl);
  107. /**
  108. * hfi_set_fw_dump_level() - set firmware dump level
  109. * @lvl: level of firmware dump level
  110. */
  111. int hfi_set_fw_dump_level(uint32_t lvl);
  112. /**
  113. * hfi_enable_ipe_bps_pc() - Enable interframe pc
  114. * Host sends a command to firmware to enable interframe
  115. * power collapse for IPE and BPS hardware.
  116. *
  117. * @enable: flag to enable/disable
  118. * @core_info: Core information to firmware
  119. */
  120. int hfi_enable_ipe_bps_pc(bool enable, uint32_t core_info);
  121. /**
  122. * hfi_cmd_ubwc_config_ext() - UBWC configuration to firmware
  123. * @ubwc_ipe_cfg: UBWC ipe fetch/write configuration params
  124. * @ubwc_bps_cfg: UBWC bps fetch/write configuration params
  125. */
  126. int hfi_cmd_ubwc_config_ext(uint32_t *ubwc_ipe_cfg,
  127. uint32_t *ubwc_bps_cfg);
  128. /**
  129. * hfi_cmd_ubwc_config() - UBWC configuration to firmware
  130. * for older targets
  131. * @ubwc_cfg: UBWC configuration parameters
  132. */
  133. int hfi_cmd_ubwc_config(uint32_t *ubwc_cfg);
  134. /**
  135. * cam_hfi_resume() - function to resume
  136. * @hfi_mem: hfi memory info
  137. * @icp_base: icp base address
  138. * @debug: debug flag
  139. *
  140. * Returns success(zero)/failure(non zero)
  141. */
  142. int cam_hfi_resume(struct hfi_mem_info *hfi_mem,
  143. void __iomem *icp_base, bool debug);
  144. /**
  145. * cam_hfi_queue_dump() - utility function to dump hfi queues
  146. */
  147. void cam_hfi_queue_dump(void);
  148. #endif /* _HFI_INTF_H_ */