1 /* $OpenBSD: rtwnvar.h,v 1.7 2016/06/17 10:53:55 stsp Exp $ */ 2 3 /*- 4 * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> 5 * Copyright (c) 2015 Stefan Sperling <stsp@openbsd.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /* Operations provided by bus-specific attachment drivers. */ 21 struct rtwn_ops { 22 void *cookie; /* Attachment driver's private data. */ 23 24 uint8_t (*read_1)(void *, uint16_t); 25 uint16_t (*read_2)(void *, uint16_t); 26 uint32_t (*read_4)(void *, uint16_t); 27 void (*write_1)(void *, uint16_t, uint8_t); 28 void (*write_2)(void *, uint16_t, uint16_t); 29 void (*write_4)(void *, uint16_t, uint32_t); 30 int (*tx)(void *, struct mbuf *, struct ieee80211_node *); 31 int (*power_on)(void *); 32 int (*dma_init)(void *); 33 int (*fw_loadpage)(void *, int, uint8_t *, int); 34 int (*load_firmware)(void *, u_char **fw, size_t *); 35 void (*mac_init)(void *); 36 void (*bb_init)(void *); 37 int (*alloc_buffers)(void *); 38 int (*init)(void *); 39 void (*stop)(void *); 40 int (*is_oactive)(void *); 41 void (*next_calib)(void *); 42 void (*cancel_calib)(void *); 43 void (*next_scan)(void *); 44 void (*cancel_scan)(void *); 45 void (*wait_async)(void *); 46 }; 47 48 #define RTWN_LED_LINK 0 49 #define RTWN_LED_DATA 1 50 51 #define RTWN_INT_ENABLE (R92C_IMR_ROK | R92C_IMR_VODOK | R92C_IMR_VIDOK | \ 52 R92C_IMR_BEDOK | R92C_IMR_BKDOK | R92C_IMR_MGNTDOK | \ 53 R92C_IMR_HIGHDOK | R92C_IMR_BDOK | R92C_IMR_RDU | \ 54 R92C_IMR_RXFOVW) 55 56 struct rtwn_softc { 57 /* sc_ops must be initialized by the attachment driver! */ 58 struct rtwn_ops sc_ops; 59 60 struct device *sc_pdev; 61 struct ieee80211com sc_ic; 62 int (*sc_newstate)(struct ieee80211com *, 63 enum ieee80211_state, int); 64 struct task init_task; 65 int ac2idx[EDCA_NUM_AC]; 66 uint32_t sc_flags; 67 #define RTWN_FLAG_CCK_HIPWR 0x01 68 #define RTWN_FLAG_BUSY 0x02 69 #define RTWN_FLAG_FORCE_RAID_11B 0x04 70 71 uint32_t chip; 72 #define RTWN_CHIP_92C 0x00000001 73 #define RTWN_CHIP_92C_1T2R 0x00000002 74 #define RTWN_CHIP_UMC 0x00000004 75 #define RTWN_CHIP_UMC_A_CUT 0x00000008 76 #define RTWN_CHIP_88C 0x00000010 77 #define RTWN_CHIP_88E 0x00000020 78 79 #define RTWN_CHIP_PCI 0x40000000 80 #define RTWN_CHIP_USB 0x80000000 81 82 uint8_t board_type; 83 uint8_t regulatory; 84 uint8_t pa_setting; 85 int avg_pwdb; 86 int thcal_state; 87 int thcal_lctemp; 88 int ntxchains; 89 int nrxchains; 90 int ledlink; 91 92 int sc_tx_timer; 93 int fwcur; 94 struct r92c_rom rom; 95 96 uint8_t r88e_rom[512]; 97 uint8_t cck_tx_pwr[6]; 98 uint8_t ht40_tx_pwr[5]; 99 int8_t bw20_tx_pwr_diff; 100 int8_t ofdm_tx_pwr_diff; 101 102 uint32_t rf_chnlbw[R92C_MAX_CHAINS]; 103 }; 104 105 int rtwn_attach(struct device *, struct rtwn_softc *, uint32_t); 106 int rtwn_detach(struct rtwn_softc *, int); 107 int rtwn_activate(struct rtwn_softc *, int); 108 int8_t rtwn_get_rssi(struct rtwn_softc *, int, void *); 109 void rtwn_update_avgrssi(struct rtwn_softc *, int, int8_t); 110 void rtwn_calib(struct rtwn_softc *); 111 void rtwn_next_scan(struct rtwn_softc *); 112 int rtwn_newstate(struct ieee80211com *, enum ieee80211_state, int); 113 void rtwn_updateedca(struct ieee80211com *); 114 int rtwn_set_key(struct ieee80211com *, struct ieee80211_node *, 115 struct ieee80211_key *); 116 void rtwn_delete_key(struct ieee80211com *, 117 struct ieee80211_node *, struct ieee80211_key *); 118 int rtwn_ioctl(struct ifnet *, u_long, caddr_t); 119 void rtwn_start(struct ifnet *); 120 void rtwn_fw_reset(struct rtwn_softc *); 121