awivar.h revision 1.24 1 /* $NetBSD: awivar.h,v 1.24 2009/05/12 14:25:17 cegger 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 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef _DEV_IC_AWIVAR_H
33 #define _DEV_IC_AWIVAR_H
34
35 /* timer values in msec */
36 #define AWI_SELFTEST_TIMEOUT 5000
37 #define AWI_CMD_TIMEOUT 2000
38 #define AWI_LOCKOUT_TIMEOUT 50
39 #define AWI_ASCAN_DURATION 100
40 #define AWI_ASCAN_WAIT 3000
41 #define AWI_PSCAN_DURATION 200
42 #define AWI_PSCAN_WAIT 5000
43 #define AWI_TRANS_TIMEOUT 5000
44
45 #define AWI_NTXBUFS 4
46
47 enum awi_sub_state {
48 AWI_ST_NONE,
49 AWI_ST_SCAN_INIT,
50 AWI_ST_SCAN_SETMIB,
51 AWI_ST_SCAN_SCCMD,
52 AWI_ST_SUB_INIT,
53 AWI_ST_SUB_SETSS,
54 AWI_ST_SUB_SYNC
55 };
56
57 #define AWI_WAIT 0 /* must wait for completion */
58 #define AWI_NOWAIT 1 /* do not wait */
59
60 struct awi_chanset {
61 u_int8_t cs_type;
62 u_int8_t cs_region;
63 u_int8_t cs_min;
64 u_int8_t cs_max;
65 u_int8_t cs_def;
66 };
67
68 struct awi_softc {
69 #ifdef __NetBSD__
70 struct device sc_dev;
71 #endif
72 #ifdef __FreeBSD__
73 device_t sc_dev;
74 #endif
75 struct am79c930_softc sc_chip;
76 struct ethercom sc_ec;
77 struct ieee80211com sc_ic;
78 u_char sc_banner[AWI_BANNER_LEN];
79 int (*sc_enable)(struct awi_softc *);
80 void (*sc_disable)(struct awi_softc *);
81 void (*sc_power)(struct awi_softc *, int);
82
83 int (*sc_newstate)(struct ieee80211com *,
84 enum ieee80211_state, int);
85 void (*sc_recv_mgmt)(struct ieee80211com *,
86 struct mbuf *, struct ieee80211_node *,
87 int, int, u_int32_t);
88 int (*sc_send_mgmt)(struct ieee80211com *,
89 struct ieee80211_node *, int, int);
90
91 void *sc_sdhook; /* shutdown hook */
92 void *sc_powerhook; /* power management hook */
93 unsigned int sc_attached:1,
94 sc_enabled:1,
95 sc_busy:1,
96 sc_cansleep:1,
97 sc_enab_intr:1,
98 sc_adhoc_ap:1,
99 sc_invalid:1;
100 enum ieee80211_state sc_nstate;
101 enum awi_sub_state sc_substate;
102 int sc_sleep_cnt;
103 u_int8_t sc_cmd_inprog;
104 u_int8_t sc_cur_chan;
105
106 int sc_rx_timer;
107 u_int32_t sc_rxdoff;
108 u_int32_t sc_rxmoff;
109 struct mbuf *sc_rxpend;
110
111 int sc_tx_timer;
112 u_int32_t sc_txbase;
113 u_int32_t sc_txend;
114 u_int32_t sc_txnext;
115 u_int32_t sc_txdone;
116
117 struct awi_mib_local sc_mib_local;
118 struct awi_mib_addr sc_mib_addr;
119 struct awi_mib_mac sc_mib_mac;
120 struct awi_mib_stat sc_mib_stat;
121 struct awi_mib_mgt sc_mib_mgt;
122 struct awi_mib_phy sc_mib_phy;
123 };
124
125 #define sc_if sc_ec.ec_if
126
127 #define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off)
128 #define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off)
129 #define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off)
130 #define awi_read_bytes(sc, off, ptr, len) \
131 ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len)
132
133 #define awi_write_1(sc, off, val) \
134 ((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val)
135 #define awi_write_2(sc, off, val) \
136 ((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val)
137 #define awi_write_4(sc, off, val) \
138 ((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val)
139 #define awi_write_bytes(sc, off, ptr, len) \
140 ((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len)
141
142 #define awi_drvstate(sc, state) \
143 awi_write_1(sc, AWI_DRIVERSTATE, \
144 ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED))
145
146 int awi_attach(struct awi_softc *);
147 int awi_detach(struct awi_softc *);
148 #ifdef __NetBSD__
149 int awi_activate(device_t, enum devact);
150 void awi_power(int, void *);
151 #endif
152 void awi_shutdown(void *);
153 int awi_intr(void *);
154
155 #endif /* _DEV_IC_AWIVAR_H */
156