bmi.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*
  2. * Copyright (c) 2004-2011 Atheros Communications 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. #ifndef BMI_H
  17. #define BMI_H
  18. /*
  19. * Bootloader Messaging Interface (BMI)
  20. *
  21. * BMI is a very simple messaging interface used during initialization
  22. * to read memory, write memory, execute code, and to define an
  23. * application entry PC.
  24. *
  25. * It is used to download an application to ATH6KL, to provide
  26. * patches to code that is already resident on ATH6KL, and generally
  27. * to examine and modify state. The Host has an opportunity to use
  28. * BMI only once during bootup. Once the Host issues a BMI_DONE
  29. * command, this opportunity ends.
  30. *
  31. * The Host writes BMI requests to mailbox0, and reads BMI responses
  32. * from mailbox0. BMI requests all begin with a command
  33. * (see below for specific commands), and are followed by
  34. * command-specific data.
  35. *
  36. * Flow control:
  37. * The Host can only issue a command once the Target gives it a
  38. * "BMI Command Credit", using ATH6KL Counter #4. As soon as the
  39. * Target has completed a command, it issues another BMI Command
  40. * Credit (so the Host can issue the next command).
  41. *
  42. * BMI handles all required Target-side cache flushing.
  43. */
  44. #define MAX_BMI_CMDBUF_SZ (BMI_DATASZ_MAX + \
  45. (sizeof(u32) * 3 /* cmd + addr + len */))
  46. /* Maximum data size used for BMI transfers */
  47. #define BMI_DATASZ_MAX 256
  48. /* BMI Commands */
  49. #define BMI_NO_COMMAND 0
  50. #define BMI_DONE 1
  51. /*
  52. * Semantics: Host is done using BMI
  53. * Request format:
  54. * u32 command (BMI_DONE)
  55. * Response format: none
  56. */
  57. #define BMI_READ_MEMORY 2
  58. /*
  59. * Semantics: Host reads ATH6KL memory
  60. * Request format:
  61. * u32 command (BMI_READ_MEMORY)
  62. * u32 address
  63. * u32 length, at most BMI_DATASZ_MAX
  64. * Response format:
  65. * u8 data[length]
  66. */
  67. #define BMI_WRITE_MEMORY 3
  68. /*
  69. * Semantics: Host writes ATH6KL memory
  70. * Request format:
  71. * u32 command (BMI_WRITE_MEMORY)
  72. * u32 address
  73. * u32 length, at most BMI_DATASZ_MAX
  74. * u8 data[length]
  75. * Response format: none
  76. */
  77. #define BMI_EXECUTE 4
  78. /*
  79. * Semantics: Causes ATH6KL to execute code
  80. * Request format:
  81. * u32 command (BMI_EXECUTE)
  82. * u32 address
  83. * u32 parameter
  84. * Response format:
  85. * u32 return value
  86. */
  87. #define BMI_SET_APP_START 5
  88. /*
  89. * Semantics: Set Target application starting address
  90. * Request format:
  91. * u32 command (BMI_SET_APP_START)
  92. * u32 address
  93. * Response format: none
  94. */
  95. #define BMI_READ_SOC_REGISTER 6
  96. /*
  97. * Semantics: Read a 32-bit Target SOC register.
  98. * Request format:
  99. * u32 command (BMI_READ_REGISTER)
  100. * u32 address
  101. * Response format:
  102. * u32 value
  103. */
  104. #define BMI_WRITE_SOC_REGISTER 7
  105. /*
  106. * Semantics: Write a 32-bit Target SOC register.
  107. * Request format:
  108. * u32 command (BMI_WRITE_REGISTER)
  109. * u32 address
  110. * u32 value
  111. *
  112. * Response format: none
  113. */
  114. #define BMI_GET_TARGET_ID 8
  115. #define BMI_GET_TARGET_INFO 8
  116. /*
  117. * Semantics: Fetch the 4-byte Target information
  118. * Request format:
  119. * u32 command (BMI_GET_TARGET_ID/INFO)
  120. * Response format1 (old firmware):
  121. * u32 TargetVersionID
  122. * Response format2 (newer firmware):
  123. * u32 TARGET_VERSION_SENTINAL
  124. * struct bmi_target_info;
  125. */
  126. #define TARGET_VERSION_SENTINAL 0xffffffff
  127. #define TARGET_TYPE_AR6003 3
  128. #define TARGET_TYPE_AR6004 5
  129. #define BMI_ROMPATCH_INSTALL 9
  130. /*
  131. * Semantics: Install a ROM Patch.
  132. * Request format:
  133. * u32 command (BMI_ROMPATCH_INSTALL)
  134. * u32 Target ROM Address
  135. * u32 Target RAM Address or Value (depending on Target Type)
  136. * u32 Size, in bytes
  137. * u32 Activate? 1-->activate;
  138. * 0-->install but do not activate
  139. * Response format:
  140. * u32 PatchID
  141. */
  142. #define BMI_ROMPATCH_UNINSTALL 10
  143. /*
  144. * Semantics: Uninstall a previously-installed ROM Patch,
  145. * automatically deactivating, if necessary.
  146. * Request format:
  147. * u32 command (BMI_ROMPATCH_UNINSTALL)
  148. * u32 PatchID
  149. *
  150. * Response format: none
  151. */
  152. #define BMI_ROMPATCH_ACTIVATE 11
  153. /*
  154. * Semantics: Activate a list of previously-installed ROM Patches.
  155. * Request format:
  156. * u32 command (BMI_ROMPATCH_ACTIVATE)
  157. * u32 rompatch_count
  158. * u32 PatchID[rompatch_count]
  159. *
  160. * Response format: none
  161. */
  162. #define BMI_ROMPATCH_DEACTIVATE 12
  163. /*
  164. * Semantics: Deactivate a list of active ROM Patches.
  165. * Request format:
  166. * u32 command (BMI_ROMPATCH_DEACTIVATE)
  167. * u32 rompatch_count
  168. * u32 PatchID[rompatch_count]
  169. *
  170. * Response format: none
  171. */
  172. #define BMI_LZ_STREAM_START 13
  173. /*
  174. * Semantics: Begin an LZ-compressed stream of input
  175. * which is to be uncompressed by the Target to an
  176. * output buffer at address. The output buffer must
  177. * be sufficiently large to hold the uncompressed
  178. * output from the compressed input stream. This BMI
  179. * command should be followed by a series of 1 or more
  180. * BMI_LZ_DATA commands.
  181. * u32 command (BMI_LZ_STREAM_START)
  182. * u32 address
  183. * Note: Not supported on all versions of ROM firmware.
  184. */
  185. #define BMI_LZ_DATA 14
  186. /*
  187. * Semantics: Host writes ATH6KL memory with LZ-compressed
  188. * data which is uncompressed by the Target. This command
  189. * must be preceded by a BMI_LZ_STREAM_START command. A series
  190. * of BMI_LZ_DATA commands are considered part of a single
  191. * input stream until another BMI_LZ_STREAM_START is issued.
  192. * Request format:
  193. * u32 command (BMI_LZ_DATA)
  194. * u32 length (of compressed data),
  195. * at most BMI_DATASZ_MAX
  196. * u8 CompressedData[length]
  197. * Response format: none
  198. * Note: Not supported on all versions of ROM firmware.
  199. */
  200. #define BMI_COMMUNICATION_TIMEOUT 1000 /* in msec */
  201. struct ath6kl;
  202. struct ath6kl_bmi_target_info {
  203. __le32 byte_count; /* size of this structure */
  204. __le32 version; /* target version id */
  205. __le32 type; /* target type */
  206. } __packed;
  207. int ath6kl_bmi_init(struct ath6kl *ar);
  208. void ath6kl_bmi_cleanup(struct ath6kl *ar);
  209. int ath6kl_bmi_done(struct ath6kl *ar);
  210. int ath6kl_bmi_get_target_info(struct ath6kl *ar,
  211. struct ath6kl_bmi_target_info *targ_info);
  212. int ath6kl_bmi_read(struct ath6kl *ar, u32 addr, u8 *buf, u32 len);
  213. int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len);
  214. int ath6kl_bmi_execute(struct ath6kl *ar,
  215. u32 addr, u32 *param);
  216. int ath6kl_bmi_set_app_start(struct ath6kl *ar,
  217. u32 addr);
  218. int ath6kl_bmi_reg_read(struct ath6kl *ar, u32 addr, u32 *param);
  219. int ath6kl_bmi_reg_write(struct ath6kl *ar, u32 addr, u32 param);
  220. int ath6kl_bmi_lz_data(struct ath6kl *ar,
  221. u8 *buf, u32 len);
  222. int ath6kl_bmi_lz_stream_start(struct ath6kl *ar,
  223. u32 addr);
  224. int ath6kl_bmi_fast_download(struct ath6kl *ar,
  225. u32 addr, u8 *buf, u32 len);
  226. #endif