iwl-context-info-gen3.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /*
  3. * Copyright (C) 2018, 2020-2022 Intel Corporation
  4. */
  5. #ifndef __iwl_context_info_file_gen3_h__
  6. #define __iwl_context_info_file_gen3_h__
  7. #include "iwl-context-info.h"
  8. #define CSR_CTXT_INFO_BOOT_CTRL 0x0
  9. #define CSR_CTXT_INFO_ADDR 0x118
  10. #define CSR_IML_DATA_ADDR 0x120
  11. #define CSR_IML_SIZE_ADDR 0x128
  12. #define CSR_IML_RESP_ADDR 0x12c
  13. /* Set bit for enabling automatic function boot */
  14. #define CSR_AUTO_FUNC_BOOT_ENA BIT(1)
  15. /* Set bit for initiating function boot */
  16. #define CSR_AUTO_FUNC_INIT BIT(7)
  17. /**
  18. * enum iwl_prph_scratch_mtr_format - tfd size configuration
  19. * @IWL_PRPH_MTR_FORMAT_16B: 16 bit tfd
  20. * @IWL_PRPH_MTR_FORMAT_32B: 32 bit tfd
  21. * @IWL_PRPH_MTR_FORMAT_64B: 64 bit tfd
  22. * @IWL_PRPH_MTR_FORMAT_256B: 256 bit tfd
  23. */
  24. enum iwl_prph_scratch_mtr_format {
  25. IWL_PRPH_MTR_FORMAT_16B = 0x0,
  26. IWL_PRPH_MTR_FORMAT_32B = 0x40000,
  27. IWL_PRPH_MTR_FORMAT_64B = 0x80000,
  28. IWL_PRPH_MTR_FORMAT_256B = 0xC0000,
  29. };
  30. /**
  31. * enum iwl_prph_scratch_flags - PRPH scratch control flags
  32. * @IWL_PRPH_SCRATCH_IMR_DEBUG_EN: IMR support for debug
  33. * @IWL_PRPH_SCRATCH_EARLY_DEBUG_EN: enable early debug conf
  34. * @IWL_PRPH_SCRATCH_EDBG_DEST_DRAM: use DRAM, with size allocated
  35. * in hwm config.
  36. * @IWL_PRPH_SCRATCH_EDBG_DEST_INTERNAL: use buffer on SRAM
  37. * @IWL_PRPH_SCRATCH_EDBG_DEST_ST_ARBITER: use st arbiter, mainly for
  38. * multicomm.
  39. * @IWL_PRPH_SCRATCH_EDBG_DEST_TB22DTF: route debug data to SoC HW
  40. * @IWL_PRPH_SCTATCH_RB_SIZE_4K: Use 4K RB size (the default is 2K)
  41. * @IWL_PRPH_SCRATCH_MTR_MODE: format used for completion - 0: for
  42. * completion descriptor, 1 for responses (legacy)
  43. * @IWL_PRPH_SCRATCH_MTR_FORMAT: a mask for the size of the tfd.
  44. * There are 4 optional values: 0: 16 bit, 1: 32 bit, 2: 64 bit,
  45. * 3: 256 bit.
  46. * @IWL_PRPH_SCRATCH_RB_SIZE_EXT_MASK: RB size full information, ignored
  47. * by older firmware versions, so set IWL_PRPH_SCRATCH_RB_SIZE_4K
  48. * appropriately; use the below values for this.
  49. * @IWL_PRPH_SCRATCH_RB_SIZE_EXT_8K: 8kB RB size
  50. * @IWL_PRPH_SCRATCH_RB_SIZE_EXT_12K: 12kB RB size
  51. * @IWL_PRPH_SCRATCH_RB_SIZE_EXT_16K: 16kB RB size
  52. */
  53. enum iwl_prph_scratch_flags {
  54. IWL_PRPH_SCRATCH_IMR_DEBUG_EN = BIT(1),
  55. IWL_PRPH_SCRATCH_EARLY_DEBUG_EN = BIT(4),
  56. IWL_PRPH_SCRATCH_EDBG_DEST_DRAM = BIT(8),
  57. IWL_PRPH_SCRATCH_EDBG_DEST_INTERNAL = BIT(9),
  58. IWL_PRPH_SCRATCH_EDBG_DEST_ST_ARBITER = BIT(10),
  59. IWL_PRPH_SCRATCH_EDBG_DEST_TB22DTF = BIT(11),
  60. IWL_PRPH_SCRATCH_RB_SIZE_4K = BIT(16),
  61. IWL_PRPH_SCRATCH_MTR_MODE = BIT(17),
  62. IWL_PRPH_SCRATCH_MTR_FORMAT = BIT(18) | BIT(19),
  63. IWL_PRPH_SCRATCH_RB_SIZE_EXT_MASK = 0xf << 20,
  64. IWL_PRPH_SCRATCH_RB_SIZE_EXT_8K = 8 << 20,
  65. IWL_PRPH_SCRATCH_RB_SIZE_EXT_12K = 9 << 20,
  66. IWL_PRPH_SCRATCH_RB_SIZE_EXT_16K = 10 << 20,
  67. };
  68. /*
  69. * struct iwl_prph_scratch_version - version structure
  70. * @mac_id: SKU and revision id
  71. * @version: prph scratch information version id
  72. * @size: the size of the context information in DWs
  73. * @reserved: reserved
  74. */
  75. struct iwl_prph_scratch_version {
  76. __le16 mac_id;
  77. __le16 version;
  78. __le16 size;
  79. __le16 reserved;
  80. } __packed; /* PERIPH_SCRATCH_VERSION_S */
  81. /*
  82. * struct iwl_prph_scratch_control - control structure
  83. * @control_flags: context information flags see &enum iwl_prph_scratch_flags
  84. * @reserved: reserved
  85. */
  86. struct iwl_prph_scratch_control {
  87. __le32 control_flags;
  88. __le32 reserved;
  89. } __packed; /* PERIPH_SCRATCH_CONTROL_S */
  90. /*
  91. * struct iwl_prph_scratch_pnvm_cfg - ror config
  92. * @pnvm_base_addr: PNVM start address
  93. * @pnvm_size: PNVM size in DWs
  94. * @reserved: reserved
  95. */
  96. struct iwl_prph_scratch_pnvm_cfg {
  97. __le64 pnvm_base_addr;
  98. __le32 pnvm_size;
  99. __le32 reserved;
  100. } __packed; /* PERIPH_SCRATCH_PNVM_CFG_S */
  101. /*
  102. * struct iwl_prph_scratch_hwm_cfg - hwm config
  103. * @hwm_base_addr: hwm start address
  104. * @hwm_size: hwm size in DWs
  105. * @debug_token_config: debug preset
  106. */
  107. struct iwl_prph_scratch_hwm_cfg {
  108. __le64 hwm_base_addr;
  109. __le32 hwm_size;
  110. __le32 debug_token_config;
  111. } __packed; /* PERIPH_SCRATCH_HWM_CFG_S */
  112. /*
  113. * struct iwl_prph_scratch_rbd_cfg - RBDs configuration
  114. * @free_rbd_addr: default queue free RB CB base address
  115. * @reserved: reserved
  116. */
  117. struct iwl_prph_scratch_rbd_cfg {
  118. __le64 free_rbd_addr;
  119. __le32 reserved;
  120. } __packed; /* PERIPH_SCRATCH_RBD_CFG_S */
  121. /*
  122. * struct iwl_prph_scratch_uefi_cfg - prph scratch reduce power table
  123. * @base_addr: reduce power table address
  124. * @size: table size in dwords
  125. */
  126. struct iwl_prph_scratch_uefi_cfg {
  127. __le64 base_addr;
  128. __le32 size;
  129. __le32 reserved;
  130. } __packed; /* PERIPH_SCRATCH_UEFI_CFG_S */
  131. /*
  132. * struct iwl_prph_scratch_ctrl_cfg - prph scratch ctrl and config
  133. * @version: version information of context info and HW
  134. * @control: control flags of FH configurations
  135. * @pnvm_cfg: ror configuration
  136. * @hwm_cfg: hwm configuration
  137. * @rbd_cfg: default RX queue configuration
  138. */
  139. struct iwl_prph_scratch_ctrl_cfg {
  140. struct iwl_prph_scratch_version version;
  141. struct iwl_prph_scratch_control control;
  142. struct iwl_prph_scratch_pnvm_cfg pnvm_cfg;
  143. struct iwl_prph_scratch_hwm_cfg hwm_cfg;
  144. struct iwl_prph_scratch_rbd_cfg rbd_cfg;
  145. struct iwl_prph_scratch_uefi_cfg reduce_power_cfg;
  146. } __packed; /* PERIPH_SCRATCH_CTRL_CFG_S */
  147. /*
  148. * struct iwl_prph_scratch - peripheral scratch mapping
  149. * @ctrl_cfg: control and configuration of prph scratch
  150. * @dram: firmware images addresses in DRAM
  151. * @reserved: reserved
  152. */
  153. struct iwl_prph_scratch {
  154. struct iwl_prph_scratch_ctrl_cfg ctrl_cfg;
  155. __le32 reserved[12];
  156. struct iwl_context_info_dram dram;
  157. } __packed; /* PERIPH_SCRATCH_S */
  158. /*
  159. * struct iwl_prph_info - peripheral information
  160. * @boot_stage_mirror: reflects the value in the Boot Stage CSR register
  161. * @ipc_status_mirror: reflects the value in the IPC Status CSR register
  162. * @sleep_notif: indicates the peripheral sleep status
  163. * @reserved: reserved
  164. */
  165. struct iwl_prph_info {
  166. __le32 boot_stage_mirror;
  167. __le32 ipc_status_mirror;
  168. __le32 sleep_notif;
  169. __le32 reserved;
  170. } __packed; /* PERIPH_INFO_S */
  171. /*
  172. * struct iwl_context_info_gen3 - device INIT configuration
  173. * @version: version of the context information
  174. * @size: size of context information in DWs
  175. * @config: context in which the peripheral would execute - a subset of
  176. * capability csr register published by the peripheral
  177. * @prph_info_base_addr: the peripheral information structure start address
  178. * @cr_head_idx_arr_base_addr: the completion ring head index array
  179. * start address
  180. * @tr_tail_idx_arr_base_addr: the transfer ring tail index array
  181. * start address
  182. * @cr_tail_idx_arr_base_addr: the completion ring tail index array
  183. * start address
  184. * @tr_head_idx_arr_base_addr: the transfer ring head index array
  185. * start address
  186. * @cr_idx_arr_size: number of entries in the completion ring index array
  187. * @tr_idx_arr_size: number of entries in the transfer ring index array
  188. * @mtr_base_addr: the message transfer ring start address
  189. * @mcr_base_addr: the message completion ring start address
  190. * @mtr_size: number of entries which the message transfer ring can hold
  191. * @mcr_size: number of entries which the message completion ring can hold
  192. * @mtr_doorbell_vec: the doorbell vector associated with the message
  193. * transfer ring
  194. * @mcr_doorbell_vec: the doorbell vector associated with the message
  195. * completion ring
  196. * @mtr_msi_vec: the MSI which shall be generated by the peripheral after
  197. * completing a transfer descriptor in the message transfer ring
  198. * @mcr_msi_vec: the MSI which shall be generated by the peripheral after
  199. * completing a completion descriptor in the message completion ring
  200. * @mtr_opt_header_size: the size of the optional header in the transfer
  201. * descriptor associated with the message transfer ring in DWs
  202. * @mtr_opt_footer_size: the size of the optional footer in the transfer
  203. * descriptor associated with the message transfer ring in DWs
  204. * @mcr_opt_header_size: the size of the optional header in the completion
  205. * descriptor associated with the message completion ring in DWs
  206. * @mcr_opt_footer_size: the size of the optional footer in the completion
  207. * descriptor associated with the message completion ring in DWs
  208. * @msg_rings_ctrl_flags: message rings control flags
  209. * @prph_info_msi_vec: the MSI which shall be generated by the peripheral
  210. * after updating the Peripheral Information structure
  211. * @prph_scratch_base_addr: the peripheral scratch structure start address
  212. * @prph_scratch_size: the size of the peripheral scratch structure in DWs
  213. * @reserved: reserved
  214. */
  215. struct iwl_context_info_gen3 {
  216. __le16 version;
  217. __le16 size;
  218. __le32 config;
  219. __le64 prph_info_base_addr;
  220. __le64 cr_head_idx_arr_base_addr;
  221. __le64 tr_tail_idx_arr_base_addr;
  222. __le64 cr_tail_idx_arr_base_addr;
  223. __le64 tr_head_idx_arr_base_addr;
  224. __le16 cr_idx_arr_size;
  225. __le16 tr_idx_arr_size;
  226. __le64 mtr_base_addr;
  227. __le64 mcr_base_addr;
  228. __le16 mtr_size;
  229. __le16 mcr_size;
  230. __le16 mtr_doorbell_vec;
  231. __le16 mcr_doorbell_vec;
  232. __le16 mtr_msi_vec;
  233. __le16 mcr_msi_vec;
  234. u8 mtr_opt_header_size;
  235. u8 mtr_opt_footer_size;
  236. u8 mcr_opt_header_size;
  237. u8 mcr_opt_footer_size;
  238. __le16 msg_rings_ctrl_flags;
  239. __le16 prph_info_msi_vec;
  240. __le64 prph_scratch_base_addr;
  241. __le32 prph_scratch_size;
  242. __le32 reserved;
  243. } __packed; /* IPC_CONTEXT_INFO_S */
  244. int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans,
  245. const struct fw_img *fw);
  246. void iwl_pcie_ctxt_info_gen3_free(struct iwl_trans *trans, bool alive);
  247. int iwl_trans_pcie_ctx_info_gen3_set_pnvm(struct iwl_trans *trans,
  248. const void *data, u32 len);
  249. int iwl_trans_pcie_ctx_info_gen3_set_reduce_power(struct iwl_trans *trans,
  250. const void *data, u32 len);
  251. #endif /* __iwl_context_info_file_gen3_h__ */