hfi_intf.h 4.2 KB

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