iwl-context-info-gen3.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /******************************************************************************
  2. *
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * GPL LICENSE SUMMARY
  7. *
  8. * Copyright(c) 2018 Intel Corporation
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of version 2 of the GNU General Public License as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * BSD LICENSE
  20. *
  21. * Copyright(c) 2018 Intel Corporation
  22. * All rights reserved.
  23. *
  24. * Redistribution and use in source and binary forms, with or without
  25. * modification, are permitted provided that the following conditions
  26. * are met:
  27. *
  28. * * Redistributions of source code must retain the above copyright
  29. * notice, this list of conditions and the following disclaimer.
  30. * * Redistributions in binary form must reproduce the above copyright
  31. * notice, this list of conditions and the following disclaimer in
  32. * the documentation and/or other materials provided with the
  33. * distribution.
  34. * * Neither the name Intel Corporation nor the names of its
  35. * contributors may be used to endorse or promote products derived
  36. * from this software without specific prior written permission.
  37. *
  38. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  39. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  40. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  41. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  42. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  43. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  44. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  45. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  46. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  47. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  48. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  49. *
  50. *****************************************************************************/
  51. #ifndef __iwl_context_info_file_gen3_h__
  52. #define __iwl_context_info_file_gen3_h__
  53. #include "iwl-context-info.h"
  54. #define CSR_CTXT_INFO_BOOT_CTRL 0x0
  55. #define CSR_CTXT_INFO_ADDR 0x118
  56. #define CSR_IML_DATA_ADDR 0x120
  57. #define CSR_IML_SIZE_ADDR 0x128
  58. #define CSR_IML_RESP_ADDR 0x12c
  59. /* Set bit for enabling automatic function boot */
  60. #define CSR_AUTO_FUNC_BOOT_ENA BIT(1)
  61. /* Set bit for initiating function boot */
  62. #define CSR_AUTO_FUNC_INIT BIT(7)
  63. /**
  64. * enum iwl_prph_scratch_mtr_format - tfd size configuration
  65. * @IWL_PRPH_MTR_FORMAT_16B: 16 bit tfd
  66. * @IWL_PRPH_MTR_FORMAT_32B: 32 bit tfd
  67. * @IWL_PRPH_MTR_FORMAT_64B: 64 bit tfd
  68. * @IWL_PRPH_MTR_FORMAT_256B: 256 bit tfd
  69. */
  70. enum iwl_prph_scratch_mtr_format {
  71. IWL_PRPH_MTR_FORMAT_16B = 0x0,
  72. IWL_PRPH_MTR_FORMAT_32B = 0x40000,
  73. IWL_PRPH_MTR_FORMAT_64B = 0x80000,
  74. IWL_PRPH_MTR_FORMAT_256B = 0xC0000,
  75. };
  76. /**
  77. * enum iwl_prph_scratch_flags - PRPH scratch control flags
  78. * @IWL_PRPH_SCRATCH_EARLY_DEBUG_EN: enable early debug conf
  79. * @IWL_PRPH_SCRATCH_EDBG_DEST_DRAM: use DRAM, with size allocated
  80. * in hwm config.
  81. * @IWL_PRPH_SCRATCH_EDBG_DEST_INTERNAL: use buffer on SRAM
  82. * @IWL_PRPH_SCRATCH_EDBG_DEST_ST_ARBITER: use st arbiter, mainly for
  83. * multicomm.
  84. * @IWL_PRPH_SCRATCH_EDBG_DEST_TB22DTF: route debug data to SoC HW
  85. * @IWL_PRPH_SCTATCH_RB_SIZE_4K: Use 4K RB size (the default is 2K)
  86. * @IWL_PRPH_SCRATCH_MTR_MODE: format used for completion - 0: for
  87. * completion descriptor, 1 for responses (legacy)
  88. * @IWL_PRPH_SCRATCH_MTR_FORMAT: a mask for the size of the tfd.
  89. * There are 4 optional values: 0: 16 bit, 1: 32 bit, 2: 64 bit,
  90. * 3: 256 bit.
  91. */
  92. enum iwl_prph_scratch_flags {
  93. IWL_PRPH_SCRATCH_EARLY_DEBUG_EN = BIT(4),
  94. IWL_PRPH_SCRATCH_EDBG_DEST_DRAM = BIT(8),
  95. IWL_PRPH_SCRATCH_EDBG_DEST_INTERNAL = BIT(9),
  96. IWL_PRPH_SCRATCH_EDBG_DEST_ST_ARBITER = BIT(10),
  97. IWL_PRPH_SCRATCH_EDBG_DEST_TB22DTF = BIT(11),
  98. IWL_PRPH_SCRATCH_RB_SIZE_4K = BIT(16),
  99. IWL_PRPH_SCRATCH_MTR_MODE = BIT(17),
  100. IWL_PRPH_SCRATCH_MTR_FORMAT = BIT(18) | BIT(19),
  101. };
  102. /*
  103. * struct iwl_prph_scratch_version - version structure
  104. * @mac_id: SKU and revision id
  105. * @version: prph scratch information version id
  106. * @size: the size of the context information in DWs
  107. * @reserved: reserved
  108. */
  109. struct iwl_prph_scratch_version {
  110. __le16 mac_id;
  111. __le16 version;
  112. __le16 size;
  113. __le16 reserved;
  114. } __packed; /* PERIPH_SCRATCH_VERSION_S */
  115. /*
  116. * struct iwl_prph_scratch_control - control structure
  117. * @control_flags: context information flags see &enum iwl_prph_scratch_flags
  118. * @reserved: reserved
  119. */
  120. struct iwl_prph_scratch_control {
  121. __le32 control_flags;
  122. __le32 reserved;
  123. } __packed; /* PERIPH_SCRATCH_CONTROL_S */
  124. /*
  125. * struct iwl_prph_scratch_ror_cfg - ror config
  126. * @ror_base_addr: ror start address
  127. * @ror_size: ror size in DWs
  128. * @reserved: reserved
  129. */
  130. struct iwl_prph_scratch_ror_cfg {
  131. __le64 ror_base_addr;
  132. __le32 ror_size;
  133. __le32 reserved;
  134. } __packed; /* PERIPH_SCRATCH_ROR_CFG_S */
  135. /*
  136. * struct iwl_prph_scratch_hwm_cfg - hwm config
  137. * @hwm_base_addr: hwm start address
  138. * @hwm_size: hwm size in DWs
  139. * @reserved: reserved
  140. */
  141. struct iwl_prph_scratch_hwm_cfg {
  142. __le64 hwm_base_addr;
  143. __le32 hwm_size;
  144. __le32 reserved;
  145. } __packed; /* PERIPH_SCRATCH_HWM_CFG_S */
  146. /*
  147. * struct iwl_prph_scratch_rbd_cfg - RBDs configuration
  148. * @free_rbd_addr: default queue free RB CB base address
  149. * @reserved: reserved
  150. */
  151. struct iwl_prph_scratch_rbd_cfg {
  152. __le64 free_rbd_addr;
  153. __le32 reserved;
  154. } __packed; /* PERIPH_SCRATCH_RBD_CFG_S */
  155. /*
  156. * struct iwl_prph_scratch_ctrl_cfg - prph scratch ctrl and config
  157. * @version: version information of context info and HW
  158. * @control: control flags of FH configurations
  159. * @ror_cfg: ror configuration
  160. * @hwm_cfg: hwm configuration
  161. * @rbd_cfg: default RX queue configuration
  162. */
  163. struct iwl_prph_scratch_ctrl_cfg {
  164. struct iwl_prph_scratch_version version;
  165. struct iwl_prph_scratch_control control;
  166. struct iwl_prph_scratch_ror_cfg ror_cfg;
  167. struct iwl_prph_scratch_hwm_cfg hwm_cfg;
  168. struct iwl_prph_scratch_rbd_cfg rbd_cfg;
  169. } __packed; /* PERIPH_SCRATCH_CTRL_CFG_S */
  170. /*
  171. * struct iwl_prph_scratch - peripheral scratch mapping
  172. * @ctrl_cfg: control and configuration of prph scratch
  173. * @dram: firmware images addresses in DRAM
  174. * @reserved: reserved
  175. */
  176. struct iwl_prph_scratch {
  177. struct iwl_prph_scratch_ctrl_cfg ctrl_cfg;
  178. __le32 reserved[16];
  179. struct iwl_context_info_dram dram;
  180. } __packed; /* PERIPH_SCRATCH_S */
  181. /*
  182. * struct iwl_prph_info - peripheral information
  183. * @boot_stage_mirror: reflects the value in the Boot Stage CSR register
  184. * @ipc_status_mirror: reflects the value in the IPC Status CSR register
  185. * @sleep_notif: indicates the peripheral sleep status
  186. * @reserved: reserved
  187. */
  188. struct iwl_prph_info {
  189. __le32 boot_stage_mirror;
  190. __le32 ipc_status_mirror;
  191. __le32 sleep_notif;
  192. __le32 reserved;
  193. } __packed; /* PERIPH_INFO_S */
  194. /*
  195. * struct iwl_context_info_gen3 - device INIT configuration
  196. * @version: version of the context information
  197. * @size: size of context information in DWs
  198. * @config: context in which the peripheral would execute - a subset of
  199. * capability csr register published by the peripheral
  200. * @prph_info_base_addr: the peripheral information structure start address
  201. * @cr_head_idx_arr_base_addr: the completion ring head index array
  202. * start address
  203. * @tr_tail_idx_arr_base_addr: the transfer ring tail index array
  204. * start address
  205. * @cr_tail_idx_arr_base_addr: the completion ring tail index array
  206. * start address
  207. * @tr_head_idx_arr_base_addr: the transfer ring head index array
  208. * start address
  209. * @cr_idx_arr_size: number of entries in the completion ring index array
  210. * @tr_idx_arr_size: number of entries in the transfer ring index array
  211. * @mtr_base_addr: the message transfer ring start address
  212. * @mcr_base_addr: the message completion ring start address
  213. * @mtr_size: number of entries which the message transfer ring can hold
  214. * @mcr_size: number of entries which the message completion ring can hold
  215. * @mtr_doorbell_vec: the doorbell vector associated with the message
  216. * transfer ring
  217. * @mcr_doorbell_vec: the doorbell vector associated with the message
  218. * completion ring
  219. * @mtr_msi_vec: the MSI which shall be generated by the peripheral after
  220. * completing a transfer descriptor in the message transfer ring
  221. * @mcr_msi_vec: the MSI which shall be generated by the peripheral after
  222. * completing a completion descriptor in the message completion ring
  223. * @mtr_opt_header_size: the size of the optional header in the transfer
  224. * descriptor associated with the message transfer ring in DWs
  225. * @mtr_opt_footer_size: the size of the optional footer in the transfer
  226. * descriptor associated with the message transfer ring in DWs
  227. * @mcr_opt_header_size: the size of the optional header in the completion
  228. * descriptor associated with the message completion ring in DWs
  229. * @mcr_opt_footer_size: the size of the optional footer in the completion
  230. * descriptor associated with the message completion ring in DWs
  231. * @msg_rings_ctrl_flags: message rings control flags
  232. * @prph_info_msi_vec: the MSI which shall be generated by the peripheral
  233. * after updating the Peripheral Information structure
  234. * @prph_scratch_base_addr: the peripheral scratch structure start address
  235. * @prph_scratch_size: the size of the peripheral scratch structure in DWs
  236. * @reserved: reserved
  237. */
  238. struct iwl_context_info_gen3 {
  239. __le16 version;
  240. __le16 size;
  241. __le32 config;
  242. __le64 prph_info_base_addr;
  243. __le64 cr_head_idx_arr_base_addr;
  244. __le64 tr_tail_idx_arr_base_addr;
  245. __le64 cr_tail_idx_arr_base_addr;
  246. __le64 tr_head_idx_arr_base_addr;
  247. __le16 cr_idx_arr_size;
  248. __le16 tr_idx_arr_size;
  249. __le64 mtr_base_addr;
  250. __le64 mcr_base_addr;
  251. __le16 mtr_size;
  252. __le16 mcr_size;
  253. __le16 mtr_doorbell_vec;
  254. __le16 mcr_doorbell_vec;
  255. __le16 mtr_msi_vec;
  256. __le16 mcr_msi_vec;
  257. u8 mtr_opt_header_size;
  258. u8 mtr_opt_footer_size;
  259. u8 mcr_opt_header_size;
  260. u8 mcr_opt_footer_size;
  261. __le16 msg_rings_ctrl_flags;
  262. __le16 prph_info_msi_vec;
  263. __le64 prph_scratch_base_addr;
  264. __le32 prph_scratch_size;
  265. __le32 reserved;
  266. } __packed; /* IPC_CONTEXT_INFO_S */
  267. int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans,
  268. const struct fw_img *fw);
  269. void iwl_pcie_ctxt_info_gen3_free(struct iwl_trans *trans);
  270. #endif /* __iwl_context_info_file_gen3_h__ */