Home | History | Annotate | Line # | Download | only in usb
      1  1.4  christos /*	$NetBSD: if_otusreg.h,v 1.4 2013/01/20 21:50:41 christos Exp $	*/
      2  1.1  christos /*	$OpenBSD: if_otusreg.h,v 1.6 2009/04/06 18:17:01 damien Exp $	*/
      3  1.1  christos 
      4  1.1  christos /*-
      5  1.1  christos  * Copyright (c) 2009 Damien Bergamini <damien.bergamini (at) free.fr>
      6  1.1  christos  * Copyright (c) 2007-2008 Atheros Communications, Inc.
      7  1.1  christos  *
      8  1.1  christos  * Permission to use, copy, modify, and distribute this software for any
      9  1.1  christos  * purpose with or without fee is hereby granted, provided that the above
     10  1.1  christos  * copyright notice and this permission notice appear in all copies.
     11  1.1  christos  *
     12  1.1  christos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     13  1.1  christos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     14  1.1  christos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     15  1.1  christos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     16  1.1  christos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     17  1.1  christos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     18  1.1  christos  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     19  1.1  christos  */
     20  1.3  christos #ifndef _IF_OTUSREG_H_
     21  1.3  christos #define _IF_OTUSREG_H_
     22  1.1  christos 
     23  1.1  christos /* USB Endpoints addresses. */
     24  1.1  christos #define AR_EPT_BULK_TX_NO	(UE_DIR_OUT | 1)
     25  1.1  christos #define AR_EPT_BULK_RX_NO	(UE_DIR_IN  | 2)
     26  1.1  christos #define AR_EPT_INTR_RX_NO	(UE_DIR_IN  | 3)
     27  1.1  christos #define AR_EPT_INTR_TX_NO	(UE_DIR_OUT | 4)
     28  1.1  christos 
     29  1.1  christos /* USB Requests. */
     30  1.1  christos #define AR_FW_DOWNLOAD			0x30
     31  1.1  christos #define AR_FW_DOWNLOAD_COMPLETE		0x31
     32  1.1  christos 
     33  1.1  christos /* Maximum number of writes that can fit in a single FW command is 7. */
     34  1.2  christos #define AR_FW_MAX_WRITES		7	/* 56 bytes */
     35  1.1  christos 
     36  1.1  christos #define AR_FW_INIT_ADDR			0x102800
     37  1.1  christos #define AR_FW_MAIN_ADDR			0x200000
     38  1.1  christos 
     39  1.1  christos /*
     40  1.1  christos  * AR9170 MAC registers.
     41  1.1  christos  */
     42  1.1  christos #define AR_MAC_REG_BASE			0x1c3000
     43  1.1  christos #define AR_MAC_REG_MAC_ADDR_L		(AR_MAC_REG_BASE + 0x610)
     44  1.1  christos #define AR_MAC_REG_MAC_ADDR_H		(AR_MAC_REG_BASE + 0x614)
     45  1.1  christos #define AR_MAC_REG_BSSID_L		(AR_MAC_REG_BASE + 0x618)
     46  1.1  christos #define AR_MAC_REG_BSSID_H		(AR_MAC_REG_BASE + 0x61c)
     47  1.1  christos #define AR_MAC_REG_GROUP_HASH_TBL_L	(AR_MAC_REG_BASE + 0x624)
     48  1.1  christos #define AR_MAC_REG_GROUP_HASH_TBL_H	(AR_MAC_REG_BASE + 0x628)
     49  1.4  christos #define AR_MAC_REG_RX_TIMEOUT		(AR_MAC_REG_BASE + 0x62c)
     50  1.1  christos #define AR_MAC_REG_BASIC_RATE		(AR_MAC_REG_BASE + 0x630)
     51  1.1  christos #define AR_MAC_REG_MANDATORY_RATE	(AR_MAC_REG_BASE + 0x634)
     52  1.1  christos #define AR_MAC_REG_RTS_CTS_RATE		(AR_MAC_REG_BASE + 0x638)
     53  1.1  christos #define AR_MAC_REG_BACKOFF_PROTECT	(AR_MAC_REG_BASE + 0x63c)
     54  1.1  christos #define AR_MAC_REG_RX_THRESHOLD		(AR_MAC_REG_BASE + 0x640)
     55  1.1  christos #define AR_MAC_REG_RX_PE_DELAY		(AR_MAC_REG_BASE + 0x64c)
     56  1.1  christos #define AR_MAC_REG_DYNAMIC_SIFS_ACK	(AR_MAC_REG_BASE + 0x658)
     57  1.1  christos #define AR_MAC_REG_SNIFFER		(AR_MAC_REG_BASE + 0x674)
     58  1.4  christos #define	  AR_MAC_REG_SNIFFER_ENABLE_PROMISC	(1 << 0)
     59  1.4  christos #define   AR_MAC_REG_SNIFFER_HW_MIC_CHECK	0x02000000
     60  1.4  christos #define	  AR_MAC_REG_SNIFFER_DEFAULTS		0x02000000
     61  1.4  christos #define AR_MAC_REG_ENCRYPTION		(AR_MAC_REG_BASE + 0x678)
     62  1.4  christos #define   AR_MAC_REG_ENCRYPTION_RX_SOFTWARE	(1 << 3)
     63  1.4  christos #define   AR_MAC_REG_ENCRYPTION_DEFAULTS	0x00000070
     64  1.4  christos 
     65  1.4  christos #define AR_MAC_REG_MISC_680		(AR_MAC_REG_BASE + 0x680)
     66  1.4  christos #define AR_MAC_REG_TX_UNDERRUN		(AR_MAC_REG_BASE + 0x688)
     67  1.4  christos 
     68  1.4  christos #define AR_MAC_REG_FRAMETYPE_FILTER	(AR_MAC_REG_BASE + 0x68c)
     69  1.4  christos #define	  AR_MAC_REG_FTF_ASSOC_REQ		(1 << 0)
     70  1.4  christos #define	  AR_MAC_REG_FTF_ASSOC_RESP		(1 << 1)
     71  1.4  christos #define	  AR_MAC_REG_FTF_REASSOC_REQ		(1 << 2)
     72  1.4  christos #define	  AR_MAC_REG_FTF_REASSOC_RESP		(1 << 3)
     73  1.4  christos #define	  AR_MAC_REG_FTF_PRB_REQ		(1 << 4)
     74  1.4  christos #define	  AR_MAC_REG_FTF_PRB_RESP		(1 << 5)
     75  1.4  christos #define	  AR_MAC_REG_FTF_BIT6			(1 << 6)
     76  1.4  christos #define	  AR_MAC_REG_FTF_BIT7			(1 << 7)
     77  1.4  christos #define	  AR_MAC_REG_FTF_BEACON			(1 << 8)
     78  1.4  christos #define	  AR_MAC_REG_FTF_ATIM			(1 << 9)
     79  1.4  christos #define	  AR_MAC_REG_FTF_DEASSOC		(1 << 10)
     80  1.4  christos #define	  AR_MAC_REG_FTF_AUTH			(1 << 11)
     81  1.4  christos #define	  AR_MAC_REG_FTF_DEAUTH			(1 << 12)
     82  1.4  christos #define	  AR_MAC_REG_FTF_BIT13			(1 << 13)
     83  1.4  christos #define	  AR_MAC_REG_FTF_BIT14			(1 << 14)
     84  1.4  christos #define	  AR_MAC_REG_FTF_BIT15			(1 << 15)
     85  1.4  christos #define	  AR_MAC_REG_FTF_BAR			(1 << 24)
     86  1.4  christos #define	  AR_MAC_REG_FTF_BA			(1 << 25)
     87  1.4  christos #define	  AR_MAC_REG_FTF_PSPOLL			(1 << 26)
     88  1.4  christos #define	  AR_MAC_REG_FTF_RTS			(1 << 27)
     89  1.4  christos #define	  AR_MAC_REG_FTF_CTS			(1 << 28)
     90  1.4  christos #define	  AR_MAC_REG_FTF_ACK			(1 << 29)
     91  1.4  christos #define	  AR_MAC_REG_FTF_CFE			(1 << 30)
     92  1.4  christos #define	  AR_MAC_REG_FTF_CFE_ACK		(1 << 31)
     93  1.4  christos #define	  AR_MAC_REG_FTF_DEFAULTS		0x0700ffff
     94  1.4  christos #define	  AR_MAC_REG_FTF_MONITOR		0xfd00ffff
     95  1.4  christos //#define	  AR_MAC_REG_FTF_MONITOR		0xff00ffff
     96  1.4  christos 
     97  1.1  christos #define AR_MAC_REG_ACK_EXTENSION	(AR_MAC_REG_BASE + 0x690)
     98  1.1  christos #define AR_MAC_REG_EIFS_AND_SIFS	(AR_MAC_REG_BASE + 0x698)
     99  1.1  christos #define AR_MAC_REG_BUSY			(AR_MAC_REG_BASE + 0x6e8)
    100  1.1  christos #define AR_MAC_REG_BUSY_EXT		(AR_MAC_REG_BASE + 0x6ec)
    101  1.1  christos #define AR_MAC_REG_SLOT_TIME		(AR_MAC_REG_BASE + 0x6f0)
    102  1.4  christos #define AR_MAC_REG_POWERMANAGEMENT	(AR_MAC_REG_BASE + 0x700)
    103  1.4  christos #define   AR_MAC_REG_POWERMGT_IBSS		0xe0
    104  1.4  christos #define	  AR_MAC_REG_POWERMGT_AP		0xa1
    105  1.4  christos #define	  AR_MAC_REG_POWERMGT_STA		0x02
    106  1.4  christos #define	  AR_MAC_REG_POWERMGT_AP_WDS		0x03
    107  1.4  christos #define	  AR_MAC_REG_POWERMGT_DEFAULTS		0x0f000000
    108  1.4  christos 
    109  1.1  christos #define AR_MAC_REG_AC0_CW		(AR_MAC_REG_BASE + 0xb00)
    110  1.1  christos #define AR_MAC_REG_AC1_CW		(AR_MAC_REG_BASE + 0xb04)
    111  1.1  christos #define AR_MAC_REG_AC2_CW		(AR_MAC_REG_BASE + 0xb08)
    112  1.1  christos #define AR_MAC_REG_AC3_CW		(AR_MAC_REG_BASE + 0xb0c)
    113  1.1  christos #define AR_MAC_REG_AC4_CW		(AR_MAC_REG_BASE + 0xb10)
    114  1.1  christos #define AR_MAC_REG_AC1_AC0_AIFS		(AR_MAC_REG_BASE + 0xb14)
    115  1.1  christos #define AR_MAC_REG_AC3_AC2_AIFS		(AR_MAC_REG_BASE + 0xb18)
    116  1.1  christos #define AR_MAC_REG_RETRY_MAX		(AR_MAC_REG_BASE + 0xb28)
    117  1.4  christos #define AR_MAC_REG_FCS_SELECT		(AR_MAC_REG_BASE + 0xbb0)
    118  1.4  christos #define	  AR_MAC_FCS_SWFCS			(1 << 0)
    119  1.4  christos #define	  AR_MAC_FCS_FIFO_PROT			(1 << 2)
    120  1.4  christos 
    121  1.1  christos #define AR_MAC_REG_TXOP_NOT_ENOUGH_INDICATION	\
    122  1.1  christos 					(AR_MAC_REG_BASE + 0xb30)
    123  1.1  christos #define AR_MAC_REG_AC1_AC0_TXOP		(AR_MAC_REG_BASE + 0xb44)
    124  1.1  christos #define AR_MAC_REG_AC3_AC2_TXOP		(AR_MAC_REG_BASE + 0xb48)
    125  1.4  christos 
    126  1.4  christos #define AR_MAC_REG_AMPDU_FACTOR		(AR_MAC_REG_BASE + 0xb9c)
    127  1.4  christos #define AR_MAC_REG_AMPDU_DENSITY	(AR_MAC_REG_BASE + 0xba0)
    128  1.4  christos 
    129  1.4  christos #define AR_MAC_REG_ACK_TABLE		(AR_MAC_REG_BASE + 0xc00)
    130  1.4  christos #define AR_MAC_REG_AMPDU_RX_THRESH	(AR_MAC_REG_BASE + 0xc50)
    131  1.4  christos 
    132  1.1  christos #define AR_MAC_REG_OFDM_PHY_ERRORS	(AR_MAC_REG_BASE + 0xcb4)
    133  1.1  christos #define AR_MAC_REG_CCK_PHY_ERRORS	(AR_MAC_REG_BASE + 0xcb8)
    134  1.4  christos 
    135  1.4  christos #define AR_MAC_REG_DMA			(AR_MAC_REG_BASE + 0xd30)
    136  1.4  christos #define   AR_MAC_REG_DMA_OFF			0
    137  1.4  christos #define   AR_MAC_REG_DMA_ENABLE			(1 << 8)
    138  1.4  christos 
    139  1.4  christos #define AR_MAC_REG_TXRX_MPI		(AR_MAC_REG_BASE + 0xd7c)
    140  1.4  christos #define	  AR_MAC_TXRX_MPI_TX_MPI_MASK		0x0000000f
    141  1.4  christos #define	  AR_MAC_TXRX_MPI_TX_TO_MASK		0x0000fff0
    142  1.4  christos #define	  AR_MAC_TXRX_MPI_RX_MPI_MASK		0x000f0000
    143  1.4  christos #define	  AR_MAC_TXRX_MPI_RX_TO_MASK		0xfff00000
    144  1.4  christos 
    145  1.4  christos #define AR_MAC_REG_BCN_ADDR		(AR_MAC_REG_BASE + 0xd84)
    146  1.4  christos #define AR_MAC_REG_BCN_LENGTH		(AR_MAC_REG_BASE + 0xd88)
    147  1.4  christos #define AR_MAC_REG_BCN_PLCP		(AR_MAC_REG_BASE + 0xd90)
    148  1.4  christos #define AR_MAC_REG_BCN_CTRL		(AR_MAC_REG_BASE + 0xd94)
    149  1.1  christos #define AR_MAC_REG_BCN_HT1		(AR_MAC_REG_BASE + 0xda0)
    150  1.4  christos #define AR_MAC_REG_BCN_HT2		(AR_MAC_REG_BASE + 0xda4)
    151  1.4  christos 
    152  1.4  christos /*
    153  1.4  christos  * GPIO register
    154  1.4  christos  */
    155  1.4  christos #define AR_GPIO_REG_BASE		0x1d0100
    156  1.4  christos #define AR_GPIO_REG_PORT_TYPE		(AR_GPIO_REG_BASE + 0)
    157  1.4  christos #define AR_GPIO_REG_DATA		(AR_GPIO_REG_BASE + 4)
    158  1.4  christos #define   AR_GPIO_REG_DATA_LED0_ON		(1 << 0)
    159  1.4  christos #define   AR_GPIO_REG_DATA_LED0_OFF		(0 << 0)
    160  1.4  christos #define   AR_GPIO_REG_DATA_LED1_ON		(1 << 1)
    161  1.4  christos #define   AR_GPIO_REG_DATA_LED1_OFF		(0 << 1)
    162  1.4  christos #define AR_NUM_LEDS				2
    163  1.4  christos 
    164  1.4  christos /*
    165  1.4  christos  * Power register
    166  1.4  christos  */
    167  1.4  christos #define AR_PWR_REG_BASE			0x1d4000
    168  1.4  christos #define AR_PWR_REG_CLOCK_SEL		(AR_PWR_REG_BASE + 0x008)
    169  1.4  christos #define	  AR_PWR_CLK_AHB_40MHZ			0
    170  1.4  christos #define	  AR_PWR_CLK_AHB_20_22MHZ		1
    171  1.4  christos #define	  AR_PWR_CLK_AHB_40_44MHZ		2
    172  1.4  christos #define	  AR_PWR_CLK_AHB_80_88MHZ		3
    173  1.4  christos #define	  AR_PWR_CLK_DAC_160_INV_DLY		0x70
    174  1.4  christos 
    175  1.4  christos /*
    176  1.4  christos  * USB register
    177  1.4  christos  */
    178  1.4  christos #define AR_USB_REG_BASE			0x1e1000
    179  1.4  christos #define AR_USB_REG_DMA_CTL		(AR_USB_REG_BASE + 0x108)
    180  1.4  christos #define   AR_USB_REG_DMA_CTL_ENABLE_TO_DEVICE		(1 << 0)
    181  1.4  christos #define	  AR_USB_REG_DMA_CTL_ENABLE_FROM_DEVICE		(1 << 1)
    182  1.4  christos #define	  AR_USB_REG_DMA_CTL_HIGH_SPEED			(1 << 2)
    183  1.4  christos #define	  AR_USB_REG_DMA_CTL_PACKET_MODE		(1 << 3)
    184  1.4  christos #define   AR_USB_REG_DMA_CTL_RX_STREAM_4K		(0 << 4)
    185  1.4  christos #define   AR_USB_REG_DMA_CTL_RX_STREAM_8K		(1 << 4)
    186  1.4  christos #define   AR_USB_REG_DMA_CTL_RX_STREAM_16K		(2 << 4)
    187  1.4  christos #define   AR_USB_REG_DMA_CTL_RX_STREAM_32K		(3 << 4)
    188  1.4  christos #define   AR_USB_REG_DMA_CTL_TX_STREAM_MODE		(1 << 6)
    189  1.4  christos 
    190  1.4  christos #define AR_USB_REG_MAX_AGG_UPLOAD	(AR_USB_REG_BASE + 0x110)
    191  1.4  christos #define AR_USB_REG_UPLOAD_TIME_CTL	(AR_USB_REG_BASE + 0x114)
    192  1.1  christos 
    193  1.1  christos /* Possible values for register AR_USB_MODE_CTRL. */
    194  1.1  christos #define AR_USB_DS_ENA		(1 << 0)
    195  1.1  christos #define AR_USB_US_ENA		(1 << 1)
    196  1.1  christos #define AR_USB_US_PACKET_MODE	(1 << 3)
    197  1.1  christos 
    198  1.1  christos /*
    199  1.1  christos  * PHY registers.
    200  1.1  christos  */
    201  1.1  christos #define AR_PHY_BASE			0x1c5800
    202  1.1  christos #define AR_PHY(reg)			(AR_PHY_BASE + (reg) * 4)
    203  1.1  christos #define AR_PHY_TURBO			(AR_PHY_BASE + 0x0004)
    204  1.1  christos #define AR_PHY_RF_CTL3			(AR_PHY_BASE + 0x0028)
    205  1.1  christos #define AR_PHY_RF_CTL4			(AR_PHY_BASE + 0x0034)
    206  1.1  christos #define AR_PHY_SETTLING			(AR_PHY_BASE + 0x0044)
    207  1.1  christos #define AR_PHY_RXGAIN			(AR_PHY_BASE + 0x0048)
    208  1.1  christos #define AR_PHY_DESIRED_SZ		(AR_PHY_BASE + 0x0050)
    209  1.1  christos #define AR_PHY_FIND_SIG			(AR_PHY_BASE + 0x0058)
    210  1.1  christos #define AR_PHY_AGC_CTL1			(AR_PHY_BASE + 0x005c)
    211  1.1  christos #define AR_PHY_SFCORR			(AR_PHY_BASE + 0x0068)
    212  1.1  christos #define AR_PHY_SFCORR_LOW		(AR_PHY_BASE + 0x006c)
    213  1.1  christos #define AR_PHY_TIMING_CTRL4		(AR_PHY_BASE + 0x0120)
    214  1.1  christos #define AR_PHY_TIMING5			(AR_PHY_BASE + 0x0124)
    215  1.1  christos #define AR_PHY_POWER_TX_RATE1		(AR_PHY_BASE + 0x0134)
    216  1.1  christos #define AR_PHY_POWER_TX_RATE2		(AR_PHY_BASE + 0x0138)
    217  1.1  christos #define AR_PHY_POWER_TX_RATE_MAX	(AR_PHY_BASE + 0x013c)
    218  1.1  christos #define AR_PHY_SWITCH_CHAIN_0		(AR_PHY_BASE + 0x0160)
    219  1.1  christos #define AR_PHY_SWITCH_COM		(AR_PHY_BASE + 0x0164)
    220  1.1  christos #define AR_PHY_HEAVY_CLIP_ENABLE	(AR_PHY_BASE + 0x01e0)
    221  1.1  christos #define AR_PHY_CCK_DETECT		(AR_PHY_BASE + 0x0a08)
    222  1.1  christos #define AR_PHY_GAIN_2GHZ		(AR_PHY_BASE + 0x0a0c)
    223  1.1  christos #define AR_PHY_POWER_TX_RATE3		(AR_PHY_BASE + 0x0a34)
    224  1.1  christos #define AR_PHY_POWER_TX_RATE4		(AR_PHY_BASE + 0x0a38)
    225  1.1  christos #define AR_PHY_TPCRG1			(AR_PHY_BASE + 0x0a58)
    226  1.1  christos #define AR_PHY_POWER_TX_RATE5		(AR_PHY_BASE + 0x0b8c)
    227  1.1  christos #define AR_PHY_POWER_TX_RATE6		(AR_PHY_BASE + 0x0b90)
    228  1.1  christos #define AR_PHY_POWER_TX_RATE7		(AR_PHY_BASE + 0x0bcc)
    229  1.1  christos #define AR_PHY_POWER_TX_RATE8		(AR_PHY_BASE + 0x0bd0)
    230  1.1  christos #define AR_PHY_POWER_TX_RATE9		(AR_PHY_BASE + 0x0bd4)
    231  1.1  christos #define AR_PHY_CCA			(AR_PHY_BASE + 0x3064)
    232  1.1  christos 
    233  1.1  christos #define AR_SEEPROM_HW_TYPE_OFFSET	0x1374
    234  1.1  christos #define AR_EEPROM_OFFSET		0x1600
    235  1.1  christos 
    236  1.1  christos #define AR_BANK4_CHUP			(1 << 0)
    237  1.1  christos #define AR_BANK4_BMODE_LF_SYNTH_FREQ	(1 << 1)
    238  1.1  christos #define AR_BANK4_AMODE_REFSEL(x)	((x) << 2)
    239  1.1  christos #define AR_BANK4_ADDR(x)		((x) << 5)
    240  1.1  christos 
    241  1.1  christos /* Tx descriptor. */
    242  1.1  christos struct ar_tx_head {
    243  1.1  christos 	uint16_t	len;
    244  1.1  christos 	uint16_t	macctl;
    245  1.1  christos #define AR_TX_MAC_RTS		(1 <<  0)
    246  1.1  christos #define AR_TX_MAC_CTS		(1 <<  1)
    247  1.1  christos #define AR_TX_MAC_BACKOFF	(1 <<  3)
    248  1.1  christos #define AR_TX_MAC_NOACK		(1 <<  2)
    249  1.1  christos #define AR_TX_MAC_HW_DUR	(1 <<  9)
    250  1.1  christos #define AR_TX_MAC_QID(qid)	((qid) << 10)
    251  1.1  christos #define AR_TX_MAC_RATE_PROBING	(1 << 15)
    252  1.1  christos 
    253  1.1  christos 	uint32_t	phyctl;
    254  1.1  christos /* Modulation type. */
    255  1.1  christos #define AR_TX_PHY_MT_CCK	0
    256  1.1  christos #define AR_TX_PHY_MT_OFDM	1
    257  1.1  christos #define AR_TX_PHY_MT_HT		2
    258  1.1  christos #define AR_TX_PHY_GF		(1 << 2)
    259  1.1  christos #define AR_TX_PHY_BW_SHIFT	3
    260  1.1  christos #define AR_TX_PHY_TPC_SHIFT	9
    261  1.1  christos #define AR_TX_PHY_ANTMSK(msk)	((msk) << 15)
    262  1.1  christos #define AR_TX_PHY_MCS(mcs)	((mcs) << 18)
    263  1.1  christos #define AR_TX_PHY_SHGI		(1 << 31)
    264  1.1  christos } __packed;
    265  1.1  christos 
    266  1.1  christos /* USB Rx stream mode header. */
    267  1.1  christos struct ar_rx_head {
    268  1.1  christos 	uint16_t	len;
    269  1.1  christos 	uint16_t	tag;
    270  1.1  christos #define AR_RX_HEAD_TAG	0x4e00
    271  1.1  christos } __packed;
    272  1.1  christos 
    273  1.1  christos /* Rx descriptor. */
    274  1.1  christos struct ar_rx_tail {
    275  1.1  christos 	uint8_t	rssi_ant[3];
    276  1.1  christos 	uint8_t	rssi_ant_ext[3];
    277  1.1  christos 	uint8_t	rssi;		/* Combined RSSI. */
    278  1.1  christos 	uint8_t	evm[2][6];	/* Error Vector Magnitude. */
    279  1.1  christos 	uint8_t	phy_err;
    280  1.1  christos 	uint8_t	sa_idx;
    281  1.1  christos 	uint8_t	da_idx;
    282  1.1  christos 	uint8_t	error;
    283  1.1  christos #define AR_RX_ERROR_TIMEOUT	(1 << 0)
    284  1.1  christos #define AR_RX_ERROR_OVERRUN	(1 << 1)
    285  1.1  christos #define AR_RX_ERROR_DECRYPT	(1 << 2)
    286  1.1  christos #define AR_RX_ERROR_FCS		(1 << 3)
    287  1.1  christos #define AR_RX_ERROR_BAD_RA	(1 << 4)
    288  1.1  christos #define AR_RX_ERROR_PLCP	(1 << 5)
    289  1.1  christos #define AR_RX_ERROR_MMIC	(1 << 6)
    290  1.1  christos 
    291  1.1  christos 	uint8_t	status;
    292  1.1  christos /* Modulation type (same as AR_TX_PHY_MT). */
    293  1.1  christos #define AR_RX_STATUS_MT_MASK	0x3
    294  1.1  christos #define AR_RX_STATUS_MT_CCK	0
    295  1.1  christos #define AR_RX_STATUS_MT_OFDM	1
    296  1.1  christos #define AR_RX_STATUS_MT_HT	2
    297  1.1  christos #define AR_RX_STATUS_SHPREAMBLE	(1 << 3)
    298  1.1  christos } __packed;
    299  1.1  christos 
    300  1.1  christos #define AR_PLCP_HDR_LEN	12
    301  1.1  christos /* Magic PLCP header for firmware notifications through Rx bulk pipe. */
    302  1.1  christos static uint8_t AR_PLCP_HDR_INTR[] = {
    303  1.1  christos 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    304  1.1  christos 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff
    305  1.1  christos };
    306  1.1  christos 
    307  1.1  christos /* Firmware command/reply header. */
    308  1.1  christos struct ar_cmd_hdr {
    309  1.1  christos 	uint8_t		len;
    310  1.1  christos 	uint8_t		code;
    311  1.1  christos #define AR_CMD_RREG		0x00
    312  1.1  christos #define AR_CMD_WREG		0x01
    313  1.1  christos #define AR_CMD_RMEM		0x02
    314  1.1  christos #define AR_CMD_WMEM		0x03
    315  1.1  christos #define AR_CMD_BITAND		0x04
    316  1.1  christos #define AR_CMD_BITOR		0x05
    317  1.1  christos #define AR_CMD_EKEY		0x28
    318  1.1  christos #define AR_CMD_DKEY		0x29
    319  1.1  christos #define AR_CMD_FREQUENCY	0x30
    320  1.1  christos #define AR_CMD_RF_INIT		0x31
    321  1.1  christos #define AR_CMD_SYNTH		0x32
    322  1.1  christos #define AR_CMD_FREQ_STRAT	0x33
    323  1.1  christos #define AR_CMD_ECHO		0x80
    324  1.1  christos #define AR_CMD_TALLY		0x81
    325  1.1  christos #define AR_CMD_TALLY_APD	0x82
    326  1.1  christos #define AR_CMD_CONFIG		0x83
    327  1.1  christos #define AR_CMD_RESET		0x90
    328  1.1  christos #define AR_CMD_DKRESET		0x91
    329  1.1  christos #define AR_CMD_DKTX_STATUS	0x92
    330  1.1  christos #define AR_CMD_FDC		0xa0
    331  1.1  christos #define AR_CMD_WREEPROM		0xb0
    332  1.1  christos #define AR_CMD_WFLASH		AR_CMD_WREEPROM
    333  1.1  christos #define AR_CMD_FLASH_ERASE	0xb1
    334  1.1  christos #define AR_CMD_FLASH_PROG	0xb2
    335  1.1  christos #define AR_CMD_FLASH_CHKSUM	0xb3
    336  1.1  christos #define AR_CMD_FLASH_READ	0xb4
    337  1.1  christos #define AR_CMD_FW_DL_INIT	0xb5
    338  1.1  christos #define AR_CMD_MEM_WREEPROM	0xbb
    339  1.1  christos /* Those have the 2 MSB set to 1. */
    340  1.1  christos #define AR_EVT_BEACON		0x00
    341  1.1  christos #define AR_EVT_TX_COMP		0x01
    342  1.1  christos #define AR_EVT_TBTT		0x02
    343  1.1  christos #define AR_EVT_ATIM		0x03
    344  1.1  christos 
    345  1.1  christos 	uint16_t	token;	/* Driver private data. */
    346  1.1  christos } __packed;
    347  1.1  christos 
    348  1.1  christos /* Structure for command AR_CMD_RF_INIT/AR_CMD_FREQUENCY. */
    349  1.1  christos struct ar_cmd_frequency {
    350  1.1  christos 	uint32_t	freq;
    351  1.1  christos 	uint32_t	dynht2040;
    352  1.1  christos 	uint32_t	htena;
    353  1.1  christos 	uint32_t	dsc_exp;
    354  1.1  christos 	uint32_t	dsc_man;
    355  1.1  christos 	uint32_t	dsc_shgi_exp;
    356  1.1  christos 	uint32_t	dsc_shgi_man;
    357  1.1  christos 	uint32_t	check_loop_count;
    358  1.1  christos } __packed;
    359  1.1  christos 
    360  1.1  christos /* Firmware reply for command AR_CMD_FREQUENCY. */
    361  1.1  christos struct ar_rsp_frequency {
    362  1.1  christos 	uint32_t	status;
    363  1.1  christos #define AR_CAL_ERR_AGC		(1 << 0)	/* AGC cal unfinished. */
    364  1.1  christos #define AR_CAL_ERR_NF		(1 << 1)	/* Noise cal unfinished. */
    365  1.1  christos #define AR_CAL_ERR_NF_VAL	(1 << 2)	/* NF value unexpected. */
    366  1.1  christos 
    367  1.1  christos 	uint32_t	nf[3];		/* Noisefloor. */
    368  1.1  christos 	uint32_t	nf_ext[3];	/* Noisefloor ext. */
    369  1.1  christos } __packed;
    370  1.1  christos 
    371  1.1  christos /* Structure for command AR_CMD_EKEY. */
    372  1.1  christos struct ar_cmd_ekey {
    373  1.1  christos 	uint16_t	uid;	/* user ID */
    374  1.1  christos 	uint16_t	kix;
    375  1.1  christos 	uint16_t	cipher;
    376  1.1  christos #define AR_CIPHER_NONE		0
    377  1.1  christos #define AR_CIPHER_WEP64		1
    378  1.1  christos #define AR_CIPHER_TKIP		2
    379  1.1  christos #define AR_CIPHER_AES		4
    380  1.1  christos #define AR_CIPHER_WEP128	5
    381  1.1  christos #define AR_CIPHER_WEP256	6
    382  1.1  christos #define AR_CIPHER_CENC		7
    383  1.1  christos 
    384  1.1  christos 	uint8_t		macaddr[IEEE80211_ADDR_LEN];
    385  1.1  christos 	uint8_t		key[16];
    386  1.1  christos } __packed;
    387  1.1  christos 
    388  1.1  christos /* Structure for event AR_EVT_TX_COMP. */
    389  1.1  christos struct ar_evt_tx_comp {
    390  1.1  christos 	uint8_t		macaddr[IEEE80211_ADDR_LEN];
    391  1.1  christos 	uint32_t	phy;
    392  1.1  christos 	uint16_t	status;
    393  1.1  christos #define AR_TX_STATUS_COMP	0
    394  1.1  christos #define AR_TX_STATUS_RETRY_COMP	1
    395  1.1  christos #define AR_TX_STATUS_FAILED	2
    396  1.1  christos } __packed;
    397  1.1  christos 
    398  1.1  christos /*
    399  1.1  christos  * EEPROM.
    400  1.1  christos  */
    401  1.1  christos /* Possible flags for opCapFlags. */
    402  1.1  christos #define AR5416_OPFLAGS_11A	0x01
    403  1.1  christos #define AR5416_OPFLAGS_11G	0x02
    404  1.1  christos #define AR5416_OPFLAGS_5G_HT40	0x04
    405  1.1  christos #define AR5416_OPFLAGS_2G_HT40	0x08
    406  1.1  christos #define AR5416_OPFLAGS_5G_HT20	0x10
    407  1.1  christos #define AR5416_OPFLAGS_2G_HT20	0x20
    408  1.1  christos 
    409  1.1  christos #define AR5416_NUM_5G_CAL_PIERS		8
    410  1.1  christos #define AR5416_NUM_2G_CAL_PIERS		4
    411  1.1  christos #define AR5416_NUM_5G_20_TARGET_POWERS	8
    412  1.1  christos #define AR5416_NUM_5G_40_TARGET_POWERS	8
    413  1.1  christos #define AR5416_NUM_2G_CCK_TARGET_POWERS	3
    414  1.1  christos #define AR5416_NUM_2G_20_TARGET_POWERS	4
    415  1.1  christos #define AR5416_NUM_2G_40_TARGET_POWERS	4
    416  1.1  christos #define AR5416_NUM_CTLS			24
    417  1.1  christos #define AR5416_NUM_BAND_EDGES		8
    418  1.1  christos #define AR5416_NUM_PD_GAINS		4
    419  1.1  christos #define AR5416_PD_GAIN_ICEPTS		5
    420  1.1  christos #define AR5416_EEPROM_MODAL_SPURS	5
    421  1.1  christos #define AR5416_MAX_CHAINS		2
    422  1.1  christos 
    423  1.1  christos typedef struct BaseEepHeader {
    424  1.1  christos 	uint16_t	length;
    425  1.1  christos 	uint16_t	checksum;
    426  1.1  christos 	uint16_t	version;
    427  1.1  christos 	uint8_t		opCapFlags;
    428  1.1  christos 	uint8_t		eepMisc;
    429  1.1  christos 	uint16_t	regDmn[2];
    430  1.1  christos 	uint8_t		macAddr[6];
    431  1.1  christos 	uint8_t		rxMask;
    432  1.1  christos 	uint8_t		txMask;
    433  1.1  christos 	uint16_t	rfSilent;
    434  1.1  christos 	uint16_t	blueToothOptions;
    435  1.1  christos 	uint16_t	deviceCap;
    436  1.1  christos 	uint32_t	binBuildNumber;
    437  1.1  christos 	uint8_t		deviceType;
    438  1.1  christos 	uint8_t		futureBase[33];
    439  1.1  christos } __packed BASE_EEP_HEADER;
    440  1.1  christos 
    441  1.1  christos typedef struct spurChanStruct {
    442  1.1  christos 	uint16_t	spurChan;
    443  1.1  christos 	uint8_t		spurRangeLow;
    444  1.1  christos 	uint8_t		spurRangeHigh;
    445  1.1  christos } __packed SPUR_CHAN;
    446  1.1  christos 
    447  1.1  christos typedef struct ModalEepHeader {
    448  1.1  christos 	uint32_t	antCtrlChain[AR5416_MAX_CHAINS];
    449  1.1  christos 	uint32_t	antCtrlCommon;
    450  1.1  christos 	int8_t		antennaGainCh[AR5416_MAX_CHAINS];
    451  1.1  christos 	uint8_t		switchSettling;
    452  1.1  christos 	uint8_t		txRxAttenCh[AR5416_MAX_CHAINS];
    453  1.1  christos 	uint8_t		rxTxMarginCh[AR5416_MAX_CHAINS];
    454  1.1  christos 	uint8_t		adcDesiredSize;
    455  1.1  christos 	int8_t		pgaDesiredSize;
    456  1.1  christos 	uint8_t		xlnaGainCh[AR5416_MAX_CHAINS];
    457  1.1  christos 	uint8_t		txEndToXpaOff;
    458  1.1  christos 	uint8_t		txEndToRxOn;
    459  1.1  christos 	uint8_t		txFrameToXpaOn;
    460  1.1  christos 	uint8_t		thresh62;
    461  1.1  christos 	uint8_t		noiseFloorThreshCh[AR5416_MAX_CHAINS];
    462  1.1  christos 	uint8_t		xpdGain;
    463  1.1  christos 	uint8_t		xpd;
    464  1.1  christos 	int8_t		iqCalICh[AR5416_MAX_CHAINS];
    465  1.1  christos 	int8_t		iqCalQCh[AR5416_MAX_CHAINS];
    466  1.1  christos 	uint8_t		pdGainOverlap;
    467  1.1  christos 	uint8_t		ob;
    468  1.1  christos 	uint8_t		db;
    469  1.1  christos 	uint8_t		xpaBiasLvl;
    470  1.1  christos 	uint8_t		pwrDecreaseFor2Chain;
    471  1.1  christos 	uint8_t		pwrDecreaseFor3Chain;
    472  1.1  christos 	uint8_t		txFrameToDataStart;
    473  1.1  christos 	uint8_t		txFrameToPaOn;
    474  1.1  christos 	uint8_t		ht40PowerIncForPdadc;
    475  1.1  christos 	uint8_t		bswAtten[AR5416_MAX_CHAINS];
    476  1.1  christos 	uint8_t		bswMargin[AR5416_MAX_CHAINS];
    477  1.1  christos 	uint8_t		swSettleHt40;
    478  1.1  christos 	uint8_t		futureModal[22];
    479  1.1  christos 	SPUR_CHAN	spurChans[AR5416_EEPROM_MODAL_SPURS];
    480  1.1  christos } __packed MODAL_EEP_HEADER;
    481  1.1  christos 
    482  1.1  christos typedef struct calDataPerFreq {
    483  1.1  christos 	uint8_t		pwrPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
    484  1.1  christos 	uint8_t		vpdPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
    485  1.1  christos } __packed CAL_DATA_PER_FREQ;
    486  1.1  christos 
    487  1.1  christos typedef struct CalTargetPowerLegacy {
    488  1.1  christos 	uint8_t		bChannel;
    489  1.1  christos 	uint8_t		tPow2x[4];
    490  1.1  christos } __packed CAL_TARGET_POWER_LEG;
    491  1.1  christos 
    492  1.1  christos typedef struct CalTargetPowerHt {
    493  1.1  christos 	uint8_t		bChannel;
    494  1.1  christos 	uint8_t		tPow2x[8];
    495  1.1  christos } __packed CAL_TARGET_POWER_HT;
    496  1.1  christos 
    497  1.1  christos typedef struct CalCtlEdges {
    498  1.1  christos 	uint8_t		bChannel;
    499  1.1  christos 	uint8_t		tPowerFlag;
    500  1.1  christos } __packed CAL_CTL_EDGES;
    501  1.1  christos 
    502  1.1  christos typedef struct CalCtlData {
    503  1.1  christos 	CAL_CTL_EDGES	ctlEdges[AR5416_MAX_CHAINS][AR5416_NUM_BAND_EDGES];
    504  1.1  christos } __packed CAL_CTL_DATA;
    505  1.1  christos 
    506  1.1  christos typedef struct ar5416eeprom {
    507  1.1  christos 	BASE_EEP_HEADER		baseEepHeader;
    508  1.1  christos 	uint8_t			custData[64];
    509  1.1  christos 	MODAL_EEP_HEADER	modalHeader[2];
    510  1.1  christos 	uint8_t			calFreqPier5G[AR5416_NUM_5G_CAL_PIERS];
    511  1.1  christos 	uint8_t			calFreqPier2G[AR5416_NUM_2G_CAL_PIERS];
    512  1.1  christos 	CAL_DATA_PER_FREQ	calPierData5G[AR5416_MAX_CHAINS]
    513  1.1  christos 					     [AR5416_NUM_5G_CAL_PIERS];
    514  1.1  christos 	CAL_DATA_PER_FREQ	calPierData2G[AR5416_MAX_CHAINS]
    515  1.1  christos 					     [AR5416_NUM_2G_CAL_PIERS];
    516  1.1  christos 	CAL_TARGET_POWER_LEG	calTPow5G[AR5416_NUM_5G_20_TARGET_POWERS];
    517  1.1  christos 	CAL_TARGET_POWER_HT	calTPow5GHT20[AR5416_NUM_5G_20_TARGET_POWERS];
    518  1.1  christos 	CAL_TARGET_POWER_HT	calTPow5GHT40[AR5416_NUM_5G_40_TARGET_POWERS];
    519  1.1  christos 	CAL_TARGET_POWER_LEG	calTPowCck[AR5416_NUM_2G_CCK_TARGET_POWERS];
    520  1.1  christos 	CAL_TARGET_POWER_LEG	calTPow2G[AR5416_NUM_2G_20_TARGET_POWERS];
    521  1.1  christos 	CAL_TARGET_POWER_HT	calTPow2GHT20[AR5416_NUM_2G_20_TARGET_POWERS];
    522  1.1  christos 	CAL_TARGET_POWER_HT	calTPow2GHT40[AR5416_NUM_2G_40_TARGET_POWERS];
    523  1.1  christos 	uint8_t			ctlIndex[AR5416_NUM_CTLS];
    524  1.1  christos 	CAL_CTL_DATA		ctlData[AR5416_NUM_CTLS];
    525  1.2  christos 	uint8_t			padding[3];
    526  1.1  christos } __packed AR5416_EEPROM;
    527  1.4  christos 
    528  1.3  christos #endif /* _IF_OTUSREG_H_ */
    529  1.4  christos 
    530