| 1 | /* $NetBSD: awivar.h,v 1.27 2012/10/27 17:18:19 chs 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 | device_t sc_dev; |
| 70 | struct am79c930_softc sc_chip; |
| 71 | struct ethercom sc_ec; |
| 72 | struct ieee80211com sc_ic; |
| 73 | u_char sc_banner[AWI_BANNER_LEN]; |
| 74 | int (*sc_enable)(struct awi_softc *); |
| 75 | void (*sc_disable)(struct awi_softc *); |
| 76 | void (*sc_power)(struct awi_softc *, int); |
| 77 | |
| 78 | int (*sc_newstate)(struct ieee80211com *, |
| 79 | enum ieee80211_state, int); |
| 80 | void (*sc_recv_mgmt)(struct ieee80211com *, |
| 81 | struct mbuf *, struct ieee80211_node *, |
| 82 | int, int, u_int32_t); |
| 83 | int (*sc_send_mgmt)(struct ieee80211com *, |
| 84 | struct ieee80211_node *, int, int); |
| 85 | |
| 86 | void *sc_sdhook; /* shutdown hook */ |
| 87 | void *sc_powerhook; /* power management hook */ |
| 88 | unsigned int sc_attached:1, |
| 89 | sc_enabled:1, |
| 90 | sc_busy:1, |
| 91 | sc_cansleep:1, |
| 92 | sc_enab_intr:1, |
| 93 | sc_adhoc_ap:1; |
| 94 | enum ieee80211_state sc_nstate; |
| 95 | enum awi_sub_state sc_substate; |
| 96 | int sc_sleep_cnt; |
| 97 | u_int8_t sc_cmd_inprog; |
| 98 | u_int8_t sc_cur_chan; |
| 99 | |
| 100 | int sc_rx_timer; |
| 101 | u_int32_t sc_rxdoff; |
| 102 | u_int32_t sc_rxmoff; |
| 103 | struct mbuf *sc_rxpend; |
| 104 | |
| 105 | int sc_tx_timer; |
| 106 | u_int32_t sc_txbase; |
| 107 | u_int32_t sc_txend; |
| 108 | u_int32_t sc_txnext; |
| 109 | u_int32_t sc_txdone; |
| 110 | |
| 111 | struct awi_mib_local sc_mib_local; |
| 112 | struct awi_mib_addr sc_mib_addr; |
| 113 | struct awi_mib_mac sc_mib_mac; |
| 114 | struct awi_mib_stat sc_mib_stat; |
| 115 | struct awi_mib_mgt sc_mib_mgt; |
| 116 | struct awi_mib_phy sc_mib_phy; |
| 117 | }; |
| 118 | |
| 119 | #define sc_if sc_ec.ec_if |
| 120 | |
| 121 | #define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off) |
| 122 | #define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off) |
| 123 | #define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off) |
| 124 | #define awi_read_bytes(sc, off, ptr, len) \ |
| 125 | ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len) |
| 126 | |
| 127 | #define awi_write_1(sc, off, val) \ |
| 128 | ((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val) |
| 129 | #define awi_write_2(sc, off, val) \ |
| 130 | ((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val) |
| 131 | #define awi_write_4(sc, off, val) \ |
| 132 | ((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val) |
| 133 | #define awi_write_bytes(sc, off, ptr, len) \ |
| 134 | ((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len) |
| 135 | |
| 136 | #define awi_drvstate(sc, state) \ |
| 137 | awi_write_1(sc, AWI_DRIVERSTATE, \ |
| 138 | ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED)) |
| 139 | |
| 140 | int awi_attach(struct awi_softc *); |
| 141 | int awi_detach(struct awi_softc *); |
| 142 | int awi_activate(device_t, enum devact); |
| 143 | void awi_power(int, void *); |
| 144 | void awi_shutdown(void *); |
| 145 | int awi_intr(void *); |
| 146 | |
| 147 | #endif /* _DEV_IC_AWIVAR_H */ |
| 148 | |