hfi_intf.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. *
  70. * Returns success(zero)/failure(non zero)
  71. */
  72. int cam_hfi_init(uint8_t event_driven_mode, struct hfi_mem_info *hfi_mem,
  73. void *__iomem icp_base);
  74. /**
  75. * hfi_get_hw_caps() - hardware capabilities from firmware
  76. * @query_caps: holds query information from hfi
  77. *
  78. * Returns success(zero)/failure(non zero)
  79. */
  80. int hfi_get_hw_caps(void *query_caps);
  81. /**
  82. * hfi_send_system_cmd() - send hfi system command to firmware
  83. * @type: type of system command
  84. * @data: command data
  85. * @size: size of command data
  86. */
  87. void hfi_send_system_cmd(uint32_t type, uint64_t data, uint32_t size);
  88. /**
  89. * cam_hfi_deinit() - cleanup HFI
  90. */
  91. void cam_hfi_deinit(void __iomem *icp_base);
  92. /**
  93. * hfi_set_debug_level() - set debug level
  94. * @a5_dbg_type: 1 for debug_q & 2 for qdss
  95. * @lvl: FW debug message level
  96. */
  97. int hfi_set_debug_level(u64 a5_dbg_type, uint32_t lvl);
  98. /**
  99. * hfi_set_fw_dump_level() - set firmware dump level
  100. * @lvl: level of firmware dump level
  101. */
  102. int hfi_set_fw_dump_level(uint32_t lvl);
  103. /**
  104. * hfi_enable_ipe_bps_pc() - Enable interframe pc
  105. * Host sends a command to firmware to enable interframe
  106. * power collapse for IPE and BPS hardware.
  107. *
  108. * @enable: flag to enable/disable
  109. * @core_info: Core information to firmware
  110. */
  111. int hfi_enable_ipe_bps_pc(bool enable, uint32_t core_info);
  112. /**
  113. * hfi_cmd_ubwc_config_ext() - UBWC configuration to firmware
  114. * @ubwc_ipe_cfg: UBWC ipe fetch/write configuration params
  115. * @ubwc_bps_cfg: UBWC bps fetch/write configuration params
  116. */
  117. int hfi_cmd_ubwc_config_ext(uint32_t *ubwc_ipe_cfg,
  118. uint32_t *ubwc_bps_cfg);
  119. /**
  120. * hfi_cmd_ubwc_config() - UBWC configuration to firmware
  121. * for older targets
  122. * @ubwc_cfg: UBWC configuration parameters
  123. */
  124. int hfi_cmd_ubwc_config(uint32_t *ubwc_cfg);
  125. /**
  126. * cam_hfi_resume() - function to resume
  127. * @hfi_mem: hfi memory info
  128. * @icp_base: icp base address
  129. *
  130. * Returns success(zero)/failure(non zero)
  131. */
  132. int cam_hfi_resume(struct hfi_mem_info *hfi_mem, void __iomem *icp_base);
  133. /**
  134. * cam_hfi_queue_dump() - utility function to dump hfi queues
  135. */
  136. void cam_hfi_queue_dump(void);
  137. #endif /* _HFI_INTF_H_ */