fw.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (c) 2014 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. /* perform action
  55. * data_size = @head.size - offsetof(struct wil_fw_record_action, data)
  56. */
  57. struct wil_fw_record_action { /* type == wil_fw_type_action */
  58. __le32 action; /* action to perform: reset, wait for fw ready etc. */
  59. __le32 data[0]; /* action specific, [data_size], see above */
  60. } __packed;
  61. /* data block for struct wil_fw_record_direct_write */
  62. struct wil_fw_data_dwrite {
  63. __le32 addr;
  64. __le32 value;
  65. __le32 mask;
  66. } __packed;
  67. /* write @value to the @addr,
  68. * preserve original bits accordingly to the @mask
  69. * data_size is @head.size where @head is record header
  70. */
  71. struct wil_fw_record_direct_write { /* type == wil_fw_type_direct_write */
  72. struct wil_fw_data_dwrite data[0];
  73. } __packed;
  74. /* verify condition: [@addr] & @mask == @value
  75. * if condition not met, firmware download fails
  76. */
  77. struct wil_fw_record_verify { /* type == wil_fw_verify */
  78. __le32 addr; /* read from this address */
  79. __le32 value; /* reference value */
  80. __le32 mask; /* mask for verification */
  81. } __packed;
  82. /* file header
  83. * First record of every file
  84. */
  85. struct wil_fw_record_file_header {
  86. __le32 signature ; /* Wilocity signature */
  87. __le32 reserved;
  88. __le32 crc; /* crc32 of the following data */
  89. __le32 version; /* format version */
  90. __le32 data_len; /* total data in file, including this record */
  91. u8 comment[32]; /* short description */
  92. } __packed;
  93. /* 1-dword gateway */
  94. /* data block for the struct wil_fw_record_gateway_data */
  95. struct wil_fw_data_gw {
  96. __le32 addr;
  97. __le32 value;
  98. } __packed;
  99. /* gateway write block.
  100. * write starting address and values from the data buffer
  101. * through the gateway
  102. * data_size inferred from the @head.size. For this case,
  103. * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data, data)
  104. */
  105. struct wil_fw_record_gateway_data { /* type == wil_fw_type_gateway_data */
  106. __le32 gateway_addr_addr;
  107. __le32 gateway_value_addr;
  108. __le32 gateway_cmd_addr;
  109. __le32 gateway_ctrl_address;
  110. #define WIL_FW_GW_CTL_BUSY BIT(29) /* gateway busy performing operation */
  111. #define WIL_FW_GW_CTL_RUN BIT(30) /* start gateway operation */
  112. __le32 command;
  113. struct wil_fw_data_gw data[0]; /* total size [data_size], see above */
  114. } __packed;
  115. /* 4-dword gateway */
  116. /* data block for the struct wil_fw_record_gateway_data4 */
  117. struct wil_fw_data_gw4 {
  118. __le32 addr;
  119. __le32 value[4];
  120. } __packed;
  121. /* gateway write block.
  122. * write starting address and values from the data buffer
  123. * through the gateway
  124. * data_size inferred from the @head.size. For this case,
  125. * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data4, data)
  126. */
  127. struct wil_fw_record_gateway_data4 { /* type == wil_fw_type_gateway_data4 */
  128. __le32 gateway_addr_addr;
  129. __le32 gateway_value_addr[4];
  130. __le32 gateway_cmd_addr;
  131. __le32 gateway_ctrl_address; /* same logic as for 1-dword gw */
  132. __le32 command;
  133. struct wil_fw_data_gw4 data[0]; /* total size [data_size], see above */
  134. } __packed;