1ceaec73dSDamien Bergamini 2ceaec73dSDamien Bergamini /*- 3*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 4718cf2ccSPedro F. Giffuni * 584ca7670SDamien Bergamini * Copyright (c) 2004-2006 6ceaec73dSDamien Bergamini * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. 7ceaec73dSDamien Bergamini * 8ceaec73dSDamien Bergamini * Redistribution and use in source and binary forms, with or without 9ceaec73dSDamien Bergamini * modification, are permitted provided that the following conditions 10ceaec73dSDamien Bergamini * are met: 11ceaec73dSDamien Bergamini * 1. Redistributions of source code must retain the above copyright 12ceaec73dSDamien Bergamini * notice unmodified, this list of conditions, and the following 13ceaec73dSDamien Bergamini * disclaimer. 14ceaec73dSDamien Bergamini * 2. Redistributions in binary form must reproduce the above copyright 15ceaec73dSDamien Bergamini * notice, this list of conditions and the following disclaimer in the 16ceaec73dSDamien Bergamini * documentation and/or other materials provided with the distribution. 17ceaec73dSDamien Bergamini * 18ceaec73dSDamien Bergamini * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19ceaec73dSDamien Bergamini * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20ceaec73dSDamien Bergamini * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21ceaec73dSDamien Bergamini * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22ceaec73dSDamien Bergamini * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23ceaec73dSDamien Bergamini * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24ceaec73dSDamien Bergamini * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25ceaec73dSDamien Bergamini * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26ceaec73dSDamien Bergamini * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27ceaec73dSDamien Bergamini * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28ceaec73dSDamien Bergamini * SUCH DAMAGE. 29ceaec73dSDamien Bergamini */ 30ceaec73dSDamien Bergamini 31ceaec73dSDamien Bergamini #define IPW_NTBD 128 32ceaec73dSDamien Bergamini #define IPW_TBD_SZ (IPW_NTBD * sizeof (struct ipw_bd)) 33ceaec73dSDamien Bergamini #define IPW_NDATA (IPW_NTBD / 2) 34ceaec73dSDamien Bergamini #define IPW_NRBD 128 35ceaec73dSDamien Bergamini #define IPW_RBD_SZ (IPW_NRBD * sizeof (struct ipw_bd)) 36ceaec73dSDamien Bergamini #define IPW_STATUS_SZ (IPW_NRBD * sizeof (struct ipw_status)) 37ceaec73dSDamien Bergamini 38ceaec73dSDamien Bergamini #define IPW_CSR_INTR 0x0008 39ceaec73dSDamien Bergamini #define IPW_CSR_INTR_MASK 0x000c 40ceaec73dSDamien Bergamini #define IPW_CSR_INDIRECT_ADDR 0x0010 41ceaec73dSDamien Bergamini #define IPW_CSR_INDIRECT_DATA 0x0014 42ceaec73dSDamien Bergamini #define IPW_CSR_AUTOINC_ADDR 0x0018 43ceaec73dSDamien Bergamini #define IPW_CSR_AUTOINC_DATA 0x001c 44ceaec73dSDamien Bergamini #define IPW_CSR_RST 0x0020 45ceaec73dSDamien Bergamini #define IPW_CSR_CTL 0x0024 46ceaec73dSDamien Bergamini #define IPW_CSR_IO 0x0030 47ceaec73dSDamien Bergamini #define IPW_CSR_TX_BASE 0x0200 48ceaec73dSDamien Bergamini #define IPW_CSR_TX_SIZE 0x0204 49ceaec73dSDamien Bergamini #define IPW_CSR_RX_BASE 0x0240 50ceaec73dSDamien Bergamini #define IPW_CSR_STATUS_BASE 0x0244 51ceaec73dSDamien Bergamini #define IPW_CSR_RX_SIZE 0x0248 52ceaec73dSDamien Bergamini #define IPW_CSR_TX_READ 0x0280 53ceaec73dSDamien Bergamini #define IPW_CSR_RX_READ 0x02a0 54ceaec73dSDamien Bergamini #define IPW_CSR_TABLE1_BASE 0x0380 55ceaec73dSDamien Bergamini #define IPW_CSR_TABLE2_BASE 0x0384 56ceaec73dSDamien Bergamini #define IPW_CSR_TX_WRITE 0x0f80 57ceaec73dSDamien Bergamini #define IPW_CSR_RX_WRITE 0x0fa0 58ceaec73dSDamien Bergamini 59ceaec73dSDamien Bergamini /* possible flags for register IPW_CSR_INTR */ 60ceaec73dSDamien Bergamini #define IPW_INTR_TX_TRANSFER 0x00000001 61ceaec73dSDamien Bergamini #define IPW_INTR_RX_TRANSFER 0x00000002 62ceaec73dSDamien Bergamini #define IPW_INTR_STATUS_CHANGE 0x00000010 63ceaec73dSDamien Bergamini #define IPW_INTR_COMMAND_DONE 0x00010000 64ceaec73dSDamien Bergamini #define IPW_INTR_FW_INIT_DONE 0x01000000 65ceaec73dSDamien Bergamini #define IPW_INTR_FATAL_ERROR 0x40000000 66ceaec73dSDamien Bergamini #define IPW_INTR_PARITY_ERROR 0x80000000 67ceaec73dSDamien Bergamini 68ceaec73dSDamien Bergamini #define IPW_INTR_MASK \ 69ceaec73dSDamien Bergamini (IPW_INTR_TX_TRANSFER | IPW_INTR_RX_TRANSFER | \ 70ceaec73dSDamien Bergamini IPW_INTR_STATUS_CHANGE | IPW_INTR_COMMAND_DONE | \ 71ceaec73dSDamien Bergamini IPW_INTR_FW_INIT_DONE | IPW_INTR_FATAL_ERROR | \ 72ceaec73dSDamien Bergamini IPW_INTR_PARITY_ERROR) 73ceaec73dSDamien Bergamini 74ceaec73dSDamien Bergamini /* possible flags for register IPW_CSR_RST */ 75ceaec73dSDamien Bergamini #define IPW_RST_PRINCETON_RESET 0x00000001 76ceaec73dSDamien Bergamini #define IPW_RST_SW_RESET 0x00000080 77ceaec73dSDamien Bergamini #define IPW_RST_MASTER_DISABLED 0x00000100 78ceaec73dSDamien Bergamini #define IPW_RST_STOP_MASTER 0x00000200 79ceaec73dSDamien Bergamini 80ceaec73dSDamien Bergamini /* possible flags for register IPW_CSR_CTL */ 81ceaec73dSDamien Bergamini #define IPW_CTL_CLOCK_READY 0x00000001 82ceaec73dSDamien Bergamini #define IPW_CTL_ALLOW_STANDBY 0x00000002 83ceaec73dSDamien Bergamini #define IPW_CTL_INIT 0x00000004 84ceaec73dSDamien Bergamini 85ceaec73dSDamien Bergamini /* possible flags for register IPW_CSR_IO */ 86ceaec73dSDamien Bergamini #define IPW_IO_GPIO1_ENABLE 0x00000008 87ceaec73dSDamien Bergamini #define IPW_IO_GPIO1_MASK 0x0000000c 88ceaec73dSDamien Bergamini #define IPW_IO_GPIO3_MASK 0x000000c0 89ceaec73dSDamien Bergamini #define IPW_IO_LED_OFF 0x00002000 90ceaec73dSDamien Bergamini #define IPW_IO_RADIO_DISABLED 0x00010000 91ceaec73dSDamien Bergamini 9288d3b172SAndrew Thompson /* state codes sent by fw on IPW_STATUS_CODE_NEWSTATE interrupt */ 9388d3b172SAndrew Thompson #define IPW_STATE_INITIALIZED 0x0001 9488d3b172SAndrew Thompson #define IPW_STATE_CC_FOUND 0x0002 /* 802.11d cc received */ 95ceaec73dSDamien Bergamini #define IPW_STATE_ASSOCIATED 0x0004 96ceaec73dSDamien Bergamini #define IPW_STATE_ASSOCIATION_LOST 0x0008 9788d3b172SAndrew Thompson #define IPW_STATE_ASSOCIATION_CHANGED 0x0010 /* assoc params changed? */ 98ceaec73dSDamien Bergamini #define IPW_STATE_SCAN_COMPLETE 0x0020 9988d3b172SAndrew Thompson #define IPW_STATE_PS_ENTER 0x0040 /* entered power-save mode */ 10088d3b172SAndrew Thompson #define IPW_STATE_PS_EXIT 0x0080 /* exited power-save mode */ 101ceaec73dSDamien Bergamini #define IPW_STATE_RADIO_DISABLED 0x0100 102ceaec73dSDamien Bergamini #define IPW_STATE_DISABLED 0x0200 10388d3b172SAndrew Thompson #define IPW_STATE_POWER_DOWN 0x0400 /* ??? */ 104ceaec73dSDamien Bergamini #define IPW_STATE_SCANNING 0x0800 105ceaec73dSDamien Bergamini 106ceaec73dSDamien Bergamini /* table1 offsets */ 107ceaec73dSDamien Bergamini #define IPW_INFO_LOCK 480 108ceaec73dSDamien Bergamini #define IPW_INFO_APS_CNT 604 109ceaec73dSDamien Bergamini #define IPW_INFO_APS_BASE 608 110ceaec73dSDamien Bergamini #define IPW_INFO_CARD_DISABLED 628 111ceaec73dSDamien Bergamini #define IPW_INFO_CURRENT_CHANNEL 756 112ceaec73dSDamien Bergamini #define IPW_INFO_CURRENT_TX_RATE 768 113ceaec73dSDamien Bergamini 114ceaec73dSDamien Bergamini /* table2 offsets */ 115ceaec73dSDamien Bergamini #define IPW_INFO_CURRENT_SSID 48 116ceaec73dSDamien Bergamini #define IPW_INFO_CURRENT_BSSID 112 117ceaec73dSDamien Bergamini 118ceaec73dSDamien Bergamini /* supported rates */ 119ceaec73dSDamien Bergamini #define IPW_RATE_DS1 1 120ceaec73dSDamien Bergamini #define IPW_RATE_DS2 2 121ceaec73dSDamien Bergamini #define IPW_RATE_DS5 4 122ceaec73dSDamien Bergamini #define IPW_RATE_DS11 8 123ceaec73dSDamien Bergamini 124ceaec73dSDamien Bergamini /* firmware binary image header */ 125ceaec73dSDamien Bergamini struct ipw_firmware_hdr { 12684ca7670SDamien Bergamini uint32_t version; 12784ca7670SDamien Bergamini uint32_t mainsz; 12884ca7670SDamien Bergamini uint32_t ucodesz; 129ceaec73dSDamien Bergamini } __packed; 130ceaec73dSDamien Bergamini 131ceaec73dSDamien Bergamini /* buffer descriptor */ 132ceaec73dSDamien Bergamini struct ipw_bd { 13384ca7670SDamien Bergamini uint32_t physaddr; 13484ca7670SDamien Bergamini uint32_t len; 13584ca7670SDamien Bergamini uint8_t flags; 136ceaec73dSDamien Bergamini #define IPW_BD_FLAG_TX_FRAME_802_3 0x00 137ceaec73dSDamien Bergamini #define IPW_BD_FLAG_TX_NOT_LAST_FRAGMENT 0x01 138ceaec73dSDamien Bergamini #define IPW_BD_FLAG_TX_FRAME_COMMAND 0x02 139ceaec73dSDamien Bergamini #define IPW_BD_FLAG_TX_FRAME_802_11 0x04 140ceaec73dSDamien Bergamini #define IPW_BD_FLAG_TX_LAST_FRAGMENT 0x08 14184ca7670SDamien Bergamini uint8_t nfrag; /* number of fragments */ 14284ca7670SDamien Bergamini uint8_t reserved[6]; 143ceaec73dSDamien Bergamini } __packed; 144ceaec73dSDamien Bergamini 145ceaec73dSDamien Bergamini /* status */ 146ceaec73dSDamien Bergamini struct ipw_status { 14784ca7670SDamien Bergamini uint32_t len; 14884ca7670SDamien Bergamini uint16_t code; 149ceaec73dSDamien Bergamini #define IPW_STATUS_CODE_COMMAND 0 150ceaec73dSDamien Bergamini #define IPW_STATUS_CODE_NEWSTATE 1 151ceaec73dSDamien Bergamini #define IPW_STATUS_CODE_DATA_802_11 2 152ceaec73dSDamien Bergamini #define IPW_STATUS_CODE_DATA_802_3 3 153ceaec73dSDamien Bergamini #define IPW_STATUS_CODE_NOTIFICATION 4 15484ca7670SDamien Bergamini uint8_t flags; 155ceaec73dSDamien Bergamini #define IPW_STATUS_FLAG_DECRYPTED 0x01 156ceaec73dSDamien Bergamini #define IPW_STATUS_FLAG_WEP_ENCRYPTED 0x02 15788d3b172SAndrew Thompson #define IPW_STATUS_FLAG_CRC_ERROR 0x04 15884ca7670SDamien Bergamini uint8_t rssi; /* received signal strength indicator */ 15988d3b172SAndrew Thompson #define IPW_RSSI_TO_DBM (-98) /* XXX fixed nf to convert dBm */ 160ceaec73dSDamien Bergamini } __packed; 161ceaec73dSDamien Bergamini 162ceaec73dSDamien Bergamini /* data header */ 163ceaec73dSDamien Bergamini struct ipw_hdr { 16484ca7670SDamien Bergamini uint32_t type; 165ceaec73dSDamien Bergamini #define IPW_HDR_TYPE_SEND 33 16684ca7670SDamien Bergamini uint32_t subtype; 16784ca7670SDamien Bergamini uint8_t encrypted; 16884ca7670SDamien Bergamini uint8_t encrypt; 16984ca7670SDamien Bergamini uint8_t keyidx; 17084ca7670SDamien Bergamini uint8_t keysz; 17184ca7670SDamien Bergamini uint8_t key[IEEE80211_KEYBUF_SIZE]; 17284ca7670SDamien Bergamini uint8_t reserved[10]; 17384ca7670SDamien Bergamini uint8_t src_addr[IEEE80211_ADDR_LEN]; 17484ca7670SDamien Bergamini uint8_t dst_addr[IEEE80211_ADDR_LEN]; 17584ca7670SDamien Bergamini uint16_t fragmentsz; 176ceaec73dSDamien Bergamini } __packed; 177ceaec73dSDamien Bergamini 178ceaec73dSDamien Bergamini /* command */ 179ceaec73dSDamien Bergamini struct ipw_cmd { 18084ca7670SDamien Bergamini uint32_t type; 181ceaec73dSDamien Bergamini #define IPW_CMD_ENABLE 2 182ceaec73dSDamien Bergamini #define IPW_CMD_SET_CONFIGURATION 6 183ceaec73dSDamien Bergamini #define IPW_CMD_SET_ESSID 8 184ceaec73dSDamien Bergamini #define IPW_CMD_SET_MANDATORY_BSSID 9 185ceaec73dSDamien Bergamini #define IPW_CMD_SET_MAC_ADDRESS 11 186ceaec73dSDamien Bergamini #define IPW_CMD_SET_MODE 12 187ceaec73dSDamien Bergamini #define IPW_CMD_SET_CHANNEL 14 188ceaec73dSDamien Bergamini #define IPW_CMD_SET_RTS_THRESHOLD 15 189ceaec73dSDamien Bergamini #define IPW_CMD_SET_FRAG_THRESHOLD 16 190ceaec73dSDamien Bergamini #define IPW_CMD_SET_POWER_MODE 17 191ceaec73dSDamien Bergamini #define IPW_CMD_SET_TX_RATES 18 192ceaec73dSDamien Bergamini #define IPW_CMD_SET_BASIC_TX_RATES 19 193ceaec73dSDamien Bergamini #define IPW_CMD_SET_WEP_KEY 20 194ceaec73dSDamien Bergamini #define IPW_CMD_SET_WEP_KEY_INDEX 25 195ceaec73dSDamien Bergamini #define IPW_CMD_SET_WEP_FLAGS 26 196ceaec73dSDamien Bergamini #define IPW_CMD_ADD_MULTICAST 27 197ceaec73dSDamien Bergamini #define IPW_CMD_SET_BEACON_INTERVAL 29 198ceaec73dSDamien Bergamini #define IPW_CMD_SET_TX_POWER_INDEX 36 199ceaec73dSDamien Bergamini #define IPW_CMD_BROADCAST_SCAN 43 200ceaec73dSDamien Bergamini #define IPW_CMD_DISABLE 44 201ceaec73dSDamien Bergamini #define IPW_CMD_SET_DESIRED_BSSID 45 202ceaec73dSDamien Bergamini #define IPW_CMD_SET_SCAN_OPTIONS 46 20388d3b172SAndrew Thompson #define IPW_CMD_SET_SCAN_DWELL_TIME 47 20488d3b172SAndrew Thompson #define IPW_CMD_SET_SHORT_RETRY 51 20588d3b172SAndrew Thompson #define IPW_CMD_SET_LONG_RETRY 52 206ceaec73dSDamien Bergamini #define IPW_CMD_PREPARE_POWER_DOWN 58 207ceaec73dSDamien Bergamini #define IPW_CMD_DISABLE_PHY 61 20888d3b172SAndrew Thompson #define IPW_CMD_SET_MSDU_TX_RATES 62 20988d3b172SAndrew Thompson #define IPW_CMD_SET_SECURITY_INFO 67 21088d3b172SAndrew Thompson #define IPW_CMD_DISASSOCIATE 68 211ceaec73dSDamien Bergamini #define IPW_CMD_SET_WPA_IE 69 21284ca7670SDamien Bergamini uint32_t subtype; 21384ca7670SDamien Bergamini uint32_t seq; 21484ca7670SDamien Bergamini uint32_t len; 21584ca7670SDamien Bergamini uint8_t data[400]; 21684ca7670SDamien Bergamini uint32_t status; 21784ca7670SDamien Bergamini uint8_t reserved[68]; 218ceaec73dSDamien Bergamini } __packed; 219ceaec73dSDamien Bergamini 220ceaec73dSDamien Bergamini /* possible values for command IPW_CMD_SET_POWER_MODE */ 221ceaec73dSDamien Bergamini #define IPW_POWER_MODE_CAM 0 22288d3b172SAndrew Thompson #define IPW_POWER_MODE_AUTO 6 223ceaec73dSDamien Bergamini 224ceaec73dSDamien Bergamini /* possible values for command IPW_CMD_SET_MODE */ 225ceaec73dSDamien Bergamini #define IPW_MODE_BSS 0 226ceaec73dSDamien Bergamini #define IPW_MODE_IBSS 1 227ceaec73dSDamien Bergamini #define IPW_MODE_MONITOR 2 228ceaec73dSDamien Bergamini 229ceaec73dSDamien Bergamini /* possible flags for command IPW_CMD_SET_WEP_FLAGS */ 230ceaec73dSDamien Bergamini #define IPW_WEPON 0x8 231ceaec73dSDamien Bergamini 232ceaec73dSDamien Bergamini /* structure for command IPW_CMD_SET_WEP_KEY */ 233ceaec73dSDamien Bergamini struct ipw_wep_key { 23484ca7670SDamien Bergamini uint8_t idx; 23584ca7670SDamien Bergamini uint8_t len; 23684ca7670SDamien Bergamini uint8_t key[13]; 237ceaec73dSDamien Bergamini } __packed; 238ceaec73dSDamien Bergamini 239ceaec73dSDamien Bergamini /* structure for command IPW_CMD_SET_SECURITY_INFORMATION */ 240ceaec73dSDamien Bergamini struct ipw_security { 24184ca7670SDamien Bergamini uint32_t ciphers; 242ceaec73dSDamien Bergamini #define IPW_CIPHER_NONE 0x00000001 243ceaec73dSDamien Bergamini #define IPW_CIPHER_WEP40 0x00000002 244ceaec73dSDamien Bergamini #define IPW_CIPHER_TKIP 0x00000004 245ceaec73dSDamien Bergamini #define IPW_CIPHER_CCMP 0x00000010 246ceaec73dSDamien Bergamini #define IPW_CIPHER_WEP104 0x00000020 247ceaec73dSDamien Bergamini #define IPW_CIPHER_CKIP 0x00000040 24884ca7670SDamien Bergamini uint16_t reserved1; 24984ca7670SDamien Bergamini uint8_t authmode; 250ceaec73dSDamien Bergamini #define IPW_AUTH_OPEN 0 251ceaec73dSDamien Bergamini #define IPW_AUTH_SHARED 1 25284ca7670SDamien Bergamini uint16_t reserved2; 253ceaec73dSDamien Bergamini } __packed; 254ceaec73dSDamien Bergamini 255ceaec73dSDamien Bergamini /* structure for command IPW_CMD_SET_SCAN_OPTIONS */ 256ceaec73dSDamien Bergamini struct ipw_scan_options { 25784ca7670SDamien Bergamini uint32_t flags; 258ceaec73dSDamien Bergamini #define IPW_SCAN_DO_NOT_ASSOCIATE 0x00000001 25988d3b172SAndrew Thompson #define IPW_SCAN_MIXED_CELL 0x00000002 260ceaec73dSDamien Bergamini #define IPW_SCAN_PASSIVE 0x00000008 26184ca7670SDamien Bergamini uint32_t channels; 262ceaec73dSDamien Bergamini } __packed; 263ceaec73dSDamien Bergamini 264ceaec73dSDamien Bergamini /* structure for command IPW_CMD_SET_CONFIGURATION */ 265ceaec73dSDamien Bergamini struct ipw_configuration { 26684ca7670SDamien Bergamini uint32_t flags; 267ceaec73dSDamien Bergamini #define IPW_CFG_PROMISCUOUS 0x00000004 268ceaec73dSDamien Bergamini #define IPW_CFG_PREAMBLE_AUTO 0x00000010 269ceaec73dSDamien Bergamini #define IPW_CFG_IBSS_AUTO_START 0x00000020 270ceaec73dSDamien Bergamini #define IPW_CFG_802_1x_ENABLE 0x00004000 271ceaec73dSDamien Bergamini #define IPW_CFG_BSS_MASK 0x00008000 272ceaec73dSDamien Bergamini #define IPW_CFG_IBSS_MASK 0x00010000 27384ca7670SDamien Bergamini uint32_t bss_chan; 27484ca7670SDamien Bergamini uint32_t ibss_chan; 275ceaec73dSDamien Bergamini } __packed; 276ceaec73dSDamien Bergamini 277ceaec73dSDamien Bergamini /* structure for command IPW_CMD_SET_WPA_IE */ 278ceaec73dSDamien Bergamini struct ipw_wpa_ie { 27984ca7670SDamien Bergamini uint16_t mask; 28084ca7670SDamien Bergamini uint16_t capinfo; 28184ca7670SDamien Bergamini uint16_t lintval; 28284ca7670SDamien Bergamini uint8_t bssid[IEEE80211_ADDR_LEN]; 28384ca7670SDamien Bergamini uint32_t len; 284ceaec73dSDamien Bergamini struct ieee80211_ie_wpa ie; 285ceaec73dSDamien Bergamini } __packed; 286ceaec73dSDamien Bergamini 287ceaec73dSDamien Bergamini /* element in AP table */ 288ceaec73dSDamien Bergamini struct ipw_node { 28984ca7670SDamien Bergamini uint32_t reserved1[2]; 29084ca7670SDamien Bergamini uint8_t bssid[IEEE80211_ADDR_LEN]; 29184ca7670SDamien Bergamini uint8_t chan; 29284ca7670SDamien Bergamini uint8_t rates; 29384ca7670SDamien Bergamini uint16_t reserved2; 29484ca7670SDamien Bergamini uint16_t capinfo; 29584ca7670SDamien Bergamini uint16_t reserved3; 29684ca7670SDamien Bergamini uint16_t intval; 29784ca7670SDamien Bergamini uint8_t reserved4[28]; 29884ca7670SDamien Bergamini uint8_t essid[IEEE80211_NWID_LEN]; 29984ca7670SDamien Bergamini uint16_t reserved5; 30084ca7670SDamien Bergamini uint8_t esslen; 30184ca7670SDamien Bergamini uint8_t reserved6[7]; 30284ca7670SDamien Bergamini uint8_t rssi; 303ceaec73dSDamien Bergamini } __packed; 304ceaec73dSDamien Bergamini 305ceaec73dSDamien Bergamini /* EEPROM = Electrically Erasable Programmable Read-Only Memory */ 306ceaec73dSDamien Bergamini 307ceaec73dSDamien Bergamini #define IPW_MEM_EEPROM_CTL 0x00300040 308ceaec73dSDamien Bergamini 309ceaec73dSDamien Bergamini #define IPW_EEPROM_RADIO 0x11 310ceaec73dSDamien Bergamini #define IPW_EEPROM_MAC 0x21 311ceaec73dSDamien Bergamini #define IPW_EEPROM_CHANNEL_LIST 0x37 312ceaec73dSDamien Bergamini 313ceaec73dSDamien Bergamini #define IPW_EEPROM_DELAY 1 /* minimum hold time (microsecond) */ 314ceaec73dSDamien Bergamini 315ceaec73dSDamien Bergamini #define IPW_EEPROM_C (1 << 0) /* Serial Clock */ 316ceaec73dSDamien Bergamini #define IPW_EEPROM_S (1 << 1) /* Chip Select */ 317ceaec73dSDamien Bergamini #define IPW_EEPROM_D (1 << 2) /* Serial data input */ 318ceaec73dSDamien Bergamini #define IPW_EEPROM_Q (1 << 4) /* Serial data output */ 319ceaec73dSDamien Bergamini 320ceaec73dSDamien Bergamini #define IPW_EEPROM_SHIFT_D 2 321ceaec73dSDamien Bergamini #define IPW_EEPROM_SHIFT_Q 4 322ceaec73dSDamien Bergamini 323ceaec73dSDamien Bergamini /* 324ceaec73dSDamien Bergamini * control and status registers access macros 325ceaec73dSDamien Bergamini */ 326ceaec73dSDamien Bergamini #define CSR_READ_1(sc, reg) \ 327ceaec73dSDamien Bergamini bus_space_read_1((sc)->sc_st, (sc)->sc_sh, (reg)) 328ceaec73dSDamien Bergamini 329ceaec73dSDamien Bergamini #define CSR_READ_2(sc, reg) \ 330ceaec73dSDamien Bergamini bus_space_read_2((sc)->sc_st, (sc)->sc_sh, (reg)) 331ceaec73dSDamien Bergamini 332ceaec73dSDamien Bergamini #define CSR_READ_4(sc, reg) \ 333ceaec73dSDamien Bergamini bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg)) 334ceaec73dSDamien Bergamini 335ceaec73dSDamien Bergamini #define CSR_WRITE_1(sc, reg, val) \ 336ceaec73dSDamien Bergamini bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val)) 337ceaec73dSDamien Bergamini 338ceaec73dSDamien Bergamini #define CSR_WRITE_2(sc, reg, val) \ 339ceaec73dSDamien Bergamini bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val)) 340ceaec73dSDamien Bergamini 341ceaec73dSDamien Bergamini #define CSR_WRITE_4(sc, reg, val) \ 342ceaec73dSDamien Bergamini bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val)) 343ceaec73dSDamien Bergamini 344ceaec73dSDamien Bergamini #define CSR_WRITE_MULTI_1(sc, reg, buf, len) \ 345ceaec73dSDamien Bergamini bus_space_write_multi_1((sc)->sc_st, (sc)->sc_sh, (reg), \ 346ceaec73dSDamien Bergamini (buf), (len)) 347ceaec73dSDamien Bergamini 348ceaec73dSDamien Bergamini /* 349ceaec73dSDamien Bergamini * indirect memory space access macros 350ceaec73dSDamien Bergamini */ 35184ca7670SDamien Bergamini #define MEM_READ_1(sc, addr) \ 35284ca7670SDamien Bergamini (CSR_WRITE_4((sc), IPW_CSR_INDIRECT_ADDR, (addr)), \ 35384ca7670SDamien Bergamini CSR_READ_1((sc), IPW_CSR_INDIRECT_DATA)) 35484ca7670SDamien Bergamini 35584ca7670SDamien Bergamini #define MEM_READ_4(sc, addr) \ 35684ca7670SDamien Bergamini (CSR_WRITE_4((sc), IPW_CSR_INDIRECT_ADDR, (addr)), \ 35784ca7670SDamien Bergamini CSR_READ_4((sc), IPW_CSR_INDIRECT_DATA)) 35884ca7670SDamien Bergamini 359ceaec73dSDamien Bergamini #define MEM_WRITE_1(sc, addr, val) do { \ 360ceaec73dSDamien Bergamini CSR_WRITE_4((sc), IPW_CSR_INDIRECT_ADDR, (addr)); \ 361ceaec73dSDamien Bergamini CSR_WRITE_1((sc), IPW_CSR_INDIRECT_DATA, (val)); \ 362ceaec73dSDamien Bergamini } while (/* CONSTCOND */0) 363ceaec73dSDamien Bergamini 364ceaec73dSDamien Bergamini #define MEM_WRITE_2(sc, addr, val) do { \ 365ceaec73dSDamien Bergamini CSR_WRITE_4((sc), IPW_CSR_INDIRECT_ADDR, (addr)); \ 366ceaec73dSDamien Bergamini CSR_WRITE_2((sc), IPW_CSR_INDIRECT_DATA, (val)); \ 367ceaec73dSDamien Bergamini } while (/* CONSTCOND */0) 368ceaec73dSDamien Bergamini 369ceaec73dSDamien Bergamini #define MEM_WRITE_4(sc, addr, val) do { \ 370ceaec73dSDamien Bergamini CSR_WRITE_4((sc), IPW_CSR_INDIRECT_ADDR, (addr)); \ 371ceaec73dSDamien Bergamini CSR_WRITE_4((sc), IPW_CSR_INDIRECT_DATA, (val)); \ 372ceaec73dSDamien Bergamini } while (/* CONSTCOND */0) 373ceaec73dSDamien Bergamini 374ceaec73dSDamien Bergamini #define MEM_WRITE_MULTI_1(sc, addr, buf, len) do { \ 375ceaec73dSDamien Bergamini CSR_WRITE_4((sc), IPW_CSR_INDIRECT_ADDR, (addr)); \ 376ceaec73dSDamien Bergamini CSR_WRITE_MULTI_1((sc), IPW_CSR_INDIRECT_DATA, (buf), (len)); \ 377ceaec73dSDamien Bergamini } while (/* CONSTCOND */0) 378ceaec73dSDamien Bergamini 379ceaec73dSDamien Bergamini /* 380ceaec73dSDamien Bergamini * EEPROM access macro 381ceaec73dSDamien Bergamini */ 382ceaec73dSDamien Bergamini #define IPW_EEPROM_CTL(sc, val) do { \ 383ceaec73dSDamien Bergamini MEM_WRITE_4((sc), IPW_MEM_EEPROM_CTL, (val)); \ 384ceaec73dSDamien Bergamini DELAY(IPW_EEPROM_DELAY); \ 385ceaec73dSDamien Bergamini } while (0) 386