add drivers for Ralink RT2500-based wireless adapters, written by
Damien Bergamini, ported and submitted by FUKAUMI Naoki per PR kern/30449 I've modified the USB "ural" driver for recent changes to the NetBSD ieee80211 framework, possibly not completely, but with an ASUS wireless adapter I'm getting some signs of life. Didn't care about pci/cardbus for now, hopefully someone with hardware will do it.
This commit is contained in:
parent
ab856de1bc
commit
c1834d85c2
246
sys/dev/cardbus/if_ral_cardbus.c
Normal file
246
sys/dev/cardbus/if_ral_cardbus.c
Normal file
@ -0,0 +1,246 @@
|
||||
/* $NetBSD: if_ral_cardbus.c,v 1.1 2005/07/01 20:06:56 drochner Exp $ */
|
||||
/* $OpenBSD: if_ral_cardbus.c,v 1.5 2005/05/16 01:36:25 brad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005
|
||||
* Damien Bergamini <damien.bergamini@free.fr>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* CardBus front-end for the Ralink RT2500 driver.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ral_cardbus.c,v 1.1 2005/07/01 20:06:56 drochner Exp $");
|
||||
|
||||
#include "bpfilter.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/intr.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_ether.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <net80211/ieee80211_var.h>
|
||||
#include <net80211/ieee80211_rssadapt.h>
|
||||
#include <net80211/ieee80211_radiotap.h>
|
||||
|
||||
#include <dev/ic/ralvar.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcidevs.h>
|
||||
|
||||
#include <dev/cardbus/cardbusvar.h>
|
||||
|
||||
struct ral_cardbus_softc {
|
||||
struct ral_softc sc_sc;
|
||||
|
||||
/* cardbus specific goo */
|
||||
cardbus_devfunc_t sc_ct;
|
||||
cardbustag_t sc_tag;
|
||||
void *sc_ih;
|
||||
bus_size_t sc_mapsize;
|
||||
pcireg_t sc_bar_val;
|
||||
int sc_intrline;
|
||||
};
|
||||
|
||||
int ral_cardbus_match(struct device *, struct cfdata *, void *);
|
||||
void ral_cardbus_attach(struct device *, struct device *, void *);
|
||||
int ral_cardbus_detach(struct device *, int);
|
||||
|
||||
CFATTACH_DECL(ral_cardbus, sizeof (struct ral_cardbus_softc),
|
||||
ral_cardbus_match, ral_cardbus_attach, ral_cardbus_detach, NULL);
|
||||
|
||||
int ral_cardbus_enable(struct ral_softc *);
|
||||
void ral_cardbus_disable(struct ral_softc *);
|
||||
void ral_cardbus_power(struct ral_softc *, int);
|
||||
void ral_cardbus_setup(struct ral_cardbus_softc *);
|
||||
|
||||
int
|
||||
ral_cardbus_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct cardbus_attach_args *ca = aux;
|
||||
|
||||
if (CARDBUS_VENDOR(ca->ca_id) == PCI_VENDOR_RALINK &&
|
||||
CARDBUS_PRODUCT(ca->ca_id) == PCI_PRODUCT_RALINK_RT2560)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ral_cardbus_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)self;
|
||||
struct ral_softc *sc = &csc->sc_sc;
|
||||
struct cardbus_attach_args *ca = aux;
|
||||
cardbus_devfunc_t ct = ca->ca_ct;
|
||||
bus_addr_t base;
|
||||
int error;
|
||||
|
||||
sc->sc_dmat = ca->ca_dmat;
|
||||
csc->sc_ct = ct;
|
||||
csc->sc_tag = ca->ca_tag;
|
||||
csc->sc_intrline = ca->ca_intrline;
|
||||
|
||||
/* power management hooks */
|
||||
sc->sc_enable = ral_cardbus_enable;
|
||||
sc->sc_disable = ral_cardbus_disable;
|
||||
sc->sc_power = ral_cardbus_power;
|
||||
|
||||
/* map control/status registers */
|
||||
error = Cardbus_mapreg_map(ct, CARDBUS_BASE0_REG,
|
||||
CARDBUS_MAPREG_TYPE_MEM, 0, &sc->sc_st, &sc->sc_sh, &base,
|
||||
&csc->sc_mapsize);
|
||||
if (error != 0) {
|
||||
printf(": could not map memory space\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#if rbus
|
||||
#else
|
||||
(*cf->cardbus_mem_open)(cc, 0, base, base + csc->sc_mapsize);
|
||||
#endif
|
||||
|
||||
csc->sc_bar_val = base | CARDBUS_MAPREG_TYPE_MEM;
|
||||
|
||||
/* set up the PCI configuration registers */
|
||||
ral_cardbus_setup(csc);
|
||||
|
||||
printf(": irq %d", csc->sc_intrline);
|
||||
|
||||
ral_attach(sc);
|
||||
|
||||
Cardbus_function_disable(ct);
|
||||
}
|
||||
|
||||
int
|
||||
ral_cardbus_detach(struct device *self, int flags)
|
||||
{
|
||||
struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)self;
|
||||
struct ral_softc *sc = &csc->sc_sc;
|
||||
cardbus_devfunc_t ct = csc->sc_ct;
|
||||
cardbus_chipset_tag_t cc = ct->ct_cc;
|
||||
cardbus_function_tag_t cf = ct->ct_cf;
|
||||
int error;
|
||||
|
||||
error = ral_detach(sc);
|
||||
if (error != 0)
|
||||
return error;
|
||||
|
||||
/* unhook the interrupt handler */
|
||||
if (csc->sc_ih != NULL) {
|
||||
cardbus_intr_disestablish(cc, cf, csc->sc_ih);
|
||||
csc->sc_ih = NULL;
|
||||
}
|
||||
|
||||
/* release bus space and close window */
|
||||
Cardbus_mapreg_unmap(ct, CARDBUS_BASE0_REG, sc->sc_st, sc->sc_sh,
|
||||
csc->sc_mapsize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ral_cardbus_enable(struct ral_softc *sc)
|
||||
{
|
||||
struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)sc;
|
||||
cardbus_devfunc_t ct = csc->sc_ct;
|
||||
cardbus_chipset_tag_t cc = ct->ct_cc;
|
||||
cardbus_function_tag_t cf = ct->ct_cf;
|
||||
|
||||
/* power on the socket */
|
||||
Cardbus_function_enable(ct);
|
||||
|
||||
/* setup the PCI configuration registers */
|
||||
ral_cardbus_setup(csc);
|
||||
|
||||
/* map and establish the interrupt handler */
|
||||
csc->sc_ih = cardbus_intr_establish(cc, cf, csc->sc_intrline, IPL_NET,
|
||||
ral_intr, sc);
|
||||
if (csc->sc_ih == NULL) {
|
||||
printf("%s: could not establish interrupt at %d\n",
|
||||
sc->sc_dev.dv_xname, csc->sc_intrline);
|
||||
Cardbus_function_disable(ct);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ral_cardbus_disable(struct ral_softc *sc)
|
||||
{
|
||||
struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)sc;
|
||||
cardbus_devfunc_t ct = csc->sc_ct;
|
||||
cardbus_chipset_tag_t cc = ct->ct_cc;
|
||||
cardbus_function_tag_t cf = ct->ct_cf;
|
||||
|
||||
/* unhook the interrupt handler */
|
||||
cardbus_intr_disestablish(cc, cf, csc->sc_ih);
|
||||
csc->sc_ih = NULL;
|
||||
|
||||
/* power down the socket */
|
||||
Cardbus_function_disable(ct);
|
||||
}
|
||||
|
||||
void
|
||||
ral_cardbus_power(struct ral_softc *sc, int why)
|
||||
{
|
||||
struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)sc;
|
||||
|
||||
if (why == PWR_RESUME) {
|
||||
/* kick the PCI configuration registers */
|
||||
ral_cardbus_setup(csc);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ral_cardbus_setup(struct ral_cardbus_softc *csc)
|
||||
{
|
||||
cardbus_devfunc_t ct = csc->sc_ct;
|
||||
cardbus_chipset_tag_t cc = ct->ct_cc;
|
||||
cardbus_function_tag_t cf = ct->ct_cf;
|
||||
pcireg_t reg;
|
||||
|
||||
/* program the BAR */
|
||||
cardbus_conf_write(cc, cf, csc->sc_tag, CARDBUS_BASE0_REG,
|
||||
csc->sc_bar_val);
|
||||
|
||||
/* make sure the right access type is on the cardbus bridge */
|
||||
(*cf->cardbus_ctrl)(cc, CARDBUS_MEM_ENABLE);
|
||||
(*cf->cardbus_ctrl)(cc, CARDBUS_BM_ENABLE);
|
||||
|
||||
/* enable the appropriate bits in the PCI CSR */
|
||||
reg = cardbus_conf_read(cc, cf, csc->sc_tag,
|
||||
CARDBUS_COMMAND_STATUS_REG);
|
||||
reg |= CARDBUS_COMMAND_MASTER_ENABLE | CARDBUS_COMMAND_MEM_ENABLE;
|
||||
cardbus_conf_write(cc, cf, csc->sc_tag, CARDBUS_COMMAND_STATUS_REG,
|
||||
reg);
|
||||
}
|
2817
sys/dev/ic/ral.c
Normal file
2817
sys/dev/ic/ral.c
Normal file
File diff suppressed because it is too large
Load Diff
314
sys/dev/ic/ralreg.h
Normal file
314
sys/dev/ic/ralreg.h
Normal file
@ -0,0 +1,314 @@
|
||||
/* $NetBSD: ralreg.h,v 1.1 2005/07/01 20:06:56 drochner Exp $ */
|
||||
/* $OpenBSD: ralreg.h,v 1.5 2005/04/01 11:12:57 damien Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005
|
||||
* Damien Bergamini <damien.bergamini@free.fr>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define RAL_TX_RING_COUNT 48
|
||||
#define RAL_ATIM_RING_COUNT 4
|
||||
#define RAL_PRIO_RING_COUNT 16
|
||||
#define RAL_BEACON_RING_COUNT 1
|
||||
#define RAL_RX_RING_COUNT 32
|
||||
|
||||
#define RAL_TX_DESC_SIZE (sizeof (struct ral_tx_desc))
|
||||
#define RAL_RX_DESC_SIZE (sizeof (struct ral_rx_desc))
|
||||
|
||||
#define RAL_MAX_SCATTER 1
|
||||
|
||||
/*
|
||||
* Control and status registers.
|
||||
*/
|
||||
#define RAL_CSR0 0x0000 /* ASIC version number */
|
||||
#define RAL_CSR1 0x0004 /* System control */
|
||||
#define RAL_CSR3 0x000c /* STA MAC address 0 */
|
||||
#define RAL_CSR4 0x0010 /* STA MAC address 1 */
|
||||
#define RAL_CSR5 0x0014 /* BSSID 0 */
|
||||
#define RAL_CSR6 0x0018 /* BSSID 1 */
|
||||
#define RAL_CSR7 0x001c /* Interrupt source */
|
||||
#define RAL_CSR8 0x0020 /* Interrupt mask */
|
||||
#define RAL_CSR9 0x0024 /* Maximum frame length */
|
||||
#define RAL_SECCSR0 0x0028 /* WEP control */
|
||||
#define RAL_CSR11 0x002c /* Back-off control */
|
||||
#define RAL_CSR12 0x0030 /* Synchronization configuration 0 */
|
||||
#define RAL_CSR13 0x0034 /* Synchronization configuration 1 */
|
||||
#define RAL_CSR14 0x0038 /* Synchronization control */
|
||||
#define RAL_CSR15 0x003c /* Synchronization status */
|
||||
#define RAL_CSR16 0x0040 /* TSF timer 0 */
|
||||
#define RAL_CSR17 0x0044 /* TSF timer 1 */
|
||||
#define RAL_CSR18 0x0048 /* IFS timer 0 */
|
||||
#define RAL_CSR19 0x004c /* IFS timer 1 */
|
||||
#define RAL_CSR20 0x0050 /* WAKEUP timer */
|
||||
#define RAL_CSR21 0x0054 /* EEPROM control */
|
||||
#define RAL_CSR22 0x0058 /* CFP control */
|
||||
#define RAL_TXCSR0 0x0060 /* TX control */
|
||||
#define RAL_TXCSR1 0x0064 /* TX configuration */
|
||||
#define RAL_TXCSR2 0x0068 /* TX descriptor configuration */
|
||||
#define RAL_TXCSR3 0x006c /* TX ring base address */
|
||||
#define RAL_TXCSR4 0x0070 /* TX ATIM ring base address */
|
||||
#define RAL_TXCSR5 0x0074 /* TX PRIO ring base address */
|
||||
#define RAL_TXCSR6 0x0078 /* Beacon base address */
|
||||
#define RAL_TXCSR7 0x007c /* AutoResponder control */
|
||||
#define RAL_RXCSR0 0x0080 /* RX control */
|
||||
#define RAL_RXCSR1 0x0084 /* RX descriptor configuration */
|
||||
#define RAL_RXCSR2 0x0088 /* RX ring base address */
|
||||
#define RAL_PCICSR 0x008c /* PCI control */
|
||||
#define RAL_RXCSR3 0x0090 /* BBP ID 0 */
|
||||
#define RAL_TXCSR9 0x0094 /* OFDM TX BBP */
|
||||
#define RAL_ARSP_PLCP_0 0x0098 /* Auto Responder PLCP address */
|
||||
#define RAL_ARSP_PLCP_1 0x009c /* Auto Responder PLCP Basic Rate bit mask */
|
||||
#define RAL_CNT0 0x00a0 /* FCS error counter */
|
||||
#define RAL_CNT1 0x00ac /* PLCP error counter */
|
||||
#define RAL_CNT2 0x00b0 /* Long error counter */
|
||||
#define RAL_CNT3 0x00b8 /* CCA false alarm counter */
|
||||
#define RAL_CNT4 0x00bc /* RX FIFO Overflow counter */
|
||||
#define RAL_CNT5 0x00c0 /* Tx FIFO Underrun counter */
|
||||
#define RAL_PWRCSR0 0x00c4 /* Power mode configuration */
|
||||
#define RAL_PSCSR0 0x00c8 /* Power state transition time */
|
||||
#define RAL_PSCSR1 0x00cc /* Power state transition time */
|
||||
#define RAL_PSCSR2 0x00d0 /* Power state transition time */
|
||||
#define RAL_PSCSR3 0x00d4 /* Power state transition time */
|
||||
#define RAL_PWRCSR1 0x00d8 /* Manual power control/status */
|
||||
#define RAL_TIMECSR 0x00dc /* Timer control */
|
||||
#define RAL_MACCSR0 0x00e0 /* MAC configuration */
|
||||
#define RAL_MACCSR1 0x00e4 /* MAC configuration */
|
||||
#define RAL_RALINKCSR 0x00e8 /* Ralink RX auto-reset BBCR */
|
||||
#define RAL_BCNCSR 0x00ec /* Beacon interval control */
|
||||
#define RAL_BBPCSR 0x00f0 /* BBP serial control */
|
||||
#define RAL_RFCSR 0x00f4 /* RF serial control */
|
||||
#define RAL_LEDCSR 0x00f8 /* LED control */
|
||||
#define RAL_SECCSR3 0x00fc /* XXX not documented */
|
||||
#define RAL_DMACSR0 0x0100 /* Current RX ring address */
|
||||
#define RAL_DMACSR1 0x0104 /* Current Tx ring address */
|
||||
#define RAL_DMACSR2 0x0104 /* Current Priority ring address */
|
||||
#define RAL_DMACSR3 0x0104 /* Current ATIM ring address */
|
||||
#define RAL_TXACKCSR0 0x0110 /* XXX not documented */
|
||||
#define RAL_GPIOCSR 0x0120 /* */
|
||||
#define RAL_BBBPPCSR 0x0124 /* BBP Pin Control */
|
||||
#define RAL_FIFOCSR0 0x0128 /* TX FIFO pointer */
|
||||
#define RAL_FIFOCSR1 0x012c /* RX FIFO pointer */
|
||||
#define RAL_BCNOCSR 0x0130 /* Beacon time offset */
|
||||
#define RAL_RLPWCSR 0x0134 /* RX_PE Low Width */
|
||||
#define RAL_TESTCSR 0x0138 /* Test Mode Select */
|
||||
#define RAL_PLCP1MCSR 0x013c /* Signal/Service/Length of ACK/CTS @1M */
|
||||
#define RAL_PLCP2MCSR 0x0140 /* Signal/Service/Length of ACK/CTS @2M */
|
||||
#define RAL_PLCP5p5MCSR 0x0144 /* Signal/Service/Length of ACK/CTS @5.5M */
|
||||
#define RAL_PLCP11MCSR 0x0148 /* Signal/Service/Length of ACK/CTS @11M */
|
||||
#define RAL_ACKPCTCSR 0x014c /* ACK/CTS padload consume time */
|
||||
#define RAL_ARTCSR1 0x0150 /* ACK/CTS padload consume time */
|
||||
#define RAL_ARTCSR2 0x0154 /* ACK/CTS padload consume time */
|
||||
#define RAL_SECCSR1 0x0158 /* WEP control */
|
||||
#define RAL_BBPCSR1 0x015c /* BBP TX Configuration */
|
||||
|
||||
|
||||
/* possible flags for register RXCSR0 */
|
||||
#define RAL_DISABLE_RX (1 << 0)
|
||||
#define RAL_DROP_CRC_ERROR (1 << 1)
|
||||
#define RAL_DROP_PHY_ERROR (1 << 2)
|
||||
#define RAL_DROP_CTL (1 << 3)
|
||||
#define RAL_DROP_NOT_TO_ME (1 << 4)
|
||||
#define RAL_DROP_TODS (1 << 5)
|
||||
#define RAL_DROP_VERSION_ERROR (1 << 6)
|
||||
|
||||
/* possible flags for register CSR1 */
|
||||
#define RAL_RESET_ASIC (1 << 0)
|
||||
#define RAL_RESET_BBP (1 << 1)
|
||||
#define RAL_HOST_READY (1 << 2)
|
||||
|
||||
/* possible flags for register CSR14 */
|
||||
#define RAL_ENABLE_TSF (1 << 0)
|
||||
#define RAL_ENABLE_TSF_SYNC(x) (((x) & 0x3) << 1)
|
||||
#define RAL_ENABLE_TBCN (1 << 3)
|
||||
#define RAL_ENABLE_BEACON_GENERATOR (1 << 6)
|
||||
|
||||
/* possible flags for register CSR21 */
|
||||
#define RAL_EEPROM_C (1 << 1)
|
||||
#define RAL_EEPROM_S (1 << 2)
|
||||
#define RAL_EEPROM_D (1 << 3)
|
||||
#define RAL_EEPROM_Q (1 << 4)
|
||||
#define RAL_EEPROM_93C46 (1 << 5)
|
||||
|
||||
#define RAL_EEPROM_SHIFT_D 3
|
||||
#define RAL_EEPROM_SHIFT_Q 4
|
||||
|
||||
/* possible flags for register TXCSR0 */
|
||||
#define RAL_KICK_TX (1 << 0)
|
||||
#define RAL_KICK_ATIM (1 << 1)
|
||||
#define RAL_KICK_PRIO (1 << 2)
|
||||
#define RAL_ABORT_TX (1 << 3)
|
||||
|
||||
/* possible flags for register SECCSR0 */
|
||||
#define RAL_KICK_DECRYPT (1 << 0)
|
||||
|
||||
/* possible flags for register SECCSR1 */
|
||||
#define RAL_KICK_ENCRYPT (1 << 0)
|
||||
|
||||
/* possible flags for register CSR7 */
|
||||
#define RAL_BEACON_EXPIRE 0x00000001
|
||||
#define RAL_WAKEUP_EXPIRE 0x00000002
|
||||
#define RAL_ATIM_EXPIRE 0x00000004
|
||||
#define RAL_TX_DONE 0x00000008
|
||||
#define RAL_ATIM_DONE 0x00000010
|
||||
#define RAL_PRIO_DONE 0x00000020
|
||||
#define RAL_RX_DONE 0x00000040
|
||||
#define RAL_DECRYPTION_DONE 0x00000080
|
||||
#define RAL_ENCRYPTION_DONE 0x00000100
|
||||
|
||||
#define RAL_INTR_MASK \
|
||||
(~(RAL_BEACON_EXPIRE | RAL_WAKEUP_EXPIRE | RAL_TX_DONE | \
|
||||
RAL_PRIO_DONE | RAL_RX_DONE | RAL_DECRYPTION_DONE | \
|
||||
RAL_ENCRYPTION_DONE))
|
||||
|
||||
/* Tx descriptor */
|
||||
struct ral_tx_desc {
|
||||
uint32_t flags;
|
||||
#define RAL_TX_BUSY (1 << 0)
|
||||
#define RAL_TX_VALID (1 << 1)
|
||||
|
||||
#define RAL_TX_RESULT_MASK 0x0000001c
|
||||
#define RAL_TX_SUCCESS (0 << 2)
|
||||
#define RAL_TX_SUCCESS_RETRY (1 << 2)
|
||||
#define RAL_TX_FAIL_RETRY (2 << 2)
|
||||
#define RAL_TX_FAIL_INVALID (3 << 2)
|
||||
#define RAL_TX_FAIL_OTHER (4 << 2)
|
||||
|
||||
#define RAL_TX_MORE_FRAG (1 << 8)
|
||||
#define RAL_TX_ACK (1 << 9)
|
||||
#define RAL_TX_TIMESTAMP (1 << 10)
|
||||
#define RAL_TX_OFDM (1 << 11)
|
||||
#define RAL_TX_CIPHER_BUSY (1 << 12)
|
||||
|
||||
#define RAL_TX_IFS_MASK 0x00006000
|
||||
#define RAL_TX_IFS_BACKOFF (0 << 13)
|
||||
#define RAL_TX_IFS_SIFS (1 << 13)
|
||||
#define RAL_TX_IFS_NEWBACKOFF (2 << 13)
|
||||
#define RAL_TX_IFS_NONE (3 << 13)
|
||||
|
||||
#define RAL_TX_LONG_RETRY (1 << 15)
|
||||
|
||||
#define RAL_TX_CIPHER_MASK 0xe0000000
|
||||
#define RAL_TX_CIPHER_NONE (0 << 29)
|
||||
#define RAL_TX_CIPHER_WEP40 (1 << 29)
|
||||
#define RAL_TX_CIPHER_WEP104 (2 << 29)
|
||||
#define RAL_TX_CIPHER_TKIP (3 << 29)
|
||||
#define RAL_TX_CIPHER_AES (4 << 29)
|
||||
|
||||
uint32_t physaddr;
|
||||
uint16_t wme;
|
||||
#define RAL_LOGCWMAX(x) (((x) & 0xf) << 12)
|
||||
#define RAL_LOGCWMIN(x) (((x) & 0xf) << 8)
|
||||
#define RAL_AIFSN(x) (((x) & 0x3) << 6)
|
||||
#define RAL_IVOFFSET(x) (((x) & 0x3f))
|
||||
|
||||
uint16_t reserved1;
|
||||
uint8_t plcp_signal;
|
||||
uint8_t plcp_service;
|
||||
#define RAL_PLCP_LENGEXT 0x80
|
||||
|
||||
uint16_t plcp_length;
|
||||
uint32_t iv;
|
||||
uint32_t eiv;
|
||||
uint8_t key[IEEE80211_KEYBUF_SIZE];
|
||||
uint32_t reserved2[2];
|
||||
} __packed;
|
||||
|
||||
/* Rx descriptor */
|
||||
struct ral_rx_desc {
|
||||
uint32_t flags;
|
||||
#define RAL_RX_BUSY (1 << 0)
|
||||
#define RAL_RX_CRC_ERROR (1 << 5)
|
||||
#define RAL_RX_PHY_ERROR (1 << 7)
|
||||
#define RAL_RX_CIPHER_BUSY (1 << 8)
|
||||
#define RAL_RX_ICV_ERROR (1 << 9)
|
||||
|
||||
#define RAL_RX_CIPHER_MASK 0xe0000000
|
||||
#define RAL_RX_CIPHER_NONE (0 << 29)
|
||||
#define RAL_RX_CIPHER_WEP40 (1 << 29)
|
||||
#define RAL_RX_CIPHER_WEP104 (2 << 29)
|
||||
#define RAL_RX_CIPHER_TKIP (3 << 29)
|
||||
#define RAL_RX_CIPHER_AES (4 << 29)
|
||||
|
||||
uint32_t physaddr;
|
||||
uint8_t rate;
|
||||
uint8_t rssi;
|
||||
uint8_t ta[IEEE80211_ADDR_LEN];
|
||||
uint32_t iv;
|
||||
uint32_t eiv;
|
||||
uint8_t key[IEEE80211_KEYBUF_SIZE];
|
||||
uint32_t reserved[2];
|
||||
} __packed;
|
||||
|
||||
#define RAL_RF1 0
|
||||
#define RAL_RF2 2
|
||||
#define RAL_RF3 1
|
||||
#define RAL_RF4 3
|
||||
|
||||
#define RAL_RF1_AUTOTUNE 0x08000
|
||||
#define RAL_RF3_AUTOTUNE 0x00040
|
||||
|
||||
#define RAL_BBP_BUSY (1 << 15)
|
||||
#define RAL_BBP_WRITE (1 << 16)
|
||||
#define RAL_RF_20BIT (20 << 24)
|
||||
#define RAL_RF_BUSY (1 << 31)
|
||||
|
||||
#define RAL_RF_2522 0x00
|
||||
#define RAL_RF_2523 0x01
|
||||
#define RAL_RF_2524 0x02
|
||||
#define RAL_RF_2525 0x03
|
||||
#define RAL_RF_2525E 0x04
|
||||
#define RAL_RF_2526 0x05
|
||||
/* dual-band RF */
|
||||
#define RAL_RF_5222 0x10
|
||||
|
||||
#define RAL_BBP_VERSION 0
|
||||
#define RAL_BBP_TX 2
|
||||
#define RAL_BBP_RX 14
|
||||
|
||||
#define RAL_BBP_ANTA 0x00
|
||||
#define RAL_BBP_DIVERSITY 0x01
|
||||
#define RAL_BBP_ANTB 0x02
|
||||
#define RAL_BBP_ANTMASK 0x03
|
||||
#define RAL_BBP_FLIPIQ 0x04
|
||||
|
||||
#define RAL_LED_MODE_DEFAULT 0
|
||||
#define RAL_LED_MODE_TXRX_ACTIVITY 1
|
||||
#define RAL_LED_MODE_SINGLE 2
|
||||
#define RAL_LED_MODE_ASUS 3
|
||||
|
||||
#define RAL_JAPAN_FILTER 0x8
|
||||
|
||||
#define RAL_EEPROM_CONFIG0 16
|
||||
#define RAL_EEPROM_BBP_BASE 19
|
||||
#define RAL_EEPROM_TXPOWER 35
|
||||
|
||||
#define RAL_EEPROM_DELAY 1 /* minimum hold time (microsecond) */
|
||||
|
||||
/*
|
||||
* control and status registers access macros
|
||||
*/
|
||||
#define RAL_READ(sc, reg) \
|
||||
bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
|
||||
|
||||
#define RAL_WRITE(sc, reg, val) \
|
||||
bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
|
||||
|
||||
/*
|
||||
* EEPROM access macro
|
||||
*/
|
||||
#define RAL_EEPROM_CTL(sc, val) do { \
|
||||
RAL_WRITE((sc), RAL_CSR21, (val)); \
|
||||
DELAY(RAL_EEPROM_DELAY); \
|
||||
} while (/* CONSTCOND */0)
|
163
sys/dev/ic/ralvar.h
Normal file
163
sys/dev/ic/ralvar.h
Normal file
@ -0,0 +1,163 @@
|
||||
/* $NetBSD: ralvar.h,v 1.1 2005/07/01 20:06:56 drochner Exp $ */
|
||||
/* $OpenBSD: ralvar.h,v 1.7 2005/03/11 19:39:35 damien Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005
|
||||
* Damien Bergamini <damien.bergamini@free.fr>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
struct ral_rx_radiotap_header {
|
||||
struct ieee80211_radiotap_header wr_ihdr;
|
||||
uint64_t wr_tsf;
|
||||
uint8_t wr_flags;
|
||||
uint16_t wr_chan_freq;
|
||||
uint16_t wr_chan_flags;
|
||||
uint8_t wr_antenna;
|
||||
uint8_t wr_antsignal;
|
||||
} __packed;
|
||||
|
||||
#define RAL_RX_RADIOTAP_PRESENT \
|
||||
((1 << IEEE80211_RADIOTAP_TSFT) | \
|
||||
(1 << IEEE80211_RADIOTAP_FLAGS) | \
|
||||
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
|
||||
(1 << IEEE80211_RADIOTAP_ANTENNA) | \
|
||||
(1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
|
||||
|
||||
struct ral_tx_radiotap_header {
|
||||
struct ieee80211_radiotap_header wt_ihdr;
|
||||
uint8_t wt_flags;
|
||||
uint8_t wt_rate;
|
||||
uint16_t wt_chan_freq;
|
||||
uint16_t wt_chan_flags;
|
||||
uint8_t wt_antenna;
|
||||
} __packed;
|
||||
|
||||
#define RAL_TX_RADIOTAP_PRESENT \
|
||||
((1 << IEEE80211_RADIOTAP_FLAGS) | \
|
||||
(1 << IEEE80211_RADIOTAP_RATE) | \
|
||||
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
|
||||
(1 << IEEE80211_RADIOTAP_ANTENNA))
|
||||
|
||||
struct ral_tx_data {
|
||||
bus_dmamap_t map;
|
||||
struct mbuf *m;
|
||||
struct ieee80211_node *ni;
|
||||
struct ieee80211_rssdesc id;
|
||||
};
|
||||
|
||||
struct ral_tx_ring {
|
||||
bus_dmamap_t map;
|
||||
bus_dma_segment_t seg;
|
||||
bus_addr_t physaddr;
|
||||
struct ral_tx_desc *desc;
|
||||
struct ral_tx_data *data;
|
||||
int count;
|
||||
int queued;
|
||||
int cur;
|
||||
int next;
|
||||
int cur_encrypt;
|
||||
int next_encrypt;
|
||||
};
|
||||
|
||||
struct ral_rx_data {
|
||||
bus_dmamap_t map;
|
||||
struct mbuf *m;
|
||||
int drop;
|
||||
};
|
||||
|
||||
struct ral_rx_ring {
|
||||
bus_dmamap_t map;
|
||||
bus_dma_segment_t seg;
|
||||
bus_addr_t physaddr;
|
||||
struct ral_rx_desc *desc;
|
||||
struct ral_rx_data *data;
|
||||
int count;
|
||||
int cur;
|
||||
int next;
|
||||
int cur_decrypt;
|
||||
};
|
||||
|
||||
struct ral_node {
|
||||
struct ieee80211_node ni;
|
||||
struct ieee80211_rssadapt rssadapt;
|
||||
};
|
||||
|
||||
struct ral_softc {
|
||||
struct device sc_dev;
|
||||
|
||||
struct ieee80211com sc_ic;
|
||||
int (*sc_newstate)(struct ieee80211com *,
|
||||
enum ieee80211_state, int);
|
||||
|
||||
int (*sc_enable)(struct ral_softc *);
|
||||
void (*sc_disable)(struct ral_softc *);
|
||||
void (*sc_power)(struct ral_softc *, int);
|
||||
|
||||
bus_dma_tag_t sc_dmat;
|
||||
bus_space_tag_t sc_st;
|
||||
bus_space_handle_t sc_sh;
|
||||
|
||||
struct callout scan_ch;
|
||||
struct callout rssadapt_ch;
|
||||
|
||||
int sc_tx_timer;
|
||||
|
||||
uint32_t asic_rev;
|
||||
uint32_t eeprom_rev;
|
||||
uint8_t rf_rev;
|
||||
|
||||
struct ral_tx_ring txq;
|
||||
struct ral_tx_ring prioq;
|
||||
struct ral_tx_ring atimq;
|
||||
struct ral_tx_ring bcnq;
|
||||
struct ral_rx_ring rxq;
|
||||
|
||||
uint32_t rf_regs[4];
|
||||
uint8_t txpow[14];
|
||||
|
||||
struct {
|
||||
uint8_t reg;
|
||||
uint8_t val;
|
||||
} bbp_prom[16];
|
||||
|
||||
int led_mode;
|
||||
int hw_radio;
|
||||
int rx_ant;
|
||||
int tx_ant;
|
||||
int nb_ant;
|
||||
|
||||
#if NBPFILTER > 0
|
||||
caddr_t sc_drvbpf;
|
||||
|
||||
union {
|
||||
struct ral_rx_radiotap_header th;
|
||||
uint8_t pad[64];
|
||||
} sc_rxtapu;
|
||||
#define sc_rxtap sc_rxtapu.th
|
||||
int sc_rxtap_len;
|
||||
|
||||
union {
|
||||
struct ral_tx_radiotap_header th;
|
||||
uint8_t pad[64];
|
||||
} sc_txtapu;
|
||||
#define sc_txtap sc_txtapu.th
|
||||
int sc_txtap_len;
|
||||
#endif
|
||||
};
|
||||
|
||||
int ral_attach(struct ral_softc *);
|
||||
int ral_detach(struct ral_softc *);
|
||||
int ral_intr(void *);
|
||||
int ral_activate(struct device *, enum devact);
|
148
sys/dev/pci/if_ral_pci.c
Normal file
148
sys/dev/pci/if_ral_pci.c
Normal file
@ -0,0 +1,148 @@
|
||||
/* $NetBSD: if_ral_pci.c,v 1.1 2005/07/01 20:06:56 drochner Exp $ */
|
||||
/* $OpenBSD: if_ral_pci.c,v 1.4 2005/02/22 10:41:30 damien Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005
|
||||
* Damien Bergamini <damien.bergamini@free.fr>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* PCI front-end for the Ralink RT2500 driver.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c,v 1.1 2005/07/01 20:06:56 drochner Exp $");
|
||||
|
||||
#include "bpfilter.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/intr.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_ether.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <net80211/ieee80211_var.h>
|
||||
#include <net80211/ieee80211_rssadapt.h>
|
||||
#include <net80211/ieee80211_radiotap.h>
|
||||
|
||||
#include <dev/ic/ralvar.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcidevs.h>
|
||||
|
||||
struct ral_pci_softc {
|
||||
struct ral_softc sc_sc;
|
||||
|
||||
/* PCI specific goo */
|
||||
pci_chipset_tag_t sc_pc;
|
||||
void *sc_ih;
|
||||
bus_size_t sc_mapsize;
|
||||
};
|
||||
|
||||
/* Base Address Register */
|
||||
#define RAL_PCI_BAR0 0x10
|
||||
|
||||
int ral_pci_match(struct device *, struct cfdata *, void *);
|
||||
void ral_pci_attach(struct device *, struct device *, void *);
|
||||
int ral_pci_detach(struct device *, int);
|
||||
|
||||
CFATTACH_DECL(ral_pci, sizeof (struct ral_pci_softc),
|
||||
ral_pci_match, ral_pci_attach, ral_pci_detach, NULL);
|
||||
|
||||
int
|
||||
ral_pci_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct pci_attach_args *pa = aux;
|
||||
|
||||
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_RALINK &&
|
||||
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_RALINK_RT2560)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ral_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct ral_pci_softc *psc = (struct ral_pci_softc *)self;
|
||||
struct ral_softc *sc = &psc->sc_sc;
|
||||
struct pci_attach_args *pa = aux;
|
||||
const char *intrstr;
|
||||
bus_addr_t base;
|
||||
pci_intr_handle_t ih;
|
||||
pcireg_t reg;
|
||||
int error;
|
||||
|
||||
sc->sc_dmat = pa->pa_dmat;
|
||||
psc->sc_pc = pa->pa_pc;
|
||||
|
||||
/* enable the appropriate bits in the PCI CSR */
|
||||
reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
|
||||
reg |= PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_MEM_ENABLE;
|
||||
pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, reg);
|
||||
|
||||
/* map control/status registers */
|
||||
error = pci_mapreg_map(pa, RAL_PCI_BAR0, PCI_MAPREG_TYPE_MEM |
|
||||
PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_st, &sc->sc_sh, &base,
|
||||
&psc->sc_mapsize);
|
||||
if (error != 0) {
|
||||
printf(": could not map memory space\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pci_intr_map(pa, &ih) != 0) {
|
||||
printf(": could not map interrupt\n");
|
||||
return;
|
||||
}
|
||||
|
||||
intrstr = pci_intr_string(psc->sc_pc, ih);
|
||||
psc->sc_ih = pci_intr_establish(psc->sc_pc, ih, IPL_NET, ral_intr, sc);
|
||||
if (psc->sc_ih == NULL) {
|
||||
printf(": could not establish interrupt");
|
||||
if (intrstr != NULL)
|
||||
printf(" at %s", intrstr);
|
||||
printf("\n");
|
||||
return;
|
||||
}
|
||||
printf(": %s", intrstr);
|
||||
|
||||
ral_attach(sc);
|
||||
}
|
||||
|
||||
int
|
||||
ral_pci_detach(struct device *self, int flags)
|
||||
{
|
||||
struct ral_pci_softc *psc = (struct ral_pci_softc *)self;
|
||||
struct ral_softc *sc = &psc->sc_sc;
|
||||
|
||||
ral_detach(sc);
|
||||
pci_intr_disestablish(psc->sc_pc, psc->sc_ih);
|
||||
|
||||
return 0;
|
||||
}
|
2246
sys/dev/usb/if_ural.c
Normal file
2246
sys/dev/usb/if_ural.c
Normal file
File diff suppressed because it is too large
Load Diff
201
sys/dev/usb/if_uralreg.h
Normal file
201
sys/dev/usb/if_uralreg.h
Normal file
@ -0,0 +1,201 @@
|
||||
/* $NetBSD: if_uralreg.h,v 1.1 2005/07/01 20:06:56 drochner Exp $ */
|
||||
/* $OpenBSD: if_ralreg.h,v 1.5 2005/04/01 13:13:43 damien Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005
|
||||
* Damien Bergamini <damien.bergamini@free.fr>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define RAL_RX_DESC_SIZE (sizeof (struct ural_rx_desc))
|
||||
#define RAL_TX_DESC_SIZE (sizeof (struct ural_tx_desc))
|
||||
|
||||
#define RAL_CONFIG_NO 1
|
||||
#define RAL_IFACE_INDEX 0
|
||||
|
||||
#define RAL_WRITE_MAC 0x02
|
||||
#define RAL_READ_MAC 0x03
|
||||
#define RAL_WRITE_MULTI_MAC 0x06
|
||||
#define RAL_READ_MULTI_MAC 0x07
|
||||
#define RAL_READ_EEPROM 0x09
|
||||
|
||||
/*
|
||||
* MAC registers.
|
||||
*/
|
||||
#define RAL_MAC_CSR0 0x0400 /* ASIC Version */
|
||||
#define RAL_MAC_CSR1 0x0402 /* System control */
|
||||
#define RAL_MAC_CSR2 0x0404 /* MAC addr0 */
|
||||
#define RAL_MAC_CSR3 0x0406 /* MAC addr1 */
|
||||
#define RAL_MAC_CSR4 0x0408 /* MAC addr2 */
|
||||
#define RAL_MAC_CSR5 0x040a /* BSSID0 */
|
||||
#define RAL_MAC_CSR6 0x040c /* BSSID1 */
|
||||
#define RAL_MAC_CSR7 0x040e /* BSSID2 */
|
||||
#define RAL_MAC_CSR8 0x0410 /* Max frame length */
|
||||
#define RAL_MAC_CSR9 0x0412 /* Timer control */
|
||||
#define RAL_MAC_CSR11 0x0416 /* IFS */
|
||||
#define RAL_MAC_CSR12 0x0418 /* EIFS */
|
||||
#define RAL_MAC_CSR13 0x041a /* Power mode0 */
|
||||
#define RAL_MAC_CSR14 0x041c /* Power mode1 */
|
||||
#define RAL_MAC_CSR15 0x041e /* Power saving transition0 */
|
||||
#define RAL_MAC_CSR16 0x0420 /* Power saving transition1 */
|
||||
#define RAL_MAC_CSR17 0x0422 /* Power state control */
|
||||
#define RAL_MAC_CSR18 0x0424 /* Auto wake-up control */
|
||||
#define RAL_MAC_CSR19 0x0426 /* GPIO control */
|
||||
#define RAL_MAC_CSR20 0x0428 /* LED control0 */
|
||||
#define RAL_MAC_CSR22 0x042c /* XXX not documented */
|
||||
|
||||
/*
|
||||
* Tx/Rx Registers.
|
||||
*/
|
||||
#define RAL_TXRX_CSR0 0x0440 /* Security control */
|
||||
#define RAL_TXRX_CSR2 0x0444 /* Rx control */
|
||||
#define RAL_TXRX_CSR5 0x044a /* CCK Tx BBP ID0 */
|
||||
#define RAL_TXRX_CSR6 0x044c /* CCK Tx BBP ID1 */
|
||||
#define RAL_TXRX_CSR7 0x044e /* OFDM Tx BBP ID0 */
|
||||
#define RAL_TXRX_CSR8 0x0450 /* OFDM Tx BBP ID1 */
|
||||
#define RAL_TXRX_CSR11 0x0456 /* Auto responder basic rate */
|
||||
#define RAL_TXRX_CSR18 0x0464 /* Beacon interval */
|
||||
#define RAL_TXRX_CSR19 0x0466 /* Beacon/sync control */
|
||||
#define RAL_TXRX_CSR20 0x0468 /* Beacon alignment */
|
||||
#define RAL_TXRX_CSR21 0x046a /* XXX not documented */
|
||||
|
||||
/*
|
||||
* Security registers.
|
||||
*/
|
||||
#define RAL_SEC_CSR0 0x0480 /* Shared key 0, word 0 */
|
||||
|
||||
/*
|
||||
* PHY registers.
|
||||
*/
|
||||
#define RAL_PHY_CSR2 0x04c4 /* Tx MAC configuration */
|
||||
#define RAL_PHY_CSR4 0x04c8 /* Interface configuration */
|
||||
#define RAL_PHY_CSR5 0x04ca /* BBP Pre-Tx CCK */
|
||||
#define RAL_PHY_CSR6 0x04cc /* BBP Pre-Tx OFDM */
|
||||
#define RAL_PHY_CSR7 0x04ce /* BBP serial control */
|
||||
#define RAL_PHY_CSR8 0x04d0 /* BBP serial status */
|
||||
#define RAL_PHY_CSR9 0x04d2 /* RF serial control0 */
|
||||
#define RAL_PHY_CSR10 0x04d4 /* RF serial control1 */
|
||||
|
||||
/*
|
||||
* Statistics registers.
|
||||
*/
|
||||
#define RAL_STA_CSR0 0x04e0 /* FCS error */
|
||||
|
||||
|
||||
#define RAL_DISABLE_RX (1 << 0)
|
||||
#define RAL_DROP_CRC_ERROR (1 << 1)
|
||||
#define RAL_DROP_PHY_ERROR (1 << 2)
|
||||
#define RAL_DROP_CTL (1 << 3)
|
||||
#define RAL_DROP_NOT_TO_ME (1 << 4)
|
||||
#define RAL_DROP_TODS (1 << 5)
|
||||
#define RAL_DROP_VERSION_ERROR (1 << 6)
|
||||
#define RAL_DROP_MULTICAST (1 << 9)
|
||||
#define RAL_DROP_BROADCAST (1 << 10)
|
||||
|
||||
#define RAL_HOST_READY (1 << 2)
|
||||
#define RAL_RESET_ASIC (1 << 0)
|
||||
#define RAL_RESET_BBP (1 << 1)
|
||||
|
||||
#define RAL_ENABLE_TSF (1 << 0)
|
||||
#define RAL_ENABLE_TSF_SYNC(x) (((x) & 0x3) << 1)
|
||||
#define RAL_ENABLE_TBCN (1 << 3)
|
||||
#define RAL_ENABLE_BEACON_GENERATOR (1 << 4)
|
||||
|
||||
#define RAL_RF_AWAKE (3 << 7)
|
||||
#define RAL_BBP_AWAKE (3 << 5)
|
||||
|
||||
#define RAL_BBP_WRITE (1 << 15)
|
||||
#define RAL_BBP_BUSY (1 << 0)
|
||||
|
||||
#define RAL_RF1_AUTOTUNE 0x08000
|
||||
#define RAL_RF3_AUTOTUNE 0x00040
|
||||
|
||||
#define RAL_RF_2522 0x00
|
||||
#define RAL_RF_2523 0x01
|
||||
#define RAL_RF_2524 0x02
|
||||
#define RAL_RF_2525 0x03
|
||||
#define RAL_RF_2525E 0x04
|
||||
#define RAL_RF_2526 0x05
|
||||
/* dual-band RF */
|
||||
#define RAL_RF_5222 0x10
|
||||
|
||||
#define RAL_BBP_VERSION 0
|
||||
#define RAL_BBP_TX 2
|
||||
#define RAL_BBP_RX 14
|
||||
|
||||
#define RAL_BBP_ANTA 0x00
|
||||
#define RAL_BBP_DIVERSITY 0x01
|
||||
#define RAL_BBP_ANTB 0x02
|
||||
#define RAL_BBP_ANTMASK 0x03
|
||||
#define RAL_BBP_FLIPIQ 0x04
|
||||
|
||||
#define RAL_JAPAN_FILTER 0x08
|
||||
|
||||
struct ural_tx_desc {
|
||||
uint32_t flags;
|
||||
#define RAL_TX_RETRY(x) ((x) << 4)
|
||||
#define RAL_TX_MORE_FRAG (1 << 8)
|
||||
#define RAL_TX_ACK (1 << 9)
|
||||
#define RAL_TX_TIMESTAMP (1 << 10)
|
||||
#define RAL_TX_OFDM (1 << 11)
|
||||
#define RAL_TX_NEWSEQ (1 << 12)
|
||||
|
||||
#define RAL_TX_IFS_MASK 0x00006000
|
||||
#define RAL_TX_IFS_BACKOFF (0 << 13)
|
||||
#define RAL_TX_IFS_SIFS (1 << 13)
|
||||
#define RAL_TX_IFS_NEWBACKOFF (2 << 13)
|
||||
#define RAL_TX_IFS_NONE (3 << 13)
|
||||
|
||||
uint16_t wme;
|
||||
#define RAL_LOGCWMAX(x) (((x) & 0xf) << 12)
|
||||
#define RAL_LOGCWMIN(x) (((x) & 0xf) << 8)
|
||||
#define RAL_AIFSN(x) (((x) & 0x3) << 6)
|
||||
#define RAL_IVOFFSET(x) (((x) & 0x3f))
|
||||
|
||||
uint16_t reserved;
|
||||
uint8_t plcp_signal;
|
||||
uint8_t plcp_service;
|
||||
#define RAL_PLCP_LENGEXT 0x80
|
||||
|
||||
uint16_t plcp_length;
|
||||
uint32_t iv;
|
||||
uint32_t eiv;
|
||||
} __packed;
|
||||
|
||||
struct ural_rx_desc {
|
||||
uint32_t flags;
|
||||
#define RAL_RX_CRC_ERROR (1 << 5)
|
||||
#define RAL_RX_PHY_ERROR (1 << 7)
|
||||
|
||||
uint8_t rate;
|
||||
uint8_t rssi;
|
||||
uint16_t reserved;
|
||||
|
||||
uint32_t iv;
|
||||
uint32_t eiv;
|
||||
} __packed;
|
||||
|
||||
#define RAL_RF_LOBUSY (1 << 15)
|
||||
#define RAL_RF_BUSY (1 << 31)
|
||||
#define RAL_RF_20BIT (20 << 24)
|
||||
|
||||
#define RAL_RF1 0
|
||||
#define RAL_RF2 2
|
||||
#define RAL_RF3 1
|
||||
#define RAL_RF4 3
|
||||
|
||||
#define RAL_EEPROM_ADDRESS 0x0004
|
||||
#define RAL_EEPROM_TXPOWER 0x003c
|
||||
#define RAL_EEPROM_CONFIG0 0x0016
|
||||
#define RAL_EEPROM_BBP_BASE 0x001c
|
134
sys/dev/usb/if_uralvar.h
Normal file
134
sys/dev/usb/if_uralvar.h
Normal file
@ -0,0 +1,134 @@
|
||||
/* $NetBSD: if_uralvar.h,v 1.1 2005/07/01 20:06:56 drochner Exp $ */
|
||||
/* $OpenBSD: if_ralvar.h,v 1.2 2005/05/13 18:42:50 damien Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005
|
||||
* Damien Bergamini <damien.bergamini@free.fr>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define RAL_RX_LIST_COUNT 1
|
||||
#define RAL_TX_LIST_COUNT 1
|
||||
|
||||
struct ural_rx_radiotap_header {
|
||||
struct ieee80211_radiotap_header wr_ihdr;
|
||||
uint8_t wr_flags;
|
||||
uint16_t wr_chan_freq;
|
||||
uint16_t wr_chan_flags;
|
||||
uint8_t wr_antenna;
|
||||
uint8_t wr_antsignal;
|
||||
} __packed;
|
||||
|
||||
#define RAL_RX_RADIOTAP_PRESENT \
|
||||
((1 << IEEE80211_RADIOTAP_FLAGS) | \
|
||||
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
|
||||
(1 << IEEE80211_RADIOTAP_ANTENNA) | \
|
||||
(1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
|
||||
|
||||
struct ural_tx_radiotap_header {
|
||||
struct ieee80211_radiotap_header wt_ihdr;
|
||||
uint8_t wt_flags;
|
||||
uint8_t wt_rate;
|
||||
uint16_t wt_chan_freq;
|
||||
uint16_t wt_chan_flags;
|
||||
uint8_t wt_antenna;
|
||||
} __packed;
|
||||
|
||||
#define RAL_TX_RADIOTAP_PRESENT \
|
||||
((1 << IEEE80211_RADIOTAP_FLAGS) | \
|
||||
(1 << IEEE80211_RADIOTAP_RATE) | \
|
||||
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
|
||||
(1 << IEEE80211_RADIOTAP_ANTENNA))
|
||||
|
||||
struct ural_softc;
|
||||
|
||||
struct ural_tx_data {
|
||||
struct ural_softc *sc;
|
||||
usbd_xfer_handle xfer;
|
||||
uint8_t *buf;
|
||||
struct mbuf *m;
|
||||
struct ieee80211_node *ni;
|
||||
};
|
||||
|
||||
struct ural_rx_data {
|
||||
struct ural_softc *sc;
|
||||
usbd_xfer_handle xfer;
|
||||
uint8_t *buf;
|
||||
struct mbuf *m;
|
||||
};
|
||||
|
||||
struct ural_softc {
|
||||
USBBASEDEVICE sc_dev;
|
||||
struct ethercom sc_ec;
|
||||
struct ieee80211com sc_ic;
|
||||
int (*sc_newstate)(struct ieee80211com *,
|
||||
enum ieee80211_state, int);
|
||||
|
||||
usbd_device_handle sc_udev;
|
||||
usbd_interface_handle sc_iface;
|
||||
|
||||
int sc_rx_no;
|
||||
int sc_tx_no;
|
||||
|
||||
uint32_t asic_rev;
|
||||
uint8_t rf_rev;
|
||||
|
||||
usbd_pipe_handle sc_rx_pipeh;
|
||||
usbd_pipe_handle sc_tx_pipeh;
|
||||
|
||||
enum ieee80211_state sc_state;
|
||||
struct usb_task sc_task;
|
||||
|
||||
struct ural_rx_data rx_data[RAL_RX_LIST_COUNT];
|
||||
struct ural_tx_data tx_data[RAL_TX_LIST_COUNT];
|
||||
int tx_queued;
|
||||
|
||||
struct ieee80211_beacon_offsets sc_bo;
|
||||
|
||||
struct callout scan_ch;
|
||||
|
||||
int sc_tx_timer;
|
||||
|
||||
uint32_t rf_regs[4];
|
||||
uint8_t txpow[14];
|
||||
|
||||
struct {
|
||||
uint8_t val;
|
||||
uint8_t reg;
|
||||
} __packed bbp_prom[16];
|
||||
|
||||
int led_mode;
|
||||
int hw_radio;
|
||||
int rx_ant;
|
||||
int tx_ant;
|
||||
int nb_ant;
|
||||
|
||||
#if NBPFILTER > 0
|
||||
caddr_t sc_drvbpf;
|
||||
|
||||
union {
|
||||
struct ural_rx_radiotap_header th;
|
||||
uint8_t pad[64];
|
||||
} sc_rxtapu;
|
||||
#define sc_rxtap sc_rxtapu.th
|
||||
int sc_rxtap_len;
|
||||
|
||||
union {
|
||||
struct ural_tx_radiotap_header th;
|
||||
uint8_t pad[64];
|
||||
} sc_txtapu;
|
||||
#define sc_txtap sc_txtapu.th
|
||||
int sc_txtap_len;
|
||||
#endif
|
||||
};
|
Loading…
Reference in New Issue
Block a user