#ifndef _ACXREG_H
#define _ACXREG_H
#define ACXREG_SOFT_RESET 0
#define ACXREG_FWMEM_ADDR 1
#define ACXREG_FWMEM_DATA 2
#define ACXREG_FWMEM_CTRL 3
#define ACXREG_FWMEM_START 4
#define ACXREG_EVENT_MASK 5
#define ACXREG_INTR_TRIG 6
#define ACXREG_INTR_MASK 7
#define ACXREG_INTR_STATUS 8
#define ACXREG_INTR_STATUS_CLR 9
#define ACXREG_INTR_ACK 10
#define ACXREG_HINTR_TRIG 11
#define ACXREG_RADIO_ENABLE 12
#define ACXREG_EEPROM_INIT 13
#define ACXREG_EEPROM_CTRL 14
#define ACXREG_EEPROM_ADDR 15
#define ACXREG_EEPROM_DATA 16
#define ACXREG_EEPROM_CONF 17
#define ACXREG_EEPROM_INFO 18
#define ACXREG_PHY_ADDR 19
#define ACXREG_PHY_DATA 20
#define ACXREG_PHY_CTRL 21
#define ACXREG_GPIO_OUT_ENABLE 22
#define ACXREG_GPIO_OUT 23
#define ACXREG_CMD_REG_OFFSET 24
#define ACXREG_INFO_REG_OFFSET 25
#define ACXREG_RESET_SENSE 26
#define ACXREG_ECPU_CTRL 27
#define ACXREG_MAX 28
#define ACXREG(reg, val) [ACXREG_##reg] = val
#define ACX_EEINFO_RADIO_TYPE_SHIFT 8
#define ACX_EEINFO_RADIO_TYPE_MASK (0xff << ACX_EEINFO_RADIO_TYPE_SHIFT)
#define ACX_EEINFO_FORM_FACTOR_MASK 0xff
#define ACX_EEINFO_HAS_RADIO_TYPE(info) ((info) & ACX_EEINFO_RADIO_TYPE_MASK)
#define ACX_EEINFO_RADIO_TYPE(info) ((info) >> ACX_EEINFO_RADIO_TYPE_SHIFT)
#define ACX_EEINFO_FORM_FACTOR(info) ((info) & ACX_EEINFO_FORM_FACTOR_MASK)
#define ACX_CMD_REG_SIZE 4
#define ACX_INFO_REG_SIZE 4
#define ACX_EE_VERSION_OFS 0x05
#define ACXRV_SOFT_RESET 0x1
#define ACXRV_FWMEM_START_OP 0x0
#define ACXRV_FWMEM_ADDR_AUTOINC 0x10000
#define ACXRV_EVENT_DISABLE 0x8000
#define ACXRV_TRIG_CMD_FINI 0x0001
#define ACXRV_TRIG_TX_FINI 0x0004
#define ACXRV_INTR_RX_DATA 0x0001
#define ACXRV_INTR_TX_FINI 0x0002
#define ACXRV_INTR_TX_XFER 0x0004
#define ACXRV_INTR_RX_FINI 0x0008
#define ACXRV_INTR_DTIM 0x0010
#define ACXRV_INTR_BEACON 0x0020
#define ACXRV_INTR_TIMER 0x0040
#define ACXRV_INTR_KEY_MISS 0x0080
#define ACXRV_INTR_WEP_FAIL 0x0100
#define ACXRV_INTR_CMD_FINI 0x0200
#define ACXRV_INTR_INFO 0x0400
#define ACXRV_INTR_OVERFLOW 0x0800
#define ACXRV_INTR_PROC_ERR 0x1000
#define ACXRV_INTR_SCAN_FINI 0x2000
#define ACXRV_INTR_FCS_THRESH 0x4000
#define ACXRV_INTR_UNKN 0x8000
#define ACXRV_INTR_ALL 0xffff
#define ACXRV_EEPROM_INIT 0x1
#define ACXRV_EEPROM_READ 0x2
#define ACXRV_PHY_WRITE 0x1
#define ACXRV_PHY_READ 0x2
#define ACXRV_PHYREG_TXPOWER 0x11
#define ACXRV_PHYREG_SENSITIVITY 0x30
#define ACXRV_ECPU_HALT 0x1
#define ACXRV_ECPU_START 0x0
#define ACXCMD_GET_CONF 0x01
#define ACXCMD_SET_CONF 0x02
#define ACXCMD_ENABLE_RXCHAN 0x03
#define ACXCMD_ENABLE_TXCHAN 0x04
#define ACXCMD_TMPLT_TIM 0x0a
#define ACXCMD_JOIN_BSS 0x0b
#define ACXCMD_WEP_MGMT 0x0c
#define ACXCMD_SLEEP 0x0f
#define ACXCMD_WAKEUP 0x10
#define ACXCMD_INIT_MEM 0x12
#define ACXCMD_TMPLT_BEACON 0x13
#define ACXCMD_TMPLT_PROBE_RESP 0x14
#define ACXCMD_TMPLT_NULL_DATA 0x15
#define ACXCMD_TMPLT_PROBE_REQ 0x16
#define ACXCMD_INIT_RADIO 0x18
#if 0
#define ACX_CONF_FW_RING 0x0003
#define ACX_CONF_MEMOPT 0x0005
#endif
#define ACX_CONF_MEMBLK_SIZE 0x0004
#define ACX_CONF_RATE_FALLBACK 0x0006
#define ACX_CONF_WEPOPT 0x0007
#define ACX_CONF_MMAP 0x0008
#define ACX_CONF_FWREV 0x000d
#define ACX_CONF_RXOPT 0x0010
#define ACX_CONF_OPTION 0x0015
#define ACX_CONF_EADDR 0x1001
#define ACX_CONF_NRETRY_SHORT 0x1005
#define ACX_CONF_NRETRY_LONG 0x1006
#define ACX_CONF_WEPKEY 0x1007
#define ACX_CONF_MSDU_LIFETIME 0x1008
#define ACX_CONF_REGDOM 0x100a
#define ACX_CONF_ANTENNA 0x100b
#define ACX_CONF_TXPOWER 0x100d
#define ACX_CONF_CCA_MODE 0x100e
#define ACX_CONF_ED_THRESH 0x100f
#define ACX_CONF_WEP_TXKEY 0x1010
struct acx_conf {
uint16_t conf_id;
uint16_t conf_data_len;
} __packed;
struct acx_conf_mmap {
struct acx_conf confcom;
uint32_t code_start;
uint32_t code_end;
uint32_t wep_cache_start;
uint32_t wep_cache_end;
uint32_t pkt_tmplt_start;
uint32_t pkt_tmplt_end;
uint32_t fw_desc_start;
uint32_t fw_desc_end;
uint32_t memblk_start;
uint32_t memblk_end;
} __packed;
struct acx_conf_wepopt {
struct acx_conf confcom;
uint16_t nkey;
uint8_t opt;
} __packed;
#define WEPOPT_HDWEP 0
struct acx_conf_eaddr {
struct acx_conf confcom;
uint8_t eaddr[IEEE80211_ADDR_LEN];
} __packed;
struct acx_conf_regdom {
struct acx_conf confcom;
uint8_t regdom;
uint8_t unknown;
} __packed;
struct acx_conf_antenna {
struct acx_conf confcom;
uint8_t antenna;
} __packed;
struct acx_conf_fwrev {
struct acx_conf confcom;
#define ACX_FWREV_LEN 20
char fw_rev[ACX_FWREV_LEN];
uint32_t hw_id;
} __packed;
struct acx_conf_nretry_long {
struct acx_conf confcom;
uint8_t nretry;
} __packed;
struct acx_conf_nretry_short {
struct acx_conf confcom;
uint8_t nretry;
} __packed;
struct acx_conf_msdu_lifetime {
struct acx_conf confcom;
uint32_t lifetime;
} __packed;
struct acx_conf_rate_fallback {
struct acx_conf confcom;
uint8_t ratefb_enable;
} __packed;
struct acx_conf_rxopt {
struct acx_conf confcom;
uint16_t opt1;
uint16_t opt2;
} __packed;
#define RXOPT1_INCL_RXBUF_HDR 0x2000
#define RXOPT1_RECV_SSID 0x0400
#define RXOPT1_FILT_BCAST 0x0200
#define RXOPT1_RECV_MCAST1 0x0100
#define RXOPT1_RECV_MCAST0 0x0080
#define RXOPT1_FILT_ALLMULTI 0x0040
#define RXOPT1_FILT_FSSID 0x0020
#define RXOPT1_FILT_FDEST 0x0010
#define RXOPT1_PROMISC 0x0008
#define RXOPT1_INCL_FCS 0x0004
#define RXOPT1_INCL_PHYHDR 0x0000
#define RXOPT2_RECV_ASSOC_REQ 0x0800
#define RXOPT2_RECV_AUTH 0x0400
#define RXOPT2_RECV_BEACON 0x0200
#define RXOPT2_RECV_CF 0x0100
#define RXOPT2_RECV_CTRL 0x0080
#define RXOPT2_RECV_DATA 0x0040
#define RXOPT2_RECV_BROKEN 0x0020
#define RXOPT2_RECV_MGMT 0x0010
#define RXOPT2_RECV_PROBE_REQ 0x0008
#define RXOPT2_RECV_PROBE_RESP 0x0004
#define RXOPT2_RECV_ACK 0x0002
#define RXOPT2_RECV_OTHER 0x0001
struct acx_conf_wep_txkey {
struct acx_conf confcom;
uint8_t wep_txkey;
} __packed;
struct acx_tmplt_null_data {
uint16_t size;
struct ieee80211_frame data;
} __packed;
struct acx_tmplt_probe_req {
uint16_t size;
union {
struct {
struct ieee80211_frame f;
uint8_t var[1];
} __packed u_data;
uint8_t u_mem[0x44];
} data;
} __packed;
#define ACX_TMPLT_PROBE_REQ_SIZ(var_len) \
(sizeof(uint16_t) + sizeof(struct ieee80211_frame) + (var_len))
struct acx_tmplt_probe_resp {
uint16_t size;
union {
struct {
struct ieee80211_frame f;
uint8_t time_stamp[8];
uint16_t beacon_intvl;
uint16_t cap;
uint8_t var[1];
} __packed u_data;
uint8_t u_mem[0x54];
} data;
} __packed;
#define ACX_TMPLT_PROBE_RESP_SIZ(var_len) \
(sizeof(uint16_t) + sizeof(struct ieee80211_frame) + \
8 * sizeof(uint8_t) + sizeof(uint16_t) + sizeof(uint16_t) + (var_len))
struct acx_tmplt_beacon {
uint16_t size;
union {
struct {
struct ieee80211_frame f;
uint8_t time_stamp[8];
uint16_t beacon_intvl;
uint16_t cap;
uint8_t var[1];
} __packed u_data;
uint8_t u_mem[0x54];
} data;
} __packed;
#define ACX_TMPLT_BEACON_SIZ(var_len) \
(sizeof(uint16_t) + sizeof(struct ieee80211_frame) + \
8 * sizeof(uint8_t) + sizeof(uint16_t) + sizeof(uint16_t) + (var_len))
struct tim_head {
uint8_t eid;
uint8_t len;
uint8_t dtim_count;
uint8_t dtim_period;
uint8_t bitmap_ctrl;
} __packed;
#define ACX_TIM_LEN(bitmap_len) \
(sizeof(struct tim_head) - (2 * sizeof(uint8_t)) + (bitmap_len))
#define ACX_TIM_BITMAP_LEN 1
struct acx_tmplt_tim {
uint16_t size;
union {
struct {
struct tim_head th;
uint8_t bitmap[1];
} __packed u_data;
uint8_t u_mem[0x100];
} data;
#define tim_eid data.u_data.th.eid
#define tim_len data.u_data.th.len
#define tim_dtim_count data.u_data.th.dtim_count
#define tim_dtim_period data.u_data.th.dtim_period
#define tim_bitmap_ctrl data.u_data.th.bitmap_ctrl
#define tim_bitmap data.u_data.bitmap
} __packed;
#define ACX_TMPLT_TIM_SIZ(bitmap_len) \
(sizeof(uint16_t) + sizeof(struct tim_head) + (bitmap_len))
#define CMDPRM_WRITE_REGION_1(sc, r, rlen) \
bus_space_write_region_1((sc)->sc_mem2_bt, \
(sc)->sc_mem2_bh, \
(sc)->sc_cmd_param, \
(const uint8_t *)(r), (rlen))
#define CMDPRM_READ_REGION_1(sc, r, rlen) \
bus_space_read_region_1((sc)->sc_mem2_bt, (sc)->sc_mem2_bh, \
(sc)->sc_cmd_param, (uint8_t *)(r), (rlen))
#define CMD_WRITE_4(sc, val) \
bus_space_write_4((sc)->sc_mem2_bt, (sc)->sc_mem2_bh, \
(sc)->sc_cmd, (val))
#define CMD_READ_4(sc) \
bus_space_read_4((sc)->sc_mem2_bt, (sc)->sc_mem2_bh, (sc)->sc_cmd)
#define ACX_CMD_STATUS_SHIFT 16
#define ACX_CMD_STATUS_OK 1
struct radio_init {
uint32_t radio_ofs;
uint32_t radio_len;
} __packed;
struct bss_join_hdr {
uint8_t bssid[IEEE80211_ADDR_LEN];
uint16_t beacon_intvl;
uint8_t chip_spec[3];
uint8_t ndata_txrate;
uint8_t ndata_txopt;
uint8_t mode;
uint8_t channel;
uint8_t esslen;
char essid[1];
} __packed;
#define ACX_NDATA_TXRATE_1 10
#define ACX_NDATA_TXRATE_2 20
#define ACX_NDATA_TXOPT_PBCC 0x40
#define ACX_NDATA_TXOPT_OFDM 0x20
#define ACX_NDATA_TXOPT_SHORT_PREAMBLE 0x10
#define BSS_JOIN_BUFLEN \
(sizeof(struct bss_join_hdr) + IEEE80211_NWID_LEN - 1)
#define BSS_JOIN_PARAM_SIZE(bj) \
(sizeof(struct bss_join_hdr) + (bj)->esslen - 1)
#define PCIR_BAR(x) (PCI_MAPS + (x) * 4)
#endif