fw.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright (c) 2014,2016 Qualcomm Atheros, Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #define WIL_FW_SIGNATURE (0x36323130) /* '0126' */
  17. #define WIL_FW_FMT_VERSION (1) /* format version driver supports */
  18. enum wil_fw_record_type {
  19. wil_fw_type_comment = 1,
  20. wil_fw_type_data = 2,
  21. wil_fw_type_fill = 3,
  22. wil_fw_type_action = 4,
  23. wil_fw_type_verify = 5,
  24. wil_fw_type_file_header = 6,
  25. wil_fw_type_direct_write = 7,
  26. wil_fw_type_gateway_data = 8,
  27. wil_fw_type_gateway_data4 = 9,
  28. };
  29. struct wil_fw_record_head {
  30. __le16 type; /* enum wil_fw_record_type */
  31. __le16 flags; /* to be defined */
  32. __le32 size; /* whole record, bytes after head */
  33. } __packed;
  34. /* data block. write starting from @addr
  35. * data_size inferred from the @head.size. For this case,
  36. * data_size = @head.size - offsetof(struct wil_fw_record_data, data)
  37. */
  38. struct wil_fw_record_data { /* type == wil_fw_type_data */
  39. __le32 addr;
  40. __le32 data[0]; /* [data_size], see above */
  41. } __packed;
  42. /* fill with constant @value, @size bytes starting from @addr */
  43. struct wil_fw_record_fill { /* type == wil_fw_type_fill */
  44. __le32 addr;
  45. __le32 value;
  46. __le32 size;
  47. } __packed;
  48. /* free-form comment
  49. * for informational purpose, data_size is @head.size from record header
  50. */
  51. struct wil_fw_record_comment { /* type == wil_fw_type_comment */
  52. u8 data[0]; /* free-form data [data_size], see above */
  53. } __packed;
  54. /* FW capabilities encoded inside a comment record */
  55. #define WIL_FW_CAPABILITIES_MAGIC (0xabcddcba)
  56. struct wil_fw_record_capabilities { /* type == wil_fw_type_comment */
  57. /* identifies capabilities record */
  58. __le32 magic;
  59. /* capabilities (variable size), see enum wmi_fw_capability */
  60. u8 capabilities[0];
  61. };
  62. /* perform action
  63. * data_size = @head.size - offsetof(struct wil_fw_record_action, data)
  64. */
  65. struct wil_fw_record_action { /* type == wil_fw_type_action */
  66. __le32 action; /* action to perform: reset, wait for fw ready etc. */
  67. __le32 data[0]; /* action specific, [data_size], see above */
  68. } __packed;
  69. /* data block for struct wil_fw_record_direct_write */
  70. struct wil_fw_data_dwrite {
  71. __le32 addr;
  72. __le32 value;
  73. __le32 mask;
  74. } __packed;
  75. /* write @value to the @addr,
  76. * preserve original bits accordingly to the @mask
  77. * data_size is @head.size where @head is record header
  78. */
  79. struct wil_fw_record_direct_write { /* type == wil_fw_type_direct_write */
  80. struct wil_fw_data_dwrite data[0];
  81. } __packed;
  82. /* verify condition: [@addr] & @mask == @value
  83. * if condition not met, firmware download fails
  84. */
  85. struct wil_fw_record_verify { /* type == wil_fw_verify */
  86. __le32 addr; /* read from this address */
  87. __le32 value; /* reference value */
  88. __le32 mask; /* mask for verification */
  89. } __packed;
  90. /* file header
  91. * First record of every file
  92. */
  93. /* the FW version prefix in the comment */
  94. #define WIL_FW_VERSION_PREFIX "FW version: "
  95. #define WIL_FW_VERSION_PREFIX_LEN (sizeof(WIL_FW_VERSION_PREFIX) - 1)
  96. struct wil_fw_record_file_header {
  97. __le32 signature ; /* Wilocity signature */
  98. __le32 reserved;
  99. __le32 crc; /* crc32 of the following data */
  100. __le32 version; /* format version */
  101. __le32 data_len; /* total data in file, including this record */
  102. u8 comment[32]; /* short description */
  103. } __packed;
  104. /* 1-dword gateway */
  105. /* data block for the struct wil_fw_record_gateway_data */
  106. struct wil_fw_data_gw {
  107. __le32 addr;
  108. __le32 value;
  109. } __packed;
  110. /* gateway write block.
  111. * write starting address and values from the data buffer
  112. * through the gateway
  113. * data_size inferred from the @head.size. For this case,
  114. * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data, data)
  115. */
  116. struct wil_fw_record_gateway_data { /* type == wil_fw_type_gateway_data */
  117. __le32 gateway_addr_addr;
  118. __le32 gateway_value_addr;
  119. __le32 gateway_cmd_addr;
  120. __le32 gateway_ctrl_address;
  121. #define WIL_FW_GW_CTL_BUSY BIT(29) /* gateway busy performing operation */
  122. #define WIL_FW_GW_CTL_RUN BIT(30) /* start gateway operation */
  123. __le32 command;
  124. struct wil_fw_data_gw data[0]; /* total size [data_size], see above */
  125. } __packed;
  126. /* 4-dword gateway */
  127. /* data block for the struct wil_fw_record_gateway_data4 */
  128. struct wil_fw_data_gw4 {
  129. __le32 addr;
  130. __le32 value[4];
  131. } __packed;
  132. /* gateway write block.
  133. * write starting address and values from the data buffer
  134. * through the gateway
  135. * data_size inferred from the @head.size. For this case,
  136. * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data4, data)
  137. */
  138. struct wil_fw_record_gateway_data4 { /* type == wil_fw_type_gateway_data4 */
  139. __le32 gateway_addr_addr;
  140. __le32 gateway_value_addr[4];
  141. __le32 gateway_cmd_addr;
  142. __le32 gateway_ctrl_address; /* same logic as for 1-dword gw */
  143. __le32 command;
  144. struct wil_fw_data_gw4 data[0]; /* total size [data_size], see above */
  145. } __packed;