fwcmd.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. /*
  2. * Shared Atheros AR9170 Header
  3. *
  4. * Firmware command interface definitions
  5. *
  6. * Copyright 2008, Johannes Berg <[email protected]>
  7. * Copyright 2009-2011 Christian Lamparter <[email protected]>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; see the file COPYING. If not, see
  20. * http://www.gnu.org/licenses/.
  21. *
  22. * This file incorporates work covered by the following copyright and
  23. * permission notice:
  24. * Copyright (c) 2007-2008 Atheros Communications, Inc.
  25. *
  26. * Permission to use, copy, modify, and/or distribute this software for any
  27. * purpose with or without fee is hereby granted, provided that the above
  28. * copyright notice and this permission notice appear in all copies.
  29. *
  30. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  31. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  32. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  33. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  34. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  35. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  36. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  37. */
  38. #ifndef __CARL9170_SHARED_FWCMD_H
  39. #define __CARL9170_SHARED_FWCMD_H
  40. #define CARL9170_MAX_CMD_LEN 64
  41. #define CARL9170_MAX_CMD_PAYLOAD_LEN 60
  42. #define CARL9170FW_API_MIN_VER 1
  43. #define CARL9170FW_API_MAX_VER 1
  44. enum carl9170_cmd_oids {
  45. CARL9170_CMD_RREG = 0x00,
  46. CARL9170_CMD_WREG = 0x01,
  47. CARL9170_CMD_ECHO = 0x02,
  48. CARL9170_CMD_SWRST = 0x03,
  49. CARL9170_CMD_REBOOT = 0x04,
  50. CARL9170_CMD_BCN_CTRL = 0x05,
  51. CARL9170_CMD_READ_TSF = 0x06,
  52. CARL9170_CMD_RX_FILTER = 0x07,
  53. CARL9170_CMD_WOL = 0x08,
  54. CARL9170_CMD_TALLY = 0x09,
  55. CARL9170_CMD_WREGB = 0x0a,
  56. /* CAM */
  57. CARL9170_CMD_EKEY = 0x10,
  58. CARL9170_CMD_DKEY = 0x11,
  59. /* RF / PHY */
  60. CARL9170_CMD_FREQUENCY = 0x20,
  61. CARL9170_CMD_RF_INIT = 0x21,
  62. CARL9170_CMD_SYNTH = 0x22,
  63. CARL9170_CMD_FREQ_START = 0x23,
  64. CARL9170_CMD_PSM = 0x24,
  65. /* Asychronous command flag */
  66. CARL9170_CMD_ASYNC_FLAG = 0x40,
  67. CARL9170_CMD_WREG_ASYNC = (CARL9170_CMD_WREG |
  68. CARL9170_CMD_ASYNC_FLAG),
  69. CARL9170_CMD_REBOOT_ASYNC = (CARL9170_CMD_REBOOT |
  70. CARL9170_CMD_ASYNC_FLAG),
  71. CARL9170_CMD_BCN_CTRL_ASYNC = (CARL9170_CMD_BCN_CTRL |
  72. CARL9170_CMD_ASYNC_FLAG),
  73. CARL9170_CMD_PSM_ASYNC = (CARL9170_CMD_PSM |
  74. CARL9170_CMD_ASYNC_FLAG),
  75. /* responses and traps */
  76. CARL9170_RSP_FLAG = 0xc0,
  77. CARL9170_RSP_PRETBTT = 0xc0,
  78. CARL9170_RSP_TXCOMP = 0xc1,
  79. CARL9170_RSP_BEACON_CONFIG = 0xc2,
  80. CARL9170_RSP_ATIM = 0xc3,
  81. CARL9170_RSP_WATCHDOG = 0xc6,
  82. CARL9170_RSP_TEXT = 0xca,
  83. CARL9170_RSP_HEXDUMP = 0xcc,
  84. CARL9170_RSP_RADAR = 0xcd,
  85. CARL9170_RSP_GPIO = 0xce,
  86. CARL9170_RSP_BOOT = 0xcf,
  87. };
  88. struct carl9170_set_key_cmd {
  89. __le16 user;
  90. __le16 keyId;
  91. __le16 type;
  92. u8 macAddr[6];
  93. u32 key[4];
  94. } __packed __aligned(4);
  95. #define CARL9170_SET_KEY_CMD_SIZE 28
  96. struct carl9170_disable_key_cmd {
  97. __le16 user;
  98. __le16 padding;
  99. } __packed __aligned(4);
  100. #define CARL9170_DISABLE_KEY_CMD_SIZE 4
  101. struct carl9170_u32_list {
  102. u32 vals[0];
  103. } __packed;
  104. struct carl9170_reg_list {
  105. __le32 regs[0];
  106. } __packed;
  107. struct carl9170_write_reg {
  108. struct {
  109. __le32 addr;
  110. __le32 val;
  111. } regs[0] __packed;
  112. } __packed;
  113. struct carl9170_write_reg_byte {
  114. __le32 addr;
  115. __le32 count;
  116. u8 val[];
  117. } __packed;
  118. #define CARL9170FW_PHY_HT_ENABLE 0x4
  119. #define CARL9170FW_PHY_HT_DYN2040 0x8
  120. #define CARL9170FW_PHY_HT_EXT_CHAN_OFF 0x3
  121. #define CARL9170FW_PHY_HT_EXT_CHAN_OFF_S 2
  122. struct carl9170_rf_init {
  123. __le32 freq;
  124. u8 ht_settings;
  125. u8 padding2[3];
  126. __le32 delta_slope_coeff_exp;
  127. __le32 delta_slope_coeff_man;
  128. __le32 delta_slope_coeff_exp_shgi;
  129. __le32 delta_slope_coeff_man_shgi;
  130. __le32 finiteLoopCount;
  131. } __packed;
  132. #define CARL9170_RF_INIT_SIZE 28
  133. struct carl9170_rf_init_result {
  134. __le32 ret; /* AR9170_PHY_REG_AGC_CONTROL */
  135. } __packed;
  136. #define CARL9170_RF_INIT_RESULT_SIZE 4
  137. #define CARL9170_PSM_SLEEP 0x1000
  138. #define CARL9170_PSM_SOFTWARE 0
  139. #define CARL9170_PSM_WAKE 0 /* internally used. */
  140. #define CARL9170_PSM_COUNTER 0xfff
  141. #define CARL9170_PSM_COUNTER_S 0
  142. struct carl9170_psm {
  143. __le32 state;
  144. } __packed;
  145. #define CARL9170_PSM_SIZE 4
  146. /*
  147. * Note: If a bit in rx_filter is set, then it
  148. * means that the particular frames which matches
  149. * the condition are FILTERED/REMOVED/DISCARDED!
  150. * (This is can be a bit confusing, especially
  151. * because someone people think it's the exact
  152. * opposite way, so watch out!)
  153. */
  154. struct carl9170_rx_filter_cmd {
  155. __le32 rx_filter;
  156. } __packed;
  157. #define CARL9170_RX_FILTER_CMD_SIZE 4
  158. #define CARL9170_RX_FILTER_BAD 0x01
  159. #define CARL9170_RX_FILTER_OTHER_RA 0x02
  160. #define CARL9170_RX_FILTER_DECRY_FAIL 0x04
  161. #define CARL9170_RX_FILTER_CTL_OTHER 0x08
  162. #define CARL9170_RX_FILTER_CTL_PSPOLL 0x10
  163. #define CARL9170_RX_FILTER_CTL_BACKR 0x20
  164. #define CARL9170_RX_FILTER_MGMT 0x40
  165. #define CARL9170_RX_FILTER_DATA 0x80
  166. #define CARL9170_RX_FILTER_EVERYTHING (~0)
  167. struct carl9170_bcn_ctrl_cmd {
  168. __le32 vif_id;
  169. __le32 mode;
  170. __le32 bcn_addr;
  171. __le32 bcn_len;
  172. } __packed;
  173. #define CARL9170_BCN_CTRL_CMD_SIZE 16
  174. #define CARL9170_BCN_CTRL_DRAIN 0
  175. #define CARL9170_BCN_CTRL_CAB_TRIGGER 1
  176. struct carl9170_wol_cmd {
  177. __le32 flags;
  178. u8 mac[6];
  179. u8 bssid[6];
  180. __le32 null_interval;
  181. __le32 free_for_use2;
  182. __le32 mask;
  183. u8 pattern[32];
  184. } __packed;
  185. #define CARL9170_WOL_CMD_SIZE 60
  186. #define CARL9170_WOL_DISCONNECT 1
  187. #define CARL9170_WOL_MAGIC_PKT 2
  188. struct carl9170_cmd_head {
  189. union {
  190. struct {
  191. u8 len;
  192. u8 cmd;
  193. u8 seq;
  194. u8 ext;
  195. } __packed;
  196. u32 hdr_data;
  197. } __packed;
  198. } __packed;
  199. struct carl9170_cmd {
  200. struct carl9170_cmd_head hdr;
  201. union {
  202. struct carl9170_set_key_cmd setkey;
  203. struct carl9170_disable_key_cmd disablekey;
  204. struct carl9170_u32_list echo;
  205. struct carl9170_reg_list rreg;
  206. struct carl9170_write_reg wreg;
  207. struct carl9170_write_reg_byte wregb;
  208. struct carl9170_rf_init rf_init;
  209. struct carl9170_psm psm;
  210. struct carl9170_wol_cmd wol;
  211. struct carl9170_bcn_ctrl_cmd bcn_ctrl;
  212. struct carl9170_rx_filter_cmd rx_filter;
  213. u8 data[CARL9170_MAX_CMD_PAYLOAD_LEN];
  214. } __packed __aligned(4);
  215. } __packed __aligned(4);
  216. #define CARL9170_TX_STATUS_QUEUE 3
  217. #define CARL9170_TX_STATUS_QUEUE_S 0
  218. #define CARL9170_TX_STATUS_RIX_S 2
  219. #define CARL9170_TX_STATUS_RIX (3 << CARL9170_TX_STATUS_RIX_S)
  220. #define CARL9170_TX_STATUS_TRIES_S 4
  221. #define CARL9170_TX_STATUS_TRIES (7 << CARL9170_TX_STATUS_TRIES_S)
  222. #define CARL9170_TX_STATUS_SUCCESS 0x80
  223. #ifdef __CARL9170FW__
  224. /*
  225. * NOTE:
  226. * Both structs [carl9170_tx_status and _carl9170_tx_status]
  227. * need to be "bit for bit" in sync.
  228. */
  229. struct carl9170_tx_status {
  230. /*
  231. * Beware of compiler bugs in all gcc pre 4.4!
  232. */
  233. u8 cookie;
  234. u8 queue:2;
  235. u8 rix:2;
  236. u8 tries:3;
  237. u8 success:1;
  238. } __packed;
  239. #endif /* __CARL9170FW__ */
  240. struct _carl9170_tx_status {
  241. /*
  242. * This version should be immune to all alignment bugs.
  243. */
  244. u8 cookie;
  245. u8 info;
  246. } __packed;
  247. #define CARL9170_TX_STATUS_SIZE 2
  248. #define CARL9170_RSP_TX_STATUS_NUM (CARL9170_MAX_CMD_PAYLOAD_LEN / \
  249. sizeof(struct _carl9170_tx_status))
  250. #define CARL9170_TX_MAX_RATE_TRIES 7
  251. #define CARL9170_TX_MAX_RATES 4
  252. #define CARL9170_TX_MAX_RETRY_RATES (CARL9170_TX_MAX_RATES - 1)
  253. #define CARL9170_ERR_MAGIC "ERR:"
  254. #define CARL9170_BUG_MAGIC "BUG:"
  255. struct carl9170_gpio {
  256. __le32 gpio;
  257. } __packed;
  258. #define CARL9170_GPIO_SIZE 4
  259. struct carl9170_tsf_rsp {
  260. union {
  261. __le32 tsf[2];
  262. __le64 tsf_64;
  263. } __packed;
  264. } __packed;
  265. #define CARL9170_TSF_RSP_SIZE 8
  266. struct carl9170_tally_rsp {
  267. __le32 active;
  268. __le32 cca;
  269. __le32 tx_time;
  270. __le32 rx_total;
  271. __le32 rx_overrun;
  272. __le32 tick;
  273. } __packed;
  274. struct carl9170_rsp {
  275. struct carl9170_cmd_head hdr;
  276. union {
  277. struct carl9170_rf_init_result rf_init_res;
  278. struct carl9170_u32_list rreg_res;
  279. struct carl9170_u32_list echo;
  280. #ifdef __CARL9170FW__
  281. struct carl9170_tx_status tx_status[0];
  282. #endif /* __CARL9170FW__ */
  283. struct _carl9170_tx_status _tx_status[0];
  284. struct carl9170_gpio gpio;
  285. struct carl9170_tsf_rsp tsf;
  286. struct carl9170_psm psm;
  287. struct carl9170_tally_rsp tally;
  288. u8 data[CARL9170_MAX_CMD_PAYLOAD_LEN];
  289. } __packed;
  290. } __packed __aligned(4);
  291. #endif /* __CARL9170_SHARED_FWCMD_H */