Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Shared Atheros AR9170 Header |
| 3 | * |
| 4 | * Firmware command interface definitions |
| 5 | * |
| 6 | * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> |
Christian Lamparter | 85ee512 | 2011-06-30 20:27:47 +0200 | [diff] [blame^] | 7 | * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com> |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 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 | |
| 39 | #ifndef __CARL9170_SHARED_FWCMD_H |
| 40 | #define __CARL9170_SHARED_FWCMD_H |
| 41 | |
| 42 | #define CARL9170_MAX_CMD_LEN 64 |
| 43 | #define CARL9170_MAX_CMD_PAYLOAD_LEN 60 |
| 44 | |
| 45 | #define CARL9170FW_API_MIN_VER 1 |
| 46 | #define CARL9170FW_API_MAX_VER 1 |
| 47 | |
| 48 | enum carl9170_cmd_oids { |
| 49 | CARL9170_CMD_RREG = 0x00, |
| 50 | CARL9170_CMD_WREG = 0x01, |
| 51 | CARL9170_CMD_ECHO = 0x02, |
| 52 | CARL9170_CMD_SWRST = 0x03, |
| 53 | CARL9170_CMD_REBOOT = 0x04, |
| 54 | CARL9170_CMD_BCN_CTRL = 0x05, |
| 55 | CARL9170_CMD_READ_TSF = 0x06, |
Christian Lamparter | 5c89569 | 2010-09-28 23:00:59 +0200 | [diff] [blame] | 56 | CARL9170_CMD_RX_FILTER = 0x07, |
Christian Lamparter | 85ee512 | 2011-06-30 20:27:47 +0200 | [diff] [blame^] | 57 | CARL9170_CMD_WOL = 0x08, |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 58 | |
| 59 | /* CAM */ |
| 60 | CARL9170_CMD_EKEY = 0x10, |
| 61 | CARL9170_CMD_DKEY = 0x11, |
| 62 | |
| 63 | /* RF / PHY */ |
| 64 | CARL9170_CMD_FREQUENCY = 0x20, |
| 65 | CARL9170_CMD_RF_INIT = 0x21, |
| 66 | CARL9170_CMD_SYNTH = 0x22, |
| 67 | CARL9170_CMD_FREQ_START = 0x23, |
| 68 | CARL9170_CMD_PSM = 0x24, |
| 69 | |
| 70 | /* Asychronous command flag */ |
| 71 | CARL9170_CMD_ASYNC_FLAG = 0x40, |
| 72 | CARL9170_CMD_WREG_ASYNC = (CARL9170_CMD_WREG | |
| 73 | CARL9170_CMD_ASYNC_FLAG), |
| 74 | CARL9170_CMD_REBOOT_ASYNC = (CARL9170_CMD_REBOOT | |
| 75 | CARL9170_CMD_ASYNC_FLAG), |
| 76 | CARL9170_CMD_BCN_CTRL_ASYNC = (CARL9170_CMD_BCN_CTRL | |
| 77 | CARL9170_CMD_ASYNC_FLAG), |
| 78 | CARL9170_CMD_PSM_ASYNC = (CARL9170_CMD_PSM | |
| 79 | CARL9170_CMD_ASYNC_FLAG), |
| 80 | |
| 81 | /* responses and traps */ |
| 82 | CARL9170_RSP_FLAG = 0xc0, |
| 83 | CARL9170_RSP_PRETBTT = 0xc0, |
| 84 | CARL9170_RSP_TXCOMP = 0xc1, |
| 85 | CARL9170_RSP_BEACON_CONFIG = 0xc2, |
| 86 | CARL9170_RSP_ATIM = 0xc3, |
| 87 | CARL9170_RSP_WATCHDOG = 0xc6, |
| 88 | CARL9170_RSP_TEXT = 0xca, |
| 89 | CARL9170_RSP_HEXDUMP = 0xcc, |
| 90 | CARL9170_RSP_RADAR = 0xcd, |
| 91 | CARL9170_RSP_GPIO = 0xce, |
| 92 | CARL9170_RSP_BOOT = 0xcf, |
| 93 | }; |
| 94 | |
| 95 | struct carl9170_set_key_cmd { |
| 96 | __le16 user; |
| 97 | __le16 keyId; |
| 98 | __le16 type; |
| 99 | u8 macAddr[6]; |
| 100 | u32 key[4]; |
Christian Lamparter | 3f1240e | 2010-10-29 22:44:59 +0200 | [diff] [blame] | 101 | } __packed __aligned(4); |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 102 | #define CARL9170_SET_KEY_CMD_SIZE 28 |
| 103 | |
| 104 | struct carl9170_disable_key_cmd { |
| 105 | __le16 user; |
| 106 | __le16 padding; |
Christian Lamparter | 3f1240e | 2010-10-29 22:44:59 +0200 | [diff] [blame] | 107 | } __packed __aligned(4); |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 108 | #define CARL9170_DISABLE_KEY_CMD_SIZE 4 |
| 109 | |
| 110 | struct carl9170_u32_list { |
| 111 | u32 vals[0]; |
| 112 | } __packed; |
| 113 | |
| 114 | struct carl9170_reg_list { |
| 115 | __le32 regs[0]; |
| 116 | } __packed; |
| 117 | |
| 118 | struct carl9170_write_reg { |
| 119 | struct { |
| 120 | __le32 addr; |
| 121 | __le32 val; |
| 122 | } regs[0] __packed; |
| 123 | } __packed; |
| 124 | |
| 125 | #define CARL9170FW_PHY_HT_ENABLE 0x4 |
| 126 | #define CARL9170FW_PHY_HT_DYN2040 0x8 |
| 127 | #define CARL9170FW_PHY_HT_EXT_CHAN_OFF 0x3 |
| 128 | #define CARL9170FW_PHY_HT_EXT_CHAN_OFF_S 2 |
| 129 | |
| 130 | struct carl9170_rf_init { |
| 131 | __le32 freq; |
| 132 | u8 ht_settings; |
| 133 | u8 padding2[3]; |
| 134 | __le32 delta_slope_coeff_exp; |
| 135 | __le32 delta_slope_coeff_man; |
| 136 | __le32 delta_slope_coeff_exp_shgi; |
| 137 | __le32 delta_slope_coeff_man_shgi; |
| 138 | __le32 finiteLoopCount; |
| 139 | } __packed; |
| 140 | #define CARL9170_RF_INIT_SIZE 28 |
| 141 | |
| 142 | struct carl9170_rf_init_result { |
| 143 | __le32 ret; /* AR9170_PHY_REG_AGC_CONTROL */ |
| 144 | } __packed; |
| 145 | #define CARL9170_RF_INIT_RESULT_SIZE 4 |
| 146 | |
| 147 | #define CARL9170_PSM_SLEEP 0x1000 |
| 148 | #define CARL9170_PSM_SOFTWARE 0 |
| 149 | #define CARL9170_PSM_WAKE 0 /* internally used. */ |
| 150 | #define CARL9170_PSM_COUNTER 0xfff |
| 151 | #define CARL9170_PSM_COUNTER_S 0 |
| 152 | |
| 153 | struct carl9170_psm { |
| 154 | __le32 state; |
| 155 | } __packed; |
| 156 | #define CARL9170_PSM_SIZE 4 |
| 157 | |
Christian Lamparter | 5c89569 | 2010-09-28 23:00:59 +0200 | [diff] [blame] | 158 | struct carl9170_rx_filter_cmd { |
| 159 | __le32 rx_filter; |
| 160 | } __packed; |
| 161 | #define CARL9170_RX_FILTER_CMD_SIZE 4 |
| 162 | |
| 163 | #define CARL9170_RX_FILTER_BAD 0x01 |
| 164 | #define CARL9170_RX_FILTER_OTHER_RA 0x02 |
| 165 | #define CARL9170_RX_FILTER_DECRY_FAIL 0x04 |
| 166 | #define CARL9170_RX_FILTER_CTL_OTHER 0x08 |
| 167 | #define CARL9170_RX_FILTER_CTL_PSPOLL 0x10 |
| 168 | #define CARL9170_RX_FILTER_CTL_BACKR 0x20 |
| 169 | #define CARL9170_RX_FILTER_MGMT 0x40 |
| 170 | #define CARL9170_RX_FILTER_DATA 0x80 |
Christian Lamparter | 9e09b5c | 2011-01-22 22:46:49 +0100 | [diff] [blame] | 171 | #define CARL9170_RX_FILTER_EVERYTHING (~0) |
Christian Lamparter | 5c89569 | 2010-09-28 23:00:59 +0200 | [diff] [blame] | 172 | |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 173 | struct carl9170_bcn_ctrl_cmd { |
| 174 | __le32 vif_id; |
| 175 | __le32 mode; |
| 176 | __le32 bcn_addr; |
| 177 | __le32 bcn_len; |
| 178 | } __packed; |
| 179 | #define CARL9170_BCN_CTRL_CMD_SIZE 16 |
| 180 | |
| 181 | #define CARL9170_BCN_CTRL_DRAIN 0 |
| 182 | #define CARL9170_BCN_CTRL_CAB_TRIGGER 1 |
| 183 | |
Christian Lamparter | 85ee512 | 2011-06-30 20:27:47 +0200 | [diff] [blame^] | 184 | struct carl9170_wol_cmd { |
| 185 | __le32 flags; |
| 186 | u8 mac[6]; |
| 187 | u8 bssid[6]; |
| 188 | __le32 null_interval; |
| 189 | __le32 free_for_use2; |
| 190 | __le32 mask; |
| 191 | u8 pattern[32]; |
| 192 | } __packed; |
| 193 | |
| 194 | #define CARL9170_WOL_CMD_SIZE 60 |
| 195 | |
| 196 | #define CARL9170_WOL_DISCONNECT 1 |
| 197 | #define CARL9170_WOL_MAGIC_PKT 2 |
| 198 | |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 199 | struct carl9170_cmd_head { |
| 200 | union { |
| 201 | struct { |
| 202 | u8 len; |
| 203 | u8 cmd; |
| 204 | u8 seq; |
| 205 | u8 ext; |
| 206 | } __packed; |
| 207 | |
| 208 | u32 hdr_data; |
| 209 | } __packed; |
| 210 | } __packed; |
| 211 | |
| 212 | struct carl9170_cmd { |
| 213 | struct carl9170_cmd_head hdr; |
| 214 | union { |
| 215 | struct carl9170_set_key_cmd setkey; |
| 216 | struct carl9170_disable_key_cmd disablekey; |
| 217 | struct carl9170_u32_list echo; |
| 218 | struct carl9170_reg_list rreg; |
| 219 | struct carl9170_write_reg wreg; |
| 220 | struct carl9170_rf_init rf_init; |
| 221 | struct carl9170_psm psm; |
Christian Lamparter | 85ee512 | 2011-06-30 20:27:47 +0200 | [diff] [blame^] | 222 | struct carl9170_wol_cmd wol; |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 223 | struct carl9170_bcn_ctrl_cmd bcn_ctrl; |
Christian Lamparter | 5c89569 | 2010-09-28 23:00:59 +0200 | [diff] [blame] | 224 | struct carl9170_rx_filter_cmd rx_filter; |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 225 | u8 data[CARL9170_MAX_CMD_PAYLOAD_LEN]; |
| 226 | } __packed; |
Christian Lamparter | 3f1240e | 2010-10-29 22:44:59 +0200 | [diff] [blame] | 227 | } __packed __aligned(4); |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 228 | |
| 229 | #define CARL9170_TX_STATUS_QUEUE 3 |
| 230 | #define CARL9170_TX_STATUS_QUEUE_S 0 |
| 231 | #define CARL9170_TX_STATUS_RIX_S 2 |
| 232 | #define CARL9170_TX_STATUS_RIX (3 << CARL9170_TX_STATUS_RIX_S) |
| 233 | #define CARL9170_TX_STATUS_TRIES_S 4 |
| 234 | #define CARL9170_TX_STATUS_TRIES (7 << CARL9170_TX_STATUS_TRIES_S) |
| 235 | #define CARL9170_TX_STATUS_SUCCESS 0x80 |
| 236 | |
Christian Lamparter | 3f1240e | 2010-10-29 22:44:59 +0200 | [diff] [blame] | 237 | #ifdef __CARL9170FW__ |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 238 | /* |
| 239 | * NOTE: |
| 240 | * Both structs [carl9170_tx_status and _carl9170_tx_status] |
| 241 | * need to be "bit for bit" in sync. |
| 242 | */ |
| 243 | struct carl9170_tx_status { |
| 244 | /* |
| 245 | * Beware of compiler bugs in all gcc pre 4.4! |
| 246 | */ |
| 247 | |
| 248 | u8 cookie; |
| 249 | u8 queue:2; |
| 250 | u8 rix:2; |
| 251 | u8 tries:3; |
| 252 | u8 success:1; |
| 253 | } __packed; |
Christian Lamparter | 3f1240e | 2010-10-29 22:44:59 +0200 | [diff] [blame] | 254 | #endif /* __CARL9170FW__ */ |
| 255 | |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 256 | struct _carl9170_tx_status { |
| 257 | /* |
| 258 | * This version should be immune to all alignment bugs. |
| 259 | */ |
| 260 | |
| 261 | u8 cookie; |
| 262 | u8 info; |
| 263 | } __packed; |
| 264 | #define CARL9170_TX_STATUS_SIZE 2 |
| 265 | |
| 266 | #define CARL9170_RSP_TX_STATUS_NUM (CARL9170_MAX_CMD_PAYLOAD_LEN / \ |
| 267 | sizeof(struct _carl9170_tx_status)) |
| 268 | |
| 269 | #define CARL9170_TX_MAX_RATE_TRIES 7 |
| 270 | |
| 271 | #define CARL9170_TX_MAX_RATES 4 |
| 272 | #define CARL9170_TX_MAX_RETRY_RATES (CARL9170_TX_MAX_RATES - 1) |
| 273 | #define CARL9170_ERR_MAGIC "ERR:" |
| 274 | #define CARL9170_BUG_MAGIC "BUG:" |
| 275 | |
| 276 | struct carl9170_gpio { |
| 277 | __le32 gpio; |
| 278 | } __packed; |
| 279 | #define CARL9170_GPIO_SIZE 4 |
| 280 | |
| 281 | struct carl9170_tsf_rsp { |
| 282 | union { |
| 283 | __le32 tsf[2]; |
| 284 | __le64 tsf_64; |
| 285 | } __packed; |
| 286 | } __packed; |
| 287 | #define CARL9170_TSF_RSP_SIZE 8 |
| 288 | |
| 289 | struct carl9170_rsp { |
| 290 | struct carl9170_cmd_head hdr; |
| 291 | |
| 292 | union { |
| 293 | struct carl9170_rf_init_result rf_init_res; |
| 294 | struct carl9170_u32_list rreg_res; |
| 295 | struct carl9170_u32_list echo; |
Christian Lamparter | 3f1240e | 2010-10-29 22:44:59 +0200 | [diff] [blame] | 296 | #ifdef __CARL9170FW__ |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 297 | struct carl9170_tx_status tx_status[0]; |
Christian Lamparter | 3f1240e | 2010-10-29 22:44:59 +0200 | [diff] [blame] | 298 | #endif /* __CARL9170FW__ */ |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 299 | struct _carl9170_tx_status _tx_status[0]; |
| 300 | struct carl9170_gpio gpio; |
| 301 | struct carl9170_tsf_rsp tsf; |
| 302 | struct carl9170_psm psm; |
| 303 | u8 data[CARL9170_MAX_CMD_PAYLOAD_LEN]; |
| 304 | } __packed; |
Christian Lamparter | 3f1240e | 2010-10-29 22:44:59 +0200 | [diff] [blame] | 305 | } __packed __aligned(4); |
Christian Lamparter | aae9af6 | 2010-09-06 01:06:57 +0200 | [diff] [blame] | 306 | |
| 307 | #endif /* __CARL9170_SHARED_FWCMD_H */ |