fw.h 7.1 KB

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