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