hfi_intf.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, 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. * @fw_uncached: FW uncached region info
  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. struct hfi_mem fw_uncached;
  46. };
  47. /**
  48. * struct hfi_ops
  49. * @irq_raise: called to raise H2ICP interrupt
  50. * @irq_enable: called to enable interrupts from ICP
  51. * @iface_addr: called to get interface registers base address
  52. */
  53. struct hfi_ops {
  54. void (*irq_raise)(void *data);
  55. void (*irq_enable)(void *data);
  56. void __iomem *(*iface_addr)(void *data);
  57. };
  58. /**
  59. * hfi_write_cmd() - function for hfi write
  60. * @cmd_ptr: pointer to command data for hfi write
  61. *
  62. * Returns success(zero)/failure(non zero)
  63. */
  64. int hfi_write_cmd(void *cmd_ptr);
  65. /**
  66. * hfi_read_message() - function for hfi read
  67. * @pmsg: buffer to place read message for hfi queue
  68. * @q_id: queue id
  69. * @words_read: total number of words read from the queue
  70. * returned as output to the caller
  71. *
  72. * Returns success(zero)/failure(non zero)
  73. */
  74. int hfi_read_message(uint32_t *pmsg, uint8_t q_id, uint32_t *words_read);
  75. /**
  76. * hfi_init() - function initialize hfi after firmware download
  77. * @hfi_mem: hfi memory info
  78. * @hfi_ops: processor-specific hfi ops
  79. * @priv: device private data
  80. * @event_driven_mode: event mode
  81. *
  82. * Returns success(zero)/failure(non zero)
  83. */
  84. int cam_hfi_init(struct hfi_mem_info *hfi_mem, const struct hfi_ops *hfi_ops,
  85. void *priv, uint8_t event_driven_mode);
  86. /**
  87. * hfi_get_hw_caps() - hardware capabilities from firmware
  88. * @query_caps: holds query information from hfi
  89. *
  90. * Returns success(zero)/failure(non zero)
  91. */
  92. int hfi_get_hw_caps(void *query_caps);
  93. /**
  94. * hfi_send_system_cmd() - send hfi system command to firmware
  95. * @type: type of system command
  96. * @data: command data
  97. * @size: size of command data
  98. */
  99. void hfi_send_system_cmd(uint32_t type, uint64_t data, uint32_t size);
  100. /**
  101. * cam_hfi_deinit() - cleanup HFI
  102. */
  103. void cam_hfi_deinit(void);
  104. /**
  105. * hfi_set_debug_level() - set debug level
  106. * @icp_dbg_type: 1 for debug_q & 2 for qdss
  107. * @lvl: FW debug message level
  108. */
  109. int hfi_set_debug_level(u64 icp_dbg_type, uint32_t lvl);
  110. /**
  111. * hfi_set_fw_dump_level() - set firmware dump level
  112. * @lvl: level of firmware dump level
  113. */
  114. int hfi_set_fw_dump_level(uint32_t lvl);
  115. /**
  116. * hfi_enable_ipe_bps_pc() - Enable interframe pc
  117. * Host sends a command to firmware to enable interframe
  118. * power collapse for IPE and BPS hardware.
  119. *
  120. * @enable: flag to enable/disable
  121. * @core_info: Core information to firmware
  122. */
  123. int hfi_enable_ipe_bps_pc(bool enable, uint32_t core_info);
  124. /**
  125. * hfi_cmd_ubwc_config_ext() - UBWC configuration to firmware
  126. * @ubwc_ipe_cfg: UBWC ipe fetch/write configuration params
  127. * @ubwc_bps_cfg: UBWC bps fetch/write configuration params
  128. */
  129. int hfi_cmd_ubwc_config_ext(uint32_t *ubwc_ipe_cfg,
  130. uint32_t *ubwc_bps_cfg);
  131. /**
  132. * hfi_cmd_ubwc_config() - UBWC configuration to firmware
  133. * for older targets
  134. * @ubwc_cfg: UBWC configuration parameters
  135. */
  136. int hfi_cmd_ubwc_config(uint32_t *ubwc_cfg);
  137. /**
  138. * cam_hfi_resume() - function to resume
  139. * @hfi_mem: hfi memory info
  140. *
  141. * Returns success(zero)/failure(non zero)
  142. */
  143. int cam_hfi_resume(struct hfi_mem_info *hfi_mem);
  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_ */