fw.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* SPDX-License-Identifier: ISC */
  2. /*
  3. * Copyright (c) 2014,2016 Qualcomm Atheros, Inc.
  4. * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef __WIL_FW_H__
  7. #define __WIL_FW_H__
  8. #define WIL_FW_SIGNATURE (0x36323130) /* '0126' */
  9. #define WIL_FW_FMT_VERSION (1) /* format version driver supports */
  10. enum wil_fw_record_type {
  11. wil_fw_type_comment = 1,
  12. wil_fw_type_data = 2,
  13. wil_fw_type_fill = 3,
  14. wil_fw_type_action = 4,
  15. wil_fw_type_verify = 5,
  16. wil_fw_type_file_header = 6,
  17. wil_fw_type_direct_write = 7,
  18. wil_fw_type_gateway_data = 8,
  19. wil_fw_type_gateway_data4 = 9,
  20. };
  21. struct wil_fw_record_head {
  22. __le16 type; /* enum wil_fw_record_type */
  23. __le16 flags; /* to be defined */
  24. __le32 size; /* whole record, bytes after head */
  25. } __packed;
  26. /* data block. write starting from @addr
  27. * data_size inferred from the @head.size. For this case,
  28. * data_size = @head.size - offsetof(struct wil_fw_record_data, data)
  29. */
  30. struct wil_fw_record_data { /* type == wil_fw_type_data */
  31. __le32 addr;
  32. __le32 data[]; /* [data_size], see above */
  33. } __packed;
  34. /* fill with constant @value, @size bytes starting from @addr */
  35. struct wil_fw_record_fill { /* type == wil_fw_type_fill */
  36. __le32 addr;
  37. __le32 value;
  38. __le32 size;
  39. } __packed;
  40. /* free-form comment
  41. * for informational purpose, data_size is @head.size from record header
  42. */
  43. struct wil_fw_record_comment { /* type == wil_fw_type_comment */
  44. u8 data[0]; /* free-form data [data_size], see above */
  45. } __packed;
  46. /* Comment header - common for all comment record types */
  47. struct wil_fw_record_comment_hdr {
  48. __le32 magic;
  49. };
  50. /* FW capabilities encoded inside a comment record */
  51. #define WIL_FW_CAPABILITIES_MAGIC (0xabcddcba)
  52. struct wil_fw_record_capabilities { /* type == wil_fw_type_comment */
  53. /* identifies capabilities record */
  54. struct wil_fw_record_comment_hdr hdr;
  55. /* capabilities (variable size), see enum wmi_fw_capability */
  56. u8 capabilities[];
  57. } __packed;
  58. /* FW VIF concurrency encoded inside a comment record
  59. * Format is similar to wiphy->iface_combinations
  60. */
  61. #define WIL_FW_CONCURRENCY_MAGIC (0xfedccdef)
  62. #define WIL_FW_CONCURRENCY_REC_VER 1
  63. struct wil_fw_concurrency_limit {
  64. __le16 max; /* maximum number of interfaces of these types */
  65. __le16 types; /* interface types (bit mask of enum nl80211_iftype) */
  66. } __packed;
  67. struct wil_fw_concurrency_combo {
  68. u8 n_limits; /* number of wil_fw_concurrency_limit entries */
  69. u8 max_interfaces; /* max number of concurrent interfaces allowed */
  70. u8 n_diff_channels; /* total number of different channels allowed */
  71. u8 same_bi; /* for APs, 1 if all APs must have same BI */
  72. /* keep last - concurrency limits, variable size by n_limits */
  73. struct wil_fw_concurrency_limit limits[];
  74. } __packed;
  75. struct wil_fw_record_concurrency { /* type == wil_fw_type_comment */
  76. /* identifies concurrency record */
  77. __le32 magic;
  78. /* structure version, currently always 1 */
  79. u8 version;
  80. /* maximum number of supported MIDs _in addition_ to MID 0 */
  81. u8 n_mids;
  82. /* number of concurrency combinations that follow */
  83. __le16 n_combos;
  84. /* keep last - combinations, variable size by n_combos */
  85. struct wil_fw_concurrency_combo combos[];
  86. } __packed;
  87. /* brd file info encoded inside a comment record */
  88. #define WIL_BRD_FILE_MAGIC (0xabcddcbb)
  89. struct brd_info {
  90. __le32 base_addr;
  91. __le32 max_size_bytes;
  92. } __packed;
  93. struct wil_fw_record_brd_file { /* type == wil_fw_type_comment */
  94. /* identifies brd file record */
  95. struct wil_fw_record_comment_hdr hdr;
  96. __le32 version;
  97. struct brd_info brd_info[];
  98. } __packed;
  99. /* perform action
  100. * data_size = @head.size - offsetof(struct wil_fw_record_action, data)
  101. */
  102. struct wil_fw_record_action { /* type == wil_fw_type_action */
  103. __le32 action; /* action to perform: reset, wait for fw ready etc. */
  104. __le32 data[]; /* action specific, [data_size], see above */
  105. } __packed;
  106. /* data block for struct wil_fw_record_direct_write */
  107. struct wil_fw_data_dwrite {
  108. __le32 addr;
  109. __le32 value;
  110. __le32 mask;
  111. } __packed;
  112. /* write @value to the @addr,
  113. * preserve original bits accordingly to the @mask
  114. * data_size is @head.size where @head is record header
  115. */
  116. struct wil_fw_record_direct_write { /* type == wil_fw_type_direct_write */
  117. struct wil_fw_data_dwrite data[0];
  118. } __packed;
  119. /* verify condition: [@addr] & @mask == @value
  120. * if condition not met, firmware download fails
  121. */
  122. struct wil_fw_record_verify { /* type == wil_fw_verify */
  123. __le32 addr; /* read from this address */
  124. __le32 value; /* reference value */
  125. __le32 mask; /* mask for verification */
  126. } __packed;
  127. /* file header
  128. * First record of every file
  129. */
  130. /* the FW version prefix in the comment */
  131. #define WIL_FW_VERSION_PREFIX "FW version: "
  132. #define WIL_FW_VERSION_PREFIX_LEN (sizeof(WIL_FW_VERSION_PREFIX) - 1)
  133. struct wil_fw_record_file_header {
  134. __le32 signature ; /* Wilocity signature */
  135. __le32 reserved;
  136. __le32 crc; /* crc32 of the following data */
  137. __le32 version; /* format version */
  138. __le32 data_len; /* total data in file, including this record */
  139. u8 comment[32]; /* short description */
  140. } __packed;
  141. /* 1-dword gateway */
  142. /* data block for the struct wil_fw_record_gateway_data */
  143. struct wil_fw_data_gw {
  144. __le32 addr;
  145. __le32 value;
  146. } __packed;
  147. /* gateway write block.
  148. * write starting address and values from the data buffer
  149. * through the gateway
  150. * data_size inferred from the @head.size. For this case,
  151. * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data, data)
  152. */
  153. struct wil_fw_record_gateway_data { /* type == wil_fw_type_gateway_data */
  154. __le32 gateway_addr_addr;
  155. __le32 gateway_value_addr;
  156. __le32 gateway_cmd_addr;
  157. __le32 gateway_ctrl_address;
  158. #define WIL_FW_GW_CTL_BUSY BIT(29) /* gateway busy performing operation */
  159. #define WIL_FW_GW_CTL_RUN BIT(30) /* start gateway operation */
  160. __le32 command;
  161. struct wil_fw_data_gw data[]; /* total size [data_size], see above */
  162. } __packed;
  163. /* 4-dword gateway */
  164. /* data block for the struct wil_fw_record_gateway_data4 */
  165. struct wil_fw_data_gw4 {
  166. __le32 addr;
  167. __le32 value[4];
  168. } __packed;
  169. /* gateway write block.
  170. * write starting address and values from the data buffer
  171. * through the gateway
  172. * data_size inferred from the @head.size. For this case,
  173. * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data4, data)
  174. */
  175. struct wil_fw_record_gateway_data4 { /* type == wil_fw_type_gateway_data4 */
  176. __le32 gateway_addr_addr;
  177. __le32 gateway_value_addr[4];
  178. __le32 gateway_cmd_addr;
  179. __le32 gateway_ctrl_address; /* same logic as for 1-dword gw */
  180. __le32 command;
  181. struct wil_fw_data_gw4 data[]; /* total size [data_size], see above */
  182. } __packed;
  183. #endif /* __WIL_FW_H__ */