Home | History | Annotate | Line # | Download | only in ic
bwivar.h revision 1.10
      1  1.10    nonaka /*	$NetBSD: bwivar.h,v 1.10 2017/02/02 10:05:35 nonaka Exp $	*/
      2   1.1  macallan /*	$OpenBSD: bwivar.h,v 1.23 2008/02/25 20:36:54 mglocker Exp $	*/
      3   1.1  macallan 
      4   1.1  macallan /*
      5   1.1  macallan  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
      6   1.1  macallan  *
      7   1.1  macallan  * This code is derived from software contributed to The DragonFly Project
      8   1.1  macallan  * by Sepherosa Ziehau <sepherosa (at) gmail.com>
      9   1.1  macallan  *
     10   1.1  macallan  * Redistribution and use in source and binary forms, with or without
     11   1.1  macallan  * modification, are permitted provided that the following conditions
     12   1.1  macallan  * are met:
     13   1.1  macallan  *
     14   1.1  macallan  * 1. Redistributions of source code must retain the above copyright
     15   1.1  macallan  *    notice, this list of conditions and the following disclaimer.
     16   1.1  macallan  * 2. Redistributions in binary form must reproduce the above copyright
     17   1.1  macallan  *    notice, this list of conditions and the following disclaimer in
     18   1.1  macallan  *    the documentation and/or other materials provided with the
     19   1.1  macallan  *    distribution.
     20   1.1  macallan  * 3. Neither the name of The DragonFly Project nor the names of its
     21   1.1  macallan  *    contributors may be used to endorse or promote products derived
     22   1.1  macallan  *    from this software without specific, prior written permission.
     23   1.1  macallan  *
     24   1.1  macallan  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     25   1.1  macallan  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     26   1.1  macallan  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     27   1.1  macallan  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
     28   1.1  macallan  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     29   1.1  macallan  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
     30   1.1  macallan  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     31   1.1  macallan  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     32   1.1  macallan  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     33   1.1  macallan  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     34   1.1  macallan  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35   1.1  macallan  * SUCH DAMAGE.
     36   1.1  macallan  *
     37   1.1  macallan  * $DragonFly: src/sys/dev/netif/bwi/if_bwivar.h,v 1.1 2007/09/08 06:15:54 sephe Exp $
     38   1.1  macallan  */
     39   1.1  macallan 
     40   1.2  macallan #ifndef _DEV_IC_BWIVAR_H
     41   1.2  macallan #define _DEV_IC_BWIVAR_H
     42   1.1  macallan 
     43   1.1  macallan #define BWI_ALIGN		0x1000
     44   1.1  macallan #define BWI_RING_ALIGN		BWI_ALIGN
     45   1.1  macallan #define BWI_BUS_SPACE_MAXADDR	0x3fffffff
     46   1.1  macallan 
     47   1.1  macallan #define BWI_TX_NRING		6
     48   1.1  macallan #define BWI_TXRX_NRING		6
     49   1.1  macallan #define BWI_TX_NDESC		128
     50   1.1  macallan #define BWI_RX_NDESC		64
     51   1.1  macallan #define BWI_TXSTATS_NDESC	64
     52   1.1  macallan #define BWI_TX_NSPRDESC		2
     53   1.1  macallan #define BWI_TX_DATA_RING	1
     54   1.1  macallan 
     55   1.1  macallan /* XXX Onoe/Sample/AMRR probably need different configuration */
     56   1.1  macallan #define BWI_SHRETRY		7
     57   1.1  macallan #define BWI_LGRETRY		4
     58   1.1  macallan #define BWI_SHRETRY_FB		3
     59   1.1  macallan #define BWI_LGRETRY_FB		2
     60   1.1  macallan 
     61   1.1  macallan #define BWI_LED_EVENT_NONE	-1
     62   1.1  macallan #define BWI_LED_EVENT_POLL	0
     63   1.1  macallan #define BWI_LED_EVENT_TX	1
     64   1.1  macallan #define BWI_LED_EVENT_RX	2
     65   1.1  macallan #define BWI_LED_SLOWDOWN(dur)	(dur) = (((dur) * 3) / 2)
     66   1.1  macallan 
     67   1.1  macallan enum bwi_txpwrcb_type {
     68   1.1  macallan 	BWI_TXPWR_INIT = 0,
     69   1.1  macallan 	BWI_TXPWR_FORCE = 1,
     70   1.1  macallan 	BWI_TXPWR_CALIB = 2
     71   1.1  macallan };
     72   1.1  macallan 
     73   1.1  macallan #define BWI_NOISE_FLOOR		-95	/* TODO: noise floor calc */
     74   1.1  macallan 
     75   1.2  macallan /* [TRC: Bizarreness.  Cf. bwi_rxeof in OpenBSD's if_bwi.c and
     76   1.2  macallan    DragonFlyBSD's bwi.c.] */
     77   1.2  macallan #define BWI_FRAME_MIN_LEN(hdr)	\
     78   1.2  macallan 	((hdr) + sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
     79   1.2  macallan 
     80   1.1  macallan #define CSR_READ_4(sc, reg)			\
     81   1.1  macallan 	bus_space_read_4((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg))
     82   1.1  macallan #define CSR_READ_2(sc, reg)			\
     83   1.1  macallan 	bus_space_read_2((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg))
     84   1.1  macallan 
     85   1.1  macallan #define CSR_WRITE_4(sc, reg, val)		\
     86   1.1  macallan 	bus_space_write_4((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))
     87   1.1  macallan #define CSR_WRITE_2(sc, reg, val)		\
     88   1.1  macallan 	bus_space_write_2((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))
     89   1.1  macallan 
     90   1.1  macallan #define CSR_SETBITS_4(sc, reg, bits)		\
     91   1.1  macallan 	CSR_WRITE_4((sc), (reg), CSR_READ_4((sc), (reg)) | (bits))
     92   1.1  macallan #define CSR_SETBITS_2(sc, reg, bits)		\
     93   1.1  macallan 	CSR_WRITE_2((sc), (reg), CSR_READ_2((sc), (reg)) | (bits))
     94   1.1  macallan 
     95   1.1  macallan #define CSR_FILT_SETBITS_4(sc, reg, filt, bits) \
     96   1.1  macallan 	CSR_WRITE_4((sc), (reg), (CSR_READ_4((sc), (reg)) & (filt)) | (bits))
     97   1.1  macallan #define CSR_FILT_SETBITS_2(sc, reg, filt, bits)	\
     98   1.1  macallan 	CSR_WRITE_2((sc), (reg), (CSR_READ_2((sc), (reg)) & (filt)) | (bits))
     99   1.1  macallan 
    100   1.1  macallan #define CSR_CLRBITS_4(sc, reg, bits)		\
    101   1.1  macallan 	CSR_WRITE_4((sc), (reg), CSR_READ_4((sc), (reg)) & ~(bits))
    102   1.1  macallan #define CSR_CLRBITS_2(sc, reg, bits)		\
    103   1.1  macallan 	CSR_WRITE_2((sc), (reg), CSR_READ_2((sc), (reg)) & ~(bits))
    104   1.1  macallan 
    105   1.1  macallan struct bwi_desc32 {
    106   1.1  macallan 	/* Little endian */
    107   1.1  macallan 	uint32_t	ctrl;
    108   1.1  macallan 	uint32_t	addr;	/* BWI_DESC32_A_ */
    109   1.1  macallan } __packed;
    110   1.1  macallan 
    111   1.1  macallan #define BWI_DESC32_A_FUNC_TXRX		0x1
    112   1.1  macallan #define BWI_DESC32_A_FUNC_MASK		0xc0000000
    113   1.1  macallan #define BWI_DESC32_A_ADDR_MASK		0x3fffffff
    114   1.1  macallan 
    115   1.1  macallan #define BWI_DESC32_C_BUFLEN_MASK	0x00001fff
    116   1.1  macallan #define BWI_DESC32_C_ADDRHI_MASK	0x00030000
    117   1.1  macallan #define BWI_DESC32_C_EOR		(1 << 28)
    118   1.1  macallan #define BWI_DESC32_C_INTR		(1 << 29)
    119   1.1  macallan #define BWI_DESC32_C_FRAME_END		(1 << 30)
    120   1.1  macallan #define BWI_DESC32_C_FRAME_START	(1 << 31)
    121   1.1  macallan 
    122   1.1  macallan struct bwi_desc64 {
    123   1.1  macallan 	/* Little endian */
    124   1.1  macallan 	uint32_t	ctrl0;
    125   1.1  macallan 	uint32_t	ctrl1;
    126   1.1  macallan 	uint32_t	addr_lo;
    127   1.1  macallan 	uint32_t	addr_hi;
    128   1.1  macallan } __packed;
    129   1.1  macallan 
    130   1.1  macallan struct bwi_rxbuf_hdr {
    131   1.1  macallan 	/* Little endian */
    132   1.1  macallan 	uint16_t	rxh_buflen;	/* exclude bwi_rxbuf_hdr */
    133   1.1  macallan 	uint8_t		rxh_pad1[2];
    134   1.1  macallan 	uint16_t	rxh_flags1;
    135   1.1  macallan 	uint8_t		rxh_rssi;
    136   1.1  macallan 	uint8_t		rxh_sq;
    137   1.1  macallan 	uint16_t	rxh_phyinfo;	/* BWI_RXH_PHYINFO_ */
    138   1.1  macallan 	uint16_t	rxh_flags3;
    139   1.1  macallan 	uint16_t	rxh_flags2;	/* BWI_RXH_F2_ */
    140   1.1  macallan 	uint16_t	rxh_tsf;
    141   1.1  macallan 	uint8_t		rxh_pad3[14];	/* Padded to 30bytes */
    142   1.1  macallan } __packed;
    143   1.1  macallan 
    144   1.1  macallan #define BWI_RXH_F1_BCM2053_RSSI (1 << 14)
    145   1.1  macallan #define BWI_RXH_F1_OFDM		(1 << 0)
    146   1.1  macallan 
    147   1.1  macallan #define BWI_RXH_F2_TYPE2FRAME	(1 << 2)
    148   1.1  macallan 
    149   1.1  macallan #define BWI_RXH_F3_BCM2050_RSSI	(1 << 10)
    150   1.1  macallan 
    151   1.1  macallan #define BWI_RXH_PHYINFO_LNAGAIN	(3 << 14)
    152   1.1  macallan 
    153   1.1  macallan struct bwi_txbuf_hdr {
    154   1.1  macallan 	/* Little endian */
    155   1.1  macallan 	uint32_t	txh_mac_ctrl;	/* BWI_TXH_MAC_C_ */
    156   1.1  macallan 	uint8_t		txh_fc[2];
    157   1.1  macallan 	uint16_t	txh_unknown1;
    158   1.1  macallan 	uint16_t	txh_phy_ctrl;	/* BWI_TXH_PHY_C_ */
    159   1.1  macallan 	uint8_t		txh_ivs[16];
    160   1.1  macallan 	uint8_t		txh_addr1[IEEE80211_ADDR_LEN];
    161   1.1  macallan 	uint16_t	txh_unknown2;
    162   1.1  macallan 	uint8_t		txh_rts_fb_plcp[4];
    163   1.1  macallan 	uint16_t	txh_rts_fb_duration;
    164   1.1  macallan 	uint8_t		txh_fb_plcp[4];
    165   1.1  macallan 	uint16_t	txh_fb_duration;
    166   1.1  macallan 	uint8_t		txh_pad2[2];
    167   1.1  macallan 	uint16_t	txh_id;		/* BWI_TXH_ID_ */
    168   1.1  macallan 	uint16_t	txh_unknown3;
    169   1.1  macallan 	uint8_t		txh_rts_plcp[6];
    170   1.1  macallan 	uint8_t		txh_rts_fc[2];
    171   1.1  macallan 	uint16_t	txh_rts_duration;
    172   1.1  macallan 	uint8_t		txh_rts_ra[IEEE80211_ADDR_LEN];
    173   1.1  macallan 	uint8_t		txh_rts_ta[IEEE80211_ADDR_LEN];
    174   1.1  macallan 	uint8_t		txh_pad3[2];
    175   1.1  macallan 	uint8_t		txh_plcp[6];
    176   1.1  macallan } __packed;
    177   1.1  macallan 
    178   1.1  macallan #define BWI_TXH_ID_RING_MASK		0xe000
    179   1.1  macallan #define BWI_TXH_ID_IDX_MASK		0x1fff
    180   1.1  macallan 
    181   1.1  macallan #define BWI_TXH_PHY_C_OFDM		(1 << 0)
    182   1.1  macallan #define BWI_TXH_PHY_C_SHPREAMBLE	(1 << 4)
    183   1.1  macallan #define BWI_TXH_PHY_C_ANTMODE_MASK	0x0300
    184   1.1  macallan 
    185   1.1  macallan #define BWI_TXH_MAC_C_ACK		(1 << 0)
    186   1.1  macallan #define BWI_TXH_MAC_C_FIRST_FRAG	(1 << 3)
    187   1.1  macallan #define BWI_TXH_MAC_C_HWSEQ		(1 << 4)
    188   1.1  macallan #define BWI_TXH_MAC_C_FB_OFDM		(1 << 8)
    189   1.1  macallan 
    190   1.1  macallan struct bwi_txstats {
    191   1.1  macallan 	/* Little endian */
    192   1.1  macallan 	uint8_t		txs_pad1[4];
    193   1.1  macallan 	uint16_t	txs_id;
    194   1.1  macallan 	uint8_t		txs_flags;
    195   1.1  macallan 	uint8_t		txs_retry_cnt;
    196   1.1  macallan 	uint8_t		txs_pad2[2];
    197   1.1  macallan 	uint16_t	txs_seq;
    198   1.1  macallan 	uint16_t	txs_unknown;
    199   1.1  macallan 	uint8_t		txs_pad3[2];	/* Padded to 16bytes */
    200   1.1  macallan } __packed;
    201   1.1  macallan 
    202   1.1  macallan struct bwi_ring_data {
    203   1.1  macallan 	uint32_t		 rdata_txrx_ctrl;
    204   1.1  macallan 	bus_dma_segment_t	 rdata_seg;
    205   1.1  macallan 	bus_dmamap_t		 rdata_dmap;
    206   1.1  macallan 	bus_addr_t		 rdata_paddr;
    207   1.1  macallan 	void			*rdata_desc;
    208   1.1  macallan };
    209   1.1  macallan 
    210   1.1  macallan struct bwi_txbuf {
    211   1.1  macallan 	struct mbuf		*tb_mbuf;
    212   1.1  macallan 	bus_dmamap_t		 tb_dmap;
    213   1.1  macallan 
    214   1.1  macallan 	struct ieee80211_node	*tb_ni;
    215   1.1  macallan 	int			 tb_rate_idx[2];
    216   1.1  macallan };
    217   1.1  macallan 
    218   1.1  macallan struct bwi_txbuf_data {
    219   1.1  macallan 	struct bwi_txbuf	tbd_buf[BWI_TX_NDESC];
    220   1.1  macallan 	int			tbd_used;
    221   1.1  macallan 	int			tbd_idx;
    222   1.1  macallan };
    223   1.1  macallan 
    224   1.1  macallan struct bwi_rxbuf {
    225   1.1  macallan 	struct mbuf		*rb_mbuf;
    226   1.1  macallan 	bus_addr_t		 rb_paddr;
    227   1.1  macallan 	bus_dmamap_t		 rb_dmap;
    228   1.1  macallan };
    229   1.1  macallan 
    230   1.1  macallan struct bwi_rxbuf_data {
    231   1.1  macallan 	struct bwi_rxbuf	rbd_buf[BWI_RX_NDESC];
    232   1.1  macallan 	bus_dmamap_t		rbd_tmp_dmap;
    233   1.1  macallan 	int			rbd_idx;
    234   1.1  macallan };
    235   1.1  macallan 
    236   1.1  macallan struct bwi_txstats_data {
    237   1.1  macallan 	bus_dma_segment_t	 stats_ring_seg;
    238   1.1  macallan 	bus_dmamap_t		 stats_ring_dmap;
    239   1.1  macallan 	bus_addr_t		 stats_ring_paddr;
    240   1.1  macallan 	void			*stats_ring;
    241   1.1  macallan 
    242   1.1  macallan 	bus_dma_segment_t	 stats_seg;
    243   1.1  macallan 	bus_dmamap_t		 stats_dmap;
    244   1.1  macallan 	bus_addr_t		 stats_paddr;
    245   1.1  macallan 	struct bwi_txstats	*stats;
    246   1.1  macallan 
    247   1.1  macallan 	uint32_t		 stats_ctrl_base;
    248   1.1  macallan 	int			 stats_idx;
    249   1.1  macallan };
    250   1.1  macallan 
    251   1.1  macallan struct bwi_fwhdr {
    252   1.1  macallan 	/* Big endian */
    253   1.1  macallan 	uint8_t		fw_type;	/* BWI_FW_T_ */
    254   1.1  macallan 	uint8_t		fw_gen;		/* BWI_FW_GEN */
    255   1.1  macallan 	uint8_t		fw_pad[2];
    256   1.1  macallan 	uint32_t	fw_size;
    257   1.1  macallan #define fw_iv_cnt	fw_size
    258   1.1  macallan } __packed;
    259   1.1  macallan 
    260   1.1  macallan #define BWI_FWHDR_SZ		sizeof(struct bwi_fwhdr)
    261   1.1  macallan #define BWI_FW_VERSION3		3
    262   1.1  macallan #define BWI_FW_VERSION4		4
    263   1.1  macallan #define BWI_FW_VERSION3_REVMAX	0x128
    264   1.1  macallan #define BWI_FW_T_UCODE          'u'
    265   1.1  macallan #define BWI_FW_T_PCM            'p'
    266   1.1  macallan #define BWI_FW_T_IV             'i'
    267   1.1  macallan #define BWI_FW_GEN_1            1
    268   1.1  macallan #define BWI_FW_IV_OFS_MASK	0x7fff
    269   1.1  macallan #define BWI_FW_IV_IS_32BIT	(1 << 15)
    270   1.1  macallan 
    271   1.2  macallan #define BWI_FW_NAME_FORMAT	"v%d/%s%d.fw"
    272   1.2  macallan #define BWI_FW_UCODE_PREFIX	"ucode"
    273   1.2  macallan #define BWI_FW_PCM_PREFIX	"pcm"
    274   1.2  macallan #define BWI_FW_IV_PREFIX	"b0g0initvals"
    275   1.2  macallan #define BWI_FW_IV_EXT_PREFIX	"b0g0bsinitvals"
    276   1.2  macallan 
    277   1.2  macallan struct bwi_fw_image {
    278   1.2  macallan 	char	 fwi_name[64];
    279   1.2  macallan 	uint8_t	*fwi_data;
    280   1.2  macallan 	size_t	 fwi_size;
    281   1.1  macallan };
    282   1.1  macallan 
    283   1.1  macallan struct bwi_fw_iv {
    284   1.1  macallan 	/* Big endian */
    285   1.1  macallan 	uint16_t		iv_ofs;
    286   1.1  macallan 	union {
    287   1.1  macallan 		uint32_t	val32;
    288   1.1  macallan 		uint16_t	val16;
    289   1.1  macallan 	}			iv_val;
    290   1.1  macallan } __packed;
    291   1.1  macallan 
    292   1.1  macallan struct bwi_led {
    293   1.1  macallan 	uint8_t			l_flags;	/* BWI_LED_F_ */
    294   1.1  macallan 	uint8_t			l_act;		/* BWI_LED_ACT_ */
    295   1.1  macallan 	uint8_t			l_mask;
    296   1.1  macallan };
    297   1.1  macallan 
    298   1.1  macallan #define BWI_LED_F_ACTLOW	0x1
    299   1.1  macallan #define BWI_LED_F_BLINK		0x2
    300   1.1  macallan #define BWI_LED_F_POLLABLE	0x4
    301   1.1  macallan #define BWI_LED_F_SLOW		0x8
    302   1.1  macallan 
    303   1.1  macallan enum bwi_clock_mode {
    304   1.1  macallan 	BWI_CLOCK_MODE_SLOW,
    305   1.1  macallan 	BWI_CLOCK_MODE_FAST,
    306   1.1  macallan 	BWI_CLOCK_MODE_DYN
    307   1.1  macallan };
    308   1.1  macallan 
    309   1.1  macallan struct bwi_regwin {
    310   1.1  macallan 	uint32_t		rw_flags;	/* BWI_REGWIN_F_ */
    311   1.1  macallan 	uint16_t		rw_type;	/* BWI_REGWIN_T_ */
    312   1.1  macallan 	uint8_t			rw_id;
    313   1.1  macallan 	uint8_t			rw_rev;
    314   1.1  macallan };
    315   1.1  macallan 
    316   1.1  macallan #define BWI_REGWIN_F_EXIST	0x1
    317   1.1  macallan 
    318   1.1  macallan #define BWI_CREATE_REGWIN(rw, id, type, rev)	\
    319   1.1  macallan do {						\
    320   1.1  macallan 	(rw)->rw_flags = BWI_REGWIN_F_EXIST;	\
    321   1.1  macallan 	(rw)->rw_type = (type);			\
    322   1.1  macallan 	(rw)->rw_id = (id);			\
    323   1.1  macallan 	(rw)->rw_rev = (rev);			\
    324   1.1  macallan } while (0)
    325   1.1  macallan 
    326   1.1  macallan #define BWI_REGWIN_EXIST(rw)	((rw)->rw_flags & BWI_REGWIN_F_EXIST)
    327   1.1  macallan #define BWI_GPIO_REGWIN(sc)				\
    328   1.1  macallan 	(BWI_REGWIN_EXIST(&(sc)->sc_com_regwin) ?	\
    329   1.1  macallan 	&(sc)->sc_com_regwin : &(sc)->sc_bus_regwin)
    330   1.1  macallan 
    331   1.1  macallan struct bwi_mac;
    332   1.1  macallan 
    333   1.1  macallan struct bwi_phy {
    334   1.1  macallan 	enum ieee80211_phymode	phy_mode;
    335   1.1  macallan 	int			phy_rev;
    336   1.1  macallan 	int			phy_version;
    337   1.1  macallan 
    338   1.1  macallan 	uint32_t		phy_flags;		/* BWI_PHY_F_ */
    339   1.1  macallan 	uint16_t		phy_tbl_ctrl;
    340   1.1  macallan 	uint16_t		phy_tbl_data_lo;
    341   1.1  macallan 	uint16_t		phy_tbl_data_hi;
    342   1.1  macallan 
    343   1.1  macallan 	void			(*phy_init)(struct bwi_mac *);
    344   1.1  macallan };
    345   1.1  macallan 
    346   1.1  macallan #define BWI_PHY_F_CALIBRATED	0x1
    347   1.1  macallan #define BWI_PHY_F_LINKED	0x2
    348   1.1  macallan #define BWI_CLEAR_PHY_FLAGS	(BWI_PHY_F_CALIBRATED)
    349   1.1  macallan 
    350   1.1  macallan /* TX power control */
    351   1.1  macallan struct bwi_tpctl {
    352   1.1  macallan 	uint16_t		bbp_atten;	/* BBP attenuation: 4bits */
    353   1.1  macallan 	uint16_t		rf_atten;	/* RF attenuation */
    354   1.1  macallan 	uint16_t		tp_ctrl1;	/* ??: 3bits */
    355   1.1  macallan 	uint16_t		tp_ctrl2;	/* ??: 4bits */
    356   1.1  macallan };
    357   1.1  macallan 
    358   1.1  macallan #define BWI_RF_ATTEN_FACTOR	4
    359   1.1  macallan #define BWI_RF_ATTEN_MAX0	9
    360   1.1  macallan #define BWI_RF_ATTEN_MAX1	31
    361   1.1  macallan #define BWI_BBP_ATTEN_MAX	11
    362   1.1  macallan #define BWI_TPCTL1_MAX		7
    363   1.1  macallan 
    364   1.1  macallan struct bwi_rf_lo {
    365   1.1  macallan 	int8_t			ctrl_lo;
    366   1.1  macallan 	int8_t			ctrl_hi;
    367   1.1  macallan };
    368   1.1  macallan 
    369   1.1  macallan struct bwi_rf {
    370   1.1  macallan 	uint16_t		rf_type;	/* BWI_RF_T_ */
    371   1.1  macallan 	uint16_t		rf_manu;
    372   1.1  macallan 	int			rf_rev;
    373   1.1  macallan 
    374   1.1  macallan 	uint32_t		rf_flags;	/* BWI_RF_F_ */
    375   1.1  macallan 
    376   1.1  macallan #define BWI_RFLO_MAX		56
    377   1.1  macallan 	struct bwi_rf_lo	rf_lo[BWI_RFLO_MAX];
    378   1.1  macallan 	uint8_t			rf_lo_used[8];
    379   1.1  macallan 
    380   1.1  macallan #define BWI_INVALID_NRSSI	-1000
    381   1.1  macallan 	int16_t			rf_nrssi[2];	/* Narrow RSSI */
    382   1.1  macallan 	int32_t			rf_nrssi_slope;
    383   1.1  macallan 
    384   1.1  macallan #define BWI_NRSSI_TBLSZ		64
    385   1.1  macallan 	int8_t			rf_nrssi_table[BWI_NRSSI_TBLSZ];
    386   1.1  macallan 
    387   1.1  macallan 	uint16_t		rf_lo_gain;	/* loopback gain */
    388   1.1  macallan 	uint16_t		rf_rx_gain;	/* TRSW RX gain */
    389   1.1  macallan 
    390   1.1  macallan 	uint16_t		rf_calib;	/* RF calibration value */
    391   1.1  macallan 	uint			rf_curchan;	/* current channel */
    392   1.1  macallan 
    393   1.1  macallan 	uint16_t		rf_ctrl_rd;
    394   1.1  macallan 	int			rf_ctrl_adj;
    395   1.1  macallan 	void			(*rf_off)(struct bwi_mac *);
    396   1.1  macallan 	void			(*rf_on)(struct bwi_mac *);
    397   1.1  macallan 
    398   1.1  macallan 	void			(*rf_set_nrssi_thr)(struct bwi_mac *);
    399   1.1  macallan 	void			(*rf_calc_nrssi_slope)(struct bwi_mac *);
    400   1.1  macallan 	int			(*rf_calc_rssi)
    401   1.1  macallan 				(struct bwi_mac *,
    402   1.1  macallan 				 const struct bwi_rxbuf_hdr *);
    403   1.1  macallan 
    404   1.1  macallan 	void			(*rf_lo_update)(struct bwi_mac *);
    405   1.1  macallan 
    406   1.1  macallan #define BWI_TSSI_MAX		64
    407   1.1  macallan 	int8_t			rf_txpower_map0[BWI_TSSI_MAX];
    408   1.1  macallan 						/* Indexed by TSSI */
    409   1.1  macallan 	int			rf_idle_tssi0;
    410   1.1  macallan 
    411   1.1  macallan 	int8_t			rf_txpower_map[BWI_TSSI_MAX];
    412   1.1  macallan 	int			rf_idle_tssi;
    413   1.1  macallan 
    414   1.1  macallan 	int			rf_base_tssi;
    415   1.1  macallan 
    416   1.1  macallan 	int			rf_txpower_max;	/* dBm */
    417   1.1  macallan 
    418   1.1  macallan 	int			rf_ant_mode;	/* BWI_ANT_MODE_ */
    419   1.1  macallan };
    420   1.1  macallan 
    421   1.1  macallan #define BWI_RF_F_INITED		0x1
    422   1.1  macallan #define BWI_RF_F_ON		0x2
    423   1.1  macallan #define BWI_RF_CLEAR_FLAGS	(BWI_RF_F_INITED)
    424   1.1  macallan 
    425   1.1  macallan #define BWI_ANT_MODE_0		0
    426   1.1  macallan #define BWI_ANT_MODE_1		1
    427   1.1  macallan #define BWI_ANT_MODE_UNKN	2
    428   1.1  macallan #define BWI_ANT_MODE_AUTO	3
    429   1.1  macallan 
    430   1.1  macallan struct fw_image;
    431   1.1  macallan 
    432   1.1  macallan struct bwi_mac {
    433   1.1  macallan 	struct bwi_regwin	 mac_regwin;	/* MUST be first field */
    434   1.1  macallan #define mac_rw_flags		 mac_regwin.rw_flags
    435   1.1  macallan #define mac_type		 mac_regwin.rw_type
    436   1.1  macallan #define mac_id			 mac_regwin.rw_id
    437   1.1  macallan #define mac_rev			 mac_regwin.rw_rev
    438   1.1  macallan 	struct bwi_softc	*mac_sc;
    439   1.1  macallan 
    440   1.1  macallan 	struct bwi_phy		 mac_phy;	/* PHY I/F */
    441   1.1  macallan 	struct bwi_rf		 mac_rf;	/* RF I/F */
    442   1.1  macallan 
    443   1.1  macallan 	struct bwi_tpctl	 mac_tpctl;	/* TX power control */
    444   1.1  macallan 	uint32_t		 mac_flags;	/* BWI_MAC_F_ */
    445   1.1  macallan 
    446   1.2  macallan 	struct bwi_fw_image	 mac_ucode_fwi;
    447   1.2  macallan 	struct bwi_fw_image	 mac_pcm_fwi;
    448   1.2  macallan 	struct bwi_fw_image	 mac_iv_fwi;
    449   1.2  macallan 	struct bwi_fw_image	 mac_iv_ext_fwi;
    450   1.1  macallan };
    451   1.1  macallan 
    452   1.2  macallan #define mac_ucode mac_ucode_fwi.fwi_data
    453   1.2  macallan #define mac_ucode_size mac_ucode_fwi.fwi_size
    454   1.2  macallan #define mac_pcm mac_pcm_fwi.fwi_data
    455   1.2  macallan #define mac_pcm_size mac_pcm_fwi.fwi_size
    456   1.2  macallan #define mac_iv mac_iv_fwi.fwi_data
    457   1.2  macallan #define mac_iv_size mac_iv_fwi.fwi_size
    458   1.2  macallan #define mac_iv_ext mac_iv_ext_fwi.fwi_data
    459   1.2  macallan #define mac_iv_ext_size mac_iv_ext_fwi.fwi_size
    460   1.2  macallan 
    461   1.1  macallan #define BWI_MAC_F_BSWAP		0x1
    462   1.1  macallan #define BWI_MAC_F_TPCTL_INITED	0x2
    463   1.1  macallan #define BWI_MAC_F_HAS_TXSTATS	0x4
    464   1.1  macallan #define BWI_MAC_F_INITED	0x8
    465   1.1  macallan #define BWI_MAC_F_ENABLED	0x10
    466   1.1  macallan #define BWI_MAC_F_LOCKED	0x20	/* for debug */
    467   1.1  macallan #define BWI_MAC_F_TPCTL_ERROR	0x40
    468   1.1  macallan #define BWI_MAC_F_PHYE_RESET	0x80
    469   1.1  macallan 
    470   1.1  macallan #define BWI_CREATE_MAC(mac, sc, id, rev)	\
    471   1.1  macallan do {						\
    472   1.1  macallan 	BWI_CREATE_REGWIN(&(mac)->mac_regwin,	\
    473   1.1  macallan 	    (id), BWI_REGWIN_T_MAC, (rev));	\
    474   1.1  macallan 	(mac)->mac_sc = (sc);			\
    475   1.1  macallan } while (0)
    476   1.1  macallan 
    477   1.1  macallan #define BWI_MAC_MAX		2
    478   1.1  macallan #define BWI_LED_MAX		4
    479   1.1  macallan 
    480   1.1  macallan enum bwi_bus_space {
    481   1.1  macallan 	BWI_BUS_SPACE_30BIT = 1,
    482   1.1  macallan 	BWI_BUS_SPACE_32BIT,
    483   1.1  macallan 	BWI_BUS_SPACE_64BIT
    484   1.1  macallan };
    485   1.1  macallan 
    486   1.1  macallan #define BWI_TX_RADIOTAP_PRESENT 		\
    487   1.1  macallan 	((1 << IEEE80211_RADIOTAP_FLAGS) |	\
    488   1.1  macallan 	 (1 << IEEE80211_RADIOTAP_RATE) |	\
    489   1.1  macallan 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
    490   1.1  macallan 
    491   1.1  macallan struct bwi_tx_radiotap_hdr {
    492   1.1  macallan 	struct ieee80211_radiotap_header wt_ihdr;
    493   1.1  macallan 	uint8_t		wt_flags;
    494   1.1  macallan 	uint8_t		wt_rate;
    495   1.1  macallan 	uint16_t	wt_chan_freq;
    496   1.1  macallan 	uint16_t	wt_chan_flags;
    497   1.1  macallan };
    498   1.1  macallan 
    499   1.1  macallan #define BWI_RX_RADIOTAP_PRESENT				\
    500   1.1  macallan 	((1 << IEEE80211_RADIOTAP_TSFT) |		\
    501   1.1  macallan 	 (1 << IEEE80211_RADIOTAP_FLAGS) |		\
    502   1.1  macallan 	 (1 << IEEE80211_RADIOTAP_RATE) |		\
    503   1.1  macallan 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |		\
    504   1.1  macallan 	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |	\
    505   1.1  macallan 	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
    506   1.1  macallan 
    507   1.1  macallan struct bwi_rx_radiotap_hdr {
    508   1.1  macallan 	struct ieee80211_radiotap_header wr_ihdr;
    509   1.1  macallan 	uint64_t	wr_tsf;
    510   1.1  macallan 	uint8_t		wr_flags;
    511   1.1  macallan 	uint8_t		wr_rate;
    512   1.1  macallan 	uint16_t	wr_chan_freq;
    513   1.1  macallan 	uint16_t	wr_chan_flags;
    514   1.1  macallan 	int8_t		wr_antsignal;
    515   1.1  macallan 	int8_t		wr_antnoise;
    516   1.1  macallan 	/* TODO: sq */
    517   1.1  macallan };
    518   1.1  macallan 
    519   1.2  macallan /* [TRC: XXX amrr] */
    520   1.1  macallan struct bwi_node {
    521   1.1  macallan 	struct ieee80211_node		ni;
    522   1.1  macallan 	struct ieee80211_amrr_node	amn;
    523   1.1  macallan };
    524   1.1  macallan 
    525   1.1  macallan struct bwi_softc {
    526   1.4    cegger 	device_t		 sc_dev;
    527   1.2  macallan 	struct ethercom		 sc_ec;
    528   1.1  macallan 	struct ieee80211com	 sc_ic;
    529   1.2  macallan #define sc_if sc_ec.ec_if
    530   1.1  macallan 	uint32_t		 sc_flags;	/* BWI_F_ */
    531   1.2  macallan 	void			*sc_ih;		/* [TRC: interrupt handler] */
    532  1.10    nonaka 	void			*sc_soft_ih;
    533   1.1  macallan 
    534   1.1  macallan 	uint32_t		 sc_cap;	/* BWI_CAP_ */
    535   1.1  macallan 	uint16_t		 sc_bbp_id;	/* BWI_BBPID_ */
    536   1.1  macallan 	uint8_t			 sc_bbp_rev;
    537   1.1  macallan 	uint8_t			 sc_bbp_pkg;
    538   1.1  macallan 
    539   1.1  macallan 	uint8_t			 sc_pci_revid;
    540   1.1  macallan 	uint16_t		 sc_pci_did;
    541   1.1  macallan 	uint16_t		 sc_pci_subvid;
    542   1.1  macallan 	uint16_t		 sc_pci_subdid;
    543   1.1  macallan 
    544   1.1  macallan 	uint16_t		 sc_card_flags;	/* BWI_CARD_F_ */
    545   1.1  macallan 	uint16_t		 sc_pwron_delay;
    546   1.1  macallan 	int			 sc_locale;
    547   1.1  macallan 
    548   1.2  macallan 	/* [TRC: No clue what these are for.]
    549   1.1  macallan 	int			 sc_irq_rid;
    550   1.1  macallan 	struct resource		*sc_irq_res;
    551   1.1  macallan 	void			*sc_irq_handle;
    552   1.2  macallan 	*/
    553   1.1  macallan 
    554   1.2  macallan 	/* [TRC: Likewise.]
    555   1.1  macallan 	int			 sc_mem_rid;
    556   1.1  macallan 	struct resource		*sc_mem_res;
    557   1.2  macallan 	*/
    558   1.1  macallan 	bus_dma_tag_t		 sc_dmat;
    559   1.1  macallan 	bus_space_tag_t		 sc_mem_bt;
    560   1.1  macallan 	bus_space_handle_t	 sc_mem_bh;
    561   1.1  macallan 
    562   1.2  macallan 	struct callout		 sc_scan_ch;
    563   1.2  macallan 	struct callout		 sc_calib_ch;
    564   1.1  macallan 
    565   1.2  macallan 	/* [TRC: XXX amrr] */
    566   1.2  macallan 	struct callout		 sc_amrr_ch;
    567   1.1  macallan 	struct ieee80211_amrr	 sc_amrr;
    568   1.1  macallan 
    569   1.1  macallan 	struct bwi_regwin	*sc_cur_regwin;
    570   1.1  macallan 	struct bwi_regwin	 sc_com_regwin;
    571   1.1  macallan 	struct bwi_regwin	 sc_bus_regwin;
    572   1.1  macallan 
    573   1.1  macallan 	int			 sc_nmac;
    574   1.1  macallan 	struct bwi_mac		 sc_mac[BWI_MAC_MAX];
    575   1.1  macallan 
    576   1.1  macallan 	int			 sc_rx_rate;
    577   1.1  macallan 	int			 sc_tx_rate;
    578   1.1  macallan 	enum bwi_txpwrcb_type	 sc_txpwrcb_type;
    579   1.1  macallan 
    580   1.1  macallan 	int			 sc_led_blinking;
    581   1.1  macallan 	int			 sc_led_ticks;
    582   1.1  macallan 	struct bwi_led		*sc_blink_led;
    583   1.2  macallan 	struct callout		 sc_led_blink_ch;
    584   1.1  macallan 	int			 sc_led_blink_offdur;
    585   1.1  macallan 	struct bwi_led		 sc_leds[BWI_LED_MAX];
    586   1.1  macallan 
    587   1.1  macallan 	enum bwi_bus_space	 sc_bus_space;
    588   1.1  macallan 
    589   1.1  macallan 	struct bwi_txbuf_data	 sc_tx_bdata[BWI_TX_NRING];
    590   1.1  macallan 	struct bwi_rxbuf_data	 sc_rx_bdata;
    591   1.1  macallan 
    592   1.1  macallan 	struct bwi_ring_data	 sc_tx_rdata[BWI_TX_NRING];
    593   1.1  macallan 	struct bwi_ring_data	 sc_rx_rdata;
    594   1.1  macallan 
    595   1.1  macallan 	struct bwi_txstats_data	*sc_txstats;
    596   1.1  macallan 
    597   1.1  macallan 	int			 sc_tx_timer;
    598   1.1  macallan 
    599   1.1  macallan 	int			 (*sc_newstate)
    600   1.1  macallan 				 (struct ieee80211com *,
    601   1.1  macallan 				     enum ieee80211_state, int);
    602   1.1  macallan 
    603   1.1  macallan 	int			 (*sc_init_tx_ring)(struct bwi_softc *, int);
    604   1.1  macallan 	void			 (*sc_free_tx_ring)(struct bwi_softc *, int);
    605   1.1  macallan 
    606   1.1  macallan 	int			 (*sc_init_rx_ring)(struct bwi_softc *);
    607   1.1  macallan 	void			 (*sc_free_rx_ring)(struct bwi_softc *);
    608   1.1  macallan 
    609   1.1  macallan 	int			 (*sc_init_txstats)(struct bwi_softc *);
    610   1.1  macallan 	void			 (*sc_free_txstats)(struct bwi_softc *);
    611   1.1  macallan 
    612   1.1  macallan 	void			 (*sc_setup_rxdesc)
    613   1.1  macallan 				 (struct bwi_softc *, int, bus_addr_t, int);
    614   1.1  macallan 	int			 (*sc_rxeof)(struct bwi_softc *);
    615   1.1  macallan 
    616   1.1  macallan 	void			 (*sc_setup_txdesc)
    617   1.1  macallan 				 (struct bwi_softc *, struct bwi_ring_data *,
    618   1.1  macallan 				     int, bus_addr_t, int);
    619   1.1  macallan 	void			 (*sc_start_tx)
    620   1.1  macallan 				 (struct bwi_softc *, uint32_t, int);
    621   1.1  macallan 
    622   1.1  macallan 	void			 (*sc_txeof_status)(struct bwi_softc *);
    623   1.1  macallan 
    624   1.9  nakayama 	int			 (*sc_enable)(struct bwi_softc *, int);
    625   1.9  nakayama 	void			 (*sc_disable)(struct bwi_softc *, int);
    626   1.1  macallan 
    627   1.1  macallan 	void			 (*sc_conf_write)(void *, uint32_t, uint32_t);
    628   1.1  macallan 	uint32_t		 (*sc_conf_read)(void *, uint32_t);
    629   1.1  macallan 
    630   1.2  macallan 	struct sysctllog	*sc_sysctllog;
    631   1.2  macallan 
    632   1.1  macallan 	/* Sysctl variables */
    633   1.1  macallan 	int			 sc_fw_version;	/* BWI_FW_VERSION[34] */
    634   1.1  macallan 	int			 sc_dwell_time;	/* milliseconds */
    635   1.1  macallan 	int			 sc_led_idle;
    636   1.1  macallan 	int			 sc_led_blink;
    637   1.2  macallan 	int			 sc_txpwr_calib;
    638   1.2  macallan 	int			 sc_debug;	/* BWI_DBG_ */
    639   1.1  macallan 
    640   1.2  macallan 	struct bpf_if		*sc_drvbpf;
    641   1.1  macallan 
    642   1.2  macallan 	union {
    643   1.2  macallan 		struct bwi_rx_radiotap_hdr th;
    644   1.2  macallan 		uint8_t pad[64];
    645   1.2  macallan 	}			 sc_rxtapu;
    646   1.2  macallan #define sc_rxtap		 sc_rxtapu.th
    647   1.2  macallan 	int			 sc_rxtap_len;
    648   1.1  macallan 
    649   1.2  macallan 	union {
    650   1.2  macallan 		struct bwi_tx_radiotap_hdr th;
    651   1.2  macallan 		uint8_t pad[64];
    652   1.2  macallan 	}			 sc_txtapu;
    653   1.2  macallan #define sc_txtap		 sc_txtapu.th
    654   1.2  macallan 	int			 sc_txtap_len;
    655   1.1  macallan };
    656   1.1  macallan 
    657   1.1  macallan #define BWI_F_BUS_INITED	0x1
    658   1.1  macallan #define BWI_F_PROMISC		0x2
    659   1.1  macallan 
    660   1.2  macallan #define BWI_DBG_MAC		0x00000001
    661   1.2  macallan #define BWI_DBG_RF		0x00000002
    662   1.2  macallan #define BWI_DBG_PHY		0x00000004
    663   1.2  macallan #define BWI_DBG_MISC		0x00000008
    664   1.2  macallan 
    665   1.2  macallan #define BWI_DBG_ATTACH		0x00000010
    666   1.2  macallan #define BWI_DBG_INIT		0x00000020
    667   1.2  macallan #define BWI_DBG_FIRMWARE	0x00000040
    668   1.2  macallan #define BWI_DBG_80211		0x00000080
    669   1.2  macallan #define BWI_DBG_TXPOWER		0x00000100
    670   1.2  macallan #define BWI_DBG_INTR		0x00000200
    671   1.2  macallan #define BWI_DBG_RX		0x00000400
    672   1.2  macallan #define BWI_DBG_TX		0x00000800
    673   1.2  macallan #define BWI_DBG_TXEOF		0x00001000
    674   1.2  macallan #define BWI_DBG_LED		0x00002000
    675   1.2  macallan #define BWI_DBG_STATION		0x00004000
    676   1.2  macallan 
    677   1.1  macallan #define abs(a)	__builtin_abs(a)
    678   1.1  macallan 
    679   1.1  macallan #define MOBJ_WRITE_2(mac, objid, ofs, val)			\
    680   1.1  macallan 	bwi_memobj_write_2((mac), (objid), (ofs), (val))
    681   1.1  macallan #define MOBJ_WRITE_4(mac, objid, ofs, val)			\
    682   1.1  macallan 	bwi_memobj_write_4((mac), (objid), (ofs), (val))
    683   1.1  macallan #define MOBJ_READ_2(mac, objid, ofs)				\
    684   1.1  macallan 	bwi_memobj_read_2((mac), (objid), (ofs))
    685   1.1  macallan #define MOBJ_READ_4(mac, objid, ofs)				\
    686   1.1  macallan 	bwi_memobj_read_4((mac), (objid), (ofs))
    687   1.1  macallan 
    688   1.1  macallan #define MOBJ_SETBITS_4(mac, objid, ofs, bits)			\
    689   1.1  macallan 	MOBJ_WRITE_4((mac), (objid), (ofs),			\
    690   1.1  macallan 	MOBJ_READ_4((mac), (objid), (ofs)) | (bits))
    691   1.1  macallan #define MOBJ_CLRBITS_4(mac, objid, ofs, bits)			\
    692   1.1  macallan 	MOBJ_WRITE_4((mac), (objid), (ofs),			\
    693   1.1  macallan 	MOBJ_READ_4((mac), (objid), (ofs)) & ~(bits))
    694   1.1  macallan 
    695   1.1  macallan #define MOBJ_FILT_SETBITS_2(mac, objid, ofs, filt, bits)	\
    696   1.1  macallan 	MOBJ_WRITE_2((mac), (objid), (ofs),			\
    697   1.1  macallan 	(MOBJ_READ_2((mac), (objid), (ofs)) & (filt)) | (bits))
    698   1.1  macallan 
    699   1.1  macallan #define TMPLT_WRITE_4(mac, ofs, val)	bwi_tmplt_write_4((mac), (ofs), (val))
    700   1.1  macallan 
    701   1.1  macallan #define HFLAGS_WRITE(mac, flags)	bwi_hostflags_write((mac), (flags))
    702   1.1  macallan #define HFLAGS_READ(mac)		bwi_hostflags_read((mac))
    703   1.1  macallan #define HFLAGS_CLRBITS(mac, bits)				\
    704   1.1  macallan 	HFLAGS_WRITE((mac), HFLAGS_READ((mac)) | (bits))
    705   1.1  macallan #define HFLAGS_SETBITS(mac, bits)				\
    706   1.1  macallan 	HFLAGS_WRITE((mac), HFLAGS_READ((mac)) & ~(bits))
    707   1.1  macallan 
    708   1.1  macallan /* PHY */
    709   1.1  macallan 
    710   1.1  macallan struct bwi_gains {
    711   1.1  macallan 	int16_t	tbl_gain1;
    712   1.1  macallan 	int16_t	tbl_gain2;
    713   1.1  macallan 	int16_t	phy_gain;
    714   1.1  macallan };
    715   1.1  macallan 
    716   1.1  macallan static __inline void
    717   1.1  macallan bwi_phy_init(struct bwi_mac *_mac)
    718   1.1  macallan {
    719   1.1  macallan 	_mac->mac_phy.phy_init(_mac);
    720   1.1  macallan }
    721   1.1  macallan 
    722   1.1  macallan #define PHY_WRITE(mac, ctrl, val)	bwi_phy_write((mac), (ctrl), (val))
    723   1.1  macallan #define PHY_READ(mac, ctrl)		bwi_phy_read((mac), (ctrl))
    724   1.1  macallan 
    725   1.1  macallan #define PHY_SETBITS(mac, ctrl, bits)		\
    726   1.1  macallan 	PHY_WRITE((mac), (ctrl), PHY_READ((mac), (ctrl)) | (bits))
    727   1.1  macallan #define PHY_CLRBITS(mac, ctrl, bits)		\
    728   1.1  macallan 	PHY_WRITE((mac), (ctrl), PHY_READ((mac), (ctrl)) & ~(bits))
    729   1.1  macallan #define PHY_FILT_SETBITS(mac, ctrl, filt, bits)	\
    730   1.1  macallan 	PHY_WRITE((mac), (ctrl), (PHY_READ((mac), (ctrl)) & (filt)) | (bits))
    731   1.1  macallan 
    732   1.1  macallan static __inline void
    733   1.1  macallan bwi_rf_off(struct bwi_mac *_mac)
    734   1.1  macallan {
    735   1.1  macallan 	_mac->mac_rf.rf_off(_mac);
    736   1.1  macallan 	/* TODO: LED */
    737   1.1  macallan 
    738   1.1  macallan 	_mac->mac_rf.rf_flags &= ~BWI_RF_F_ON;
    739   1.1  macallan }
    740   1.1  macallan 
    741   1.1  macallan static __inline void
    742   1.1  macallan bwi_rf_on(struct bwi_mac *_mac)
    743   1.1  macallan {
    744   1.1  macallan 	if (_mac->mac_rf.rf_flags & BWI_RF_F_ON)
    745   1.1  macallan 		return;
    746   1.1  macallan 
    747   1.1  macallan 	_mac->mac_rf.rf_on(_mac);
    748   1.1  macallan 	/* TODO: LED */
    749   1.1  macallan 
    750   1.1  macallan 	_mac->mac_rf.rf_flags |= BWI_RF_F_ON;
    751   1.1  macallan }
    752   1.1  macallan 
    753   1.1  macallan static __inline void
    754   1.1  macallan bwi_rf_calc_nrssi_slope(struct bwi_mac *_mac)
    755   1.1  macallan {
    756   1.1  macallan 	_mac->mac_rf.rf_calc_nrssi_slope(_mac);
    757   1.1  macallan }
    758   1.1  macallan 
    759   1.1  macallan static __inline void
    760   1.1  macallan bwi_rf_set_nrssi_thr(struct bwi_mac *_mac)
    761   1.1  macallan {
    762   1.1  macallan 	_mac->mac_rf.rf_set_nrssi_thr(_mac);
    763   1.1  macallan }
    764   1.1  macallan 
    765   1.1  macallan static __inline int
    766   1.1  macallan bwi_rf_calc_rssi(struct bwi_mac *_mac, const struct bwi_rxbuf_hdr *_hdr)
    767   1.1  macallan {
    768   1.1  macallan 	return (_mac->mac_rf.rf_calc_rssi(_mac, _hdr));
    769   1.1  macallan }
    770   1.1  macallan 
    771   1.1  macallan static __inline void
    772   1.1  macallan bwi_rf_lo_update(struct bwi_mac *_mac)
    773   1.1  macallan {
    774   1.8  dholland 	_mac->mac_rf.rf_lo_update(_mac);
    775   1.1  macallan }
    776   1.1  macallan 
    777   1.1  macallan #define RF_WRITE(mac, ofs, val)		bwi_rf_write((mac), (ofs), (val))
    778   1.1  macallan #define RF_READ(mac, ofs)		bwi_rf_read((mac), (ofs))
    779   1.1  macallan 
    780   1.1  macallan #define RF_SETBITS(mac, ofs, bits)		\
    781   1.1  macallan 	RF_WRITE((mac), (ofs), RF_READ((mac), (ofs)) | (bits))
    782   1.1  macallan #define RF_CLRBITS(mac, ofs, bits)		\
    783   1.1  macallan 	RF_WRITE((mac), (ofs), RF_READ((mac), (ofs)) & ~(bits))
    784   1.1  macallan #define RF_FILT_SETBITS(mac, ofs, filt, bits)	\
    785   1.1  macallan 	RF_WRITE((mac), (ofs), (RF_READ((mac), (ofs)) & (filt)) | (bits))
    786   1.1  macallan 
    787   1.2  macallan /* [TRC: XXX Why are these visible at all externally?] */
    788   1.1  macallan 
    789   1.1  macallan int		bwi_intr(void *);
    790   1.1  macallan int		bwi_attach(struct bwi_softc *);
    791   1.2  macallan void		bwi_detach(struct bwi_softc *);
    792   1.2  macallan 
    793   1.3    kefren /* Power Management Framework */
    794   1.7    dyoung bool		bwi_suspend(device_t, const pmf_qual_t *);
    795   1.7    dyoung bool		bwi_resume(device_t, const pmf_qual_t *);
    796   1.3    kefren 
    797   1.2  macallan #endif	/* !_DEV_IC_BWIVAR_H */
    798