Home | History | Annotate | Line # | Download | only in ic
rtwvar.h revision 1.19.2.2
      1  1.19.2.2  kent /* $NetBSD: rtwvar.h,v 1.19.2.2 2005/04/29 11:28:52 kent Exp $ */
      2  1.19.2.2  kent /*-
      3  1.19.2.2  kent  * Copyright (c) 2004, 2005 David Young.  All rights reserved.
      4  1.19.2.2  kent  *
      5  1.19.2.2  kent  * Driver for the Realtek RTL8180 802.11 MAC/BBP by David Young.
      6  1.19.2.2  kent  *
      7  1.19.2.2  kent  * Redistribution and use in source and binary forms, with or without
      8  1.19.2.2  kent  * modification, are permitted provided that the following conditions
      9  1.19.2.2  kent  * are met:
     10  1.19.2.2  kent  * 1. Redistributions of source code must retain the above copyright
     11  1.19.2.2  kent  *    notice, this list of conditions and the following disclaimer.
     12  1.19.2.2  kent  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.19.2.2  kent  *    notice, this list of conditions and the following disclaimer in the
     14  1.19.2.2  kent  *    documentation and/or other materials provided with the distribution.
     15  1.19.2.2  kent  * 3. The name of David Young may not be used to endorse or promote
     16  1.19.2.2  kent  *    products derived from this software without specific prior
     17  1.19.2.2  kent  *    written permission.
     18  1.19.2.2  kent  *
     19  1.19.2.2  kent  * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
     20  1.19.2.2  kent  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     21  1.19.2.2  kent  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
     22  1.19.2.2  kent  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL David
     23  1.19.2.2  kent  * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     24  1.19.2.2  kent  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
     25  1.19.2.2  kent  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  1.19.2.2  kent  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     27  1.19.2.2  kent  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     28  1.19.2.2  kent  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29  1.19.2.2  kent  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
     30  1.19.2.2  kent  * OF SUCH DAMAGE.
     31  1.19.2.2  kent  */
     32  1.19.2.2  kent 
     33  1.19.2.2  kent #ifndef _DEV_IC_RTWVAR_H_
     34  1.19.2.2  kent #define	_DEV_IC_RTWVAR_H_
     35  1.19.2.2  kent 
     36  1.19.2.2  kent #include <sys/queue.h>
     37  1.19.2.2  kent #include <sys/callout.h>
     38  1.19.2.2  kent 
     39  1.19.2.2  kent #ifdef RTW_DEBUG
     40  1.19.2.2  kent #define	RTW_DEBUG_TUNE		0x000001
     41  1.19.2.2  kent #define	RTW_DEBUG_PKTFILT	0x000002
     42  1.19.2.2  kent #define	RTW_DEBUG_XMIT		0x000004
     43  1.19.2.2  kent #define	RTW_DEBUG_XMIT_DESC	0x000008
     44  1.19.2.2  kent #define	RTW_DEBUG_NODE		0x000010
     45  1.19.2.2  kent #define	RTW_DEBUG_PWR		0x000020
     46  1.19.2.2  kent #define	RTW_DEBUG_ATTACH	0x000040
     47  1.19.2.2  kent #define	RTW_DEBUG_REGDUMP	0x000080
     48  1.19.2.2  kent #define	RTW_DEBUG_ACCESS	0x000100
     49  1.19.2.2  kent #define	RTW_DEBUG_RESET		0x000200
     50  1.19.2.2  kent #define	RTW_DEBUG_INIT		0x000400
     51  1.19.2.2  kent #define	RTW_DEBUG_IOSTATE	0x000800
     52  1.19.2.2  kent #define	RTW_DEBUG_RECV		0x001000
     53  1.19.2.2  kent #define	RTW_DEBUG_RECV_DESC	0x002000
     54  1.19.2.2  kent #define	RTW_DEBUG_IO_KICK	0x004000
     55  1.19.2.2  kent #define	RTW_DEBUG_INTR		0x008000
     56  1.19.2.2  kent #define	RTW_DEBUG_PHY		0x010000
     57  1.19.2.2  kent #define	RTW_DEBUG_PHYIO		0x020000
     58  1.19.2.2  kent #define	RTW_DEBUG_PHYBITIO	0x040000
     59  1.19.2.2  kent #define	RTW_DEBUG_TIMEOUT	0x080000
     60  1.19.2.2  kent #define	RTW_DEBUG_BUGS		0x100000
     61  1.19.2.2  kent #define	RTW_DEBUG_BEACON	0x200000
     62  1.19.2.2  kent #define	RTW_DEBUG_LED		0x400000
     63  1.19.2.2  kent #define	RTW_DEBUG_MAX		0x7fffff
     64  1.19.2.2  kent 
     65  1.19.2.2  kent extern int rtw_debug;
     66  1.19.2.2  kent #define RTW_DPRINTF(__flags, __x)	\
     67  1.19.2.2  kent 	if ((rtw_debug & (__flags)) != 0) printf __x
     68  1.19.2.2  kent #define	DPRINTF(__sc, __flags, __x)				\
     69  1.19.2.2  kent 	if (((__sc)->sc_ic.ic_if.if_flags & IFF_DEBUG) != 0)	\
     70  1.19.2.2  kent 		RTW_DPRINTF(__flags, __x)
     71  1.19.2.2  kent #define	RTW_PRINT_REGS(__regs, __dvname, __where)	\
     72  1.19.2.2  kent 	rtw_print_regs((__regs), (__dvname), (__where))
     73  1.19.2.2  kent #else /* RTW_DEBUG */
     74  1.19.2.2  kent #define RTW_DPRINTF(__flags, __x)
     75  1.19.2.2  kent #define	DPRINTF(__sc, __flags, __x)
     76  1.19.2.2  kent #define	RTW_PRINT_REGS(__regs, __dvname, __where)
     77  1.19.2.2  kent #endif /* RTW_DEBUG */
     78  1.19.2.2  kent 
     79  1.19.2.2  kent enum rtw_locale {
     80  1.19.2.2  kent 	RTW_LOCALE_USA = 0,
     81  1.19.2.2  kent 	RTW_LOCALE_EUROPE,
     82  1.19.2.2  kent 	RTW_LOCALE_JAPAN,
     83  1.19.2.2  kent 	RTW_LOCALE_UNKNOWN
     84  1.19.2.2  kent };
     85  1.19.2.2  kent 
     86  1.19.2.2  kent enum rtw_rfchipid {
     87  1.19.2.2  kent 	RTW_RFCHIPID_RESERVED = 0,
     88  1.19.2.2  kent 	RTW_RFCHIPID_INTERSIL = 1,
     89  1.19.2.2  kent 	RTW_RFCHIPID_RFMD = 2,
     90  1.19.2.2  kent 	RTW_RFCHIPID_PHILIPS = 3,
     91  1.19.2.2  kent 	RTW_RFCHIPID_MAXIM = 4,
     92  1.19.2.2  kent 	RTW_RFCHIPID_GCT = 5
     93  1.19.2.2  kent };
     94  1.19.2.2  kent 
     95  1.19.2.2  kent /* sc_flags */
     96  1.19.2.2  kent #define RTW_F_ENABLED		0x00000001	/* chip is enabled */
     97  1.19.2.2  kent #define RTW_F_DIGPHY		0x00000002	/* digital PHY */
     98  1.19.2.2  kent #define RTW_F_DFLANTB		0x00000004	/* B antenna is default */
     99  1.19.2.2  kent #define RTW_F_ANTDIV		0x00000010	/* h/w antenna diversity */
    100  1.19.2.2  kent #define RTW_F_9356SROM		0x00000020	/* 93c56 SROM */
    101  1.19.2.2  kent #define RTW_F_SLEEP		0x00000040	/* chip is asleep */
    102  1.19.2.2  kent #define RTW_F_INVALID		0x00000080	/* chip is absent */
    103  1.19.2.2  kent 	/* all PHY flags */
    104  1.19.2.2  kent #define RTW_F_ALLPHY		(RTW_F_DIGPHY|RTW_F_DFLANTB|RTW_F_ANTDIV)
    105  1.19.2.2  kent 
    106  1.19.2.2  kent enum rtw_access {RTW_ACCESS_NONE = 0,
    107  1.19.2.2  kent 		 RTW_ACCESS_CONFIG = 1,
    108  1.19.2.2  kent 		 RTW_ACCESS_ANAPARM = 2};
    109  1.19.2.2  kent 
    110  1.19.2.2  kent struct rtw_regs {
    111  1.19.2.2  kent 	bus_space_tag_t		r_bt;
    112  1.19.2.2  kent 	bus_space_handle_t	r_bh;
    113  1.19.2.2  kent 	enum rtw_access		r_access;
    114  1.19.2.2  kent };
    115  1.19.2.2  kent 
    116  1.19.2.2  kent #define RTW_SR_GET(sr, ofs) \
    117  1.19.2.2  kent     (((sr)->sr_content[(ofs)/2] >> (((ofs) % 2 == 0) ? 0 : 8)) & 0xff)
    118  1.19.2.2  kent 
    119  1.19.2.2  kent #define RTW_SR_GET16(sr, ofs) \
    120  1.19.2.2  kent     (RTW_SR_GET((sr), (ofs)) | (RTW_SR_GET((sr), (ofs) + 1) << 8))
    121  1.19.2.2  kent 
    122  1.19.2.2  kent struct rtw_srom {
    123  1.19.2.2  kent 	uint16_t		*sr_content;
    124  1.19.2.2  kent 	uint16_t		sr_size;
    125  1.19.2.2  kent };
    126  1.19.2.2  kent 
    127  1.19.2.2  kent struct rtw_rxsoft {
    128  1.19.2.2  kent 	struct mbuf			*rs_mbuf;
    129  1.19.2.2  kent 	bus_dmamap_t			rs_dmamap;
    130  1.19.2.2  kent };
    131  1.19.2.2  kent 
    132  1.19.2.2  kent struct rtw_txsoft {
    133  1.19.2.2  kent 	SIMPLEQ_ENTRY(rtw_txsoft)	ts_q;
    134  1.19.2.2  kent 	struct mbuf			*ts_mbuf;
    135  1.19.2.2  kent 	bus_dmamap_t			ts_dmamap;
    136  1.19.2.2  kent 	struct ieee80211_node		*ts_ni;	/* destination node */
    137  1.19.2.2  kent 	u_int				ts_first;	/* 1st hw descriptor */
    138  1.19.2.2  kent 	u_int				ts_last;	/* last hw descriptor */
    139  1.19.2.2  kent 	struct ieee80211_duration	ts_d0;
    140  1.19.2.2  kent 	struct ieee80211_duration	ts_dn;
    141  1.19.2.2  kent };
    142  1.19.2.2  kent 
    143  1.19.2.2  kent #define RTW_NTXPRI	4	/* number of Tx priorities */
    144  1.19.2.2  kent #define RTW_TXPRILO	0
    145  1.19.2.2  kent #define RTW_TXPRIMD	1
    146  1.19.2.2  kent #define RTW_TXPRIHI	2
    147  1.19.2.2  kent #define RTW_TXPRIBCN	3	/* beacon priority */
    148  1.19.2.2  kent 
    149  1.19.2.2  kent #define RTW_MAXPKTSEGS		64	/* Max 64 segments per Tx packet */
    150  1.19.2.2  kent 
    151  1.19.2.2  kent #define CASSERT(cond, complaint) complaint[(cond) ? 0 : -1] = complaint[(cond) ? 0 : -1]
    152  1.19.2.2  kent 
    153  1.19.2.2  kent /* Note well: the descriptor rings must begin on RTW_DESC_ALIGNMENT
    154  1.19.2.2  kent  * boundaries.  I allocate them consecutively from one buffer, so
    155  1.19.2.2  kent  * just round up.
    156  1.19.2.2  kent  */
    157  1.19.2.2  kent #define RTW_TXQLENLO	64	/* low-priority queue length */
    158  1.19.2.2  kent #define RTW_TXQLENMD	64	/* medium-priority */
    159  1.19.2.2  kent #define RTW_TXQLENHI	64	/* high-priority */
    160  1.19.2.2  kent #define RTW_TXQLENBCN	2	/* beacon */
    161  1.19.2.2  kent 
    162  1.19.2.2  kent #define RTW_NTXDESCLO	RTW_TXQLENLO
    163  1.19.2.2  kent #define RTW_NTXDESCMD	RTW_TXQLENMD
    164  1.19.2.2  kent #define RTW_NTXDESCHI	RTW_TXQLENHI
    165  1.19.2.2  kent #define RTW_NTXDESCBCN	RTW_TXQLENBCN
    166  1.19.2.2  kent 
    167  1.19.2.2  kent #define RTW_NTXDESCTOTAL	(RTW_NTXDESCLO + RTW_NTXDESCMD + \
    168  1.19.2.2  kent 				 RTW_NTXDESCHI + RTW_NTXDESCBCN)
    169  1.19.2.2  kent 
    170  1.19.2.2  kent #define RTW_RXQLEN	64
    171  1.19.2.2  kent 
    172  1.19.2.2  kent struct rtw_rxdesc_blk {
    173  1.19.2.2  kent 	struct rtw_rxdesc	*rdb_desc;
    174  1.19.2.2  kent 	u_int			rdb_next;
    175  1.19.2.2  kent 	u_int			rdb_ndesc;
    176  1.19.2.2  kent 	bus_dma_tag_t		rdb_dmat;
    177  1.19.2.2  kent 	bus_dmamap_t		rdb_dmamap;
    178  1.19.2.2  kent };
    179  1.19.2.2  kent 
    180  1.19.2.2  kent struct rtw_txdesc_blk {
    181  1.19.2.2  kent 	u_int			tdb_ndesc;
    182  1.19.2.2  kent 	u_int			tdb_next;
    183  1.19.2.2  kent 	u_int			tdb_nfree;
    184  1.19.2.2  kent 	bus_dma_tag_t		tdb_dmat;
    185  1.19.2.2  kent 	bus_dmamap_t		tdb_dmamap;
    186  1.19.2.2  kent 	bus_addr_t		tdb_physbase;
    187  1.19.2.2  kent 	bus_addr_t		tdb_ofs;
    188  1.19.2.2  kent 	struct rtw_txdesc	*tdb_desc;
    189  1.19.2.2  kent };
    190  1.19.2.2  kent 
    191  1.19.2.2  kent #define RTW_NEXT_IDX(__htc, __idx)	(((__idx) + 1) % (__htc)->tdb_ndesc)
    192  1.19.2.2  kent 
    193  1.19.2.2  kent #define RTW_NEXT_DESC(__htc, __idx) \
    194  1.19.2.2  kent     ((__htc)->tdb_physbase + \
    195  1.19.2.2  kent      sizeof(struct rtw_txdesc) * RTW_NEXT_IDX((__htc), (__idx)))
    196  1.19.2.2  kent 
    197  1.19.2.2  kent SIMPLEQ_HEAD(rtw_txq, rtw_txsoft);
    198  1.19.2.2  kent 
    199  1.19.2.2  kent struct rtw_txsoft_blk {
    200  1.19.2.2  kent 	/* dirty/free s/w descriptors */
    201  1.19.2.2  kent 	struct rtw_txq		tsb_dirtyq;
    202  1.19.2.2  kent 	struct rtw_txq		tsb_freeq;
    203  1.19.2.2  kent 	u_int			tsb_ndesc;
    204  1.19.2.2  kent 	int			tsb_tx_timer;
    205  1.19.2.2  kent 	struct rtw_txsoft	*tsb_desc;
    206  1.19.2.2  kent 	uint8_t			tsb_poll;
    207  1.19.2.2  kent };
    208  1.19.2.2  kent 
    209  1.19.2.2  kent struct rtw_descs {
    210  1.19.2.2  kent 	struct rtw_txdesc	hd_txlo[RTW_NTXDESCLO];
    211  1.19.2.2  kent 	struct rtw_txdesc	hd_txmd[RTW_NTXDESCMD];
    212  1.19.2.2  kent 	struct rtw_txdesc	hd_txhi[RTW_NTXDESCMD];
    213  1.19.2.2  kent 	struct rtw_rxdesc	hd_rx[RTW_RXQLEN];
    214  1.19.2.2  kent 	struct rtw_txdesc	hd_bcn[RTW_NTXDESCBCN];
    215  1.19.2.2  kent };
    216  1.19.2.2  kent #define RTW_DESC_OFFSET(ring, i)	offsetof(struct rtw_descs, ring[i])
    217  1.19.2.2  kent #define RTW_RING_OFFSET(ring)		RTW_DESC_OFFSET(ring, 0)
    218  1.19.2.2  kent #define RTW_RING_BASE(sc, ring)		((sc)->sc_desc_physaddr + \
    219  1.19.2.2  kent 					 RTW_RING_OFFSET(ring))
    220  1.19.2.2  kent 
    221  1.19.2.2  kent /* Radio capture format for RTL8180. */
    222  1.19.2.2  kent 
    223  1.19.2.2  kent #define RTW_RX_RADIOTAP_PRESENT					\
    224  1.19.2.2  kent 	((1 << IEEE80211_RADIOTAP_TSFT)			|	\
    225  1.19.2.2  kent 	 (1 << IEEE80211_RADIOTAP_FLAGS)		|	\
    226  1.19.2.2  kent 	 (1 << IEEE80211_RADIOTAP_RATE)			|	\
    227  1.19.2.2  kent 	 (1 << IEEE80211_RADIOTAP_CHANNEL)		|	\
    228  1.19.2.2  kent 	 (1 << IEEE80211_RADIOTAP_LOCK_QUALITY)		|	\
    229  1.19.2.2  kent 	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL)		|	\
    230  1.19.2.2  kent 	 0)
    231  1.19.2.2  kent 
    232  1.19.2.2  kent struct rtw_rx_radiotap_header {
    233  1.19.2.2  kent 	struct ieee80211_radiotap_header	rr_ihdr;
    234  1.19.2.2  kent 	uint64_t				rr_tsft;
    235  1.19.2.2  kent 	uint8_t				rr_flags;
    236  1.19.2.2  kent 	uint8_t				rr_rate;
    237  1.19.2.2  kent 	uint16_t				rr_chan_freq;
    238  1.19.2.2  kent 	uint16_t				rr_chan_flags;
    239  1.19.2.2  kent 	uint16_t				rr_barker_lock;
    240  1.19.2.2  kent 	uint8_t				rr_antsignal;
    241  1.19.2.2  kent } __attribute__((__packed__));
    242  1.19.2.2  kent 
    243  1.19.2.2  kent #define RTW_TX_RADIOTAP_PRESENT				\
    244  1.19.2.2  kent 	((1 << IEEE80211_RADIOTAP_FLAGS)	|	\
    245  1.19.2.2  kent 	 (1 << IEEE80211_RADIOTAP_RATE)		|	\
    246  1.19.2.2  kent 	 (1 << IEEE80211_RADIOTAP_CHANNEL)	|	\
    247  1.19.2.2  kent 	 0)
    248  1.19.2.2  kent 
    249  1.19.2.2  kent struct rtw_tx_radiotap_header {
    250  1.19.2.2  kent 	struct ieee80211_radiotap_header	rt_ihdr;
    251  1.19.2.2  kent 	uint8_t				rt_flags;
    252  1.19.2.2  kent 	uint8_t				rt_rate;
    253  1.19.2.2  kent 	uint16_t				rt_chan_freq;
    254  1.19.2.2  kent 	uint16_t				rt_chan_flags;
    255  1.19.2.2  kent } __attribute__((__packed__));
    256  1.19.2.2  kent 
    257  1.19.2.2  kent enum rtw_attach_state {FINISHED, FINISH_DESCMAP_LOAD, FINISH_DESCMAP_CREATE,
    258  1.19.2.2  kent 	FINISH_DESC_MAP, FINISH_DESC_ALLOC, FINISH_RXMAPS_CREATE,
    259  1.19.2.2  kent 	FINISH_TXMAPS_CREATE, FINISH_RESET, FINISH_READ_SROM, FINISH_PARSE_SROM,
    260  1.19.2.2  kent 	FINISH_RF_ATTACH, FINISH_ID_STA, FINISH_TXDESCBLK_SETUP,
    261  1.19.2.2  kent 	FINISH_TXCTLBLK_SETUP, DETACHED};
    262  1.19.2.2  kent 
    263  1.19.2.2  kent struct rtw_hooks {
    264  1.19.2.2  kent 	void			*rh_shutdown;	/* shutdown hook */
    265  1.19.2.2  kent 	void			*rh_power;	/* power management hook */
    266  1.19.2.2  kent };
    267  1.19.2.2  kent 
    268  1.19.2.2  kent struct rtw_mtbl {
    269  1.19.2.2  kent 	int			(*mt_newstate)(struct ieee80211com *,
    270  1.19.2.2  kent 					enum ieee80211_state, int);
    271  1.19.2.2  kent 	void			(*mt_recv_mgmt)(struct ieee80211com *,
    272  1.19.2.2  kent 				    struct mbuf *, struct ieee80211_node *,
    273  1.19.2.2  kent 				    int, int, uint32_t);
    274  1.19.2.2  kent 	struct ieee80211_node	*(*mt_node_alloc)(struct ieee80211com *);
    275  1.19.2.2  kent 	void			(*mt_node_free)(struct ieee80211com *,
    276  1.19.2.2  kent 					struct ieee80211_node *);
    277  1.19.2.2  kent };
    278  1.19.2.2  kent 
    279  1.19.2.2  kent enum rtw_pwrstate { RTW_OFF = 0, RTW_SLEEP, RTW_ON };
    280  1.19.2.2  kent 
    281  1.19.2.2  kent typedef void (*rtw_continuous_tx_cb_t)(void *arg, int);
    282  1.19.2.2  kent 
    283  1.19.2.2  kent struct rtw_phy {
    284  1.19.2.2  kent 	struct rtw_rf	*p_rf;
    285  1.19.2.2  kent 	struct rtw_regs	*p_regs;
    286  1.19.2.2  kent };
    287  1.19.2.2  kent 
    288  1.19.2.2  kent struct rtw_bbpset {
    289  1.19.2.2  kent 	u_int	bb_antatten;
    290  1.19.2.2  kent 	u_int	bb_chestlim;
    291  1.19.2.2  kent 	u_int	bb_chsqlim;
    292  1.19.2.2  kent 	u_int	bb_ifagcdet;
    293  1.19.2.2  kent 	u_int	bb_ifagcini;
    294  1.19.2.2  kent 	u_int	bb_ifagclimit;
    295  1.19.2.2  kent 	u_int	bb_lnadet;
    296  1.19.2.2  kent 	u_int	bb_sys1;
    297  1.19.2.2  kent 	u_int	bb_sys2;
    298  1.19.2.2  kent 	u_int	bb_sys3;
    299  1.19.2.2  kent 	u_int	bb_trl;
    300  1.19.2.2  kent 	u_int	bb_txagc;
    301  1.19.2.2  kent };
    302  1.19.2.2  kent 
    303  1.19.2.2  kent struct rtw_rf {
    304  1.19.2.2  kent 	void	(*rf_destroy)(struct rtw_rf *);
    305  1.19.2.2  kent 	/* args: frequency, txpower, power state */
    306  1.19.2.2  kent 	int	(*rf_init)(struct rtw_rf *, u_int, uint8_t,
    307  1.19.2.2  kent 	                  enum rtw_pwrstate);
    308  1.19.2.2  kent 	/* arg: power state */
    309  1.19.2.2  kent 	int	(*rf_pwrstate)(struct rtw_rf *, enum rtw_pwrstate);
    310  1.19.2.2  kent 	/* arg: frequency */
    311  1.19.2.2  kent 	int	(*rf_tune)(struct rtw_rf *, u_int);
    312  1.19.2.2  kent 	/* arg: txpower */
    313  1.19.2.2  kent 	int	(*rf_txpower)(struct rtw_rf *, uint8_t);
    314  1.19.2.2  kent 	rtw_continuous_tx_cb_t	rf_continuous_tx_cb;
    315  1.19.2.2  kent 	void			*rf_continuous_tx_arg;
    316  1.19.2.2  kent 	struct rtw_bbpset	rf_bbpset;
    317  1.19.2.2  kent };
    318  1.19.2.2  kent 
    319  1.19.2.2  kent static __inline void
    320  1.19.2.2  kent rtw_rf_destroy(struct rtw_rf *rf)
    321  1.19.2.2  kent {
    322  1.19.2.2  kent 	(*rf->rf_destroy)(rf);
    323  1.19.2.2  kent }
    324  1.19.2.2  kent 
    325  1.19.2.2  kent static __inline int
    326  1.19.2.2  kent rtw_rf_init(struct rtw_rf *rf, u_int freq, uint8_t opaque_txpower,
    327  1.19.2.2  kent     enum rtw_pwrstate power)
    328  1.19.2.2  kent {
    329  1.19.2.2  kent 	return (*rf->rf_init)(rf, freq, opaque_txpower, power);
    330  1.19.2.2  kent }
    331  1.19.2.2  kent 
    332  1.19.2.2  kent static __inline int
    333  1.19.2.2  kent rtw_rf_pwrstate(struct rtw_rf *rf, enum rtw_pwrstate power)
    334  1.19.2.2  kent {
    335  1.19.2.2  kent 	return (*rf->rf_pwrstate)(rf, power);
    336  1.19.2.2  kent }
    337  1.19.2.2  kent 
    338  1.19.2.2  kent static __inline int
    339  1.19.2.2  kent rtw_rf_tune(struct rtw_rf *rf, u_int freq)
    340  1.19.2.2  kent {
    341  1.19.2.2  kent 	return (*rf->rf_tune)(rf, freq);
    342  1.19.2.2  kent }
    343  1.19.2.2  kent 
    344  1.19.2.2  kent static __inline int
    345  1.19.2.2  kent rtw_rf_txpower(struct rtw_rf *rf, uint8_t opaque_txpower)
    346  1.19.2.2  kent {
    347  1.19.2.2  kent 	return (*rf->rf_txpower)(rf, opaque_txpower);
    348  1.19.2.2  kent }
    349  1.19.2.2  kent 
    350  1.19.2.2  kent typedef int (*rtw_rf_write_t)(struct rtw_regs *, enum rtw_rfchipid, u_int,
    351  1.19.2.2  kent     uint32_t);
    352  1.19.2.2  kent 
    353  1.19.2.2  kent struct rtw_rfbus {
    354  1.19.2.2  kent 	struct rtw_regs		*b_regs;
    355  1.19.2.2  kent 	rtw_rf_write_t		b_write;
    356  1.19.2.2  kent };
    357  1.19.2.2  kent 
    358  1.19.2.2  kent static __inline int
    359  1.19.2.2  kent rtw_rfbus_write(struct rtw_rfbus *bus, enum rtw_rfchipid rfchipid, u_int addr,
    360  1.19.2.2  kent     uint32_t val)
    361  1.19.2.2  kent {
    362  1.19.2.2  kent 	return (*bus->b_write)(bus->b_regs, rfchipid, addr, val);
    363  1.19.2.2  kent }
    364  1.19.2.2  kent 
    365  1.19.2.2  kent struct rtw_max2820 {
    366  1.19.2.2  kent 	struct rtw_rf		mx_rf;
    367  1.19.2.2  kent 	struct rtw_rfbus	mx_bus;
    368  1.19.2.2  kent 	int			mx_is_a;	/* 1: MAX2820A/MAX2821A */
    369  1.19.2.2  kent };
    370  1.19.2.2  kent 
    371  1.19.2.2  kent struct rtw_sa2400 {
    372  1.19.2.2  kent 	struct rtw_rf		sa_rf;
    373  1.19.2.2  kent 	struct rtw_rfbus	sa_bus;
    374  1.19.2.2  kent 	int			sa_digphy;	/* 1: digital PHY */
    375  1.19.2.2  kent };
    376  1.19.2.2  kent 
    377  1.19.2.2  kent typedef void (*rtw_pwrstate_t)(struct rtw_regs *, enum rtw_pwrstate, int, int);
    378  1.19.2.2  kent 
    379  1.19.2.2  kent union rtw_keys {
    380  1.19.2.2  kent 	uint8_t		rk_keys[4][16];
    381  1.19.2.2  kent 	uint32_t	rk_words[16];
    382  1.19.2.2  kent };
    383  1.19.2.2  kent 
    384  1.19.2.2  kent #define	RTW_LED_SLOW_TICKS	MAX(1, hz/2)
    385  1.19.2.2  kent #define	RTW_LED_FAST_TICKS	MAX(1, hz/10)
    386  1.19.2.2  kent 
    387  1.19.2.2  kent struct rtw_led_state {
    388  1.19.2.2  kent #define	RTW_LED0	0x1
    389  1.19.2.2  kent #define	RTW_LED1	0x2
    390  1.19.2.2  kent 	uint8_t		ls_slowblink:2;
    391  1.19.2.2  kent 	uint8_t		ls_actblink:2;
    392  1.19.2.2  kent 	uint8_t		ls_default:2;
    393  1.19.2.2  kent 	uint8_t		ls_state;
    394  1.19.2.2  kent 	uint8_t		ls_event;
    395  1.19.2.2  kent #define	RTW_LED_S_RX	0x1
    396  1.19.2.2  kent #define	RTW_LED_S_TX	0x2
    397  1.19.2.2  kent #define	RTW_LED_S_SLOW	0x4
    398  1.19.2.2  kent 	struct callout	ls_slow_ch;
    399  1.19.2.2  kent 	struct callout	ls_fast_ch;
    400  1.19.2.2  kent };
    401  1.19.2.2  kent 
    402  1.19.2.2  kent struct rtw_softc {
    403  1.19.2.2  kent 	struct device		sc_dev;
    404  1.19.2.2  kent 	struct ieee80211com	sc_ic;
    405  1.19.2.2  kent 	struct rtw_regs		sc_regs;
    406  1.19.2.2  kent 	bus_dma_tag_t		sc_dmat;
    407  1.19.2.2  kent 	uint32_t		sc_flags;
    408  1.19.2.2  kent 
    409  1.19.2.2  kent 	enum rtw_attach_state	sc_attach_state;
    410  1.19.2.2  kent 	enum rtw_rfchipid	sc_rfchipid;
    411  1.19.2.2  kent 	enum rtw_locale		sc_locale;
    412  1.19.2.2  kent 	uint8_t		sc_phydelay;
    413  1.19.2.2  kent 
    414  1.19.2.2  kent 	/* s/w Tx/Rx descriptors */
    415  1.19.2.2  kent 	struct rtw_txsoft_blk	sc_txsoft_blk[RTW_NTXPRI];
    416  1.19.2.2  kent 	struct rtw_txdesc_blk	sc_txdesc_blk[RTW_NTXPRI];
    417  1.19.2.2  kent 
    418  1.19.2.2  kent 	struct rtw_rxsoft	sc_rxsoft[RTW_RXQLEN];
    419  1.19.2.2  kent 	struct rtw_rxdesc_blk	sc_rxdesc_blk;
    420  1.19.2.2  kent 
    421  1.19.2.2  kent 	struct rtw_descs	*sc_descs;
    422  1.19.2.2  kent 
    423  1.19.2.2  kent 	bus_dma_segment_t	sc_desc_segs;
    424  1.19.2.2  kent 	int			sc_desc_nsegs;
    425  1.19.2.2  kent 	bus_dmamap_t		sc_desc_dmamap;
    426  1.19.2.2  kent #define	sc_desc_physaddr sc_desc_dmamap->dm_segs[0].ds_addr
    427  1.19.2.2  kent 
    428  1.19.2.2  kent 	struct rtw_srom		sc_srom;
    429  1.19.2.2  kent 
    430  1.19.2.2  kent 	enum rtw_pwrstate	sc_pwrstate;
    431  1.19.2.2  kent 
    432  1.19.2.2  kent 	rtw_pwrstate_t		sc_pwrstate_cb;
    433  1.19.2.2  kent 
    434  1.19.2.2  kent 	struct rtw_rf		*sc_rf;
    435  1.19.2.2  kent 
    436  1.19.2.2  kent 	uint16_t		sc_inten;
    437  1.19.2.2  kent 
    438  1.19.2.2  kent 	/* interrupt acknowledge hook */
    439  1.19.2.2  kent 	void (*sc_intr_ack)(struct rtw_regs *);
    440  1.19.2.2  kent 
    441  1.19.2.2  kent 	int			(*sc_enable)(struct rtw_softc *);
    442  1.19.2.2  kent 	void			(*sc_disable)(struct rtw_softc *);
    443  1.19.2.2  kent 	void			(*sc_power)(struct rtw_softc *, int);
    444  1.19.2.2  kent 	struct rtw_mtbl		sc_mtbl;
    445  1.19.2.2  kent 	struct rtw_hooks	sc_hooks;
    446  1.19.2.2  kent 
    447  1.19.2.2  kent 	caddr_t			sc_radiobpf;
    448  1.19.2.2  kent 
    449  1.19.2.2  kent 	struct callout		sc_scan_ch;
    450  1.19.2.2  kent 	u_int			sc_cur_chan;
    451  1.19.2.2  kent 
    452  1.19.2.2  kent 	uint32_t		sc_tsfth;	/* most significant TSFT bits */
    453  1.19.2.2  kent 	uint32_t		sc_rcr;		/* RTW_RCR */
    454  1.19.2.2  kent 	uint8_t		sc_csthr;	/* carrier-sense threshold */
    455  1.19.2.2  kent 
    456  1.19.2.2  kent 	int			sc_do_tick;	/* indicate 1s ticks */
    457  1.19.2.2  kent 	struct timeval		sc_tick0;	/* first tick */
    458  1.19.2.2  kent 
    459  1.19.2.2  kent 	uint8_t			sc_rev;		/* PCI/Cardbus revision */
    460  1.19.2.2  kent 
    461  1.19.2.2  kent 	uint32_t		sc_anaparm;	/* register RTW_ANAPARM */
    462  1.19.2.2  kent 
    463  1.19.2.2  kent 	union {
    464  1.19.2.2  kent 		struct rtw_rx_radiotap_header	tap;
    465  1.19.2.2  kent 		uint8_t			pad[64];
    466  1.19.2.2  kent 	} sc_rxtapu;
    467  1.19.2.2  kent 	union {
    468  1.19.2.2  kent 		struct rtw_tx_radiotap_header	tap;
    469  1.19.2.2  kent 		uint8_t			pad[64];
    470  1.19.2.2  kent 	} sc_txtapu;
    471  1.19.2.2  kent 	union rtw_keys		sc_keys;
    472  1.19.2.2  kent 	int			sc_txkey;
    473  1.19.2.2  kent 	struct ifqueue		sc_beaconq;
    474  1.19.2.2  kent 	struct rtw_led_state	sc_led_state;
    475  1.19.2.2  kent 	int			sc_hwverid;
    476  1.19.2.2  kent };
    477  1.19.2.2  kent 
    478  1.19.2.2  kent #define	sc_if		sc_ic.ic_if
    479  1.19.2.2  kent #define sc_rxtap	sc_rxtapu.tap
    480  1.19.2.2  kent #define sc_txtap	sc_txtapu.tap
    481  1.19.2.2  kent 
    482  1.19.2.2  kent extern int rtw_host_rfio;
    483  1.19.2.2  kent 
    484  1.19.2.2  kent void rtw_txdac_enable(struct rtw_softc *, int);
    485  1.19.2.2  kent void rtw_anaparm_enable(struct rtw_regs *, int);
    486  1.19.2.2  kent void rtw_config0123_enable(struct rtw_regs *, int);
    487  1.19.2.2  kent void rtw_continuous_tx_enable(struct rtw_softc *, int);
    488  1.19.2.2  kent void rtw_set_access(struct rtw_regs *, enum rtw_access);
    489  1.19.2.2  kent 
    490  1.19.2.2  kent void rtw_attach(struct rtw_softc *);
    491  1.19.2.2  kent int rtw_detach(struct rtw_softc *);
    492  1.19.2.2  kent int rtw_intr(void *);
    493  1.19.2.2  kent 
    494  1.19.2.2  kent void rtw_disable(struct rtw_softc *);
    495  1.19.2.2  kent int rtw_enable(struct rtw_softc *);
    496  1.19.2.2  kent 
    497  1.19.2.2  kent int rtw_activate(struct device *, enum devact);
    498  1.19.2.2  kent void rtw_power(int, void *);
    499  1.19.2.2  kent void rtw_shutdown(void *);
    500  1.19.2.2  kent 
    501  1.19.2.2  kent const char *rtw_pwrstate_string(enum rtw_pwrstate);
    502  1.19.2.2  kent 
    503  1.19.2.2  kent #endif /* _DEV_IC_RTWVAR_H_ */
    504