1/* $NetBSD: awivar.h,v 1.28 2017/02/02 10:05:35 nonaka 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 47enum 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 60struct 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 68struct 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_soft_ih; 87 void *sc_sdhook; /* shutdown hook */ 88 void *sc_powerhook; /* power management hook */ 89 unsigned int sc_attached:1, 90 sc_enabled:1, 91 sc_busy:1, 92 sc_cansleep:1, 93 sc_enab_intr:1, 94 sc_adhoc_ap:1; 95 enum ieee80211_state sc_nstate; 96 enum awi_sub_state sc_substate; 97 int sc_sleep_cnt; 98 u_int8_t sc_cmd_inprog; 99 u_int8_t sc_cur_chan; 100 101 int sc_rx_timer; 102 u_int32_t sc_rxdoff; 103 u_int32_t sc_rxmoff; 104 struct mbuf *sc_rxpend; 105 106 int sc_tx_timer; 107 u_int32_t sc_txbase; 108 u_int32_t sc_txend; 109 u_int32_t sc_txnext; 110 u_int32_t sc_txdone; 111 112 struct awi_mib_local sc_mib_local; 113 struct awi_mib_addr sc_mib_addr; 114 struct awi_mib_mac sc_mib_mac; 115 struct awi_mib_stat sc_mib_stat; 116 struct awi_mib_mgt sc_mib_mgt; 117 struct awi_mib_phy sc_mib_phy; 118}; 119 120#define sc_if sc_ec.ec_if 121 122#define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off) 123#define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off) 124#define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off) 125#define awi_read_bytes(sc, off, ptr, len) \ 126 ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len) 127 128#define awi_write_1(sc, off, val) \ 129 ((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val) 130#define awi_write_2(sc, off, val) \ 131 ((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val) 132#define awi_write_4(sc, off, val) \ 133 ((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val) 134#define awi_write_bytes(sc, off, ptr, len) \ 135 ((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len) 136 137#define awi_drvstate(sc, state) \ 138 awi_write_1(sc, AWI_DRIVERSTATE, \ 139 ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED)) 140 141int awi_attach(struct awi_softc *); 142int awi_detach(struct awi_softc *); 143int awi_activate(device_t, enum devact); 144void awi_power(int, void *); 145void awi_shutdown(void *); 146int awi_intr(void *); 147 148#endif /* _DEV_IC_AWIVAR_H */ 149