Home | History | Annotate | Line # | Download | only in ic
awivar.h revision 1.19
      1 /*	$NetBSD: awivar.h,v 1.19 2003/10/13 08:10:48 dyoung Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999,2000,2001 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Bill Sommerfeld
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #ifndef _DEV_IC_AWIVAR_H
     40 #define	_DEV_IC_AWIVAR_H
     41 
     42 /* timer values in msec */
     43 #define	AWI_SELFTEST_TIMEOUT	5000
     44 #define	AWI_CMD_TIMEOUT		2000
     45 #define	AWI_LOCKOUT_TIMEOUT	50
     46 #define	AWI_ASCAN_DURATION	100
     47 #define	AWI_ASCAN_WAIT		3000
     48 #define	AWI_PSCAN_DURATION	200
     49 #define	AWI_PSCAN_WAIT		5000
     50 #define	AWI_TRANS_TIMEOUT	5000
     51 
     52 #define	AWI_NTXBUFS		4
     53 
     54 enum awi_sub_state {
     55 	AWI_ST_NONE,
     56 	AWI_ST_SCAN_INIT,
     57 	AWI_ST_SCAN_SETMIB,
     58 	AWI_ST_SCAN_SCCMD,
     59 	AWI_ST_SUB_INIT,
     60 	AWI_ST_SUB_SETSS,
     61 	AWI_ST_SUB_SYNC
     62 };
     63 
     64 #define	AWI_WAIT		0		/* must wait for completion */
     65 #define	AWI_NOWAIT		1		/* do not wait */
     66 
     67 struct awi_chanset {
     68 	u_int8_t	cs_type;
     69 	u_int8_t	cs_region;
     70 	u_int8_t	cs_min;
     71 	u_int8_t	cs_max;
     72 	u_int8_t	cs_def;
     73 };
     74 
     75 struct awi_softc {
     76 	struct device		sc_dev;
     77 	struct am79c930_softc 	sc_chip;
     78 	struct ieee80211com	sc_ic;
     79 	u_char			sc_banner[AWI_BANNER_LEN];
     80 	int			(*sc_enable)(struct awi_softc *);
     81 	void			(*sc_disable)(struct awi_softc *);
     82 	void			(*sc_power)(struct awi_softc *, int);
     83 
     84 	int			(*sc_newstate)(struct ieee80211com *,
     85 				    enum ieee80211_state, int);
     86 	void			(*sc_recv_mgmt)(struct ieee80211com *,
     87 				    struct mbuf *, struct ieee80211_node *,
     88 				    int, int, u_int32_t);
     89 	int			(*sc_send_mgmt)(struct ieee80211com *,
     90 				    struct ieee80211_node *, int, int);
     91 
     92 	void			*sc_sdhook;	/* shutdown hook */
     93 	void			*sc_powerhook;	/* power management hook */
     94 	unsigned int		sc_attached:1,
     95 				sc_enabled:1,
     96 				sc_busy:1,
     97 				sc_cansleep:1,
     98 				sc_enab_intr:1,
     99 				sc_adhoc_ap:1,
    100 				sc_invalid:1;
    101 	enum ieee80211_state	sc_nstate;
    102 	enum awi_sub_state	sc_substate;
    103 	int			sc_sleep_cnt;
    104 	u_int8_t		sc_cmd_inprog;
    105 	u_int8_t		sc_cur_chan;
    106 
    107 	int			sc_rx_timer;
    108 	u_int32_t		sc_rxdoff;
    109 	u_int32_t		sc_rxmoff;
    110 	struct mbuf		*sc_rxpend;
    111 
    112 	int			sc_tx_timer;
    113 	u_int32_t		sc_txbase;
    114 	u_int32_t		sc_txend;
    115 	u_int32_t		sc_txnext;
    116 	u_int32_t		sc_txdone;
    117 
    118 	struct awi_mib_local	sc_mib_local;
    119 	struct awi_mib_addr	sc_mib_addr;
    120 	struct awi_mib_mac	sc_mib_mac;
    121 	struct awi_mib_stat	sc_mib_stat;
    122 	struct awi_mib_mgt	sc_mib_mgt;
    123 	struct awi_mib_phy	sc_mib_phy;
    124 };
    125 
    126 #define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
    127 #define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
    128 #define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off)
    129 #define awi_read_bytes(sc, off, ptr, len) \
    130 	((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len)
    131 
    132 #define awi_write_1(sc, off, val) \
    133 	((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val)
    134 #define awi_write_2(sc, off, val) \
    135 	((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val)
    136 #define awi_write_4(sc, off, val) \
    137 	((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val)
    138 #define awi_write_bytes(sc, off, ptr, len) \
    139 	((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len)
    140 
    141 #define awi_drvstate(sc, state) \
    142 	awi_write_1(sc, AWI_DRIVERSTATE, \
    143 	    ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED))
    144 
    145 int	awi_attach(struct awi_softc *);
    146 int	awi_detach(struct awi_softc *);
    147 int	awi_activate(struct device *, enum devact);
    148 void	awi_power(int, void *);
    149 void	awi_shutdown(void *);
    150 int	awi_intr(void *);
    151 
    152 #endif /* _DEV_IC_AWIVAR_H */
    153