[Zrouter-src-freebsd] [rt2860-in-ral] push by r... at ddteam.net - remove old on 2012-03-13 18:19 GMT

rt2860-in-ral at googlecode.com rt2860-in-ral at googlecode.com
Tue Mar 13 18:20:41 UTC 2012


Revision: d3840932414b
Author:   ray at terran.dlink.ua
Date:     Tue Mar 13 11:19:29 2012
Log:      remove old
http://code.google.com/p/rt2860-in-ral/source/detail?r=d3840932414b

Deleted:
  /if_ral_nexus.c
  /if_ral_pci.c
  /rt2560.c
  /rt2560reg.h
  /rt2560var.h
  /rt2661.c
  /rt2661reg.h
  /rt2661var.h
  /rt2860.c
  /rt2860reg.h
  /rt2860ucode.h
  /rt2860var.h

=======================================
--- /if_ral_nexus.c	Tue Mar 13 05:46:45 2012
+++ /dev/null
@@ -1,93 +0,0 @@
-
-/*-
- * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar at gmail.com>
- * Copyright (c) 2009 Damien Bergamini <damien.bergamini at 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.
- */
-
-#include <dev/ral/rt2860_softc.h>
-#include <dev/ral/rt2860_reg.h>
-#include <dev/ral/rt2860_eeprom.h>
-#include <dev/ral/rt2860_ucode.h>
-#include <dev/ral/rt2860_txwi.h>
-#include <dev/ral/rt2860_rxwi.h>
-#include <dev/ral/rt2860_io.h>
-#include <dev/ral/rt2860_read_eeprom.h>
-#include <dev/ral/rt2860_led.h>
-#include <dev/ral/rt2860_rf.h>
-#include <dev/ral/rt2860_debug.h>
-
-/*
- * Static function prototypes
- */
-
-static int rt2860_nexus_probe(device_t dev);
-
-static int rt2860_nexus_attach(device_t dev);
-
-int rt2860_attach(device_t dev);
-
-int rt2860_detach(device_t dev);
-
-int rt2860_shutdown(device_t dev);
-
-int rt2860_suspend(device_t dev);
-
-int rt2860_resume(device_t dev);
-
-/*
- * rt2860_nexus_probe
- */
-static int rt2860_nexus_probe(device_t dev)
-{
-	device_set_desc(dev, "Ralink RT2860 802.11n MAC/BPP");
-	return 0;
-}
-
-/*
- * rt2860_nexus_attach
- */
-static int rt2860_nexus_attach(device_t dev)
-{
-	struct rt2860_softc *sc;
-
-	sc = device_get_softc(dev);
-	sc->mem_rid = 0;
-
-	return (rt2860_attach(dev));
-}
-
-static device_method_t rt2860_nexus_dev_methods[] =
-{
-	DEVMETHOD(device_probe, rt2860_nexus_probe),
-	DEVMETHOD(device_attach, rt2860_nexus_attach),
-	DEVMETHOD(device_detach, rt2860_detach),
-	DEVMETHOD(device_shutdown, rt2860_shutdown),
-	DEVMETHOD(device_suspend, rt2860_suspend),
-	DEVMETHOD(device_resume, rt2860_resume),
-	{ 0, 0 }
-};
-
-static driver_t rt2860_nexus_driver =
-{
-	"rt2860",
-	rt2860_nexus_dev_methods,
-	sizeof(struct rt2860_softc)
-};
-
-static devclass_t rt2860_nexus_dev_class;
-
-DRIVER_MODULE(rt2860, nexus, rt2860_nexus_driver, rt2860_nexus_dev_class,  
0, 0);
-MODULE_DEPEND(rt2860, wlan, 1, 1, 1);
-
=======================================
--- /if_ral_pci.c	Tue Mar 13 05:46:45 2012
+++ /dev/null
@@ -1,307 +0,0 @@
-/*	$FreeBSD$	*/
-
-/*-
- * Copyright (c) 2005, 2006
- *	Damien Bergamini <damien.bergamini at 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * PCI/Cardbus front-end for the Ralink RT2xxx wireless driver.
- */
-
-#include <sys/param.h>
-#include <sys/sysctl.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/module.h>
-#include <sys/bus.h>
-#include <sys/endian.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-#include <net/if_types.h>
-
-#include <net80211/ieee80211_var.h>
-#include <net80211/ieee80211_radiotap.h>
-#include <net80211/ieee80211_amrr.h>
-
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-
-#include <dev/ral/rt2560var.h>
-#include <dev/ral/rt2661var.h>
-#include <dev/ral/rt2860var.h>
-
-MODULE_DEPEND(ral, pci, 1, 1, 1);
-MODULE_DEPEND(ral, firmware, 1, 1, 1);
-MODULE_DEPEND(ral, wlan, 1, 1, 1);
-MODULE_DEPEND(ral, wlan_amrr, 1, 1, 1);
-
-struct ral_pci_ident {
-	uint16_t	vendor;
-	uint16_t	device;
-	const char	*name;
-};
-
-static const struct ral_pci_ident ral_pci_ids[] = {
-	{ 0x1814, 0x0201, "Ralink Technology RT2560" },
-	{ 0x1814, 0x0301, "Ralink Technology RT2561S" },
-	{ 0x1814, 0x0302, "Ralink Technology RT2561" },
-	{ 0x1814, 0x0401, "Ralink Technology RT2661" },
-	{ 0x1814, 0x0601, "Ralink Technology RT2860 PCI" },
-	{ 0x1814, 0x0681, "Ralink Technology RT2860 PCIe" },
-	{ 0x1814, 0x0701, "Ralink Technology RT2870 PCI" },
-	{ 0x1814, 0x0781, "Ralink Technology RT2870 PCIe" },
-	{ 0x1814, 0x3090, "Ralink Technology RT3090 PCIe" },
-
-	{ 0, 0, NULL }
-};
-
-static struct ral_opns {
-	int	(*attach)(device_t, int);
-	int	(*detach)(void *);
-	void	(*shutdown)(void *);
-	void	(*suspend)(void *);
-	void	(*resume)(void *);
-	void	(*intr)(void *);
-
-}  ral_rt2560_opns = {
-	rt2560_attach,
-	rt2560_detach,
-	rt2560_stop,
-	rt2560_stop,
-	rt2560_resume,
-	rt2560_intr
-
-}, ral_rt2661_opns = {
-	rt2661_attach,
-	rt2661_detach,
-	rt2661_shutdown,
-	rt2661_suspend,
-	rt2661_resume,
-	rt2661_intr
-}, ral_rt2860_opns = {
-	rt2860_attach,
-	rt2860_detach,
-	rt2860_shutdown,
-	rt2860_suspend,
-	rt2860_resume,
-	rt2860_intr
-};
-
-struct ral_pci_softc {
-	union {
-		struct rt2560_softc sc_rt2560;
-		struct rt2661_softc sc_rt2661;
-		struct rt2860_softc sc_rt2860;
-	} u;
-
-	struct ral_opns		*sc_opns;
-	int			irq_rid;
-	int			mem_rid;
-	struct resource		*irq;
-	struct resource		*mem;
-	void			*sc_ih;
-};
-
-static int ral_pci_probe(device_t);
-static int ral_pci_attach(device_t);
-static int ral_pci_detach(device_t);
-static int ral_pci_shutdown(device_t);
-static int ral_pci_suspend(device_t);
-static int ral_pci_resume(device_t);
-
-static device_method_t ral_pci_methods[] = {
-	/* Device interface */
-	DEVMETHOD(device_probe,		ral_pci_probe),
-	DEVMETHOD(device_attach,	ral_pci_attach),
-	DEVMETHOD(device_detach,	ral_pci_detach),
-	DEVMETHOD(device_shutdown,	ral_pci_shutdown),
-	DEVMETHOD(device_suspend,	ral_pci_suspend),
-	DEVMETHOD(device_resume,	ral_pci_resume),
-
-	{ 0, 0 }
-};
-
-static driver_t ral_pci_driver = {
-	"ral",
-	ral_pci_methods,
-	sizeof (struct ral_pci_softc)
-};
-
-static devclass_t ral_devclass;
-
-DRIVER_MODULE(ral, pci, ral_pci_driver, ral_devclass, 0, 0);
-
-static int
-ral_pci_probe(device_t dev)
-{
-	const struct ral_pci_ident *ident;
-
-	for (ident = ral_pci_ids; ident->name != NULL; ident++) {
-		if (pci_get_vendor(dev) == ident->vendor &&
-		    pci_get_device(dev) == ident->device) {
-			device_set_desc(dev, ident->name);
-			return 0;
-		}
-	}
-	return ENXIO;
-}
-
-/* Base Address Register */
-#define RAL_PCI_BAR0	0x10
-
-static int
-ral_pci_attach(device_t dev)
-{
-	struct ral_pci_softc *psc = device_get_softc(dev);
-	struct rt2560_softc *sc = &psc->u.sc_rt2560;
-	int error;
-
-	if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
-		device_printf(dev, "chip is in D%d power mode "
-		    "-- setting to D0\n", pci_get_powerstate(dev));
-		pci_set_powerstate(dev, PCI_POWERSTATE_D0);
-	}
-
-	/* enable bus-mastering */
-	pci_enable_busmaster(dev);
-
-	psc->sc_opns = (pci_get_device(dev) == 0x0201) ? &ral_rt2560_opns :
-	    &ral_rt2661_opns;
-	switch (pci_get_device(dev)) {
-	case 0x0201:
-		psc->sc_opns = &ral_rt2560_opns;
-		break;
-	case 0x0301:
-	case 0x0302:
-	case 0x0401:
-		psc->sc_opns = &ral_rt2661_opns;
-		break;
-	case 0x0601:
-	case 0x0681:
-	case 0x0701:
-	case 0x0781:
-	case 0x3090:
-		psc->sc_opns = &ral_rt2860_opns;
-		break;
-	default:
-		device_printf(dev, "ERROR: Unknown card 0x%04x\n",
-		    pci_get_device(dev));
-		return (ENXIO);
-	}
-
-	psc->mem_rid = RAL_PCI_BAR0;
-	psc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &psc->mem_rid,
-	    RF_ACTIVE);
-	if (psc->mem == NULL) {
-		device_printf(dev, "could not allocate memory resource\n");
-		return ENXIO;
-	}
-
-	sc->sc_st = rman_get_bustag(psc->mem);
-	sc->sc_sh = rman_get_bushandle(psc->mem);
-	sc->sc_invalid = 1;
-
-	psc->irq_rid = 0;
-	psc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &psc->irq_rid,
-	    RF_ACTIVE | RF_SHAREABLE);
-	if (psc->irq == NULL) {
-		device_printf(dev, "could not allocate interrupt resource\n");
-		return ENXIO;
-	}
-
-	error = (*psc->sc_opns->attach)(dev, pci_get_device(dev));
-	if (error != 0)
-		return error;
-
-	/*
-	 * Hook our interrupt after all initialization is complete.
-	 */
-	error = bus_setup_intr(dev, psc->irq, INTR_TYPE_NET | INTR_MPSAFE,
-	    NULL, psc->sc_opns->intr, psc, &psc->sc_ih);
-	if (error != 0) {
-		device_printf(dev, "could not set up interrupt\n");
-		return error;
-	}
-	sc->sc_invalid = 0;
-
-	return 0;
-}
-
-static int
-ral_pci_detach(device_t dev)
-{
-	struct ral_pci_softc *psc = device_get_softc(dev);
-	struct rt2560_softc *sc = &psc->u.sc_rt2560;
-
-	/* check if device was removed */
-	sc->sc_invalid = !bus_child_present(dev);
-
-	(*psc->sc_opns->detach)(psc);
-
-	bus_generic_detach(dev);
-	bus_teardown_intr(dev, psc->irq, psc->sc_ih);
-	bus_release_resource(dev, SYS_RES_IRQ, psc->irq_rid, psc->irq);
-
-	bus_release_resource(dev, SYS_RES_MEMORY, psc->mem_rid, psc->mem);
-
-	return 0;
-}
-
-static int
-ral_pci_shutdown(device_t dev)
-{
-	struct ral_pci_softc *psc = device_get_softc(dev);
-
-	(*psc->sc_opns->shutdown)(psc);
-
-	return 0;
-}
-
-static int
-ral_pci_suspend(device_t dev)
-{
-	struct ral_pci_softc *psc = device_get_softc(dev);
-
-	(*psc->sc_opns->suspend)(psc);
-
-	return 0;
-}
-
-static int
-ral_pci_resume(device_t dev)
-{
-	struct ral_pci_softc *psc = device_get_softc(dev);
-
-	(*psc->sc_opns->resume)(psc);
-
-	return 0;
-}
=======================================
--- /rt2560.c	Tue Mar 13 05:46:45 2012
+++ /dev/null
@@ -1,2825 +0,0 @@
-/*	$FreeBSD: head/sys/dev/ral/rt2560.c 228621 2011-12-17 10:23:17Z  
bschmidt $	*/
-
-/*-
- * Copyright (c) 2005, 2006
- *	Damien Bergamini <damien.bergamini at 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/ral/rt2560.c 228621 2011-12-17 10:23:17Z  
bschmidt $");
-
-/*-
- * Ralink Technology RT2560 chipset driver
- * http://www.ralinktech.com/
- */
-
-#include <sys/param.h>
-#include <sys/sysctl.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/lock.h>
-#include <sys/mutex.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/endian.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-#include <net/if_types.h>
-
-#include <net80211/ieee80211_var.h>
-#include <net80211/ieee80211_radiotap.h>
-#include <net80211/ieee80211_regdomain.h>
-#include <net80211/ieee80211_ratectl.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
-
-#include <dev/ral/rt2560reg.h>
-#include <dev/ral/rt2560var.h>
-
-#define RT2560_RSSI(sc, rssi)					\
-	((rssi) > (RT2560_NOISE_FLOOR + (sc)->rssi_corr) ?	\
-	 ((rssi) - RT2560_NOISE_FLOOR - (sc)->rssi_corr) : 0)
-
-#define RAL_DEBUG
-#ifdef RAL_DEBUG
-#define DPRINTF(sc, fmt, ...) do {				\
-	if (sc->sc_debug > 0)					\
-		printf(fmt, __VA_ARGS__);			\
-} while (0)
-#define DPRINTFN(sc, n, fmt, ...) do {				\
-	if (sc->sc_debug >= (n))				\
-		printf(fmt, __VA_ARGS__);			\
-} while (0)
-#else
-#define DPRINTF(sc, fmt, ...)
-#define DPRINTFN(sc, n, fmt, ...)
-#endif
-
-static struct ieee80211vap *rt2560_vap_create(struct ieee80211com *,
-			    const char [IFNAMSIZ], int, enum ieee80211_opmode,
-			    int, const uint8_t [IEEE80211_ADDR_LEN],
-			    const uint8_t [IEEE80211_ADDR_LEN]);
-static void		rt2560_vap_delete(struct ieee80211vap *);
-static void		rt2560_dma_map_addr(void *, bus_dma_segment_t *, int,
-			    int);
-static int		rt2560_alloc_tx_ring(struct rt2560_softc *,
-			    struct rt2560_tx_ring *, int);
-static void		rt2560_reset_tx_ring(struct rt2560_softc *,
-			    struct rt2560_tx_ring *);
-static void		rt2560_free_tx_ring(struct rt2560_softc *,
-			    struct rt2560_tx_ring *);
-static int		rt2560_alloc_rx_ring(struct rt2560_softc *,
-			    struct rt2560_rx_ring *, int);
-static void		rt2560_reset_rx_ring(struct rt2560_softc *,
-			    struct rt2560_rx_ring *);
-static void		rt2560_free_rx_ring(struct rt2560_softc *,
-			    struct rt2560_rx_ring *);
-static int		rt2560_newstate(struct ieee80211vap *,
-			    enum ieee80211_state, int);
-static uint16_t		rt2560_eeprom_read(struct rt2560_softc *, uint8_t);
-static void		rt2560_encryption_intr(struct rt2560_softc *);
-static void		rt2560_tx_intr(struct rt2560_softc *);
-static void		rt2560_prio_intr(struct rt2560_softc *);
-static void		rt2560_decryption_intr(struct rt2560_softc *);
-static void		rt2560_rx_intr(struct rt2560_softc *);
-static void		rt2560_beacon_update(struct ieee80211vap *, int item);
-static void		rt2560_beacon_expire(struct rt2560_softc *);
-static void		rt2560_wakeup_expire(struct rt2560_softc *);
-static void		rt2560_scan_start(struct ieee80211com *);
-static void		rt2560_scan_end(struct ieee80211com *);
-static void		rt2560_set_channel(struct ieee80211com *);
-static void		rt2560_setup_tx_desc(struct rt2560_softc *,
-			    struct rt2560_tx_desc *, uint32_t, int, int, int,
-			    bus_addr_t);
-static int		rt2560_tx_bcn(struct rt2560_softc *, struct mbuf *,
-			    struct ieee80211_node *);
-static int		rt2560_tx_mgt(struct rt2560_softc *, struct mbuf *,
-			    struct ieee80211_node *);
-static int		rt2560_tx_data(struct rt2560_softc *, struct mbuf *,
-			    struct ieee80211_node *);
-static void		rt2560_start_locked(struct ifnet *);
-static void		rt2560_start(struct ifnet *);
-static void		rt2560_watchdog(void *);
-static int		rt2560_ioctl(struct ifnet *, u_long, caddr_t);
-static void		rt2560_bbp_write(struct rt2560_softc *, uint8_t,
-			    uint8_t);
-static uint8_t		rt2560_bbp_read(struct rt2560_softc *, uint8_t);
-static void		rt2560_rf_write(struct rt2560_softc *, uint8_t,
-			    uint32_t);
-static void		rt2560_set_chan(struct rt2560_softc *,
-			    struct ieee80211_channel *);
-#if 0
-static void		rt2560_disable_rf_tune(struct rt2560_softc *);
-#endif
-static void		rt2560_enable_tsf_sync(struct rt2560_softc *);
-static void		rt2560_enable_tsf(struct rt2560_softc *);
-static void		rt2560_update_plcp(struct rt2560_softc *);
-static void		rt2560_update_slot(struct ifnet *);
-static void		rt2560_set_basicrates(struct rt2560_softc *,
-			    const struct ieee80211_rateset *);
-static void		rt2560_update_led(struct rt2560_softc *, int, int);
-static void		rt2560_set_bssid(struct rt2560_softc *, const uint8_t *);
-static void		rt2560_set_macaddr(struct rt2560_softc *, uint8_t *);
-static void		rt2560_get_macaddr(struct rt2560_softc *, uint8_t *);
-static void		rt2560_update_promisc(struct ifnet *);
-static const char	*rt2560_get_rf(int);
-static void		rt2560_read_config(struct rt2560_softc *);
-static int		rt2560_bbp_init(struct rt2560_softc *);
-static void		rt2560_set_txantenna(struct rt2560_softc *, int);
-static void		rt2560_set_rxantenna(struct rt2560_softc *, int);
-static void		rt2560_init_locked(struct rt2560_softc *);
-static void		rt2560_init(void *);
-static void		rt2560_stop_locked(struct rt2560_softc *);
-static int		rt2560_raw_xmit(struct ieee80211_node *, struct mbuf *,
-				const struct ieee80211_bpf_params *);
-
-static const struct {
-	uint32_t	reg;
-	uint32_t	val;
-} rt2560_def_mac[] = {
-	RT2560_DEF_MAC
-};
-
-static const struct {
-	uint8_t	reg;
-	uint8_t	val;
-} rt2560_def_bbp[] = {
-	RT2560_DEF_BBP
-};
-
-static const uint32_t rt2560_rf2522_r2[]    = RT2560_RF2522_R2;
-static const uint32_t rt2560_rf2523_r2[]    = RT2560_RF2523_R2;
-static const uint32_t rt2560_rf2524_r2[]    = RT2560_RF2524_R2;
-static const uint32_t rt2560_rf2525_r2[]    = RT2560_RF2525_R2;
-static const uint32_t rt2560_rf2525_hi_r2[] = RT2560_RF2525_HI_R2;
-static const uint32_t rt2560_rf2525e_r2[]   = RT2560_RF2525E_R2;
-static const uint32_t rt2560_rf2526_r2[]    = RT2560_RF2526_R2;
-static const uint32_t rt2560_rf2526_hi_r2[] = RT2560_RF2526_HI_R2;
-
-static const struct {
-	uint8_t		chan;
-	uint32_t	r1, r2, r4;
-} rt2560_rf5222[] = {
-	RT2560_RF5222
-};
-
-int
-rt2560_attach(device_t dev, int id)
-{
-	struct rt2560_softc *sc = device_get_softc(dev);
-	struct ieee80211com *ic;
-	struct ifnet *ifp;
-	int error;
-	uint8_t bands;
-	uint8_t macaddr[IEEE80211_ADDR_LEN];
-
-	sc->sc_dev = dev;
-
-	mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
-	    MTX_DEF | MTX_RECURSE);
-
-	callout_init_mtx(&sc->watchdog_ch, &sc->sc_mtx, 0);
-
-	/* retrieve RT2560 rev. no */
-	sc->asic_rev = RAL_READ(sc, RT2560_CSR0);
-
-	/* retrieve RF rev. no and various other things from EEPROM */
-	rt2560_read_config(sc);
-
-	device_printf(dev, "MAC/BBP RT2560 (rev 0x%02x), RF %s\n",
-	    sc->asic_rev, rt2560_get_rf(sc->rf_rev));
-
-	/*
-	 * Allocate Tx and Rx rings.
-	 */
-	error = rt2560_alloc_tx_ring(sc, &sc->txq, RT2560_TX_RING_COUNT);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate Tx ring\n");
-		goto fail1;
-	}
-
-	error = rt2560_alloc_tx_ring(sc, &sc->atimq, RT2560_ATIM_RING_COUNT);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate ATIM ring\n");
-		goto fail2;
-	}
-
-	error = rt2560_alloc_tx_ring(sc, &sc->prioq, RT2560_PRIO_RING_COUNT);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate Prio ring\n");
-		goto fail3;
-	}
-
-	error = rt2560_alloc_tx_ring(sc, &sc->bcnq, RT2560_BEACON_RING_COUNT);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate Beacon ring\n");
-		goto fail4;
-	}
-
-	error = rt2560_alloc_rx_ring(sc, &sc->rxq, RT2560_RX_RING_COUNT);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate Rx ring\n");
-		goto fail5;
-	}
-
-	ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
-	if (ifp == NULL) {
-		device_printf(sc->sc_dev, "can not if_alloc()\n");
-		goto fail6;
-	}
-	ic = ifp->if_l2com;
-
-	/* retrieve MAC address */
-	rt2560_get_macaddr(sc, macaddr);
-
-	ifp->if_softc = sc;
-	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-	ifp->if_init = rt2560_init;
-	ifp->if_ioctl = rt2560_ioctl;
-	ifp->if_start = rt2560_start;
-	IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
-	ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
-	IFQ_SET_READY(&ifp->if_snd);
-
-	ic->ic_ifp = ifp;
-	ic->ic_opmode = IEEE80211_M_STA;
-	ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
-
-	/* set device capabilities */
-	ic->ic_caps =
-		  IEEE80211_C_STA		/* station mode */
-		| IEEE80211_C_IBSS		/* ibss, nee adhoc, mode */
-		| IEEE80211_C_HOSTAP		/* hostap mode */
-		| IEEE80211_C_MONITOR		/* monitor mode */
-		| IEEE80211_C_AHDEMO		/* adhoc demo mode */
-		| IEEE80211_C_WDS		/* 4-address traffic works */
-		| IEEE80211_C_MBSS		/* mesh point link mode */
-		| IEEE80211_C_SHPREAMBLE	/* short preamble supported */
-		| IEEE80211_C_SHSLOT		/* short slot time supported */
-		| IEEE80211_C_WPA		/* capable of WPA1+WPA2 */
-		| IEEE80211_C_BGSCAN		/* capable of bg scanning */
-#ifdef notyet
-		| IEEE80211_C_TXFRAG		/* handle tx frags */
-#endif
-		;
-
-	bands = 0;
-	setbit(&bands, IEEE80211_MODE_11B);
-	setbit(&bands, IEEE80211_MODE_11G);
-	if (sc->rf_rev == RT2560_RF_5222)
-		setbit(&bands, IEEE80211_MODE_11A);
-	ieee80211_init_channels(ic, NULL, &bands);
-
-	ieee80211_ifattach(ic, macaddr);
-	ic->ic_raw_xmit = rt2560_raw_xmit;
-	ic->ic_updateslot = rt2560_update_slot;
-	ic->ic_update_promisc = rt2560_update_promisc;
-	ic->ic_scan_start = rt2560_scan_start;
-	ic->ic_scan_end = rt2560_scan_end;
-	ic->ic_set_channel = rt2560_set_channel;
-
-	ic->ic_vap_create = rt2560_vap_create;
-	ic->ic_vap_delete = rt2560_vap_delete;
-
-	ieee80211_radiotap_attach(ic,
-	    &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap),
-		RT2560_TX_RADIOTAP_PRESENT,
-	    &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap),
-		RT2560_RX_RADIOTAP_PRESENT);
-
-	/*
-	 * Add a few sysctl knobs.
-	 */
-#ifdef RAL_DEBUG
-	SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
-	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
-	    "debug", CTLFLAG_RW, &sc->sc_debug, 0, "debug msgs");
-#endif
-	SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
-	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
-	    "txantenna", CTLFLAG_RW, &sc->tx_ant, 0, "tx antenna (0=auto)");
-
-	SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
-	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
-	    "rxantenna", CTLFLAG_RW, &sc->rx_ant, 0, "rx antenna (0=auto)");
-
-	if (bootverbose)
-		ieee80211_announce(ic);
-
-	return 0;
-
-fail6:	rt2560_free_rx_ring(sc, &sc->rxq);
-fail5:	rt2560_free_tx_ring(sc, &sc->bcnq);
-fail4:	rt2560_free_tx_ring(sc, &sc->prioq);
-fail3:	rt2560_free_tx_ring(sc, &sc->atimq);
-fail2:	rt2560_free_tx_ring(sc, &sc->txq);
-fail1:	mtx_destroy(&sc->sc_mtx);
-
-	return ENXIO;
-}
-
-int
-rt2560_detach(void *xsc)
-{
-	struct rt2560_softc *sc = xsc;
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-
-	rt2560_stop(sc);
-
-	ieee80211_ifdetach(ic);
-
-	rt2560_free_tx_ring(sc, &sc->txq);
-	rt2560_free_tx_ring(sc, &sc->atimq);
-	rt2560_free_tx_ring(sc, &sc->prioq);
-	rt2560_free_tx_ring(sc, &sc->bcnq);
-	rt2560_free_rx_ring(sc, &sc->rxq);
-
-	if_free(ifp);
-
-	mtx_destroy(&sc->sc_mtx);
-
-	return 0;
-}
-
-static struct ieee80211vap *
-rt2560_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int  
unit,
-    enum ieee80211_opmode opmode, int flags,
-    const uint8_t bssid[IEEE80211_ADDR_LEN],
-    const uint8_t mac[IEEE80211_ADDR_LEN])
-{
-	struct ifnet *ifp = ic->ic_ifp;
-	struct rt2560_vap *rvp;
-	struct ieee80211vap *vap;
-
-	switch (opmode) {
-	case IEEE80211_M_STA:
-	case IEEE80211_M_IBSS:
-	case IEEE80211_M_AHDEMO:
-	case IEEE80211_M_MONITOR:
-	case IEEE80211_M_HOSTAP:
-	case IEEE80211_M_MBSS:
-		/* XXXRP: TBD */
-		if (!TAILQ_EMPTY(&ic->ic_vaps)) {
-			if_printf(ifp, "only 1 vap supported\n");
-			return NULL;
-		}
-		if (opmode == IEEE80211_M_STA)
-			flags |= IEEE80211_CLONE_NOBEACONS;
-		break;
-	case IEEE80211_M_WDS:
-		if (TAILQ_EMPTY(&ic->ic_vaps) ||
-		    ic->ic_opmode != IEEE80211_M_HOSTAP) {
-			if_printf(ifp, "wds only supported in ap mode\n");
-			return NULL;
-		}
-		/*
-		 * Silently remove any request for a unique
-		 * bssid; WDS vap's always share the local
-		 * mac address.
-		 */
-		flags &= ~IEEE80211_CLONE_BSSID;
-		break;
-	default:
-		if_printf(ifp, "unknown opmode %d\n", opmode);
-		return NULL;
-	}
-	rvp = (struct rt2560_vap *) malloc(sizeof(struct rt2560_vap),
-	    M_80211_VAP, M_NOWAIT | M_ZERO);
-	if (rvp == NULL)
-		return NULL;
-	vap = &rvp->ral_vap;
-	ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid, mac);
-
-	/* override state transition machine */
-	rvp->ral_newstate = vap->iv_newstate;
-	vap->iv_newstate = rt2560_newstate;
-	vap->iv_update_beacon = rt2560_beacon_update;
-
-	ieee80211_ratectl_init(vap);
-	/* complete setup */
-	ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status);
-	if (TAILQ_FIRST(&ic->ic_vaps) == vap)
-		ic->ic_opmode = opmode;
-	return vap;
-}
-
-static void
-rt2560_vap_delete(struct ieee80211vap *vap)
-{
-	struct rt2560_vap *rvp = RT2560_VAP(vap);
-
-	ieee80211_ratectl_deinit(vap);
-	ieee80211_vap_detach(vap);
-	free(rvp, M_80211_VAP);
-}
-
-void
-rt2560_resume(void *xsc)
-{
-	struct rt2560_softc *sc = xsc;
-	struct ifnet *ifp = sc->sc_ifp;
-
-	if (ifp->if_flags & IFF_UP)
-		rt2560_init(sc);
-}
-
-static void
-rt2560_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int  
error)
-{
-	if (error != 0)
-		return;
-
-	KASSERT(nseg == 1, ("too many DMA segments, %d should be 1", nseg));
-
-	*(bus_addr_t *)arg = segs[0].ds_addr;
-}
-
-static int
-rt2560_alloc_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring,
-    int count)
-{
-	int i, error;
-
-	ring->count = count;
-	ring->queued = 0;
-	ring->cur = ring->next = 0;
-	ring->cur_encrypt = ring->next_encrypt = 0;
-
-	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    count * RT2560_TX_DESC_SIZE, 1, count * RT2560_TX_DESC_SIZE,
-	    0, NULL, NULL, &ring->desc_dmat);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not create desc DMA tag\n");
-		goto fail;
-	}
-
-	error = bus_dmamem_alloc(ring->desc_dmat, (void **)&ring->desc,
-	    BUS_DMA_NOWAIT | BUS_DMA_ZERO, &ring->desc_map);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate DMA memory\n");
-		goto fail;
-	}
-
-	error = bus_dmamap_load(ring->desc_dmat, ring->desc_map, ring->desc,
-	    count * RT2560_TX_DESC_SIZE, rt2560_dma_map_addr, &ring->physaddr,
-	    0);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not load desc DMA map\n");
-		goto fail;
-	}
-
-	ring->data = malloc(count * sizeof (struct rt2560_tx_data), M_DEVBUF,
-	    M_NOWAIT | M_ZERO);
-	if (ring->data == NULL) {
-		device_printf(sc->sc_dev, "could not allocate soft data\n");
-		error = ENOMEM;
-		goto fail;
-	}
-
-	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    MCLBYTES, RT2560_MAX_SCATTER, MCLBYTES, 0, NULL, NULL,
-	    &ring->data_dmat);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not create data DMA tag\n");
-		goto fail;
-	}
-
-	for (i = 0; i < count; i++) {
-		error = bus_dmamap_create(ring->data_dmat, 0,
-		    &ring->data[i].map);
-		if (error != 0) {
-			device_printf(sc->sc_dev, "could not create DMA map\n");
-			goto fail;
-		}
-	}
-
-	return 0;
-
-fail:	rt2560_free_tx_ring(sc, ring);
-	return error;
-}
-
-static void
-rt2560_reset_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring)
-{
-	struct rt2560_tx_desc *desc;
-	struct rt2560_tx_data *data;
-	int i;
-
-	for (i = 0; i < ring->count; i++) {
-		desc = &ring->desc[i];
-		data = &ring->data[i];
-
-		if (data->m != NULL) {
-			bus_dmamap_sync(ring->data_dmat, data->map,
-			    BUS_DMASYNC_POSTWRITE);
-			bus_dmamap_unload(ring->data_dmat, data->map);
-			m_freem(data->m);
-			data->m = NULL;
-		}
-
-		if (data->ni != NULL) {
-			ieee80211_free_node(data->ni);
-			data->ni = NULL;
-		}
-
-		desc->flags = 0;
-	}
-
-	bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
-
-	ring->queued = 0;
-	ring->cur = ring->next = 0;
-	ring->cur_encrypt = ring->next_encrypt = 0;
-}
-
-static void
-rt2560_free_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring)
-{
-	struct rt2560_tx_data *data;
-	int i;
-
-	if (ring->desc != NULL) {
-		bus_dmamap_sync(ring->desc_dmat, ring->desc_map,
-		    BUS_DMASYNC_POSTWRITE);
-		bus_dmamap_unload(ring->desc_dmat, ring->desc_map);
-		bus_dmamem_free(ring->desc_dmat, ring->desc, ring->desc_map);
-	}
-
-	if (ring->desc_dmat != NULL)
-		bus_dma_tag_destroy(ring->desc_dmat);
-
-	if (ring->data != NULL) {
-		for (i = 0; i < ring->count; i++) {
-			data = &ring->data[i];
-
-			if (data->m != NULL) {
-				bus_dmamap_sync(ring->data_dmat, data->map,
-				    BUS_DMASYNC_POSTWRITE);
-				bus_dmamap_unload(ring->data_dmat, data->map);
-				m_freem(data->m);
-			}
-
-			if (data->ni != NULL)
-				ieee80211_free_node(data->ni);
-
-			if (data->map != NULL)
-				bus_dmamap_destroy(ring->data_dmat, data->map);
-		}
-
-		free(ring->data, M_DEVBUF);
-	}
-
-	if (ring->data_dmat != NULL)
-		bus_dma_tag_destroy(ring->data_dmat);
-}
-
-static int
-rt2560_alloc_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring,
-    int count)
-{
-	struct rt2560_rx_desc *desc;
-	struct rt2560_rx_data *data;
-	bus_addr_t physaddr;
-	int i, error;
-
-	ring->count = count;
-	ring->cur = ring->next = 0;
-	ring->cur_decrypt = 0;
-
-	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    count * RT2560_RX_DESC_SIZE, 1, count * RT2560_RX_DESC_SIZE,
-	    0, NULL, NULL, &ring->desc_dmat);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not create desc DMA tag\n");
-		goto fail;
-	}
-
-	error = bus_dmamem_alloc(ring->desc_dmat, (void **)&ring->desc,
-	    BUS_DMA_NOWAIT | BUS_DMA_ZERO, &ring->desc_map);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate DMA memory\n");
-		goto fail;
-	}
-
-	error = bus_dmamap_load(ring->desc_dmat, ring->desc_map, ring->desc,
-	    count * RT2560_RX_DESC_SIZE, rt2560_dma_map_addr, &ring->physaddr,
-	    0);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not load desc DMA map\n");
-		goto fail;
-	}
-
-	ring->data = malloc(count * sizeof (struct rt2560_rx_data), M_DEVBUF,
-	    M_NOWAIT | M_ZERO);
-	if (ring->data == NULL) {
-		device_printf(sc->sc_dev, "could not allocate soft data\n");
-		error = ENOMEM;
-		goto fail;
-	}
-
-	/*
-	 * Pre-allocate Rx buffers and populate Rx ring.
-	 */
-	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES,
-	    1, MCLBYTES, 0, NULL, NULL, &ring->data_dmat);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not create data DMA tag\n");
-		goto fail;
-	}
-
-	for (i = 0; i < count; i++) {
-		desc = &sc->rxq.desc[i];
-		data = &sc->rxq.data[i];
-
-		error = bus_dmamap_create(ring->data_dmat, 0, &data->map);
-		if (error != 0) {
-			device_printf(sc->sc_dev, "could not create DMA map\n");
-			goto fail;
-		}
-
-		data->m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
-		if (data->m == NULL) {
-			device_printf(sc->sc_dev,
-			    "could not allocate rx mbuf\n");
-			error = ENOMEM;
-			goto fail;
-		}
-
-		error = bus_dmamap_load(ring->data_dmat, data->map,
-		    mtod(data->m, void *), MCLBYTES, rt2560_dma_map_addr,
-		    &physaddr, 0);
-		if (error != 0) {
-			device_printf(sc->sc_dev,
-			    "could not load rx buf DMA map");
-			goto fail;
-		}
-
-		desc->flags = htole32(RT2560_RX_BUSY);
-		desc->physaddr = htole32(physaddr);
-	}
-
-	bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
-
-	return 0;
-
-fail:	rt2560_free_rx_ring(sc, ring);
-	return error;
-}
-
-static void
-rt2560_reset_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring)
-{
-	int i;
-
-	for (i = 0; i < ring->count; i++) {
-		ring->desc[i].flags = htole32(RT2560_RX_BUSY);
-		ring->data[i].drop = 0;
-	}
-
-	bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
-
-	ring->cur = ring->next = 0;
-	ring->cur_decrypt = 0;
-}
-
-static void
-rt2560_free_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring)
-{
-	struct rt2560_rx_data *data;
-	int i;
-
-	if (ring->desc != NULL) {
-		bus_dmamap_sync(ring->desc_dmat, ring->desc_map,
-		    BUS_DMASYNC_POSTWRITE);
-		bus_dmamap_unload(ring->desc_dmat, ring->desc_map);
-		bus_dmamem_free(ring->desc_dmat, ring->desc, ring->desc_map);
-	}
-
-	if (ring->desc_dmat != NULL)
-		bus_dma_tag_destroy(ring->desc_dmat);
-
-	if (ring->data != NULL) {
-		for (i = 0; i < ring->count; i++) {
-			data = &ring->data[i];
-
-			if (data->m != NULL) {
-				bus_dmamap_sync(ring->data_dmat, data->map,
-				    BUS_DMASYNC_POSTREAD);
-				bus_dmamap_unload(ring->data_dmat, data->map);
-				m_freem(data->m);
-			}
-
-			if (data->map != NULL)
-				bus_dmamap_destroy(ring->data_dmat, data->map);
-		}
-
-		free(ring->data, M_DEVBUF);
-	}
-
-	if (ring->data_dmat != NULL)
-		bus_dma_tag_destroy(ring->data_dmat);
-}
-
-static int
-rt2560_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int  
arg)
-{
-	struct rt2560_vap *rvp = RT2560_VAP(vap);
-	struct ifnet *ifp = vap->iv_ic->ic_ifp;
-	struct rt2560_softc *sc = ifp->if_softc;
-	int error;
-
-	if (nstate == IEEE80211_S_INIT && vap->iv_state == IEEE80211_S_RUN) {
-		/* abort TSF synchronization */
-		RAL_WRITE(sc, RT2560_CSR14, 0);
-
-		/* turn association led off */
-		rt2560_update_led(sc, 0, 0);
-	}
-
-	error = rvp->ral_newstate(vap, nstate, arg);
-
-	if (error == 0 && nstate == IEEE80211_S_RUN) {
-		struct ieee80211_node *ni = vap->iv_bss;
-		struct mbuf *m;
-
-		if (vap->iv_opmode != IEEE80211_M_MONITOR) {
-			rt2560_update_plcp(sc);
-			rt2560_set_basicrates(sc, &ni->ni_rates);
-			rt2560_set_bssid(sc, ni->ni_bssid);
-		}
-
-		if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
-		    vap->iv_opmode == IEEE80211_M_IBSS ||
-		    vap->iv_opmode == IEEE80211_M_MBSS) {
-			m = ieee80211_beacon_alloc(ni, &rvp->ral_bo);
-			if (m == NULL) {
-				if_printf(ifp, "could not allocate beacon\n");
-				return ENOBUFS;
-			}
-			ieee80211_ref_node(ni);
-			error = rt2560_tx_bcn(sc, m, ni);
-			if (error != 0)
-				return error;
-		}
-
-		/* turn assocation led on */
-		rt2560_update_led(sc, 1, 0);
-
-		if (vap->iv_opmode != IEEE80211_M_MONITOR)
-			rt2560_enable_tsf_sync(sc);
-		else
-			rt2560_enable_tsf(sc);
-	}
-	return error;
-}
-
-/*
- * Read 16 bits at address 'addr' from the serial EEPROM (either 93C46 or
- * 93C66).
- */
-static uint16_t
-rt2560_eeprom_read(struct rt2560_softc *sc, uint8_t addr)
-{
-	uint32_t tmp;
-	uint16_t val;
-	int n;
-
-	/* clock C once before the first command */
-	RT2560_EEPROM_CTL(sc, 0);
-
-	RT2560_EEPROM_CTL(sc, RT2560_S);
-	RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_C);
-	RT2560_EEPROM_CTL(sc, RT2560_S);
-
-	/* write start bit (1) */
-	RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D);
-	RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D | RT2560_C);
-
-	/* write READ opcode (10) */
-	RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D);
-	RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D | RT2560_C);
-	RT2560_EEPROM_CTL(sc, RT2560_S);
-	RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_C);
-
-	/* write address (A5-A0 or A7-A0) */
-	n = (RAL_READ(sc, RT2560_CSR21) & RT2560_93C46) ? 5 : 7;
-	for (; n >= 0; n--) {
-		RT2560_EEPROM_CTL(sc, RT2560_S |
-		    (((addr >> n) & 1) << RT2560_SHIFT_D));
-		RT2560_EEPROM_CTL(sc, RT2560_S |
-		    (((addr >> n) & 1) << RT2560_SHIFT_D) | RT2560_C);
-	}
-
-	RT2560_EEPROM_CTL(sc, RT2560_S);
-
-	/* read data Q15-Q0 */
-	val = 0;
-	for (n = 15; n >= 0; n--) {
-		RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_C);
-		tmp = RAL_READ(sc, RT2560_CSR21);
-		val |= ((tmp & RT2560_Q) >> RT2560_SHIFT_Q) << n;
-		RT2560_EEPROM_CTL(sc, RT2560_S);
-	}
-
-	RT2560_EEPROM_CTL(sc, 0);
-
-	/* clear Chip Select and clock C */
-	RT2560_EEPROM_CTL(sc, RT2560_S);
-	RT2560_EEPROM_CTL(sc, 0);
-	RT2560_EEPROM_CTL(sc, RT2560_C);
-
-	return val;
-}
-
-/*
- * Some frames were processed by the hardware cipher engine and are ready  
for
- * transmission.
- */
-static void
-rt2560_encryption_intr(struct rt2560_softc *sc)
-{
-	struct rt2560_tx_desc *desc;
-	int hw;
-
-	/* retrieve last descriptor index processed by cipher engine */
-	hw = RAL_READ(sc, RT2560_SECCSR1) - sc->txq.physaddr;
-	hw /= RT2560_TX_DESC_SIZE;
-
-	bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
-	    BUS_DMASYNC_POSTREAD);
-
-	while (sc->txq.next_encrypt != hw) {
-		if (sc->txq.next_encrypt == sc->txq.cur_encrypt) {
-			printf("hw encrypt %d, cur_encrypt %d\n", hw,
-			    sc->txq.cur_encrypt);
-			break;
-		}
-
-		desc = &sc->txq.desc[sc->txq.next_encrypt];
-
-		if ((le32toh(desc->flags) & RT2560_TX_BUSY) ||
-		    (le32toh(desc->flags) & RT2560_TX_CIPHER_BUSY))
-			break;
-
-		/* for TKIP, swap eiv field to fix a bug in ASIC */
-		if ((le32toh(desc->flags) & RT2560_TX_CIPHER_MASK) ==
-		    RT2560_TX_CIPHER_TKIP)
-			desc->eiv = bswap32(desc->eiv);
-
-		/* mark the frame ready for transmission */
-		desc->flags |= htole32(RT2560_TX_VALID);
-		desc->flags |= htole32(RT2560_TX_BUSY);
-
-		DPRINTFN(sc, 15, "encryption done idx=%u\n",
-		    sc->txq.next_encrypt);
-
-		sc->txq.next_encrypt =
-		    (sc->txq.next_encrypt + 1) % RT2560_TX_RING_COUNT;
-	}
-
-	bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
-	    BUS_DMASYNC_PREWRITE);
-
-	/* kick Tx */
-	RAL_WRITE(sc, RT2560_TXCSR0, RT2560_KICK_TX);
-}
-
-static void
-rt2560_tx_intr(struct rt2560_softc *sc)
-{
-	struct ifnet *ifp = sc->sc_ifp;
-	struct rt2560_tx_desc *desc;
-	struct rt2560_tx_data *data;
-	struct mbuf *m;
-	uint32_t flags;
-	int retrycnt;
-	struct ieee80211vap *vap;
-	struct ieee80211_node *ni;
-
-	bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
-	    BUS_DMASYNC_POSTREAD);
-
-	for (;;) {
-		desc = &sc->txq.desc[sc->txq.next];
-		data = &sc->txq.data[sc->txq.next];
-
-		flags = le32toh(desc->flags);
-		if ((flags & RT2560_TX_BUSY) ||
-		    (flags & RT2560_TX_CIPHER_BUSY) ||
-		    !(flags & RT2560_TX_VALID))
-			break;
-
-		m = data->m;
-		ni = data->ni;
-		vap = ni->ni_vap;
-
-		switch (flags & RT2560_TX_RESULT_MASK) {
-		case RT2560_TX_SUCCESS:
-			retrycnt = 0;
-
-			DPRINTFN(sc, 10, "%s\n", "data frame sent successfully");
-			if (data->rix != IEEE80211_FIXED_RATE_NONE)
-				ieee80211_ratectl_tx_complete(vap, ni,
-				    IEEE80211_RATECTL_TX_SUCCESS,
-				    &retrycnt, NULL);
-			ifp->if_opackets++;
-			break;
-
-		case RT2560_TX_SUCCESS_RETRY:
-			retrycnt = RT2560_TX_RETRYCNT(flags);
-
-			DPRINTFN(sc, 9, "data frame sent after %u retries\n",
-			    retrycnt);
-			if (data->rix != IEEE80211_FIXED_RATE_NONE)
-				ieee80211_ratectl_tx_complete(vap, ni,
-				    IEEE80211_RATECTL_TX_SUCCESS,
-				    &retrycnt, NULL);
-			ifp->if_opackets++;
-			break;
-
-		case RT2560_TX_FAIL_RETRY:
-			retrycnt = RT2560_TX_RETRYCNT(flags);
-
-			DPRINTFN(sc, 9, "data frame failed after %d retries\n",
-			    retrycnt);
-			if (data->rix != IEEE80211_FIXED_RATE_NONE)
-				ieee80211_ratectl_tx_complete(vap, ni,
-				    IEEE80211_RATECTL_TX_FAILURE,
-				    &retrycnt, NULL);
-			ifp->if_oerrors++;
-			break;
-
-		case RT2560_TX_FAIL_INVALID:
-		case RT2560_TX_FAIL_OTHER:
-		default:
-			device_printf(sc->sc_dev, "sending data frame failed "
-			    "0x%08x\n", flags);
-			ifp->if_oerrors++;
-		}
-
-		bus_dmamap_sync(sc->txq.data_dmat, data->map,
-		    BUS_DMASYNC_POSTWRITE);
-		bus_dmamap_unload(sc->txq.data_dmat, data->map);
***The diff for this file has been truncated for email.***
=======================================
--- /rt2560reg.h	Tue Mar 13 05:46:45 2012
+++ /dev/null
@@ -1,489 +0,0 @@
-/*	$FreeBSD$	*/
-
-/*-
- * Copyright (c) 2005, 2006
- *	Damien Bergamini <damien.bergamini at 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 RT2560_DEFAULT_RSSI_CORR	0x79
-#define RT2560_NOISE_FLOOR		-95
-
-#define RT2560_TX_RING_COUNT		48
-#define RT2560_ATIM_RING_COUNT		4
-#define RT2560_PRIO_RING_COUNT		16
-#define RT2560_BEACON_RING_COUNT	1
-#define RT2560_RX_RING_COUNT		32
-
-#define RT2560_TX_DESC_SIZE	(sizeof (struct rt2560_tx_desc))
-#define RT2560_RX_DESC_SIZE	(sizeof (struct rt2560_rx_desc))
-
-#define RT2560_MAX_SCATTER	1
-
-/*
- * Control and status registers.
- */
-#define RT2560_CSR0		0x0000	/* ASIC version number */
-#define RT2560_CSR1		0x0004	/* System control */
-#define RT2560_CSR3		0x000c	/* STA MAC address 0 */
-#define RT2560_CSR4		0x0010	/* STA MAC address 1 */
-#define RT2560_CSR5		0x0014	/* BSSID 0 */
-#define RT2560_CSR6		0x0018	/* BSSID 1 */
-#define RT2560_CSR7		0x001c	/* Interrupt source */
-#define RT2560_CSR8		0x0020	/* Interrupt mask */
-#define RT2560_CSR9		0x0024	/* Maximum frame length */
-#define RT2560_SECCSR0		0x0028	/* WEP control */
-#define RT2560_CSR11		0x002c	/* Back-off control */
-#define RT2560_CSR12		0x0030	/* Synchronization configuration 0 */
-#define RT2560_CSR13		0x0034	/* Synchronization configuration 1 */
-#define RT2560_CSR14		0x0038	/* Synchronization control */
-#define RT2560_CSR15		0x003c	/* Synchronization status */
-#define RT2560_CSR16		0x0040	/* TSF timer 0 */
-#define RT2560_CSR17		0x0044	/* TSF timer 1 */
-#define RT2560_CSR18		0x0048	/* IFS timer 0 */
-#define RT2560_CSR19		0x004c	/* IFS timer 1 */
-#define RT2560_CSR20		0x0050	/* WAKEUP timer */
-#define RT2560_CSR21		0x0054	/* EEPROM control */
-#define RT2560_CSR22		0x0058	/* CFP control */
-#define RT2560_TXCSR0		0x0060	/* TX control */
-#define RT2560_TXCSR1		0x0064	/* TX configuration */
-#define RT2560_TXCSR2		0x0068	/* TX descriptor configuration */
-#define RT2560_TXCSR3		0x006c	/* TX ring base address */
-#define RT2560_TXCSR4		0x0070	/* TX ATIM ring base address */
-#define RT2560_TXCSR5		0x0074	/* TX PRIO ring base address */
-#define RT2560_TXCSR6		0x0078	/* Beacon base address */
-#define RT2560_TXCSR7		0x007c	/* AutoResponder control */
-#define RT2560_RXCSR0		0x0080	/* RX control */
-#define RT2560_RXCSR1		0x0084	/* RX descriptor configuration */
-#define RT2560_RXCSR2		0x0088	/* RX ring base address */
-#define RT2560_PCICSR		0x008c	/* PCI control */
-#define RT2560_RXCSR3		0x0090	/* BBP ID 0 */
-#define RT2560_TXCSR9		0x0094	/* OFDM TX BBP */
-#define RT2560_ARSP_PLCP_0	0x0098	/* Auto Responder PLCP address */
-#define RT2560_ARSP_PLCP_1	0x009c	/* Auto Responder Basic Rate mask */
-#define RT2560_CNT0		0x00a0	/* FCS error counter */
-#define RT2560_CNT1		0x00ac	/* PLCP error counter */
-#define RT2560_CNT2		0x00b0	/* Long error counter */
-#define RT2560_CNT3		0x00b8	/* CCA false alarm counter */
-#define RT2560_CNT4		0x00bc	/* RX FIFO Overflow counter */
-#define RT2560_CNT5		0x00c0	/* Tx FIFO Underrun counter */
-#define RT2560_PWRCSR0		0x00c4	/* Power mode configuration */
-#define RT2560_PSCSR0		0x00c8	/* Power state transition time */
-#define RT2560_PSCSR1		0x00cc	/* Power state transition time */
-#define RT2560_PSCSR2		0x00d0	/* Power state transition time */
-#define RT2560_PSCSR3		0x00d4	/* Power state transition time */
-#define RT2560_PWRCSR1		0x00d8	/* Manual power control/status */
-#define RT2560_TIMECSR		0x00dc	/* Timer control */
-#define RT2560_MACCSR0		0x00e0	/* MAC configuration */
-#define RT2560_MACCSR1		0x00e4	/* MAC configuration */
-#define RT2560_RALINKCSR	0x00e8	/* Ralink RX auto-reset BBCR */
-#define RT2560_BCNCSR		0x00ec	/* Beacon interval control */
-#define RT2560_BBPCSR		0x00f0	/* BBP serial control */
-#define RT2560_RFCSR		0x00f4	/* RF serial control */
-#define RT2560_LEDCSR		0x00f8	/* LED control */
-#define RT2560_SECCSR3		0x00fc	/* XXX not documented */
-#define RT2560_DMACSR0		0x0100	/* Current RX ring address */
-#define RT2560_DMACSR1		0x0104	/* Current Tx ring address */
-#define RT2560_DMACSR2		0x0104	/* Current Priority ring address */
-#define RT2560_DMACSR3		0x0104	/* Current ATIM ring address */
-#define RT2560_TXACKCSR0	0x0110	/* XXX not documented */
-#define RT2560_GPIOCSR		0x0120	/* */
-#define RT2560_BBBPPCSR		0x0124	/* BBP Pin Control */
-#define RT2560_FIFOCSR0		0x0128	/* TX FIFO pointer */
-#define RT2560_FIFOCSR1		0x012c	/* RX FIFO pointer */
-#define RT2560_BCNOCSR		0x0130	/* Beacon time offset */
-#define RT2560_RLPWCSR		0x0134	/* RX_PE Low Width */
-#define RT2560_TESTCSR		0x0138	/* Test Mode Select */
-#define RT2560_PLCP1MCSR	0x013c	/* Signal/Service/Length of ACK @1M */
-#define RT2560_PLCP2MCSR	0x0140	/* Signal/Service/Length of ACK @2M */
-#define RT2560_PLCP5p5MCSR	0x0144	/* Signal/Service/Length of ACK @5.5M */
-#define RT2560_PLCP11MCSR	0x0148	/* Signal/Service/Length of ACK @11M */
-#define RT2560_ACKPCTCSR	0x014c	/* ACK/CTS padload consume time */
-#define RT2560_ARTCSR1		0x0150	/* ACK/CTS padload consume time */
-#define RT2560_ARTCSR2		0x0154	/* ACK/CTS padload consume time */
-#define RT2560_SECCSR1		0x0158	/* WEP control */
-#define RT2560_BBPCSR1		0x015c	/* BBP TX Configuration */
-
-
-/* possible flags for register RXCSR0 */
-#define RT2560_DISABLE_RX		(1 << 0)
-#define RT2560_DROP_CRC_ERROR		(1 << 1)
-#define RT2560_DROP_PHY_ERROR		(1 << 2)
-#define RT2560_DROP_CTL			(1 << 3)
-#define RT2560_DROP_NOT_TO_ME		(1 << 4)
-#define RT2560_DROP_TODS		(1 << 5)
-#define RT2560_DROP_VERSION_ERROR	(1 << 6)
-
-/* possible flags for register CSR1 */
-#define RT2560_RESET_ASIC	(1 << 0)
-#define RT2560_RESET_BBP	(1 << 1)
-#define RT2560_HOST_READY	(1 << 2)
-
-/* possible flags for register CSR14 */
-#define RT2560_ENABLE_TSF		(1 << 0)
-#define RT2560_ENABLE_TSF_SYNC(x)	(((x) & 0x3) << 1)
-#define RT2560_ENABLE_TBCN		(1 << 3)
-#define RT2560_ENABLE_BEACON_GENERATOR	(1 << 6)
-
-/* possible flags for register CSR21 */
-#define RT2560_C	(1 << 1)
-#define RT2560_S	(1 << 2)
-#define RT2560_D	(1 << 3)
-#define RT2560_Q	(1 << 4)
-#define RT2560_93C46	(1 << 5)
-
-#define RT2560_SHIFT_D	3
-#define RT2560_SHIFT_Q	4
-
-/* possible flags for register TXCSR0 */
-#define RT2560_KICK_TX		(1 << 0)
-#define RT2560_KICK_ATIM	(1 << 1)
-#define RT2560_KICK_PRIO	(1 << 2)
-#define RT2560_ABORT_TX		(1 << 3)
-
-/* possible flags for register SECCSR0 */
-#define RT2560_KICK_DECRYPT	(1 << 0)
-
-/* possible flags for register SECCSR1 */
-#define RT2560_KICK_ENCRYPT	(1 << 0)
-
-/* possible flags for register CSR7 */
-#define RT2560_BEACON_EXPIRE	0x00000001
-#define RT2560_WAKEUP_EXPIRE	0x00000002
-#define RT2560_ATIM_EXPIRE	0x00000004
-#define RT2560_TX_DONE		0x00000008
-#define RT2560_ATIM_DONE	0x00000010
-#define RT2560_PRIO_DONE	0x00000020
-#define RT2560_RX_DONE		0x00000040
-#define RT2560_DECRYPTION_DONE	0x00000080
-#define RT2560_ENCRYPTION_DONE	0x00000100
-
-#define RT2560_INTR_MASK							\
-	(~(RT2560_BEACON_EXPIRE | RT2560_WAKEUP_EXPIRE | RT2560_TX_DONE |	\
-	   RT2560_PRIO_DONE | RT2560_RX_DONE | RT2560_DECRYPTION_DONE |		\
-	   RT2560_ENCRYPTION_DONE))
-
-/* Tx descriptor */
-struct rt2560_tx_desc {
-	uint32_t	flags;
-#define RT2560_TX_BUSY			(1 << 0)
-#define RT2560_TX_VALID			(1 << 1)
-
-#define RT2560_TX_RESULT_MASK		0x0000001c
-#define RT2560_TX_SUCCESS		(0 << 2)
-#define RT2560_TX_SUCCESS_RETRY		(1 << 2)
-#define RT2560_TX_FAIL_RETRY		(2 << 2)
-#define RT2560_TX_FAIL_INVALID		(3 << 2)
-#define RT2560_TX_FAIL_OTHER		(4 << 2)
-
-#define RT2560_TX_MORE_FRAG		(1 << 8)
-#define RT2560_TX_ACK			(1 << 9)
-#define RT2560_TX_TIMESTAMP		(1 << 10)
-#define RT2560_TX_OFDM			(1 << 11)
-#define RT2560_TX_CIPHER_BUSY		(1 << 12)
-
-#define RT2560_TX_IFS_MASK		0x00006000
-#define RT2560_TX_IFS_BACKOFF		(0 << 13)
-#define RT2560_TX_IFS_SIFS		(1 << 13)
-#define RT2560_TX_IFS_NEWBACKOFF	(2 << 13)
-#define RT2560_TX_IFS_NONE		(3 << 13)
-
-#define RT2560_TX_LONG_RETRY		(1 << 15)
-
-#define RT2560_TX_CIPHER_MASK		0xe0000000
-#define RT2560_TX_CIPHER_NONE		(0 << 29)
-#define RT2560_TX_CIPHER_WEP40		(1 << 29)
-#define RT2560_TX_CIPHER_WEP104		(2 << 29)
-#define RT2560_TX_CIPHER_TKIP		(3 << 29)
-#define RT2560_TX_CIPHER_AES		(4 << 29)
-
-#define RT2560_TX_RETRYCNT(v)	(((v) >> 5) & 0x7)
-
-	uint32_t	physaddr;
-	uint16_t	wme;
-#define RT2560_LOGCWMAX(x)	(((x) & 0xf) << 12)
-#define RT2560_LOGCWMIN(x)	(((x) & 0xf) << 8)
-#define RT2560_AIFSN(x)		(((x) & 0x3) << 6)
-#define RT2560_IVOFFSET(x)	(((x) & 0x3f))
-
-	uint16_t	reserved1;
-	uint8_t		plcp_signal;
-	uint8_t		plcp_service;
-#define RT2560_PLCP_LENGEXT	0x80
-
-	uint8_t		plcp_length_lo;
-	uint8_t		plcp_length_hi;
-	uint32_t	iv;
-	uint32_t	eiv;
-	uint8_t		key[IEEE80211_KEYBUF_SIZE];
-	uint32_t	reserved2[2];
-} __packed;
-
-/* Rx descriptor */
-struct rt2560_rx_desc {
-	uint32_t	flags;
-#define RT2560_RX_BUSY		(1 << 0)
-#define RT2560_RX_CRC_ERROR	(1 << 5)
-#define RT2560_RX_OFDM		(1 << 6)
-#define RT2560_RX_PHY_ERROR	(1 << 7)
-#define RT2560_RX_CIPHER_BUSY	(1 << 8)
-#define RT2560_RX_ICV_ERROR	(1 << 9)
-
-#define RT2560_RX_CIPHER_MASK	0xe0000000
-#define RT2560_RX_CIPHER_NONE	(0 << 29)
-#define RT2560_RX_CIPHER_WEP40	(1 << 29)
-#define RT2560_RX_CIPHER_WEP104	(2 << 29)
-#define RT2560_RX_CIPHER_TKIP	(3 << 29)
-#define RT2560_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 RT2560_RF1_AUTOTUNE	0x08000
-#define RT2560_RF3_AUTOTUNE	0x00040
-
-#define RT2560_BBP_BUSY		(1 << 15)
-#define RT2560_BBP_WRITE	(1 << 16)
-#define RT2560_RF_20BIT		(20 << 24)
-#define RT2560_RF_BUSY		(1 << 31)
-
-#define RT2560_RF_2522	0x00
-#define RT2560_RF_2523	0x01
-#define RT2560_RF_2524	0x02
-#define RT2560_RF_2525	0x03
-#define RT2560_RF_2525E	0x04
-#define RT2560_RF_2526	0x05
-/* dual-band RF */
-#define RT2560_RF_5222	0x10
-
-#define RT2560_BBP_VERSION	0
-#define RT2560_BBP_TX		2
-#define RT2560_BBP_RX		14
-
-#define RT2560_BBP_ANTA		0x00
-#define RT2560_BBP_DIVERSITY	0x01
-#define RT2560_BBP_ANTB		0x02
-#define RT2560_BBP_ANTMASK	0x03
-#define RT2560_BBP_FLIPIQ	0x04
-
-#define RT2560_LED_MODE_DEFAULT		0
-#define RT2560_LED_MODE_TXRX_ACTIVITY	1
-#define RT2560_LED_MODE_SINGLE		2
-#define RT2560_LED_MODE_ASUS		3
-
-#define RT2560_JAPAN_FILTER	0x8
-
-#define RT2560_EEPROM_DELAY	1	/* minimum hold time (microsecond) */
-
-#define RT2560_EEPROM_CONFIG0	16
-#define RT2560_EEPROM_BBP_BASE	19
-#define RT2560_EEPROM_TXPOWER	35
-#define RT2560_EEPROM_CALIBRATE	62
-
-/*
- * 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 RT2560_EEPROM_CTL(sc, val) do {					\
-	RAL_WRITE((sc), RT2560_CSR21, (val));				\
-	DELAY(RT2560_EEPROM_DELAY);					\
-} while (/* CONSTCOND */0)
-
-/*
- * Default values for MAC registers; values taken from the reference  
driver.
- */
-#define RT2560_DEF_MAC				\
-	{ RT2560_PSCSR0,      0x00020002 },	\
-	{ RT2560_PSCSR1,      0x00000002 },	\
-	{ RT2560_PSCSR2,      0x00020002 },	\
-	{ RT2560_PSCSR3,      0x00000002 },	\
-	{ RT2560_TIMECSR,     0x00003f21 },	\
-	{ RT2560_CSR9,        0x00000780 },	\
-	{ RT2560_CSR11,       0x07041483 },	\
-	{ RT2560_CNT3,        0x00000000 },	\
-	{ RT2560_TXCSR1,      0x07614562 },	\
-	{ RT2560_ARSP_PLCP_0, 0x8c8d8b8a },	\
-	{ RT2560_ACKPCTCSR,   0x7038140a },	\
-	{ RT2560_ARTCSR1,     0x21212929 },	\
-	{ RT2560_ARTCSR2,     0x1d1d1d1d },	\
-	{ RT2560_RXCSR0,      0xffffffff },	\
-	{ RT2560_RXCSR3,      0xb3aab3af },	\
-	{ RT2560_PCICSR,      0x000003b8 },	\
-	{ RT2560_PWRCSR0,     0x3f3b3100 },	\
-	{ RT2560_GPIOCSR,     0x0000ff00 },	\
-	{ RT2560_TESTCSR,     0x000000f0 },	\
-	{ RT2560_PWRCSR1,     0x000001ff },	\
-	{ RT2560_MACCSR0,     0x00213223 },	\
-	{ RT2560_MACCSR1,     0x00235518 },	\
-	{ RT2560_RLPWCSR,     0x00000040 },	\
-	{ RT2560_RALINKCSR,   0x9a009a11 },	\
-	{ RT2560_CSR7,        0xffffffff },	\
-	{ RT2560_BBPCSR1,     0x82188200 },	\
-	{ RT2560_TXACKCSR0,   0x00000020 },	\
-	{ RT2560_SECCSR3,     0x0000e78f }
-
-/*
- * Default values for BBP registers; values taken from the reference  
driver.
- */
-#define RT2560_DEF_BBP	\
-	{  3, 0x02 },	\
-	{  4, 0x19 },	\
-	{ 14, 0x1c },	\
-	{ 15, 0x30 },	\
-	{ 16, 0xac },	\
-	{ 17, 0x48 },	\
-	{ 18, 0x18 },	\
-	{ 19, 0xff },	\
-	{ 20, 0x1e },	\
-	{ 21, 0x08 },	\
-	{ 22, 0x08 },	\
-	{ 23, 0x08 },	\
-	{ 24, 0x80 },	\
-	{ 25, 0x50 },	\
-	{ 26, 0x08 },	\
-	{ 27, 0x23 },	\
-	{ 30, 0x10 },	\
-	{ 31, 0x2b },	\
-	{ 32, 0xb9 },	\
-	{ 34, 0x12 },	\
-	{ 35, 0x50 },	\
-	{ 39, 0xc4 },	\
-	{ 40, 0x02 },	\
-	{ 41, 0x60 },	\
-	{ 53, 0x10 },	\
-	{ 54, 0x18 },	\
-	{ 56, 0x08 },	\
-	{ 57, 0x10 },	\
-	{ 58, 0x08 },	\
-	{ 61, 0x60 },	\
-	{ 62, 0x10 },	\
-	{ 75, 0xff }
-
-/*
- * Default values for RF register R2 indexed by channel numbers; values  
taken
- * from the reference driver.
- */
-#define RT2560_RF2522_R2						\
-{									\
-	0x307f6, 0x307fb, 0x30800, 0x30805, 0x3080a, 0x3080f, 0x30814,	\
-	0x30819, 0x3081e, 0x30823, 0x30828, 0x3082d, 0x30832, 0x3083e	\
-}
-
-#define RT2560_RF2523_R2						\
-{									\
-	0x00327, 0x00328, 0x00329, 0x0032a, 0x0032b, 0x0032c, 0x0032d,	\
-	0x0032e, 0x0032f, 0x00340, 0x00341, 0x00342, 0x00343, 0x00346	\
-}
-
-#define RT2560_RF2524_R2						\
-{									\
-	0x00327, 0x00328, 0x00329, 0x0032a, 0x0032b, 0x0032c, 0x0032d,	\
-	0x0032e, 0x0032f, 0x00340, 0x00341, 0x00342, 0x00343, 0x00346	\
-}
-
-#define RT2560_RF2525_R2						\
-{									\
-	0x20327, 0x20328, 0x20329, 0x2032a, 0x2032b, 0x2032c, 0x2032d,	\
-	0x2032e, 0x2032f, 0x20340, 0x20341, 0x20342, 0x20343, 0x20346	\
-}
-
-#define RT2560_RF2525_HI_R2						\
-{									\
-	0x2032f, 0x20340, 0x20341, 0x20342, 0x20343, 0x20344, 0x20345,	\
-	0x20346, 0x20347, 0x20348, 0x20349, 0x2034a, 0x2034b, 0x2034e	\
-}
-
-#define RT2560_RF2525E_R2						\
-{									\
-	0x2044d, 0x2044e, 0x2044f, 0x20460, 0x20461, 0x20462, 0x20463,	\
-	0x20464, 0x20465, 0x20466, 0x20467, 0x20468, 0x20469, 0x2046b	\
-}
-
-#define RT2560_RF2526_HI_R2						\
-{									\
-	0x0022a, 0x0022b, 0x0022b, 0x0022c, 0x0022c, 0x0022d, 0x0022d,	\
-	0x0022e, 0x0022e, 0x0022f, 0x0022d, 0x00240, 0x00240, 0x00241	\
-}
-
-#define RT2560_RF2526_R2						\
-{									\
-	0x00226, 0x00227, 0x00227, 0x00228, 0x00228, 0x00229, 0x00229,	\
-	0x0022a, 0x0022a, 0x0022b, 0x0022b, 0x0022c, 0x0022c, 0x0022d	\
-}
-
-/*
- * For dual-band RF, RF registers R1 and R4 also depend on channel number;
- * values taken from the reference driver.
- */
-#define RT2560_RF5222				\
-	{   1, 0x08808, 0x0044d, 0x00282 },	\
-	{   2, 0x08808, 0x0044e, 0x00282 },	\
-	{   3, 0x08808, 0x0044f, 0x00282 },	\
-	{   4, 0x08808, 0x00460, 0x00282 },	\
-	{   5, 0x08808, 0x00461, 0x00282 },	\
-	{   6, 0x08808, 0x00462, 0x00282 },	\
-	{   7, 0x08808, 0x00463, 0x00282 },	\
-	{   8, 0x08808, 0x00464, 0x00282 },	\
-	{   9, 0x08808, 0x00465, 0x00282 },	\
-	{  10, 0x08808, 0x00466, 0x00282 },	\
-	{  11, 0x08808, 0x00467, 0x00282 },	\
-	{  12, 0x08808, 0x00468, 0x00282 },	\
-	{  13, 0x08808, 0x00469, 0x00282 },	\
-	{  14, 0x08808, 0x0046b, 0x00286 },	\
-						\
-	{  36, 0x08804, 0x06225, 0x00287 },	\
-	{  40, 0x08804, 0x06226, 0x00287 },	\
-	{  44, 0x08804, 0x06227, 0x00287 },	\
-	{  48, 0x08804, 0x06228, 0x00287 },	\
-	{  52, 0x08804, 0x06229, 0x00287 },	\
-	{  56, 0x08804, 0x0622a, 0x00287 },	\
-	{  60, 0x08804, 0x0622b, 0x00287 },	\
-	{  64, 0x08804, 0x0622c, 0x00287 },	\
-						\
-	{ 100, 0x08804, 0x02200, 0x00283 },	\
-	{ 104, 0x08804, 0x02201, 0x00283 },	\
-	{ 108, 0x08804, 0x02202, 0x00283 },	\
-	{ 112, 0x08804, 0x02203, 0x00283 },	\
-	{ 116, 0x08804, 0x02204, 0x00283 },	\
-	{ 120, 0x08804, 0x02205, 0x00283 },	\
-	{ 124, 0x08804, 0x02206, 0x00283 },	\
-	{ 128, 0x08804, 0x02207, 0x00283 },	\
-	{ 132, 0x08804, 0x02208, 0x00283 },	\
-	{ 136, 0x08804, 0x02209, 0x00283 },	\
-	{ 140, 0x08804, 0x0220a, 0x00283 },	\
-						\
-	{ 149, 0x08808, 0x02429, 0x00281 },	\
-	{ 153, 0x08808, 0x0242b, 0x00281 },	\
-	{ 157, 0x08808, 0x0242d, 0x00281 },	\
-	{ 161, 0x08808, 0x0242f, 0x00281 }
=======================================
--- /rt2560var.h	Tue Mar 13 05:46:45 2012
+++ /dev/null
@@ -1,168 +0,0 @@
-/*	$FreeBSD$	*/
-
-/*-
- * Copyright (c) 2005, 2006
- *	Damien Bergamini <damien.bergamini at 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 rt2560_rx_radiotap_header {
-	struct ieee80211_radiotap_header wr_ihdr;
-	uint64_t	wr_tsf;
-	uint8_t		wr_flags;
-	uint8_t		wr_rate;
-	uint16_t	wr_chan_freq;
-	uint16_t	wr_chan_flags;
-	int8_t		wr_antsignal;
-	int8_t		wr_antnoise;
-	uint8_t		wr_antenna;
-};
-
-#define RT2560_RX_RADIOTAP_PRESENT					\
-	((1 << IEEE80211_RADIOTAP_TSFT) |				\
-	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
-	 (1 << IEEE80211_RADIOTAP_RATE) |				\
-	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
-	 (1 << IEEE80211_RADIOTAP_ANTENNA) |				\
-	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
-	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
-
-struct rt2560_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;
-};
-
-#define RT2560_TX_RADIOTAP_PRESENT					\
-	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
-	 (1 << IEEE80211_RADIOTAP_RATE) |				\
-	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
-	 (1 << IEEE80211_RADIOTAP_ANTENNA))
-
-struct rt2560_tx_data {
-	bus_dmamap_t			map;
-	struct mbuf			*m;
-	struct ieee80211_node		*ni;
-	uint8_t				rix;
-	int8_t				rssi;
-};
-
-struct rt2560_tx_ring {
-	bus_dma_tag_t		desc_dmat;
-	bus_dma_tag_t		data_dmat;
-	bus_dmamap_t		desc_map;
-	bus_addr_t		physaddr;
-	struct rt2560_tx_desc	*desc;
-	struct rt2560_tx_data	*data;
-	int			count;
-	int			queued;
-	int			cur;
-	int			next;
-	int			cur_encrypt;
-	int			next_encrypt;
-};
-
-struct rt2560_rx_data {
-	bus_dmamap_t	map;
-	struct mbuf	*m;
-	int		drop;
-};
-
-struct rt2560_rx_ring {
-	bus_dma_tag_t		desc_dmat;
-	bus_dma_tag_t		data_dmat;
-	bus_dmamap_t		desc_map;
-	bus_addr_t		physaddr;
-	struct rt2560_rx_desc	*desc;
-	struct rt2560_rx_data	*data;
-	int			count;
-	int			cur;
-	int			next;
-	int			cur_decrypt;
-};
-
-struct rt2560_vap {
-	struct ieee80211vap	ral_vap;
-	struct ieee80211_beacon_offsets	ral_bo;
-
-	int			(*ral_newstate)(struct ieee80211vap *,
-				    enum ieee80211_state, int);
-};
-#define	RT2560_VAP(vap)		((struct rt2560_vap *)(vap))
-
-struct rt2560_softc {
-	struct ifnet		*sc_ifp;
-	device_t		sc_dev;
-	bus_space_tag_t		sc_st;
-	bus_space_handle_t	sc_sh;
-
-	struct mtx		sc_mtx;
-
-	struct callout		watchdog_ch;
-
-	int			sc_tx_timer;
-	int                     sc_invalid;
-	int			sc_debug;
-/*
- * The same in both up to here
- * ------------------------------------------------
- */
-	uint32_t		asic_rev;
-	uint32_t		eeprom_rev;
-	uint8_t			rf_rev;
-	uint8_t			rssi_corr;
-
-	struct rt2560_tx_ring	txq;
-	struct rt2560_tx_ring	prioq;
-	struct rt2560_tx_ring	atimq;
-	struct rt2560_tx_ring	bcnq;
-	struct rt2560_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;
-
-	struct rt2560_rx_radiotap_header sc_rxtap;
-	int			sc_rxtap_len;
-
-	struct rt2560_tx_radiotap_header sc_txtap;
-	int			sc_txtap_len;
-#define RT2560_F_INPUT_RUNNING	0x1
-#define RT2560_F_PRIO_OACTIVE	0x2
-#define RT2560_F_DATA_OACTIVE	0x4
-	int			sc_flags;
-};
-
-int	rt2560_attach(device_t, int);
-int	rt2560_detach(void *);
-void	rt2560_stop(void *);
-void	rt2560_resume(void *);
-void	rt2560_intr(void *);
-
-#define RAL_LOCK(sc)		mtx_lock(&(sc)->sc_mtx)
-#define RAL_LOCK_ASSERT(sc)	mtx_assert(&(sc)->sc_mtx, MA_OWNED)
-#define RAL_UNLOCK(sc)		mtx_unlock(&(sc)->sc_mtx)
=======================================
--- /rt2661.c	Tue Mar 13 05:46:45 2012
+++ /dev/null
@@ -1,2844 +0,0 @@
-/*	$FreeBSD: head/sys/dev/ral/rt2661.c 228621 2011-12-17 10:23:17Z  
bschmidt $	*/
-
-/*-
- * Copyright (c) 2006
- *	Damien Bergamini <damien.bergamini at 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/ral/rt2661.c 228621 2011-12-17 10:23:17Z  
bschmidt $");
-
-/*-
- * Ralink Technology RT2561, RT2561S and RT2661 chipset driver
- * http://www.ralinktech.com/
- */
-
-#include <sys/param.h>
-#include <sys/sysctl.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/lock.h>
-#include <sys/mutex.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/endian.h>
-#include <sys/firmware.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-#include <net/if_types.h>
-
-#include <net80211/ieee80211_var.h>
-#include <net80211/ieee80211_radiotap.h>
-#include <net80211/ieee80211_regdomain.h>
-#include <net80211/ieee80211_ratectl.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
-
-#include <dev/ral/rt2661reg.h>
-#include <dev/ral/rt2661var.h>
-
-#define RAL_DEBUG
-#ifdef RAL_DEBUG
-#define DPRINTF(sc, fmt, ...) do {				\
-	if (sc->sc_debug > 0)					\
-		printf(fmt, __VA_ARGS__);			\
-} while (0)
-#define DPRINTFN(sc, n, fmt, ...) do {				\
-	if (sc->sc_debug >= (n))				\
-		printf(fmt, __VA_ARGS__);			\
-} while (0)
-#else
-#define DPRINTF(sc, fmt, ...)
-#define DPRINTFN(sc, n, fmt, ...)
-#endif
-
-static struct ieee80211vap *rt2661_vap_create(struct ieee80211com *,
-			    const char [IFNAMSIZ], int, enum ieee80211_opmode,
-			    int, const uint8_t [IEEE80211_ADDR_LEN],
-			    const uint8_t [IEEE80211_ADDR_LEN]);
-static void		rt2661_vap_delete(struct ieee80211vap *);
-static void		rt2661_dma_map_addr(void *, bus_dma_segment_t *, int,
-			    int);
-static int		rt2661_alloc_tx_ring(struct rt2661_softc *,
-			    struct rt2661_tx_ring *, int);
-static void		rt2661_reset_tx_ring(struct rt2661_softc *,
-			    struct rt2661_tx_ring *);
-static void		rt2661_free_tx_ring(struct rt2661_softc *,
-			    struct rt2661_tx_ring *);
-static int		rt2661_alloc_rx_ring(struct rt2661_softc *,
-			    struct rt2661_rx_ring *, int);
-static void		rt2661_reset_rx_ring(struct rt2661_softc *,
-			    struct rt2661_rx_ring *);
-static void		rt2661_free_rx_ring(struct rt2661_softc *,
-			    struct rt2661_rx_ring *);
-static int		rt2661_newstate(struct ieee80211vap *,
-			    enum ieee80211_state, int);
-static uint16_t		rt2661_eeprom_read(struct rt2661_softc *, uint8_t);
-static void		rt2661_rx_intr(struct rt2661_softc *);
-static void		rt2661_tx_intr(struct rt2661_softc *);
-static void		rt2661_tx_dma_intr(struct rt2661_softc *,
-			    struct rt2661_tx_ring *);
-static void		rt2661_mcu_beacon_expire(struct rt2661_softc *);
-static void		rt2661_mcu_wakeup(struct rt2661_softc *);
-static void		rt2661_mcu_cmd_intr(struct rt2661_softc *);
-static void		rt2661_scan_start(struct ieee80211com *);
-static void		rt2661_scan_end(struct ieee80211com *);
-static void		rt2661_set_channel(struct ieee80211com *);
-static void		rt2661_setup_tx_desc(struct rt2661_softc *,
-			    struct rt2661_tx_desc *, uint32_t, uint16_t, int,
-			    int, const bus_dma_segment_t *, int, int);
-static int		rt2661_tx_data(struct rt2661_softc *, struct mbuf *,
-			    struct ieee80211_node *, int);
-static int		rt2661_tx_mgt(struct rt2661_softc *, struct mbuf *,
-			    struct ieee80211_node *);
-static void		rt2661_start_locked(struct ifnet *);
-static void		rt2661_start(struct ifnet *);
-static int		rt2661_raw_xmit(struct ieee80211_node *, struct mbuf *,
-			    const struct ieee80211_bpf_params *);
-static void		rt2661_watchdog(void *);
-static int		rt2661_ioctl(struct ifnet *, u_long, caddr_t);
-static void		rt2661_bbp_write(struct rt2661_softc *, uint8_t,
-			    uint8_t);
-static uint8_t		rt2661_bbp_read(struct rt2661_softc *, uint8_t);
-static void		rt2661_rf_write(struct rt2661_softc *, uint8_t,
-			    uint32_t);
-static int		rt2661_tx_cmd(struct rt2661_softc *, uint8_t,
-			    uint16_t);
-static void		rt2661_select_antenna(struct rt2661_softc *);
-static void		rt2661_enable_mrr(struct rt2661_softc *);
-static void		rt2661_set_txpreamble(struct rt2661_softc *);
-static void		rt2661_set_basicrates(struct rt2661_softc *,
-			    const struct ieee80211_rateset *);
-static void		rt2661_select_band(struct rt2661_softc *,
-			    struct ieee80211_channel *);
-static void		rt2661_set_chan(struct rt2661_softc *,
-			    struct ieee80211_channel *);
-static void		rt2661_set_bssid(struct rt2661_softc *,
-			    const uint8_t *);
-static void		rt2661_set_macaddr(struct rt2661_softc *,
-			   const uint8_t *);
-static void		rt2661_update_promisc(struct ifnet *);
-static int		rt2661_wme_update(struct ieee80211com *) __unused;
-static void		rt2661_update_slot(struct ifnet *);
-static const char	*rt2661_get_rf(int);
-static void		rt2661_read_eeprom(struct rt2661_softc *,
-			    uint8_t macaddr[IEEE80211_ADDR_LEN]);
-static int		rt2661_bbp_init(struct rt2661_softc *);
-static void		rt2661_init_locked(struct rt2661_softc *);
-static void		rt2661_init(void *);
-static void             rt2661_stop_locked(struct rt2661_softc *);
-static void		rt2661_stop(void *);
-static int		rt2661_load_microcode(struct rt2661_softc *);
-#ifdef notyet
-static void		rt2661_rx_tune(struct rt2661_softc *);
-static void		rt2661_radar_start(struct rt2661_softc *);
-static int		rt2661_radar_stop(struct rt2661_softc *);
-#endif
-static int		rt2661_prepare_beacon(struct rt2661_softc *,
-			    struct ieee80211vap *);
-static void		rt2661_enable_tsf_sync(struct rt2661_softc *);
-static void		rt2661_enable_tsf(struct rt2661_softc *);
-static int		rt2661_get_rssi(struct rt2661_softc *, uint8_t);
-
-static const struct {
-	uint32_t	reg;
-	uint32_t	val;
-} rt2661_def_mac[] = {
-	RT2661_DEF_MAC
-};
-
-static const struct {
-	uint8_t	reg;
-	uint8_t	val;
-} rt2661_def_bbp[] = {
-	RT2661_DEF_BBP
-};
-
-static const struct rfprog {
-	uint8_t		chan;
-	uint32_t	r1, r2, r3, r4;
-}  rt2661_rf5225_1[] = {
-	RT2661_RF5225_1
-}, rt2661_rf5225_2[] = {
-	RT2661_RF5225_2
-};
-
-int
-rt2661_attach(device_t dev, int id)
-{
-	struct rt2661_softc *sc = device_get_softc(dev);
-	struct ieee80211com *ic;
-	struct ifnet *ifp;
-	uint32_t val;
-	int error, ac, ntries;
-	uint8_t bands;
-	uint8_t macaddr[IEEE80211_ADDR_LEN];
-
-	sc->sc_id = id;
-	sc->sc_dev = dev;
-
-	ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
-	if (ifp == NULL) {
-		device_printf(sc->sc_dev, "can not if_alloc()\n");
-		return ENOMEM;
-	}
-	ic = ifp->if_l2com;
-
-	mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
-	    MTX_DEF | MTX_RECURSE);
-
-	callout_init_mtx(&sc->watchdog_ch, &sc->sc_mtx, 0);
-
-	/* wait for NIC to initialize */
-	for (ntries = 0; ntries < 1000; ntries++) {
-		if ((val = RAL_READ(sc, RT2661_MAC_CSR0)) != 0)
-			break;
-		DELAY(1000);
-	}
-	if (ntries == 1000) {
-		device_printf(sc->sc_dev,
-		    "timeout waiting for NIC to initialize\n");
-		error = EIO;
-		goto fail1;
-	}
-
-	/* retrieve RF rev. no and various other things from EEPROM */
-	rt2661_read_eeprom(sc, macaddr);
-
-	device_printf(dev, "MAC/BBP RT%X, RF %s\n", val,
-	    rt2661_get_rf(sc->rf_rev));
-
-	/*
-	 * Allocate Tx and Rx rings.
-	 */
-	for (ac = 0; ac < 4; ac++) {
-		error = rt2661_alloc_tx_ring(sc, &sc->txq[ac],
-		    RT2661_TX_RING_COUNT);
-		if (error != 0) {
-			device_printf(sc->sc_dev,
-			    "could not allocate Tx ring %d\n", ac);
-			goto fail2;
-		}
-	}
-
-	error = rt2661_alloc_tx_ring(sc, &sc->mgtq, RT2661_MGT_RING_COUNT);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate Mgt ring\n");
-		goto fail2;
-	}
-
-	error = rt2661_alloc_rx_ring(sc, &sc->rxq, RT2661_RX_RING_COUNT);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate Rx ring\n");
-		goto fail3;
-	}
-
-	ifp->if_softc = sc;
-	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-	ifp->if_init = rt2661_init;
-	ifp->if_ioctl = rt2661_ioctl;
-	ifp->if_start = rt2661_start;
-	IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
-	ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
-	IFQ_SET_READY(&ifp->if_snd);
-
-	ic->ic_ifp = ifp;
-	ic->ic_opmode = IEEE80211_M_STA;
-	ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
-
-	/* set device capabilities */
-	ic->ic_caps =
-		  IEEE80211_C_STA		/* station mode */
-		| IEEE80211_C_IBSS		/* ibss, nee adhoc, mode */
-		| IEEE80211_C_HOSTAP		/* hostap mode */
-		| IEEE80211_C_MONITOR		/* monitor mode */
-		| IEEE80211_C_AHDEMO		/* adhoc demo mode */
-		| IEEE80211_C_WDS		/* 4-address traffic works */
-		| IEEE80211_C_MBSS		/* mesh point link mode */
-		| IEEE80211_C_SHPREAMBLE	/* short preamble supported */
-		| IEEE80211_C_SHSLOT		/* short slot time supported */
-		| IEEE80211_C_WPA		/* capable of WPA1+WPA2 */
-		| IEEE80211_C_BGSCAN		/* capable of bg scanning */
-#ifdef notyet
-		| IEEE80211_C_TXFRAG		/* handle tx frags */
-		| IEEE80211_C_WME		/* 802.11e */
-#endif
-		;
-
-	bands = 0;
-	setbit(&bands, IEEE80211_MODE_11B);
-	setbit(&bands, IEEE80211_MODE_11G);
-	if (sc->rf_rev == RT2661_RF_5225 || sc->rf_rev == RT2661_RF_5325)
-		setbit(&bands, IEEE80211_MODE_11A);
-	ieee80211_init_channels(ic, NULL, &bands);
-
-	ieee80211_ifattach(ic, macaddr);
-#if 0
-	ic->ic_wme.wme_update = rt2661_wme_update;
-#endif
-	ic->ic_scan_start = rt2661_scan_start;
-	ic->ic_scan_end = rt2661_scan_end;
-	ic->ic_set_channel = rt2661_set_channel;
-	ic->ic_updateslot = rt2661_update_slot;
-	ic->ic_update_promisc = rt2661_update_promisc;
-	ic->ic_raw_xmit = rt2661_raw_xmit;
-
-	ic->ic_vap_create = rt2661_vap_create;
-	ic->ic_vap_delete = rt2661_vap_delete;
-
-	ieee80211_radiotap_attach(ic,
-	    &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap),
-		RT2661_TX_RADIOTAP_PRESENT,
-	    &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap),
-		RT2661_RX_RADIOTAP_PRESENT);
-
-#ifdef RAL_DEBUG
-	SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
-	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
-	    "debug", CTLFLAG_RW, &sc->sc_debug, 0, "debug msgs");
-#endif
-	if (bootverbose)
-		ieee80211_announce(ic);
-
-	return 0;
-
-fail3:	rt2661_free_tx_ring(sc, &sc->mgtq);
-fail2:	while (--ac >= 0)
-		rt2661_free_tx_ring(sc, &sc->txq[ac]);
-fail1:	mtx_destroy(&sc->sc_mtx);
-	if_free(ifp);
-	return error;
-}
-
-int
-rt2661_detach(void *xsc)
-{
-	struct rt2661_softc *sc = xsc;
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-
-	RAL_LOCK(sc);
-	rt2661_stop_locked(sc);
-	RAL_UNLOCK(sc);
-
-	ieee80211_ifdetach(ic);
-
-	rt2661_free_tx_ring(sc, &sc->txq[0]);
-	rt2661_free_tx_ring(sc, &sc->txq[1]);
-	rt2661_free_tx_ring(sc, &sc->txq[2]);
-	rt2661_free_tx_ring(sc, &sc->txq[3]);
-	rt2661_free_tx_ring(sc, &sc->mgtq);
-	rt2661_free_rx_ring(sc, &sc->rxq);
-
-	if_free(ifp);
-
-	mtx_destroy(&sc->sc_mtx);
-
-	return 0;
-}
-
-static struct ieee80211vap *
-rt2661_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int  
unit,
-    enum ieee80211_opmode opmode, int flags,
-    const uint8_t bssid[IEEE80211_ADDR_LEN],
-    const uint8_t mac[IEEE80211_ADDR_LEN])
-{
-	struct ifnet *ifp = ic->ic_ifp;
-	struct rt2661_vap *rvp;
-	struct ieee80211vap *vap;
-
-	switch (opmode) {
-	case IEEE80211_M_STA:
-	case IEEE80211_M_IBSS:
-	case IEEE80211_M_AHDEMO:
-	case IEEE80211_M_MONITOR:
-	case IEEE80211_M_HOSTAP:
-	case IEEE80211_M_MBSS:
-		/* XXXRP: TBD */
-		if (!TAILQ_EMPTY(&ic->ic_vaps)) {
-			if_printf(ifp, "only 1 vap supported\n");
-			return NULL;
-		}
-		if (opmode == IEEE80211_M_STA)
-			flags |= IEEE80211_CLONE_NOBEACONS;
-		break;
-	case IEEE80211_M_WDS:
-		if (TAILQ_EMPTY(&ic->ic_vaps) ||
-		    ic->ic_opmode != IEEE80211_M_HOSTAP) {
-			if_printf(ifp, "wds only supported in ap mode\n");
-			return NULL;
-		}
-		/*
-		 * Silently remove any request for a unique
-		 * bssid; WDS vap's always share the local
-		 * mac address.
-		 */
-		flags &= ~IEEE80211_CLONE_BSSID;
-		break;
-	default:
-		if_printf(ifp, "unknown opmode %d\n", opmode);
-		return NULL;
-	}
-	rvp = (struct rt2661_vap *) malloc(sizeof(struct rt2661_vap),
-	    M_80211_VAP, M_NOWAIT | M_ZERO);
-	if (rvp == NULL)
-		return NULL;
-	vap = &rvp->ral_vap;
-	ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid, mac);
-
-	/* override state transition machine */
-	rvp->ral_newstate = vap->iv_newstate;
-	vap->iv_newstate = rt2661_newstate;
-#if 0
-	vap->iv_update_beacon = rt2661_beacon_update;
-#endif
-
-	ieee80211_ratectl_init(vap);
-	/* complete setup */
-	ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status);
-	if (TAILQ_FIRST(&ic->ic_vaps) == vap)
-		ic->ic_opmode = opmode;
-	return vap;
-}
-
-static void
-rt2661_vap_delete(struct ieee80211vap *vap)
-{
-	struct rt2661_vap *rvp = RT2661_VAP(vap);
-
-	ieee80211_ratectl_deinit(vap);
-	ieee80211_vap_detach(vap);
-	free(rvp, M_80211_VAP);
-}
-
-void
-rt2661_shutdown(void *xsc)
-{
-	struct rt2661_softc *sc = xsc;
-
-	rt2661_stop(sc);
-}
-
-void
-rt2661_suspend(void *xsc)
-{
-	struct rt2661_softc *sc = xsc;
-
-	rt2661_stop(sc);
-}
-
-void
-rt2661_resume(void *xsc)
-{
-	struct rt2661_softc *sc = xsc;
-	struct ifnet *ifp = sc->sc_ifp;
-
-	if (ifp->if_flags & IFF_UP)
-		rt2661_init(sc);
-}
-
-static void
-rt2661_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int  
error)
-{
-	if (error != 0)
-		return;
-
-	KASSERT(nseg == 1, ("too many DMA segments, %d should be 1", nseg));
-
-	*(bus_addr_t *)arg = segs[0].ds_addr;
-}
-
-static int
-rt2661_alloc_tx_ring(struct rt2661_softc *sc, struct rt2661_tx_ring *ring,
-    int count)
-{
-	int i, error;
-
-	ring->count = count;
-	ring->queued = 0;
-	ring->cur = ring->next = ring->stat = 0;
-
-	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    count * RT2661_TX_DESC_SIZE, 1, count * RT2661_TX_DESC_SIZE,
-	    0, NULL, NULL, &ring->desc_dmat);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not create desc DMA tag\n");
-		goto fail;
-	}
-
-	error = bus_dmamem_alloc(ring->desc_dmat, (void **)&ring->desc,
-	    BUS_DMA_NOWAIT | BUS_DMA_ZERO, &ring->desc_map);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate DMA memory\n");
-		goto fail;
-	}
-
-	error = bus_dmamap_load(ring->desc_dmat, ring->desc_map, ring->desc,
-	    count * RT2661_TX_DESC_SIZE, rt2661_dma_map_addr, &ring->physaddr,
-	    0);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not load desc DMA map\n");
-		goto fail;
-	}
-
-	ring->data = malloc(count * sizeof (struct rt2661_tx_data), M_DEVBUF,
-	    M_NOWAIT | M_ZERO);
-	if (ring->data == NULL) {
-		device_printf(sc->sc_dev, "could not allocate soft data\n");
-		error = ENOMEM;
-		goto fail;
-	}
-
-	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES,
-	    RT2661_MAX_SCATTER, MCLBYTES, 0, NULL, NULL, &ring->data_dmat);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not create data DMA tag\n");
-		goto fail;
-	}
-
-	for (i = 0; i < count; i++) {
-		error = bus_dmamap_create(ring->data_dmat, 0,
-		    &ring->data[i].map);
-		if (error != 0) {
-			device_printf(sc->sc_dev, "could not create DMA map\n");
-			goto fail;
-		}
-	}
-
-	return 0;
-
-fail:	rt2661_free_tx_ring(sc, ring);
-	return error;
-}
-
-static void
-rt2661_reset_tx_ring(struct rt2661_softc *sc, struct rt2661_tx_ring *ring)
-{
-	struct rt2661_tx_desc *desc;
-	struct rt2661_tx_data *data;
-	int i;
-
-	for (i = 0; i < ring->count; i++) {
-		desc = &ring->desc[i];
-		data = &ring->data[i];
-
-		if (data->m != NULL) {
-			bus_dmamap_sync(ring->data_dmat, data->map,
-			    BUS_DMASYNC_POSTWRITE);
-			bus_dmamap_unload(ring->data_dmat, data->map);
-			m_freem(data->m);
-			data->m = NULL;
-		}
-
-		if (data->ni != NULL) {
-			ieee80211_free_node(data->ni);
-			data->ni = NULL;
-		}
-
-		desc->flags = 0;
-	}
-
-	bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
-
-	ring->queued = 0;
-	ring->cur = ring->next = ring->stat = 0;
-}
-
-static void
-rt2661_free_tx_ring(struct rt2661_softc *sc, struct rt2661_tx_ring *ring)
-{
-	struct rt2661_tx_data *data;
-	int i;
-
-	if (ring->desc != NULL) {
-		bus_dmamap_sync(ring->desc_dmat, ring->desc_map,
-		    BUS_DMASYNC_POSTWRITE);
-		bus_dmamap_unload(ring->desc_dmat, ring->desc_map);
-		bus_dmamem_free(ring->desc_dmat, ring->desc, ring->desc_map);
-	}
-
-	if (ring->desc_dmat != NULL)
-		bus_dma_tag_destroy(ring->desc_dmat);
-
-	if (ring->data != NULL) {
-		for (i = 0; i < ring->count; i++) {
-			data = &ring->data[i];
-
-			if (data->m != NULL) {
-				bus_dmamap_sync(ring->data_dmat, data->map,
-				    BUS_DMASYNC_POSTWRITE);
-				bus_dmamap_unload(ring->data_dmat, data->map);
-				m_freem(data->m);
-			}
-
-			if (data->ni != NULL)
-				ieee80211_free_node(data->ni);
-
-			if (data->map != NULL)
-				bus_dmamap_destroy(ring->data_dmat, data->map);
-		}
-
-		free(ring->data, M_DEVBUF);
-	}
-
-	if (ring->data_dmat != NULL)
-		bus_dma_tag_destroy(ring->data_dmat);
-}
-
-static int
-rt2661_alloc_rx_ring(struct rt2661_softc *sc, struct rt2661_rx_ring *ring,
-    int count)
-{
-	struct rt2661_rx_desc *desc;
-	struct rt2661_rx_data *data;
-	bus_addr_t physaddr;
-	int i, error;
-
-	ring->count = count;
-	ring->cur = ring->next = 0;
-
-	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    count * RT2661_RX_DESC_SIZE, 1, count * RT2661_RX_DESC_SIZE,
-	    0, NULL, NULL, &ring->desc_dmat);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not create desc DMA tag\n");
-		goto fail;
-	}
-
-	error = bus_dmamem_alloc(ring->desc_dmat, (void **)&ring->desc,
-	    BUS_DMA_NOWAIT | BUS_DMA_ZERO, &ring->desc_map);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate DMA memory\n");
-		goto fail;
-	}
-
-	error = bus_dmamap_load(ring->desc_dmat, ring->desc_map, ring->desc,
-	    count * RT2661_RX_DESC_SIZE, rt2661_dma_map_addr, &ring->physaddr,
-	    0);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not load desc DMA map\n");
-		goto fail;
-	}
-
-	ring->data = malloc(count * sizeof (struct rt2661_rx_data), M_DEVBUF,
-	    M_NOWAIT | M_ZERO);
-	if (ring->data == NULL) {
-		device_printf(sc->sc_dev, "could not allocate soft data\n");
-		error = ENOMEM;
-		goto fail;
-	}
-
-	/*
-	 * Pre-allocate Rx buffers and populate Rx ring.
-	 */
-	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES,
-	    1, MCLBYTES, 0, NULL, NULL, &ring->data_dmat);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not create data DMA tag\n");
-		goto fail;
-	}
-
-	for (i = 0; i < count; i++) {
-		desc = &sc->rxq.desc[i];
-		data = &sc->rxq.data[i];
-
-		error = bus_dmamap_create(ring->data_dmat, 0, &data->map);
-		if (error != 0) {
-			device_printf(sc->sc_dev, "could not create DMA map\n");
-			goto fail;
-		}
-
-		data->m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
-		if (data->m == NULL) {
-			device_printf(sc->sc_dev,
-			    "could not allocate rx mbuf\n");
-			error = ENOMEM;
-			goto fail;
-		}
-
-		error = bus_dmamap_load(ring->data_dmat, data->map,
-		    mtod(data->m, void *), MCLBYTES, rt2661_dma_map_addr,
-		    &physaddr, 0);
-		if (error != 0) {
-			device_printf(sc->sc_dev,
-			    "could not load rx buf DMA map");
-			goto fail;
-		}
-
-		desc->flags = htole32(RT2661_RX_BUSY);
-		desc->physaddr = htole32(physaddr);
-	}
-
-	bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
-
-	return 0;
-
-fail:	rt2661_free_rx_ring(sc, ring);
-	return error;
-}
-
-static void
-rt2661_reset_rx_ring(struct rt2661_softc *sc, struct rt2661_rx_ring *ring)
-{
-	int i;
-
-	for (i = 0; i < ring->count; i++)
-		ring->desc[i].flags = htole32(RT2661_RX_BUSY);
-
-	bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
-
-	ring->cur = ring->next = 0;
-}
-
-static void
-rt2661_free_rx_ring(struct rt2661_softc *sc, struct rt2661_rx_ring *ring)
-{
-	struct rt2661_rx_data *data;
-	int i;
-
-	if (ring->desc != NULL) {
-		bus_dmamap_sync(ring->desc_dmat, ring->desc_map,
-		    BUS_DMASYNC_POSTWRITE);
-		bus_dmamap_unload(ring->desc_dmat, ring->desc_map);
-		bus_dmamem_free(ring->desc_dmat, ring->desc, ring->desc_map);
-	}
-
-	if (ring->desc_dmat != NULL)
-		bus_dma_tag_destroy(ring->desc_dmat);
-
-	if (ring->data != NULL) {
-		for (i = 0; i < ring->count; i++) {
-			data = &ring->data[i];
-
-			if (data->m != NULL) {
-				bus_dmamap_sync(ring->data_dmat, data->map,
-				    BUS_DMASYNC_POSTREAD);
-				bus_dmamap_unload(ring->data_dmat, data->map);
-				m_freem(data->m);
-			}
-
-			if (data->map != NULL)
-				bus_dmamap_destroy(ring->data_dmat, data->map);
-		}
-
-		free(ring->data, M_DEVBUF);
-	}
-
-	if (ring->data_dmat != NULL)
-		bus_dma_tag_destroy(ring->data_dmat);
-}
-
-static int
-rt2661_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int  
arg)
-{
-	struct rt2661_vap *rvp = RT2661_VAP(vap);
-	struct ieee80211com *ic = vap->iv_ic;
-	struct rt2661_softc *sc = ic->ic_ifp->if_softc;
-	int error;
-
-	if (nstate == IEEE80211_S_INIT && vap->iv_state == IEEE80211_S_RUN) {
-		uint32_t tmp;
-
-		/* abort TSF synchronization */
-		tmp = RAL_READ(sc, RT2661_TXRX_CSR9);
-		RAL_WRITE(sc, RT2661_TXRX_CSR9, tmp & ~0x00ffffff);
-	}
-
-	error = rvp->ral_newstate(vap, nstate, arg);
-
-	if (error == 0 && nstate == IEEE80211_S_RUN) {
-		struct ieee80211_node *ni = vap->iv_bss;
-
-		if (vap->iv_opmode != IEEE80211_M_MONITOR) {
-			rt2661_enable_mrr(sc);
-			rt2661_set_txpreamble(sc);
-			rt2661_set_basicrates(sc, &ni->ni_rates);
-			rt2661_set_bssid(sc, ni->ni_bssid);
-		}
-
-		if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
-		    vap->iv_opmode == IEEE80211_M_IBSS ||
-		    vap->iv_opmode == IEEE80211_M_MBSS) {
-			error = rt2661_prepare_beacon(sc, vap);
-			if (error != 0)
-				return error;
-		}
-		if (vap->iv_opmode != IEEE80211_M_MONITOR)
-			rt2661_enable_tsf_sync(sc);
-		else
-			rt2661_enable_tsf(sc);
-	}
-	return error;
-}
-
-/*
- * Read 16 bits at address 'addr' from the serial EEPROM (either 93C46 or
- * 93C66).
- */
-static uint16_t
-rt2661_eeprom_read(struct rt2661_softc *sc, uint8_t addr)
-{
-	uint32_t tmp;
-	uint16_t val;
-	int n;
-
-	/* clock C once before the first command */
-	RT2661_EEPROM_CTL(sc, 0);
-
-	RT2661_EEPROM_CTL(sc, RT2661_S);
-	RT2661_EEPROM_CTL(sc, RT2661_S | RT2661_C);
-	RT2661_EEPROM_CTL(sc, RT2661_S);
-
-	/* write start bit (1) */
-	RT2661_EEPROM_CTL(sc, RT2661_S | RT2661_D);
-	RT2661_EEPROM_CTL(sc, RT2661_S | RT2661_D | RT2661_C);
-
-	/* write READ opcode (10) */
-	RT2661_EEPROM_CTL(sc, RT2661_S | RT2661_D);
-	RT2661_EEPROM_CTL(sc, RT2661_S | RT2661_D | RT2661_C);
-	RT2661_EEPROM_CTL(sc, RT2661_S);
-	RT2661_EEPROM_CTL(sc, RT2661_S | RT2661_C);
-
-	/* write address (A5-A0 or A7-A0) */
-	n = (RAL_READ(sc, RT2661_E2PROM_CSR) & RT2661_93C46) ? 5 : 7;
-	for (; n >= 0; n--) {
-		RT2661_EEPROM_CTL(sc, RT2661_S |
-		    (((addr >> n) & 1) << RT2661_SHIFT_D));
-		RT2661_EEPROM_CTL(sc, RT2661_S |
-		    (((addr >> n) & 1) << RT2661_SHIFT_D) | RT2661_C);
-	}
-
-	RT2661_EEPROM_CTL(sc, RT2661_S);
-
-	/* read data Q15-Q0 */
-	val = 0;
-	for (n = 15; n >= 0; n--) {
-		RT2661_EEPROM_CTL(sc, RT2661_S | RT2661_C);
-		tmp = RAL_READ(sc, RT2661_E2PROM_CSR);
-		val |= ((tmp & RT2661_Q) >> RT2661_SHIFT_Q) << n;
-		RT2661_EEPROM_CTL(sc, RT2661_S);
-	}
-
-	RT2661_EEPROM_CTL(sc, 0);
-
-	/* clear Chip Select and clock C */
-	RT2661_EEPROM_CTL(sc, RT2661_S);
-	RT2661_EEPROM_CTL(sc, 0);
-	RT2661_EEPROM_CTL(sc, RT2661_C);
-
-	return val;
-}
-
-static void
-rt2661_tx_intr(struct rt2661_softc *sc)
-{
-	struct ifnet *ifp = sc->sc_ifp;
-	struct rt2661_tx_ring *txq;
-	struct rt2661_tx_data *data;
-	uint32_t val;
-	int qid, retrycnt;
-	struct ieee80211vap *vap;
-
-	for (;;) {
-		struct ieee80211_node *ni;
-		struct mbuf *m;
-
-		val = RAL_READ(sc, RT2661_STA_CSR4);
-		if (!(val & RT2661_TX_STAT_VALID))
-			break;
-
-		/* retrieve the queue in which this frame was sent */
-		qid = RT2661_TX_QID(val);
-		txq = (qid <= 3) ? &sc->txq[qid] : &sc->mgtq;
-
-		/* retrieve rate control algorithm context */
-		data = &txq->data[txq->stat];
-		m = data->m;
-		data->m = NULL;
-		ni = data->ni;
-		data->ni = NULL;
-
-		/* if no frame has been sent, ignore */
-		if (ni == NULL)
-			continue;
-		else
-			vap = ni->ni_vap;
-
-		switch (RT2661_TX_RESULT(val)) {
-		case RT2661_TX_SUCCESS:
-			retrycnt = RT2661_TX_RETRYCNT(val);
-
-			DPRINTFN(sc, 10, "data frame sent successfully after "
-			    "%d retries\n", retrycnt);
-			if (data->rix != IEEE80211_FIXED_RATE_NONE)
-				ieee80211_ratectl_tx_complete(vap, ni,
-				    IEEE80211_RATECTL_TX_SUCCESS,
-				    &retrycnt, NULL);
-			ifp->if_opackets++;
-			break;
-
-		case RT2661_TX_RETRY_FAIL:
-			retrycnt = RT2661_TX_RETRYCNT(val);
-
-			DPRINTFN(sc, 9, "%s\n",
-			    "sending data frame failed (too much retries)");
-			if (data->rix != IEEE80211_FIXED_RATE_NONE)
-				ieee80211_ratectl_tx_complete(vap, ni,
-				    IEEE80211_RATECTL_TX_FAILURE,
-				    &retrycnt, NULL);
-			ifp->if_oerrors++;
-			break;
-
-		default:
-			/* other failure */
-			device_printf(sc->sc_dev,
-			    "sending data frame failed 0x%08x\n", val);
-			ifp->if_oerrors++;
-		}
-
-		DPRINTFN(sc, 15, "tx done q=%d idx=%u\n", qid, txq->stat);
-
-		txq->queued--;
-		if (++txq->stat >= txq->count)	/* faster than % count */
-			txq->stat = 0;
-
-		if (m->m_flags & M_TXCB)
-			ieee80211_process_callback(ni, m,
-				RT2661_TX_RESULT(val) != RT2661_TX_SUCCESS);
-		m_freem(m);
-		ieee80211_free_node(ni);
-	}
-
-	sc->sc_tx_timer = 0;
-	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
-
-	rt2661_start_locked(ifp);
-}
-
-static void
-rt2661_tx_dma_intr(struct rt2661_softc *sc, struct rt2661_tx_ring *txq)
-{
-	struct rt2661_tx_desc *desc;
-	struct rt2661_tx_data *data;
-
-	bus_dmamap_sync(txq->desc_dmat, txq->desc_map, BUS_DMASYNC_POSTREAD);
-
-	for (;;) {
-		desc = &txq->desc[txq->next];
-		data = &txq->data[txq->next];
-
-		if ((le32toh(desc->flags) & RT2661_TX_BUSY) ||
-		    !(le32toh(desc->flags) & RT2661_TX_VALID))
-			break;
-
-		bus_dmamap_sync(txq->data_dmat, data->map,
-		    BUS_DMASYNC_POSTWRITE);
-		bus_dmamap_unload(txq->data_dmat, data->map);
-
-		/* descriptor is no longer valid */
-		desc->flags &= ~htole32(RT2661_TX_VALID);
-
-		DPRINTFN(sc, 15, "tx dma done q=%p idx=%u\n", txq, txq->next);
-
-		if (++txq->next >= txq->count)	/* faster than % count */
-			txq->next = 0;
-	}
-
-	bus_dmamap_sync(txq->desc_dmat, txq->desc_map, BUS_DMASYNC_PREWRITE);
-}
-
-static void
-rt2661_rx_intr(struct rt2661_softc *sc)
-{
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct rt2661_rx_desc *desc;
-	struct rt2661_rx_data *data;
-	bus_addr_t physaddr;
-	struct ieee80211_frame *wh;
-	struct ieee80211_node *ni;
-	struct mbuf *mnew, *m;
-	int error;
-
-	bus_dmamap_sync(sc->rxq.desc_dmat, sc->rxq.desc_map,
-	    BUS_DMASYNC_POSTREAD);
***The diff for this file has been truncated for email.***
=======================================
--- /rt2661reg.h	Tue Mar 13 05:46:45 2012
+++ /dev/null
@@ -1,488 +0,0 @@
-/*	$FreeBSD$	*/
-
-/*-
- * Copyright (c) 2006
- *	Damien Bergamini <damien.bergamini at 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 RT2661_NOISE_FLOOR	-95
-
-#define RT2661_TX_RING_COUNT	32
-#define RT2661_MGT_RING_COUNT	32
-#define RT2661_RX_RING_COUNT	64
-
-#define RT2661_TX_DESC_SIZE	(sizeof (struct rt2661_tx_desc))
-#define RT2661_TX_DESC_WSIZE	(RT2661_TX_DESC_SIZE / 4)
-#define RT2661_RX_DESC_SIZE	(sizeof (struct rt2661_rx_desc))
-#define RT2661_RX_DESC_WSIZE	(RT2661_RX_DESC_SIZE / 4)
-
-#define RT2661_MAX_SCATTER	5
-
-/*
- * Control and status registers.
- */
-#define RT2661_HOST_CMD_CSR		0x0008
-#define RT2661_MCU_CNTL_CSR		0x000c
-#define RT2661_SOFT_RESET_CSR		0x0010
-#define RT2661_MCU_INT_SOURCE_CSR	0x0014
-#define RT2661_MCU_INT_MASK_CSR		0x0018
-#define RT2661_PCI_USEC_CSR		0x001c
-#define RT2661_H2M_MAILBOX_CSR		0x2100
-#define RT2661_M2H_CMD_DONE_CSR		0x2104
-#define RT2661_HW_BEACON_BASE0		0x2c00
-#define RT2661_MAC_CSR0			0x3000
-#define RT2661_MAC_CSR1			0x3004
-#define RT2661_MAC_CSR2			0x3008
-#define RT2661_MAC_CSR3			0x300c
-#define RT2661_MAC_CSR4			0x3010
-#define RT2661_MAC_CSR5			0x3014
-#define RT2661_MAC_CSR6			0x3018
-#define RT2661_MAC_CSR7			0x301c
-#define RT2661_MAC_CSR8			0x3020
-#define RT2661_MAC_CSR9			0x3024
-#define RT2661_MAC_CSR10		0x3028
-#define RT2661_MAC_CSR11		0x302c
-#define RT2661_MAC_CSR12		0x3030
-#define RT2661_MAC_CSR13		0x3034
-#define RT2661_MAC_CSR14		0x3038
-#define RT2661_MAC_CSR15		0x303c
-#define RT2661_TXRX_CSR0		0x3040
-#define RT2661_TXRX_CSR1		0x3044
-#define RT2661_TXRX_CSR2		0x3048
-#define RT2661_TXRX_CSR3		0x304c
-#define RT2661_TXRX_CSR4		0x3050
-#define RT2661_TXRX_CSR5		0x3054
-#define RT2661_TXRX_CSR6		0x3058
-#define RT2661_TXRX_CSR7		0x305c
-#define RT2661_TXRX_CSR8		0x3060
-#define RT2661_TXRX_CSR9		0x3064
-#define RT2661_TXRX_CSR10		0x3068
-#define RT2661_TXRX_CSR11		0x306c
-#define RT2661_TXRX_CSR12		0x3070
-#define RT2661_TXRX_CSR13		0x3074
-#define RT2661_TXRX_CSR14		0x3078
-#define RT2661_TXRX_CSR15		0x307c
-#define RT2661_PHY_CSR0			0x3080
-#define RT2661_PHY_CSR1			0x3084
-#define RT2661_PHY_CSR2			0x3088
-#define RT2661_PHY_CSR3			0x308c
-#define RT2661_PHY_CSR4			0x3090
-#define RT2661_PHY_CSR5			0x3094
-#define RT2661_PHY_CSR6			0x3098
-#define RT2661_PHY_CSR7			0x309c
-#define RT2661_SEC_CSR0			0x30a0
-#define RT2661_SEC_CSR1			0x30a4
-#define RT2661_SEC_CSR2			0x30a8
-#define RT2661_SEC_CSR3			0x30ac
-#define RT2661_SEC_CSR4			0x30b0
-#define RT2661_SEC_CSR5			0x30b4
-#define RT2661_STA_CSR0			0x30c0
-#define RT2661_STA_CSR1			0x30c4
-#define RT2661_STA_CSR2			0x30c8
-#define RT2661_STA_CSR3			0x30cc
-#define RT2661_STA_CSR4			0x30d0
-#define RT2661_AC0_BASE_CSR		0x3400
-#define RT2661_AC1_BASE_CSR		0x3404
-#define RT2661_AC2_BASE_CSR		0x3408
-#define RT2661_AC3_BASE_CSR		0x340c
-#define RT2661_MGT_BASE_CSR		0x3410
-#define RT2661_TX_RING_CSR0		0x3418
-#define RT2661_TX_RING_CSR1		0x341c
-#define RT2661_AIFSN_CSR		0x3420
-#define RT2661_CWMIN_CSR		0x3424
-#define RT2661_CWMAX_CSR		0x3428
-#define RT2661_TX_DMA_DST_CSR		0x342c
-#define RT2661_TX_CNTL_CSR		0x3430
-#define RT2661_LOAD_TX_RING_CSR		0x3434
-#define RT2661_RX_BASE_CSR		0x3450
-#define RT2661_RX_RING_CSR		0x3454
-#define RT2661_RX_CNTL_CSR		0x3458
-#define RT2661_PCI_CFG_CSR		0x3460
-#define RT2661_INT_SOURCE_CSR		0x3468
-#define RT2661_INT_MASK_CSR		0x346c
-#define RT2661_E2PROM_CSR		0x3470
-#define RT2661_AC_TXOP_CSR0		0x3474
-#define RT2661_AC_TXOP_CSR1		0x3478
-#define RT2661_TEST_MODE_CSR		0x3484
-#define RT2661_IO_CNTL_CSR		0x3498
-#define RT2661_MCU_CODE_BASE		0x4000
-
-
-/* possible flags for register HOST_CMD_CSR */
-#define RT2661_KICK_CMD		(1 << 7)
-/* Host to MCU (8051) command identifiers */
-#define RT2661_MCU_CMD_SLEEP	0x30
-#define RT2661_MCU_CMD_WAKEUP	0x31
-#define RT2661_MCU_SET_LED	0x50
-#define RT2661_MCU_SET_RSSI_LED	0x52
-
-/* possible flags for register MCU_CNTL_CSR */
-#define RT2661_MCU_SEL		(1 << 0)
-#define RT2661_MCU_RESET	(1 << 1)
-#define RT2661_MCU_READY	(1 << 2)
-
-/* possible flags for register MCU_INT_SOURCE_CSR */
-#define RT2661_MCU_CMD_DONE		0xff
-#define RT2661_MCU_WAKEUP		(1 << 8)
-#define RT2661_MCU_BEACON_EXPIRE	(1 << 9)
-
-/* possible flags for register H2M_MAILBOX_CSR */
-#define RT2661_H2M_BUSY		(1 << 24)
-#define RT2661_TOKEN_NO_INTR	0xff
-
-/* possible flags for register MAC_CSR5 */
-#define RT2661_ONE_BSSID	3
-
-/* possible flags for register TXRX_CSR0 */
-/* Tx filter flags are in the low 16 bits */
-#define RT2661_AUTO_TX_SEQ	(1 << 15)
-/* Rx filter flags are in the high 16 bits */
-#define RT2661_DISABLE_RX	(1 << 16)
-#define RT2661_DROP_CRC_ERROR	(1 << 17)
-#define RT2661_DROP_PHY_ERROR	(1 << 18)
-#define RT2661_DROP_CTL		(1 << 19)
-#define RT2661_DROP_NOT_TO_ME	(1 << 20)
-#define RT2661_DROP_TODS	(1 << 21)
-#define RT2661_DROP_VER_ERROR	(1 << 22)
-#define RT2661_DROP_MULTICAST	(1 << 23)
-#define RT2661_DROP_BROADCAST	(1 << 24)
-#define RT2661_DROP_ACKCTS	(1 << 25)
-
-/* possible flags for register TXRX_CSR4 */
-#define RT2661_SHORT_PREAMBLE	(1 << 19)
-#define RT2661_MRR_ENABLED	(1 << 20)
-#define RT2661_MRR_CCK_FALLBACK	(1 << 23)
-
-/* possible flags for register TXRX_CSR9 */
-#define RT2661_TSF_TICKING	(1 << 16)
-#define RT2661_TSF_MODE(x)	(((x) & 0x3) << 17)
-/* TBTT stands for Target Beacon Transmission Time */
-#define RT2661_ENABLE_TBTT	(1 << 19)
-#define RT2661_GENERATE_BEACON	(1 << 20)
-
-/* possible flags for register PHY_CSR0 */
-#define RT2661_PA_PE_2GHZ	(1 << 16)
-#define RT2661_PA_PE_5GHZ	(1 << 17)
-
-/* possible flags for register PHY_CSR3 */
-#define RT2661_BBP_READ	(1 << 15)
-#define RT2661_BBP_BUSY	(1 << 16)
-
-/* possible flags for register PHY_CSR4 */
-#define RT2661_RF_21BIT	(21 << 24)
-#define RT2661_RF_BUSY	(1 << 31)
-
-/* possible values for register STA_CSR4 */
-#define RT2661_TX_STAT_VALID	(1 << 0)
-#define RT2661_TX_RESULT(v)	(((v) >> 1) & 0x7)
-#define RT2661_TX_RETRYCNT(v)	(((v) >> 4) & 0xf)
-#define RT2661_TX_QID(v)	(((v) >> 8) & 0xf)
-#define RT2661_TX_SUCCESS	0
-#define RT2661_TX_RETRY_FAIL	6
-
-/* possible flags for register TX_CNTL_CSR */
-#define RT2661_KICK_MGT	(1 << 4)
-
-/* possible flags for register INT_SOURCE_CSR */
-#define RT2661_TX_DONE		(1 << 0)
-#define RT2661_RX_DONE		(1 << 1)
-#define RT2661_TX0_DMA_DONE	(1 << 16)
-#define RT2661_TX1_DMA_DONE	(1 << 17)
-#define RT2661_TX2_DMA_DONE	(1 << 18)
-#define RT2661_TX3_DMA_DONE	(1 << 19)
-#define RT2661_MGT_DONE		(1 << 20)
-
-/* possible flags for register E2PROM_CSR */
-#define RT2661_C	(1 << 1)
-#define RT2661_S	(1 << 2)
-#define RT2661_D	(1 << 3)
-#define RT2661_Q	(1 << 4)
-#define RT2661_93C46	(1 << 5)
-
-/* Tx descriptor */
-struct rt2661_tx_desc {
-	uint32_t	flags;
-#define RT2661_TX_BUSY		(1 << 0)
-#define RT2661_TX_VALID		(1 << 1)
-#define RT2661_TX_MORE_FRAG	(1 << 2)
-#define RT2661_TX_NEED_ACK	(1 << 3)
-#define RT2661_TX_TIMESTAMP	(1 << 4)
-#define RT2661_TX_OFDM		(1 << 5)
-#define RT2661_TX_IFS		(1 << 6)
-#define RT2661_TX_LONG_RETRY	(1 << 7)
-#define RT2661_TX_BURST		(1 << 28)
-
-	uint16_t	wme;
-#define RT2661_QID(v)		(v)
-#define RT2661_AIFSN(v)		((v) << 4)
-#define RT2661_LOGCWMIN(v)	((v) << 8)
-#define RT2661_LOGCWMAX(v)	((v) << 12)
-
-	uint16_t	xflags;
-#define RT2661_TX_HWSEQ		(1 << 12)
-
-	uint8_t		plcp_signal;
-	uint8_t		plcp_service;
-#define RT2661_PLCP_LENGEXT	0x80
-
-	uint8_t		plcp_length_lo;
-	uint8_t		plcp_length_hi;
-
-	uint32_t	iv;
-	uint32_t	eiv;
-
-	uint8_t		offset;
-	uint8_t		qid;
-#define RT2661_QID_MGT	13
-
-	uint8_t		txpower;
-#define RT2661_DEFAULT_TXPOWER	0
-
-	uint8_t		reserved1;
-
-	uint32_t	addr[RT2661_MAX_SCATTER];
-	uint16_t	len[RT2661_MAX_SCATTER];
-
-	uint16_t	reserved2;
-} __packed;
-
-/* Rx descriptor */
-struct rt2661_rx_desc {
-	uint32_t	flags;
-#define RT2661_RX_BUSY		(1 << 0)
-#define RT2661_RX_DROP		(1 << 1)
-#define RT2661_RX_CRC_ERROR	(1 << 6)
-#define RT2661_RX_OFDM		(1 << 7)
-#define RT2661_RX_PHY_ERROR	(1 << 8)
-#define RT2661_RX_CIPHER_MASK	0x00000600
-
-	uint8_t		rate;
-	uint8_t		rssi;
-	uint8_t		reserved1;
-	uint8_t		offset;
-	uint32_t	iv;
-	uint32_t	eiv;
-	uint32_t	reserved2;
-	uint32_t	physaddr;
-	uint32_t	reserved3[10];
-} __packed;
-
-#define RAL_RF1	0
-#define RAL_RF2	2
-#define RAL_RF3	1
-#define RAL_RF4	3
-
-/* dual-band RF */
-#define RT2661_RF_5225	1
-#define RT2661_RF_5325	2
-/* single-band RF */
-#define RT2661_RF_2527	3
-#define RT2661_RF_2529	4
-
-#define RT2661_RX_DESC_BACK	4
-
-#define RT2661_SMART_MODE	(1 << 0)
-
-#define RT2661_BBPR94_DEFAULT	6
-
-#define RT2661_SHIFT_D	3
-#define RT2661_SHIFT_Q	4
-
-#define RT2661_EEPROM_MAC01		0x02
-#define RT2661_EEPROM_MAC23		0x03
-#define RT2661_EEPROM_MAC45		0x04
-#define RT2661_EEPROM_ANTENNA		0x10
-#define RT2661_EEPROM_CONFIG2		0x11
-#define RT2661_EEPROM_BBP_BASE		0x13
-#define RT2661_EEPROM_TXPOWER		0x23
-#define RT2661_EEPROM_FREQ_OFFSET	0x2f
-#define RT2661_EEPROM_RSSI_2GHZ_OFFSET	0x4d
-#define RT2661_EEPROM_RSSI_5GHZ_OFFSET	0x4e
-
-#define RT2661_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_READ_REGION_4(sc, offset, datap, count)			\
-	bus_space_read_region_4((sc)->sc_st, (sc)->sc_sh, (offset),	\
-	    (datap), (count))
-
-#define RAL_WRITE(sc, reg, val)						\
-	bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
-
-#define RAL_WRITE_REGION_1(sc, offset, datap, count)			\
-	bus_space_write_region_1((sc)->sc_st, (sc)->sc_sh, (offset),	\
-	    (datap), (count))
-
-/*
- * EEPROM access macro
- */
-#define RT2661_EEPROM_CTL(sc, val) do {					\
-	RAL_WRITE((sc), RT2661_E2PROM_CSR, (val));			\
-	DELAY(RT2661_EEPROM_DELAY);					\
-} while (/* CONSTCOND */0)
-
-/*
- * Default values for MAC registers; values taken from the reference  
driver.
- */
-#define RT2661_DEF_MAC					\
-	{ RT2661_TXRX_CSR0,        0x0000b032 },	\
-	{ RT2661_TXRX_CSR1,        0x9eb39eb3 },	\
-	{ RT2661_TXRX_CSR2,        0x8a8b8c8d },	\
-	{ RT2661_TXRX_CSR3,        0x00858687 },	\
-	{ RT2661_TXRX_CSR7,        0x2e31353b },	\
-	{ RT2661_TXRX_CSR8,        0x2a2a2a2c },	\
-	{ RT2661_TXRX_CSR15,       0x0000000f },	\
-	{ RT2661_MAC_CSR6,         0x00000fff },	\
-	{ RT2661_MAC_CSR8,         0x016c030a },	\
-	{ RT2661_MAC_CSR10,        0x00000718 },	\
-	{ RT2661_MAC_CSR12,        0x00000004 },	\
-	{ RT2661_MAC_CSR13,        0x0000e000 },	\
-	{ RT2661_SEC_CSR0,         0x00000000 },	\
-	{ RT2661_SEC_CSR1,         0x00000000 },	\
-	{ RT2661_SEC_CSR5,         0x00000000 },	\
-	{ RT2661_PHY_CSR1,         0x000023b0 },	\
-	{ RT2661_PHY_CSR5,         0x060a100c },	\
-	{ RT2661_PHY_CSR6,         0x00080606 },	\
-	{ RT2661_PHY_CSR7,         0x00000a08 },	\
-	{ RT2661_PCI_CFG_CSR,      0x3cca4808 },	\
-	{ RT2661_AIFSN_CSR,        0x00002273 },	\
-	{ RT2661_CWMIN_CSR,        0x00002344 },	\
-	{ RT2661_CWMAX_CSR,        0x000034aa },	\
-	{ RT2661_TEST_MODE_CSR,    0x00000200 },	\
-	{ RT2661_M2H_CMD_DONE_CSR, 0xffffffff }
-
-/*
- * Default values for BBP registers; values taken from the reference  
driver.
- */
-#define RT2661_DEF_BBP	\
-	{   3, 0x00 },	\
-	{  15, 0x30 },	\
-	{  17, 0x20 },	\
-	{  21, 0xc8 },	\
-	{  22, 0x38 },	\
-	{  23, 0x06 },	\
-	{  24, 0xfe },	\
-	{  25, 0x0a },	\
-	{  26, 0x0d },	\
-	{  34, 0x12 },	\
-	{  37, 0x07 },	\
-	{  39, 0xf8 },	\
-	{  41, 0x60 },	\
-	{  53, 0x10 },	\
-	{  54, 0x18 },	\
-	{  60, 0x10 },	\
-	{  61, 0x04 },	\
-	{  62, 0x04 },	\
-	{  75, 0xfe },	\
-	{  86, 0xfe },	\
-	{  88, 0xfe },	\
-	{  90, 0x0f },	\
-	{  99, 0x00 },	\
-	{ 102, 0x16 },	\
-	{ 107, 0x04 }
-
-/*
- * Default settings for RF registers; values taken from the reference  
driver.
- */
-#define RT2661_RF5225_1					\
-	{   1, 0x00b33, 0x011e1, 0x1a014, 0x30282 },	\
-	{   2, 0x00b33, 0x011e1, 0x1a014, 0x30287 },	\
-	{   3, 0x00b33, 0x011e2, 0x1a014, 0x30282 },	\
-	{   4, 0x00b33, 0x011e2, 0x1a014, 0x30287 },	\
-	{   5, 0x00b33, 0x011e3, 0x1a014, 0x30282 },	\
-	{   6, 0x00b33, 0x011e3, 0x1a014, 0x30287 },	\
-	{   7, 0x00b33, 0x011e4, 0x1a014, 0x30282 },	\
-	{   8, 0x00b33, 0x011e4, 0x1a014, 0x30287 },	\
-	{   9, 0x00b33, 0x011e5, 0x1a014, 0x30282 },	\
-	{  10, 0x00b33, 0x011e5, 0x1a014, 0x30287 },	\
-	{  11, 0x00b33, 0x011e6, 0x1a014, 0x30282 },	\
-	{  12, 0x00b33, 0x011e6, 0x1a014, 0x30287 },	\
-	{  13, 0x00b33, 0x011e7, 0x1a014, 0x30282 },	\
-	{  14, 0x00b33, 0x011e8, 0x1a014, 0x30284 },	\
-							\
-	{  36, 0x00b33, 0x01266, 0x26014, 0x30288 },	\
-	{  40, 0x00b33, 0x01268, 0x26014, 0x30280 },	\
-	{  44, 0x00b33, 0x01269, 0x26014, 0x30282 },	\
-	{  48, 0x00b33, 0x0126a, 0x26014, 0x30284 },	\
-	{  52, 0x00b33, 0x0126b, 0x26014, 0x30286 },	\
-	{  56, 0x00b33, 0x0126c, 0x26014, 0x30288 },	\
-	{  60, 0x00b33, 0x0126e, 0x26014, 0x30280 },	\
-	{  64, 0x00b33, 0x0126f, 0x26014, 0x30282 },	\
-							\
-	{ 100, 0x00b33, 0x0128a, 0x2e014, 0x30280 },	\
-	{ 104, 0x00b33, 0x0128b, 0x2e014, 0x30282 },	\
-	{ 108, 0x00b33, 0x0128c, 0x2e014, 0x30284 },	\
-	{ 112, 0x00b33, 0x0128d, 0x2e014, 0x30286 },	\
-	{ 116, 0x00b33, 0x0128e, 0x2e014, 0x30288 },	\
-	{ 120, 0x00b33, 0x012a0, 0x2e014, 0x30280 },	\
-	{ 124, 0x00b33, 0x012a1, 0x2e014, 0x30282 },	\
-	{ 128, 0x00b33, 0x012a2, 0x2e014, 0x30284 },	\
-	{ 132, 0x00b33, 0x012a3, 0x2e014, 0x30286 },	\
-	{ 136, 0x00b33, 0x012a4, 0x2e014, 0x30288 },	\
-	{ 140, 0x00b33, 0x012a6, 0x2e014, 0x30280 },	\
-							\
-	{ 149, 0x00b33, 0x012a8, 0x2e014, 0x30287 },	\
-	{ 153, 0x00b33, 0x012a9, 0x2e014, 0x30289 },	\
-	{ 157, 0x00b33, 0x012ab, 0x2e014, 0x30281 },	\
-	{ 161, 0x00b33, 0x012ac, 0x2e014, 0x30283 },	\
-	{ 165, 0x00b33, 0x012ad, 0x2e014, 0x30285 }
-
-#define RT2661_RF5225_2					\
-	{   1, 0x00b33, 0x011e1, 0x1a014, 0x30282 },	\
-	{   2, 0x00b33, 0x011e1, 0x1a014, 0x30287 },	\
-	{   3, 0x00b33, 0x011e2, 0x1a014, 0x30282 },	\
-	{   4, 0x00b33, 0x011e2, 0x1a014, 0x30287 },	\
-	{   5, 0x00b33, 0x011e3, 0x1a014, 0x30282 },	\
-	{   6, 0x00b33, 0x011e3, 0x1a014, 0x30287 },	\
-	{   7, 0x00b33, 0x011e4, 0x1a014, 0x30282 },	\
-	{   8, 0x00b33, 0x011e4, 0x1a014, 0x30287 },	\
-	{   9, 0x00b33, 0x011e5, 0x1a014, 0x30282 },	\
-	{  10, 0x00b33, 0x011e5, 0x1a014, 0x30287 },	\
-	{  11, 0x00b33, 0x011e6, 0x1a014, 0x30282 },	\
-	{  12, 0x00b33, 0x011e6, 0x1a014, 0x30287 },	\
-	{  13, 0x00b33, 0x011e7, 0x1a014, 0x30282 },	\
-	{  14, 0x00b33, 0x011e8, 0x1a014, 0x30284 },	\
-							\
-	{  36, 0x00b35, 0x11206, 0x26014, 0x30280 },	\
-	{  40, 0x00b34, 0x111a0, 0x26014, 0x30280 },	\
-	{  44, 0x00b34, 0x111a1, 0x26014, 0x30286 },	\
-	{  48, 0x00b34, 0x111a3, 0x26014, 0x30282 },	\
-	{  52, 0x00b34, 0x111a4, 0x26014, 0x30288 },	\
-	{  56, 0x00b34, 0x111a6, 0x26014, 0x30284 },	\
-	{  60, 0x00b34, 0x111a8, 0x26014, 0x30280 },	\
-	{  64, 0x00b34, 0x111a9, 0x26014, 0x30286 },	\
-							\
-	{ 100, 0x00b35, 0x11226, 0x2e014, 0x30280 },	\
-	{ 104, 0x00b35, 0x11228, 0x2e014, 0x30280 },	\
-	{ 108, 0x00b35, 0x1122a, 0x2e014, 0x30280 },	\
-	{ 112, 0x00b35, 0x1122c, 0x2e014, 0x30280 },	\
-	{ 116, 0x00b35, 0x1122e, 0x2e014, 0x30280 },	\
-	{ 120, 0x00b34, 0x111c0, 0x2e014, 0x30280 },	\
-	{ 124, 0x00b34, 0x111c1, 0x2e014, 0x30286 },	\
-	{ 128, 0x00b34, 0x111c3, 0x2e014, 0x30282 },	\
-	{ 132, 0x00b34, 0x111c4, 0x2e014, 0x30288 },	\
-	{ 136, 0x00b34, 0x111c6, 0x2e014, 0x30284 },	\
-	{ 140, 0x00b34, 0x111c8, 0x2e014, 0x30280 },	\
-							\
-	{ 149, 0x00b34, 0x111cb, 0x2e014, 0x30286 },	\
-	{ 153, 0x00b34, 0x111cd, 0x2e014, 0x30282 },	\
-	{ 157, 0x00b35, 0x11242, 0x2e014, 0x30285 },	\
-	{ 161, 0x00b35, 0x11244, 0x2e014, 0x30285 },	\
-	{ 165, 0x00b35, 0x11246, 0x2e014, 0x30285 }
=======================================
--- /rt2661var.h	Tue Mar 13 05:46:45 2012
+++ /dev/null
@@ -1,173 +0,0 @@
-/*	$FreeBSD$	*/
-
-/*-
- * Copyright (c) 2005
- *	Damien Bergamini <damien.bergamini at 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 rt2661_rx_radiotap_header {
-	struct ieee80211_radiotap_header wr_ihdr;
-	uint64_t	wr_tsf;
-	uint8_t		wr_flags;
-	uint8_t		wr_rate;
-	uint16_t	wr_chan_freq;
-	uint16_t	wr_chan_flags;
-	int8_t		wr_antsignal;
-	int8_t		wr_antnoise;
-} __packed;
-
-#define RT2661_RX_RADIOTAP_PRESENT					\
-	((1 << IEEE80211_RADIOTAP_TSFT) |				\
-	 (1 << IEEE80211_RADIOTAP_FLAGS) |				\
-	 (1 << IEEE80211_RADIOTAP_RATE) |				\
-	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
-	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
-	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
-
-struct rt2661_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;
-} __packed;
-
-#define RT2661_TX_RADIOTAP_PRESENT					\
-	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
-	 (1 << IEEE80211_RADIOTAP_RATE) |				\
-	 (1 << IEEE80211_RADIOTAP_CHANNEL))
-
-struct rt2661_tx_data {
-	bus_dmamap_t		map;
-	struct mbuf		*m;
-	struct ieee80211_node	*ni;
-	uint8_t			rix;
-	int8_t			rssi;
-};
-
-struct rt2661_tx_ring {
-	bus_dma_tag_t		desc_dmat;
-	bus_dma_tag_t		data_dmat;
-	bus_dmamap_t		desc_map;
-	bus_addr_t		physaddr;
-	struct rt2661_tx_desc	*desc;
-	struct rt2661_tx_data	*data;
-	int			count;
-	int			queued;
-	int			cur;
-	int			next;
-	int			stat;
-};
-
-struct rt2661_rx_data {
-	bus_dmamap_t	map;
-	struct mbuf	*m;
-};
-
-struct rt2661_rx_ring {
-	bus_dma_tag_t		desc_dmat;
-	bus_dma_tag_t		data_dmat;
-	bus_dmamap_t		desc_map;
-	bus_addr_t		physaddr;
-	struct rt2661_rx_desc	*desc;
-	struct rt2661_rx_data	*data;
-	int			count;
-	int			cur;
-	int			next;
-};
-
-struct rt2661_vap {
-	struct ieee80211vap	ral_vap;
-
-	int			(*ral_newstate)(struct ieee80211vap *,
-				    enum ieee80211_state, int);
-};
-#define	RT2661_VAP(vap)		((struct rt2661_vap *)(vap))
-
-struct rt2661_softc {
-	struct ifnet			*sc_ifp;
-	device_t			sc_dev;
-	bus_space_tag_t			sc_st;
-	bus_space_handle_t		sc_sh;
-
-	struct mtx			sc_mtx;
-
-	struct callout			watchdog_ch;
-
-	int				sc_tx_timer;
-	int                             sc_invalid;
-	int				sc_debug;
-/*
- * The same in both up to here
- * ------------------------------------------------
- */
-
-	int                             sc_flags;
-#define	RAL_FW_LOADED		0x1
-#define	RAL_INPUT_RUNNING	0x2
-	int				sc_id;
-	struct ieee80211_channel	*sc_curchan;
-
-	uint8_t				rf_rev;
-
-	uint8_t				rfprog;
-	uint8_t				rffreq;
-
-	struct rt2661_tx_ring		txq[4];
-	struct rt2661_tx_ring		mgtq;
-	struct rt2661_rx_ring		rxq;
-
-	uint32_t			rf_regs[4];
-	int8_t				txpow[38];
-
-	struct {
-		uint8_t	reg;
-		uint8_t	val;
-	}				bbp_prom[16];
-
-	int				hw_radio;
-	int				rx_ant;
-	int				tx_ant;
-	int				nb_ant;
-	int				ext_2ghz_lna;
-	int				ext_5ghz_lna;
-	int				rssi_2ghz_corr;
-	int				rssi_5ghz_corr;
-
-	uint8_t				bbp18;
-	uint8_t				bbp21;
-	uint8_t				bbp22;
-	uint8_t				bbp16;
-	uint8_t				bbp17;
-	uint8_t				bbp64;
-
-	int				dwelltime;
-
-	struct rt2661_rx_radiotap_header sc_rxtap;
-	int				sc_rxtap_len;
-	struct rt2661_tx_radiotap_header sc_txtap;
-	int				sc_txtap_len;
-};
-
-int	rt2661_attach(device_t, int);
-int	rt2661_detach(void *);
-void	rt2661_shutdown(void *);
-void	rt2661_suspend(void *);
-void	rt2661_resume(void *);
-void	rt2661_intr(void *);
-
-#define RAL_LOCK(sc)		mtx_lock(&(sc)->sc_mtx)
-#define RAL_LOCK_ASSERT(sc)	mtx_assert(&(sc)->sc_mtx, MA_OWNED)
-#define RAL_UNLOCK(sc)		mtx_unlock(&(sc)->sc_mtx)
=======================================
--- /rt2860.c	Tue Mar 13 06:53:27 2012
+++ /dev/null
@@ -1,9283 +0,0 @@
-/*-
- * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar at gmail.com>
- * Copyright (c) 2009 Damien Bergamini <damien.bergamini at 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.
- */
-
-#include <dev/ral/rt2860var.h>
-#include <dev/ral/rt2860reg.h>
-#include <dev/ral/rt2860ucode.h>
-
-/*
- * Defines and macros
- */
-#define RT2860_MAX_AGG_SIZE						3840
-
-#define RT2860_TX_DATA_SEG0_SIZE				\
-	(sizeof(struct rt2860_txwi) + sizeof(struct ieee80211_qosframe_addr4))
-
-#define RT2860_NOISE_FLOOR						-95
-
-#define IEEE80211_HAS_ADDR4(wh)					\
-	(((wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS)
-
-#define	RT2860_MS(_v, _f)			(((_v) & _f) >> _f##_S)
-#define	RT2860_SM(_v, _f)			(((_v) << _f##_S) & _f)
-
-#define RT2860_TX_WATCHDOG_TIMEOUT				5
-
-#define RUN_AID2WCID(aid)					((aid) & 0xff)
-#define RT2860_WCID_RESERVED					0xff
-#define RT2860_WCID_MCAST						0xf7
-
-#define LED_CFG_LED_POLARITY	(1<<30)
-#define LED_CFG_Y_LED_MODE_ONTX	(1<<28)
-#define LED_CFG_G_LED_MODE_ONTX	(1<<26)
-#define LED_CFG_R_LED_MODE_ONTX	(1<<24)
-#define LED_CFG_SLOW_BLK_TIME 	(0x03<<16) /* sec */
-#define LED_CFG_LED_OFF_TIME 	(0x1e<<8) /* msec */
-#define LED_CFG_LED_ON_TIME 	(0x46) /* msec */
-
-static void rt2872_rf_set_chan(struct rt2860_softc *sc,
-			       struct ieee80211_channel *c);
-
-/*
- * Static variables
- */
-
-static const struct rt2860_rf_prog
-{
-	uint8_t chan;
-	uint32_t r1, r2, r3, r4;
-} rt2860_rf_2850[] =
-{
-	{   1, 0x98402ecc, 0x984c0786, 0x9816b455, 0x9800510b },
-	{   2, 0x98402ecc, 0x984c0786, 0x98168a55, 0x9800519f },
-	{   3, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800518b },
-	{   4, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800519f },
-	{   5, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800518b },
-	{   6, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800519f },
-	{   7, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800518b },
-	{   8, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800519f },
-	{   9, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800518b },
-	{  10, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800519f },
-	{  11, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800518b },
-	{  12, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800519f },
-	{  13, 0x98402ecc, 0x984c079e, 0x98168a55, 0x9800518b },
-	{  14, 0x98402ecc, 0x984c07a2, 0x98168a55, 0x98005193 },
-	{  36, 0x98402ecc, 0x984c099a, 0x98158a55, 0x980ed1a3 },
-	{  38, 0x98402ecc, 0x984c099e, 0x98158a55, 0x980ed193 },
-	{  40, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed183 },
-	{  44, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed1a3 },
-	{  46, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed18b },
-	{  48, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed19b },
-	{  52, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed193 },
-	{  54, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed1a3 },
-	{  56, 0x98402ec8, 0x984c068e, 0x98158a55, 0x980ed18b },
-	{  60, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed183 },
-	{  62, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed193 },
-	{  64, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed1a3 },
-	{ 100, 0x98402ec8, 0x984c06b2, 0x98178a55, 0x980ed783 },
-	{ 102, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed793 },
-	{ 104, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed1a3 },
-	{ 108, 0x98402ecc, 0x985c0a32, 0x98578a55, 0x980ed193 },
-	{ 110, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed183 },
-	{ 112, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed19b },
-	{ 116, 0x98402ecc, 0x984c0a3a, 0x98178a55, 0x980ed1a3 },
-	{ 118, 0x98402ecc, 0x984c0a3e, 0x98178a55, 0x980ed193 },
-	{ 120, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed183 },
-	{ 124, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed193 },
-	{ 126, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed15b },
-	{ 128, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed1a3 },
-	{ 132, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed18b },
-	{ 134, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed193 },
-	{ 136, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed19b },
-	{ 140, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed183 },
-	{ 149, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed1a7 },
-	{ 151, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed187 },
-	{ 153, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed18f },
-	{ 157, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed19f },
-	{ 159, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed1a7 },
-	{ 161, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed187 },
-	{ 165, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed197 },
-	{ 184, 0x95002ccc, 0x9500491e, 0x9509be55, 0x950c0a0b },
-	{ 188, 0x95002ccc, 0x95004922, 0x9509be55, 0x950c0a13 },
-	{ 192, 0x95002ccc, 0x95004926, 0x9509be55, 0x950c0a1b },
-	{ 196, 0x95002ccc, 0x9500492a, 0x9509be55, 0x950c0a23 },
-	{ 208, 0x95002ccc, 0x9500493a, 0x9509be55, 0x950c0a13 },
-	{ 212, 0x95002ccc, 0x9500493e, 0x9509be55, 0x950c0a1b },
-	{ 216, 0x95002ccc, 0x95004982, 0x9509be55, 0x950c0a23 },
-};
-
-static const struct rfprog {
-	uint8_t		chan;
-	uint32_t	r1, r2, r3, r4;
-} rt2860_rf2850[] = {
-	{   1, 0x100bb3, 0x1301e1, 0x05a014, 0x001402 },
-	{   2, 0x100bb3, 0x1301e1, 0x05a014, 0x001407 },
-	{   3, 0x100bb3, 0x1301e2, 0x05a014, 0x001402 },
-	{   4, 0x100bb3, 0x1301e2, 0x05a014, 0x001407 },
-	{   5, 0x100bb3, 0x1301e3, 0x05a014, 0x001402 },
-	{   6, 0x100bb3, 0x1301e3, 0x05a014, 0x001407 },
-	{   7, 0x100bb3, 0x1301e4, 0x05a014, 0x001402 },
-	{   8, 0x100bb3, 0x1301e4, 0x05a014, 0x001407 },
-	{   9, 0x100bb3, 0x1301e5, 0x05a014, 0x001402 },
-	{  10, 0x100bb3, 0x1301e5, 0x05a014, 0x001407 },
-	{  11, 0x100bb3, 0x1301e6, 0x05a014, 0x001402 },
-	{  12, 0x100bb3, 0x1301e6, 0x05a014, 0x001407 },
-	{  13, 0x100bb3, 0x1301e7, 0x05a014, 0x001402 },
-	{  14, 0x100bb3, 0x1301e8, 0x05a014, 0x001404 },
-	{  36, 0x100bb3, 0x130266, 0x056014, 0x001408 },
-	{  38, 0x100bb3, 0x130267, 0x056014, 0x001404 },
-	{  40, 0x100bb2, 0x1301a0, 0x056014, 0x001400 },
-	{  44, 0x100bb2, 0x1301a0, 0x056014, 0x001408 },
-	{  46, 0x100bb2, 0x1301a1, 0x056014, 0x001402 },
-	{  48, 0x100bb2, 0x1301a1, 0x056014, 0x001406 },
-	{  52, 0x100bb2, 0x1301a2, 0x056014, 0x001404 },
-	{  54, 0x100bb2, 0x1301a2, 0x056014, 0x001408 },
-	{  56, 0x100bb2, 0x1301a3, 0x056014, 0x001402 },
-	{  60, 0x100bb2, 0x1301a4, 0x056014, 0x001400 },
-	{  62, 0x100bb2, 0x1301a4, 0x056014, 0x001404 },
-	{  64, 0x100bb2, 0x1301a4, 0x056014, 0x001408 },
-	{ 100, 0x100bb2, 0x1301ac, 0x05e014, 0x001400 },
-	{ 102, 0x100bb2, 0x1701ac, 0x15e014, 0x001404 },
-	{ 104, 0x100bb2, 0x1701ac, 0x15e014, 0x001408 },
-	{ 108, 0x100bb3, 0x17028c, 0x15e014, 0x001404 },
-	{ 110, 0x100bb3, 0x13028d, 0x05e014, 0x001400 },
-	{ 112, 0x100bb3, 0x13028d, 0x05e014, 0x001406 },
-	{ 116, 0x100bb3, 0x13028e, 0x05e014, 0x001408 },
-	{ 118, 0x100bb3, 0x13028f, 0x05e014, 0x001404 },
-	{ 120, 0x100bb1, 0x1300e0, 0x05e014, 0x001400 },
-	{ 124, 0x100bb1, 0x1300e0, 0x05e014, 0x001404 },
-	{ 126, 0x100bb1, 0x1300e0, 0x05e014, 0x001406 },
-	{ 128, 0x100bb1, 0x1300e0, 0x05e014, 0x001408 },
-	{ 132, 0x100bb1, 0x1300e1, 0x05e014, 0x001402 },
-	{ 134, 0x100bb1, 0x1300e1, 0x05e014, 0x001404 },
-	{ 136, 0x100bb1, 0x1300e1, 0x05e014, 0x001406 },
-	{ 140, 0x100bb1, 0x1300e2, 0x05e014, 0x001400 },
-	{ 149, 0x100bb1, 0x1300e2, 0x05e014, 0x001409 },
-	{ 151, 0x100bb1, 0x1300e3, 0x05e014, 0x001401 },
-	{ 153, 0x100bb1, 0x1300e3, 0x05e014, 0x001403 },
-	{ 157, 0x100bb1, 0x1300e3, 0x05e014, 0x001407 },
-	{ 159, 0x100bb1, 0x1300e3, 0x05e014, 0x001409 },
-	{ 161, 0x100bb1, 0x1300e4, 0x05e014, 0x001401 },
-	{ 165, 0x100bb1, 0x1300e4, 0x05e014, 0x001405 },
-	{ 167, 0x100bb1, 0x1300f4, 0x05e014, 0x001407 },
-	{ 169, 0x100bb1, 0x1300f4, 0x05e014, 0x001409 },
-	{ 171, 0x100bb1, 0x1300f5, 0x05e014, 0x001401 },
-	{ 173, 0x100bb1, 0x1300f5, 0x05e014, 0x001403 }
-};
-
-static const struct rt2860_rf_fi3020
-{
-	uint8_t channel, n, r, k;
-} rt2860_rf_fi3020[] =
-{
-	/* 802.11g  */
-	{1,	241,	2,	2},
-	{2,	241,	2,	7},
-	{3,	242,	2,	2},
-	{4,	242,	2,	7},
-	{5,	243,	2,	2},
-	{6,	243,	2,	7},
-	{7,	244,	2,	2},
-	{8,	244,	2,	7},
-	{9,	245,	2,	2},
-	{10,	245,	2,	7},
-	{11,	246,	2,	2},
-	{12,	246,	2,	7},
-	{13,	247,	2,	2},
-	{14,	248,	2,	4},
-
-	/* 802.11 UNI / HyperLan 2 */
-	{36,	0x56,	0,	4},
-	{38,	0x56,	0,	6},
-	{40,	0x56,	0,	8},
-	{44,	0x57,	0,	0},
-	{46,	0x57,	0,	2},
-	{48,	0x57,	0,	4},
-	{52,	0x57,	0,	8},
-	{54,	0x57,	0,	10},
-	{56,	0x58,	0,	0},
-	{60,	0x58,	0,	4},
-	{62,	0x58,	0,	6},
-	{64,	0x58,	0,	8},
-
-	/* 802.11 HyperLan 2 */
-	{100,	0x5b,	0,	8},
-	{102,	0x5b,	0,	10},
-	{104,	0x5c,	0,	0},
-	{108,	0x5c,	0,	4},
-	{110,	0x5c,	0,	6},
-	{112,	0x5c,	0,	8},
-	{116,	0x5d,	0,	0},
-	{118,	0x5d,	0,	2},
-	{120,	0x5d,	0,	4},
-	{124,	0x5d,	0,	8},
-	{126,	0x5d,	0,	10},
-	{128,	0x5e,	0,	0},
-	{132,	0x5e,	0,	4},
-	{134,	0x5e,	0,	6},
-	{136,	0x5e,	0,	8},
-	{140,	0x5f,	0,	0},
-
-	/* 802.11 UNII */
-	{149,	0x5f,	0,	9},
-	{151,	0x5f,	0,	11},
-	{153,	0x60,	0,	1},
-	{157,	0x60,	0,	5},
-	{159,	0x60,	0,	7},
-	{161,	0x60,	0,	9},
-	{165,	0x61,	0,	1},
-	{167,	0x61,	0,	3},
-	{169,	0x61,	0,	5},
-	{171,	0x61,	0,	7},
-	{173,	0x61,	0,	9},
-};
-
-static const struct {
-	uint8_t	reg;
-	uint8_t	val;
-}  rt3090_def_rf[] = {
-	{  4, 0x40 },
-	{  5, 0x03 },
-	{  6, 0x02 },
-	{  7, 0x70 },
-	{  9, 0x0f },
-	{ 10, 0x41 },
-	{ 11, 0x21 },
-	{ 12, 0x7b },
-	{ 14, 0x90 },
-	{ 15, 0x58 },
-	{ 16, 0xb3 },
-	{ 17, 0x92 },
-	{ 18, 0x2c },
-	{ 19, 0x02 },
-	{ 20, 0xba },
-	{ 21, 0xdb },
-	{ 24, 0x16 },
-	{ 25, 0x01 },
-	{ 29, 0x1f }
-};
-
-struct {
-	uint8_t	n, r, k;
-} rt3090_freqs[] = {
-	{ 0xf1, 2,  2 },
-	{ 0xf1, 2,  7 },
-	{ 0xf2, 2,  2 },
-	{ 0xf2, 2,  7 },
-	{ 0xf3, 2,  2 },
-	{ 0xf3, 2,  7 },
-	{ 0xf4, 2,  2 },
-	{ 0xf4, 2,  7 },
-	{ 0xf5, 2,  2 },
-	{ 0xf5, 2,  7 },
-	{ 0xf6, 2,  2 },
-	{ 0xf6, 2,  7 },
-	{ 0xf7, 2,  2 },
-	{ 0xf8, 2,  4 },
-	{ 0x56, 0,  4 },
-	{ 0x56, 0,  6 },
-	{ 0x56, 0,  8 },
-	{ 0x57, 0,  0 },
-	{ 0x57, 0,  2 },
-	{ 0x57, 0,  4 },
-	{ 0x57, 0,  8 },
-	{ 0x57, 0, 10 },
-	{ 0x58, 0,  0 },
-	{ 0x58, 0,  4 },
-	{ 0x58, 0,  6 },
-	{ 0x58, 0,  8 },
-	{ 0x5b, 0,  8 },
-	{ 0x5b, 0, 10 },
-	{ 0x5c, 0,  0 },
-	{ 0x5c, 0,  4 },
-	{ 0x5c, 0,  6 },
-	{ 0x5c, 0,  8 },
-	{ 0x5d, 0,  0 },
-	{ 0x5d, 0,  2 },
-	{ 0x5d, 0,  4 },
-	{ 0x5d, 0,  8 },
-	{ 0x5d, 0, 10 },
-	{ 0x5e, 0,  0 },
-	{ 0x5e, 0,  4 },
-	{ 0x5e, 0,  6 },
-	{ 0x5e, 0,  8 },
-	{ 0x5f, 0,  0 },
-	{ 0x5f, 0,  9 },
-	{ 0x5f, 0, 11 },
-	{ 0x60, 0,  1 },
-	{ 0x60, 0,  5 },
-	{ 0x60, 0,  7 },
-	{ 0x60, 0,  9 },
-	{ 0x61, 0,  1 },
-	{ 0x61, 0,  3 },
-	{ 0x61, 0,  5 },
-	{ 0x61, 0,  7 },
-	{ 0x61, 0,  9 }
-};
-
-static const struct {
-	uint32_t reg;
-	uint32_t val;
-} rt2860_def_mac[] = {
-	{ RT2860_REG_PBF_BCN_OFFSET0, 		0xf8f0e8e0 },
-	{ RT2860_REG_PBF_BCN_OFFSET1, 		0x6f77d0c8 },
-	{ RT2860_REG_LEGACY_BASIC_RATE, 	0x0000013f },
-	{ RT2860_REG_HT_BASIC_RATE, 		0x00008003 },
-	{ RT2860_REG_SYS_CTRL, 			0x00000000 },
-	{ RT2860_REG_RX_FILTER_CFG, 		0x00017f97 },
-	{ RT2860_REG_BKOFF_SLOT_CFG, 		0x00000209 },
-	{ RT2860_REG_TX_SW_CFG0, 		0x00000000 },
-	{ RT2860_REG_TX_SW_CFG1, 		0x00080606 },
-	{ RT2860_REG_TX_LINK_CFG, 		0x00001020 },
-	{ RT2860_REG_TX_TIMEOUT_CFG, 		0x000a2090 },
-	{ RT2860_REG_MAX_LEN_CFG, 	(1 << 12) | RT2860_MAX_AGG_SIZE },
-	{ RT2860_REG_LED_CFG, 			0x7f031e46 },
-	{ RT2860_REG_PBF_MAX_PCNT, 		0x1f3fbf9f },
-	{ RT2860_REG_TX_RTY_CFG, 		0x47d01f0f },
-	{ RT2860_REG_AUTO_RSP_CFG, 		0x00000013 },
-	{ RT2860_REG_TX_CCK_PROT_CFG, 		0x05740003 },
-	{ RT2860_REG_TX_OFDM_PROT_CFG, 		0x05740003 },
-	{ RT2860_REG_TX_GF20_PROT_CFG, 		0x01744004 },
-	{ RT2860_REG_TX_GF40_PROT_CFG, 		0x03f44084 },
-	{ RT2860_REG_TX_MM20_PROT_CFG, 		0x01744004 },
-	{ RT2860_REG_TX_MM40_PROT_CFG,		0x03f54084 },
-	{ RT2860_REG_TX_TXOP_CTRL_CFG, 		0x0000583f },
-	{ RT2860_REG_TX_RTS_CFG, 		0x00092b20 },
-	{ RT2860_REG_TX_EXP_ACK_TIME, 		0x002400ca },
-	{ RT2860_REG_HCCAPSMP_TXOP_HLDR_ET, 	0x00000002 },
-	{ RT2860_REG_XIFS_TIME_CFG, 		0x33a41010 },
-	{ RT2860_REG_PWR_PIN_CFG, 		0x00000003 },
-	{ RT2860_REG_SCHDMA_WMM_AIFSN_CFG,	0x00002273 },
-	{ RT2860_REG_SCHDMA_WMM_CWMIN_CFG,	0x00002344 },
-	{ RT2860_REG_SCHDMA_WMM_CWMAX_CFG,	0x000034aa },
-};
-
-#define	RT2860_DEF_MAC_SIZE				\
-    (sizeof(rt2860_def_mac) / sizeof(rt2860_def_mac[0]))
-
-static const struct {
-	uint8_t	reg;
-	uint8_t	val;
-} rt2860_def_bbp[] = {
-	{ 65,	0x2c },
-	{ 66,	0x38 },
-	{ 69,	0x12 },
-	{ 70,	0x0a },
-	{ 73,	0x10 },
-	{ 81,	0x37 },
-	{ 82,	0x62 },
-	{ 83,	0x6a },
-	{ 84,	0x99 },
-	{ 86,	0x00 },
-	{ 91,	0x04 },
-	{ 92,	0x00 },
-	{ 103,	0x00 },
-	{ 105,	0x05 },
-	{ 106,	0x35 },
-};
-
-#define RT2860_DEF_BBP_SIZE			\
-    (sizeof(rt2860_def_bbp) / sizeof(rt2860_def_bbp[0]))
-
-/*
- * Static function prototypes
- */
-static void rt2860_init_channels(struct rt2860_softc *sc);
-static void rt2860_init_channels_ht40(struct rt2860_softc *sc);
-static void rt2860_init_locked(void *priv);
-static void rt2860_init(void *priv);
-static int rt2860_init_bbp(struct rt2860_softc *sc);
-static void rt2860_stop_locked(void *priv);
-static void rt2860_stop(void *priv);
-static void rt2860_start(struct ifnet *ifp);
-static int rt2860_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
-static struct ieee80211vap *rt2860_vap_create(struct ieee80211com *ic,
-	const char name[IFNAMSIZ], int unit, enum ieee80211_opmode, int flags,
-	const uint8_t bssid[IEEE80211_ADDR_LEN],
-	const uint8_t mac[IEEE80211_ADDR_LEN]);
-static void rt2860_vap_delete(struct ieee80211vap *vap);
-static int rt2860_vap_reset(struct ieee80211vap *vap, u_long cmd);
-static int rt2860_vap_newstate(struct ieee80211vap *vap,
-	enum ieee80211_state nstate, int arg);
-
-#ifndef RT2860_NO_HW_CRYPTO
-static void rt2860_vap_key_update_begin(struct ieee80211vap *vap);
-static void rt2860_vap_key_update_end(struct ieee80211vap *vap);
-static int rt2860_vap_key_set(struct ieee80211vap *vap,
-	const struct ieee80211_key *k, const uint8_t mac[IEEE80211_ADDR_LEN]);
-static int rt2860_vap_key_delete(struct ieee80211vap *vap,
-	const struct ieee80211_key *k);
-#endif
-
-static void rt2860_vap_update_beacon(struct ieee80211vap *vap, int what);
-static int rt2860_media_change(struct ifnet *ifp);
-static struct ieee80211_node *rt2860_node_alloc(struct ieee80211vap *vap,
-	const uint8_t mac[IEEE80211_ADDR_LEN]);
-static void rt2860_node_cleanup(struct ieee80211_node *ni);
-static void rt2860_node_getmimoinfo(const struct ieee80211_node *ni,
-	struct ieee80211_mimo_info *mi);
-static int rt2860_setregdomain(struct ieee80211com *ic,
-	struct ieee80211_regdomain *reg,
-	int nchans, struct ieee80211_channel chans[]);
-static void rt2860_getradiocaps(struct ieee80211com *ic,
-	int maxchans, int *nchans, struct ieee80211_channel chans[]);
-static void rt2860_scan_start(struct ieee80211com *ic);
-static void rt2860_scan_end(struct ieee80211com *ic);
-static void rt2860_set_channel(struct ieee80211com *ic);
-static void rt2860_newassoc(struct ieee80211_node *ni, int isnew);
-static void rt2860_updateslot(struct ifnet *ifp);
-static void rt2860_update_promisc(struct ifnet *ifp);
-static void rt2860_update_mcast(struct ifnet *ifp);
-static int rt2860_wme_update(struct ieee80211com *ic);
-static int rt2860_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
-	const struct ieee80211_bpf_params *params);
-static int rt2860_recv_action(struct ieee80211_node *ni,
-	const struct ieee80211_frame *wh,
-	const uint8_t *frm, const uint8_t *efrm);
-static int rt2860_send_action(struct ieee80211_node *ni,
-	int cat, int act, void *sa);
-static int rt2860_addba_response(struct ieee80211_node *ni,
-	struct ieee80211_tx_ampdu *tap,
-	int status, int baparamset, int batimeout);
-static void rt2860_addba_stop(struct ieee80211_node *ni,
-	struct ieee80211_tx_ampdu *tap);
-static int rt2860_ampdu_rx_start(struct ieee80211_node *ni,
-	struct ieee80211_rx_ampdu *rap,
-	int baparamset, int batimeout, int baseqctl);
-static void rt2860_ampdu_rx_stop(struct ieee80211_node *ni,
-	struct ieee80211_rx_ampdu *rap);
-static int rt2860_send_bar(struct ieee80211_node *ni,
-	struct ieee80211_tx_ampdu *tap, ieee80211_seq seqno);
-static void rt2860_amrr_update_iter_func(void *arg, struct ieee80211_node  
*ni);
-static void rt2860_periodic(void *arg);
-static void rt2860_tx_watchdog(void *arg);
-static int rt2860_staid_alloc(struct rt2860_softc *sc, int aid);
-static void rt2860_staid_delete(struct rt2860_softc *sc, int staid);
-void rt2860_amrr_init(struct rt2860_amrr *amrr, struct ieee80211vap *vap,
-		      int ntxpath, int min_success_threshold,
-		      int max_success_threshold, int msecs);
-void rt2860_amrr_cleanup(struct rt2860_amrr *amrr);
-void rt2860_amrr_node_init(struct rt2860_amrr *amrr,
-    struct rt2860_amrr_node *amrr_node, struct ieee80211_node *ni);
-int rt2860_amrr_choose(struct ieee80211_node *ni,
-	struct rt2860_amrr_node *amrr_node);
-
-static __inline void
-rt2860_amrr_tx_complete(struct rt2860_amrr_node *amrr_node, int ok, int  
retries)
-{
-
-	amrr_node->txcnt++;
-
-	if (ok)
-		amrr_node->success++;
-
-	amrr_node->retrycnt += retries;
-}
-
-static __inline void
-rt2860_amrr_tx_update(struct rt2860_amrr_node *amrr_node, int txcnt,
-		      int success, int retrycnt)
-{
-
-	amrr_node->txcnt = txcnt;
-	amrr_node->success = success;
-	amrr_node->retrycnt = retrycnt;
-}
-
-static void rt2860_asic_set_bssid(struct rt2860_softc *sc,
-				  const uint8_t *bssid);
-static void rt2860_asic_set_macaddr(struct rt2860_softc *sc,
-				    const uint8_t *addr);
-static void rt2860_asic_enable_tsf_sync(struct rt2860_softc *sc);
-static void rt2860_asic_disable_tsf_sync(struct rt2860_softc *sc);
-static void rt2860_asic_enable_mrr(struct rt2860_softc *sc);
-static void rt2860_asic_set_txpreamble(struct rt2860_softc *sc);
-static void rt2860_asic_set_basicrates(struct rt2860_softc *sc);
-static void rt2860_asic_update_rtsthreshold(struct rt2860_softc *sc);
-static void rt2860_asic_update_txpower(struct rt2860_softc *sc);
-static void rt2860_asic_update_promisc(struct rt2860_softc *sc);
-static void rt2860_asic_updateprot(struct rt2860_softc *sc);
-static void rt2860_asic_updateslot(struct rt2860_softc *sc);
-static void rt2860_asic_wme_update(struct rt2860_softc *sc);
-static void rt2860_asic_update_beacon(struct rt2860_softc *sc,
-				      struct ieee80211vap *vap);
-static void rt2860_asic_clear_keytables(struct rt2860_softc *sc);
-static void rt2860_asic_add_ba_session(struct rt2860_softc *sc,
-				       uint8_t wcid, int tid);
-static void rt2860_asic_del_ba_session(struct rt2860_softc *sc,
-				       uint8_t wcid, int tid);
-void rt2860_led_brightness(struct rt2860_softc *sc, uint8_t brightness);
-void rt2860_led_cmd(struct rt2860_softc *sc, uint8_t cmd);
-const char *rt2860_rf_name(int rf_rev);
-void rt2860_rf_select_chan_group(struct rt2860_softc *sc,
-	struct ieee80211_channel *c);
-void rt2860_rf_set_chan(struct rt2860_softc *sc,
-	struct ieee80211_channel *c);
-uint8_t rt3090_rf_read(struct rt2860_softc *sc, uint8_t reg);
-void rt3090_rf_write(struct rt2860_softc *sc, uint8_t reg, uint8_t val);
-void rt3090_set_chan(struct rt2860_softc *sc, u_int chan);
-int rt3090_rf_init(struct rt2860_softc *sc);
-void rt3090_set_rx_antenna(struct rt2860_softc *, int);
-void rt3090_rf_wakeup(struct rt2860_softc *sc);
-int rt3090_filter_calib(struct rt2860_softc *sc, uint8_t init, uint8_t  
target,
-			uint8_t *val);
-void rt3090_rf_setup(struct rt2860_softc *sc);
-void rt2860_read_eeprom(struct rt2860_softc *sc);
-uint32_t rt2860_read_eeprom_txpow_rate_add_delta(uint32_t txpow_rate,
-						 int8_t delta);
-void rt2860_io_rf_load_defaults(struct rt2860_softc *sc);
-uint32_t rt2860_io_mac_read(struct rt2860_softc *sc, uint16_t reg);
-void rt2860_io_mac_read_multi(struct rt2860_softc *sc,
-			      uint16_t reg, void *buf, size_t len);
-void rt2860_io_mac_write(struct rt2860_softc *sc,
-			 uint16_t reg, uint32_t val);
-void rt2860_io_mac_write_multi(struct rt2860_softc *sc,
-			       uint16_t reg, const void *buf, size_t len);
-void rt2860_io_mac_set_region_4(struct rt2860_softc *sc,
-				uint16_t reg, uint32_t val, size_t len);
-uint16_t rt2860_io_eeprom_read(struct rt2860_softc *sc, uint16_t addr);
-void rt2860_io_eeprom_read_multi(struct rt2860_softc *sc,
-				 uint16_t addr, void *buf, size_t len);
-uint8_t rt2860_io_bbp_read(struct rt2860_softc *sc, uint8_t reg);
-void rt2860_io_bbp_write(struct rt2860_softc *sc, uint8_t reg, uint8_t  
val);
-void rt2860_io_rf_write(struct rt2860_softc *sc, uint8_t reg, uint32_t  
val);
-int32_t rt2860_io_rf_read(struct rt2860_softc *sc, uint8_t reg);
-void rt2860_io_mcu_cmd(struct rt2860_softc *sc, uint8_t cmd,
-		       uint8_t token, uint16_t arg);
-int rt2860_io_mcu_cmd_check(struct rt2860_softc *sc, uint8_t cid);
-int rt2860_io_mcu_load_ucode(struct rt2860_softc *sc,
-			     const uint8_t *ucode, size_t len);
-static int rt2860_beacon_alloc(struct rt2860_softc *sc,
-			       struct ieee80211vap *vap);
-static uint8_t rt2860_rxrate(struct rt2860_rxwi *rxwi);
-static uint8_t rt2860_maxrssi_rxpath(struct rt2860_softc *sc,
-				     const struct rt2860_rxwi *rxwi);
-static int8_t rt2860_rssi2dbm(struct rt2860_softc *sc,
-			      uint8_t rssi, uint8_t rxpath);
-static uint8_t rt2860_rate2mcs(uint8_t rate);
-static int rt2860_tx_mgmt(struct rt2860_softc *sc,
-			  struct mbuf *m, struct ieee80211_node *ni, int qid);
-static int rt2860_tx_data(struct rt2860_softc *sc,
-			  struct mbuf *m, struct ieee80211_node *ni, int qid);
-
-static void rt2860_tx_coherent_intr(struct rt2860_softc *sc);
-static void rt2860_rx_coherent_intr(struct rt2860_softc *sc);
-static void rt2860_txrx_coherent_intr(struct rt2860_softc *sc);
-static void rt2860_fifo_sta_full_intr(struct rt2860_softc *sc);
-static void rt2860_rx_intr(struct rt2860_softc *sc);
-static void rt2860_tx_intr(struct rt2860_softc *sc, int qid);
-static void rt2860_rx_done_task(void *context, int pending);
-static void rt2860_tx_done_task(void *context, int pending);
-static void rt2860_fifo_sta_full_task(void *context, int pending);
-static void rt2860_periodic_task(void *context, int pending);
-static int rt2860_rx_eof(struct rt2860_softc *sc, int limit);
-static void rt2860_tx_eof(struct rt2860_softc *sc,
-	struct rt2860_softc_tx_ring *ring);
-static void rt2860_update_stats(struct rt2860_softc *sc);
-static void rt2860_bbp_tuning(struct rt2860_softc *sc);
-static void rt2860_watchdog(struct rt2860_softc *sc);
-static void rt2860_drain_fifo_stats(struct rt2860_softc *sc);
-static void rt2860_update_raw_counters(struct rt2860_softc *sc);
-static void rt2860_intr_enable(struct rt2860_softc *sc, uint32_t  
intr_mask);
-static void rt2860_intr_disable(struct rt2860_softc *sc, uint32_t  
intr_mask);
-static int rt2860_txrx_enable(struct rt2860_softc *sc);
-static int rt2860_alloc_rx_ring(struct rt2860_softc *sc,
-	struct rt2860_softc_rx_ring *ring);
-static void rt2860_reset_rx_ring(struct rt2860_softc *sc,
-	struct rt2860_softc_rx_ring *ring);
-static void rt2860_free_rx_ring(struct rt2860_softc *sc,
-	struct rt2860_softc_rx_ring *ring);
-static int rt2860_alloc_tx_ring(struct rt2860_softc *sc,
-	struct rt2860_softc_tx_ring *ring, int qid);
-static void rt2860_reset_tx_ring(struct rt2860_softc *sc,
-	struct rt2860_softc_tx_ring *ring);
-static void rt2860_free_tx_ring(struct rt2860_softc *sc,
-	struct rt2860_softc_tx_ring *ring);
-static void rt2860_dma_map_addr(void *arg, bus_dma_segment_t *segs,
-	int nseg, int error);
-static void rt2860_sysctl_attach(struct rt2860_softc *sc);
-
-/*
- * Static variables
- */
-
-SYSCTL_NODE(_hw, OID_AUTO, ral, CTLFLAG_RD, 0, "RT2860 driver parameters");
-
-static int rt2860_tx_stbc = 1;
-SYSCTL_INT(_hw_ral, OID_AUTO, tx_stbc, CTLFLAG_RW, &rt2860_tx_stbc, 0,
-	   "RT2860 Tx STBC");
-TUNABLE_INT("hw.ral.tx_stbc", &rt2860_tx_stbc);
-
-#ifdef RT2860_DEBUG
-static int rt2860_debug = 0;
-SYSCTL_INT(_hw_ral, OID_AUTO, debug, CTLFLAG_RW, &rt2860_debug, 0,
-	   "RT2860 debug level");
-TUNABLE_INT("hw.ral.debug", &rt2860_debug);
-#endif
-
-/*
- * rt2860_attach
- */
-int rt2860_attach(device_t dev, int id)
-{
-	struct rt2860_softc *sc;
-	struct ifnet *ifp;
-	struct ieee80211com *ic;
-	int error, ntries, i;
-
-	sc = device_get_softc(dev);
-
-	sc->sc_dev = dev;
-	sc->id = id;
-
-	mtx_init(&sc->sc_mtx, device_get_nameunit(dev),
-		MTX_NETWORK_LOCK, MTX_DEF | MTX_RECURSE);
-
-	sc->tx_stbc = rt2860_tx_stbc;
-
-#ifdef RT2860_DEBUG
-	sc->debug = rt2860_debug;
-
-	SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
-		SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
-		"debug", CTLFLAG_RW, &sc->debug, 0, "rt2860 debug level");
-#endif
-
-	RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
-		"%s: attaching\n",
-		device_get_nameunit(sc->sc_dev));
-
-	/* wait for NIC to initialize */
-	for (ntries = 0; ntries < 100; ntries++) {
-		sc->mac_rev = rt2860_io_mac_read(sc, RT2860_REG_MAC_CSR0);
-		if (sc->mac_rev != 0x00000000 && sc->mac_rev != 0xffffffff)
-			break;
-
-		DELAY(10);
-	}
-
-	if (ntries == 100) {
-		device_printf(dev, "timeout waiting for NIC to initialize\n");
-		error = EIO;
-		goto fail;
-	}
-
-	rt2860_read_eeprom(sc);
-
-	device_printf(sc->sc_dev, "MAC/BBP RT2860 (rev 0x%08x), RF %s\n",
-	    sc->mac_rev,rt2860_rf_name(sc->rf_rev));
-
-	RT2860_SOFTC_LOCK(sc);
-	/* clear key tables */
-	rt2860_asic_clear_keytables(sc);
-	RT2860_SOFTC_UNLOCK(sc);
-
-	/* allocate Tx and Rx rings */
-	for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++) {
-		error = rt2860_alloc_tx_ring(sc, &sc->tx_ring[i], i);
-		if (error != 0) {
-			device_printf(sc->sc_dev, "could not allocate Tx "
-			    "ring #%d\n", i);
-			goto fail;
-		}
-	}
-
-	sc->tx_ring_mgtqid = 5;
-
-	error = rt2860_alloc_rx_ring(sc, &sc->rx_ring);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not allocate Rx ring\n");
-		goto fail;
-	}
-
-	callout_init(&sc->periodic_ch, 0);
-	callout_init_mtx(&sc->tx_watchdog_ch, &sc->sc_mtx, 0);
-
-	ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
-	if (ifp == NULL) {
-		device_printf(sc->sc_dev, "could not if_alloc()\n");
-		error = ENOMEM;
-		goto fail;
-	}
-
-	ifp->if_softc = sc;
-
-	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-
-	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-
-	ifp->if_init = rt2860_init;
-	ifp->if_ioctl = rt2860_ioctl;
-	ifp->if_start = rt2860_start;
-
-	IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
-	ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
-	IFQ_SET_READY(&ifp->if_snd);
-
-	ic = ifp->if_l2com;
-
-	ic->ic_ifp = ifp;
-
-	ic->ic_phytype = IEEE80211_T_HT;
-	ic->ic_opmode = IEEE80211_M_STA;
-
-	ic->ic_caps = IEEE80211_C_MONITOR |
-		IEEE80211_C_IBSS |
-		IEEE80211_C_STA |
-		IEEE80211_C_AHDEMO |
-		IEEE80211_C_HOSTAP |
-		IEEE80211_C_WDS |
-		IEEE80211_C_MBSS |
-		IEEE80211_C_BGSCAN |
-		IEEE80211_C_TXPMGT |
-		IEEE80211_C_SHPREAMBLE |
-		IEEE80211_C_SHSLOT |
-		IEEE80211_C_TXFRAG |
-		IEEE80211_C_BURST |
-		IEEE80211_C_WME |
-		IEEE80211_C_WPA;
-
-#ifndef RT2860_NO_HW_CRYPTO
-	ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP |
-		IEEE80211_CRYPTO_TKIP |
-		IEEE80211_CRYPTO_TKIPMIC |
-		IEEE80211_CRYPTO_AES_CCM;
-#endif
-	ic->ic_htcaps = IEEE80211_HTC_HT |
-		IEEE80211_HTC_AMSDU |		/* A-MSDU Tx */
-		IEEE80211_HTC_AMPDU |		/* A-MPDU Tx */
-		IEEE80211_HTC_SMPS |		/* MIMO power save */
-		IEEE80211_HTCAP_MAXAMSDU_3839 |	/* max. A-MSDU Rx length */
-		IEEE80211_HTCAP_CHWIDTH40 |	/* HT 40MHz channel width */
-		IEEE80211_HTCAP_GREENFIELD |	/* HT greenfield */
-		IEEE80211_HTCAP_SHORTGI20 |	/* HT 20MHz short GI */
-		IEEE80211_HTCAP_SHORTGI40 |	/* HT 40MHz short GI */
-		IEEE80211_HTCAP_SMPS_OFF;	/* MIMO power save disabled */
-
-	/* spatial streams */
-	if (sc->nrxpath == 2)
-		ic->ic_htcaps |= IEEE80211_HTCAP_RXSTBC_2STREAM;
-	else if (sc->nrxpath == 3)
-		ic->ic_htcaps |= IEEE80211_HTCAP_RXSTBC_3STREAM;
-	else
-		ic->ic_htcaps |= IEEE80211_HTCAP_RXSTBC_1STREAM;
-
-	if (sc->ntxpath > 1)
-		ic->ic_htcaps |= IEEE80211_HTCAP_TXSTBC;
-
-	/* delayed BA */
-	if (sc->mac_rev != 0x28600100)
-		ic->ic_htcaps |= IEEE80211_HTCAP_DELBA;
-
-	/* init channels */
-	ic->ic_nchans = 0;
-
-	rt2860_init_channels(sc);
-	rt2860_init_channels_ht40(sc);
-
-	ieee80211_ifattach(ic, sc->mac_addr);
-
-	ic->ic_vap_create = rt2860_vap_create;
-	ic->ic_vap_delete = rt2860_vap_delete;
-
-	ic->ic_node_alloc = rt2860_node_alloc;
-	sc->node_cleanup = ic->ic_node_cleanup;
-	ic->ic_node_cleanup = rt2860_node_cleanup;
-
-	ic->ic_node_getmimoinfo = rt2860_node_getmimoinfo;
-	ic->ic_setregdomain = rt2860_setregdomain;
-	ic->ic_getradiocaps = rt2860_getradiocaps;
-	ic->ic_scan_start = rt2860_scan_start;
-	ic->ic_scan_end = rt2860_scan_end;
-	ic->ic_set_channel = rt2860_set_channel;
-	ic->ic_newassoc = rt2860_newassoc;
-	ic->ic_updateslot = rt2860_updateslot;
-	ic->ic_update_promisc = rt2860_update_promisc;
-	ic->ic_update_mcast = rt2860_update_mcast;
-	ic->ic_wme.wme_update = rt2860_wme_update;
-	ic->ic_raw_xmit = rt2860_raw_xmit;
-
-	sc->recv_action = ic->ic_recv_action;
-	ic->ic_recv_action = rt2860_recv_action;
-
-	sc->send_action = ic->ic_send_action;
-	ic->ic_send_action = rt2860_send_action;
-
-	sc->addba_response = ic->ic_addba_response;
-	ic->ic_addba_response = rt2860_addba_response;
-
-	sc->addba_stop = ic->ic_addba_stop;
-	ic->ic_addba_stop = rt2860_addba_stop;
-
-	sc->ampdu_rx_start = ic->ic_ampdu_rx_start;
-	ic->ic_ampdu_rx_start = rt2860_ampdu_rx_start;
-
-	sc->ampdu_rx_stop = ic->ic_ampdu_rx_stop;
-	ic->ic_ampdu_rx_stop = rt2860_ampdu_rx_stop;
-
-	/* hardware requires padding between 802.11 frame header and body */
-	ic->ic_flags |= IEEE80211_F_DATAPAD | IEEE80211_F_DOTH;
-	ic->ic_flags_ext |= IEEE80211_FEXT_SWBMISS;
-
-	ieee80211_radiotap_attach(ic,
-	    &sc->txtap.ihdr, sizeof(sc->txtap),
-		RT2860_SOFTC_TX_RADIOTAP_PRESENT,
-	    &sc->rxtap.ihdr, sizeof(sc->rxtap),
-		RT2860_SOFTC_RX_RADIOTAP_PRESENT);
-
-	/* init task queue */
-	TASK_INIT(&sc->rx_done_task, 0, rt2860_rx_done_task, sc);
-	TASK_INIT(&sc->tx_done_task, 0, rt2860_tx_done_task, sc);
-	TASK_INIT(&sc->fifo_sta_full_task, 0, rt2860_fifo_sta_full_task, sc);
-	TASK_INIT(&sc->periodic_task, 0, rt2860_periodic_task, sc);
-
-	sc->rx_process_limit = 100;
-
-	sc->taskqueue = taskqueue_create("rt2860_taskq", M_NOWAIT,
-	    taskqueue_thread_enqueue, &sc->taskqueue);
-
-	taskqueue_start_threads(&sc->taskqueue, 1, PI_NET, "%s taskq",
-	    device_get_nameunit(sc->sc_dev));
-
-	rt2860_sysctl_attach(sc);
-
-	if (bootverbose)
-		ieee80211_announce(ic);
-
-	return 0;
-
-fail:
-
-	/* free Tx and Rx rings */
-	for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
-		rt2860_free_tx_ring(sc, &sc->tx_ring[i]);
-
-	rt2860_free_rx_ring(sc, &sc->rx_ring);
-
-	mtx_destroy(&sc->sc_mtx);
-
-	if (sc->mem != NULL)
-		bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem);
-
-	if (sc->irq != NULL)
-		bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq);
-
-	return error;
-}
-
-/*
- * rt2860_detach
- */
-int rt2860_detach(void *xsc)
-{
-	struct rt2860_softc *sc = xsc;
-	struct ifnet *ifp;
-	struct ieee80211com *ic;
-	int i;
-
-	ifp = sc->sc_ifp;
-	ic = ifp->if_l2com;
-
-	RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
-		"%s: detaching\n",
-		device_get_nameunit(sc->sc_dev));
-
-	RT2860_SOFTC_LOCK(sc);
-
-	ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
-
-	callout_stop(&sc->periodic_ch);
-	callout_stop(&sc->tx_watchdog_ch);
-
-	taskqueue_drain(sc->taskqueue, &sc->rx_done_task);
-	taskqueue_drain(sc->taskqueue, &sc->tx_done_task);
-	taskqueue_drain(sc->taskqueue, &sc->fifo_sta_full_task);
-	taskqueue_drain(sc->taskqueue, &sc->periodic_task);
-
-	/* free Tx and Rx rings */
-	for (i = 0; i < RT2860_SOFTC_TX_RING_COUNT; i++)
-		rt2860_free_tx_ring(sc, &sc->tx_ring[i]);
-
-	rt2860_free_rx_ring(sc, &sc->rx_ring);
-
-	RT2860_SOFTC_UNLOCK(sc);
-
-	ieee80211_ifdetach(ic);
-
-	if_free(ifp);
-
-	taskqueue_free(sc->taskqueue);
-
-	mtx_destroy(&sc->sc_mtx);
-
-	return 0;
-}
-
-/*
- * rt2860_shutdown
- */
-void
-rt2860_shutdown(void *xsc)
-{
-	struct rt2860_softc *sc = xsc;
-
-	RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
-		"%s: shutting down\n",
-		device_get_nameunit(sc->sc_dev));
-
-	rt2860_stop(sc);
-
-	sc->flags &= ~RT2860_SOFTC_FLAGS_UCODE_LOADED;
-
-	return;
-}
-
-/*
- * rt2860_suspend
- */
-void
-rt2860_suspend(void *xsc)
-{
-	struct rt2860_softc *sc = xsc;
-
-	RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
-		"%s: suspending\n",
-		device_get_nameunit(sc->sc_dev));
-
-	rt2860_stop(sc);
-
-	sc->flags &= ~RT2860_SOFTC_FLAGS_UCODE_LOADED;
-
-	return;
-}
-
-/*
- * rt2860_resume
- */
-void
-rt2860_resume(void *xsc)
-{
-	struct rt2860_softc *sc = xsc;
-	struct ifnet *ifp;
-
-	ifp = sc->sc_ifp;
-
-	RT2860_DPRINTF(sc, RT2860_DEBUG_ANY,
-		"%s: resuming\n",
-		device_get_nameunit(sc->sc_dev));
-
-	if (ifp->if_flags & IFF_UP)
-		rt2860_init(sc);
-
-	return;
-}
-
-/*
- * rt2860_init_channels
- */
-static void
-rt2860_init_channels(struct rt2860_softc *sc)
-{
-	struct ifnet *ifp;
-	struct ieee80211com *ic;
-	struct ieee80211_channel *c;
-	int i, flags;
***The diff for this file has been truncated for email.***
=======================================
--- /rt2860reg.h	Tue Mar 13 05:46:45 2012
+++ /dev/null
@@ -1,562 +0,0 @@
-
-/*-
- * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar at gmail.com>
- * Copyright (c) 2009 Damien Bergamini <damien.bergamini at 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.
- */
-
-#ifndef _RT2860_REG_H_
-#define _RT2860_REG_H_
-
-#define RT2860_REG_PCI_CFG				0x0000
-#define RT2860_REG_EEPROM_CSR				0x0004
-#define RT2860_REG_PCI_MCU_CSR				0x0008
-#define RT2860_REG_PCI_SYS_CSR				0x000c
-#define RT2860_REG_PCIE_JTAG				0x0010
-
-#define RT2860_REG_SCHDMA_INT_STATUS			0x0200
-#define RT2860_REG_SCHDMA_INT_MASK				0x0204
-#define RT2860_REG_SCHDMA_WPDMA_GLO_CFG			0x0208
-#define RT2860_REG_SCHDMA_WPDMA_RST_IDX			0x020c
-#define RT2860_REG_SCHDMA_DELAY_INT_CFG			0x0210
-#define RT2860_REG_SCHDMA_WMM_AIFSN_CFG			0x0214
-#define RT2860_REG_SCHDMA_WMM_CWMIN_CFG			0x0218
-#define RT2860_REG_SCHDMA_WMM_CWMAX_CFG			0x021c
-#define RT2860_REG_SCHDMA_WMM_TXOP0_CFG    		0x0220
-#define RT2860_REG_SCHDMA_WMM_TXOP1_CFG    		0x0224
-#define RT2860_REG_SCHDMA_GPIO_CTRL_CFG    		0x0228
-#define RT2860_REG_SCHDMA_RX_BASE_PTR			0x0290
-#define RT2860_REG_SCHDMA_RX_MAX_CNT			0x0294
-#define RT2860_REG_SCHDMA_RX_CALC_IDX			0x0298
-#define RT2860_REG_SCHDMA_RX_DRX_IDX			0x029c
-#define RT2860_REG_SCHDMA_TX_BASE_PTR(qid)		(0x0230 + (qid) * 16)
-#define RT2860_REG_SCHDMA_TX_MAX_CNT(qid)		(0x0234 + (qid) * 16)
-#define RT2860_REG_SCHDMA_TX_CTX_IDX(qid)		(0x0238 + (qid) * 16)
-#define RT2860_REG_SCHDMA_TX_DTX_IDX(qid)		(0x023c + (qid) * 16)
-#define RT2860_REG_SCHDMA_US_CYC_CNT			0x02a4
-
-#define RT2860_REG_PBF_SYS_CTRL				0x0400
-#define RT2860_REG_PBF_HOST_CMD				0x0404
-#define RT2860_REG_PBF_CFG				0x0408
-#define RT2860_REG_PBF_MAX_PCNT				0x040c
-#define RT2860_REG_PBF_BUF_CTRL				0x0410
-#define RT2860_REG_PBF_MCU_INT_STA			0x0414
-#define RT2860_REG_PBF_MCU_INT_ENA			0x0418
-#define RT2860_REG_PBF_TX0Q_IO				0x041c
-#define RT2860_REG_PBF_TX1Q_IO				0x0420
-#define RT2860_REG_PBF_TX2Q_IO				0x0424
-#define RT2860_REG_PBF_RX0Q_IO				0x0428
-#define RT2860_REG_PBF_BCN_OFFSET0			0x042c
-#define RT2860_REG_PBF_BCN_OFFSET1			0x0430
-#define RT2860_REG_PBF_TXRXQ_STA			0x0434
-#define RT2860_REG_PBF_TXRXQ_PCNT			0x0438
-#define RT2860_REG_PBF_DBG				0x043c
-#define RT2860_REG_PBF_CAP_CTRL				0x0440
-
-#define RT2872_REG_RF_CSR_CFG				0x500
-#define RT2872_REG_RF_SETTING				0x504
-#define RT2872_REG_RF_TEST_CONTROL			0x508
-
-#define RT2860_REG_MAC_CSR0				0x1000
-#define RT2860_REG_SYS_CTRL				0x1004
-#define RT2860_REG_ADDR_DW0				0x1008
-#define RT2860_REG_ADDR_DW1				0x100c
-#define RT2860_REG_BSSID_DW0				0x1010
-#define RT2860_REG_BSSID_DW1				0x1014
-#define RT2860_REG_MAX_LEN_CFG				0x1018
-#define RT2860_REG_BBP_CSR_CFG				0x101c
-#define RT2860_REG_RF_CSR_CFG0				0x1020
-#define RT2860_REG_LED_CFG				0x102c
-#define RT2860_REG_AMPDU_MAX_LEN_20M1S			0x1030
-#define RT2860_REG_AMPDU_MAX_LEN_20M2S			0x1034
-#define RT2860_REG_AMPDU_MAX_LEN_40M1S			0x1038
-#define RT2860_REG_AMPDU_MAX_LEN_40M2S			0x103c
-#define RT2860_REG_AMPDU_BA_WINSIZE			0x1040
-
-#define RT2860_REG_XIFS_TIME_CFG             		0x1100
-#define RT2860_REG_BKOFF_SLOT_CFG			0x1104
-#define RT2860_REG_NAV_TIME_CFG				0x1108
-#define RT2860_REG_CH_TIME_CFG				0x110c
-#define RT2860_REG_PBF_LIFE_TIMER			0x1110
-#define RT2860_REG_BCN_TIME_CFG				0x1114
-#define RT2860_REG_TBTT_SYNC_CFG			0x1118
-#define RT2860_REG_TSF_TIMER_DW0			0x111c
-#define RT2860_REG_TSF_TIMER_DW1			0x1120
-#define RT2860_REG_TBTT_TIMER				0x1124
-#define RT2860_REG_INT_TIMER				0x1128
-#define RT2860_REG_INT_TIMER_EN				0x112c
-#define RT2860_REG_CH_IDLE_STA				0x1130
-
-#define RT2860_REG_STATUS_CFG				0x1200
-#define RT2860_REG_PWR_PIN_CFG				0x1204
-#define RT2860_REG_AUTO_WAKEUP_CFG			0x1208
-
-#define RT2860_REG_TX_EDCA_AC_CFG(aci)			(0x1300 + (aci) * 4)
-#define RT2860_REG_TX_EDCA_TID_AC_MAP			0x1310
-#define RT2860_REG_TX_PWR_CFG(ridx)			(0x1314 + (ridx) * 4)
-#define RT2860_REG_TX_PIN_CFG				0x1328
-#define RT2860_REG_TX_BAND_CFG				0x132c
-#define RT2860_REG_TX_SW_CFG0				0x1330
-#define RT2860_REG_TX_SW_CFG1				0x1334
-#define RT2860_REG_TX_SW_CFG2				0x1338
-#define RT2860_REG_TX_TXOP_THRES_CFG			0x133c
-#define RT2860_REG_TX_TXOP_CTRL_CFG			0x1340
-#define RT2860_REG_TX_RTS_CFG				0x1344
-#define RT2860_REG_TX_TIMEOUT_CFG			0x1348
-#define RT2860_REG_TX_RTY_CFG				0x134c
-#define RT2860_REG_TX_LINK_CFG				0x1350
-#define RT2860_REG_TX_HT_FBK_CFG0			0x1354
-#define RT2860_REG_TX_HT_FBK_CFG1			0x1358
-#define RT2860_REG_TX_LG_FBK_CFG0			0x135c
-#define RT2860_REG_TX_LG_FBK_CFG1			0x1360
-#define RT2860_REG_TX_CCK_PROT_CFG			0x1364
-#define RT2860_REG_TX_OFDM_PROT_CFG			0x1368
-#define RT2860_REG_TX_MM20_PROT_CFG			0x136c
-#define RT2860_REG_TX_MM40_PROT_CFG			0x1370
-#define RT2860_REG_TX_GF20_PROT_CFG			0x1374
-#define RT2860_REG_TX_GF40_PROT_CFG			0x1378
-#define RT2860_REG_TX_EXP_CTS_TIME			0x137c
-#define RT2860_REG_TX_EXP_ACK_TIME			0x1380
-
-#define RT2860_REG_RX_FILTER_CFG			0x1400
-#define RT2860_REG_AUTO_RSP_CFG				0x1404
-#define RT2860_REG_LEGACY_BASIC_RATE			0x1408
-#define RT2860_REG_HT_BASIC_RATE			0x140c
-#define RT2860_REG_HT_CTRL_CFG				0x1410
-#define RT2860_REG_SIFS_COST_CFG			0x1414
-#define RT2860_REG_RX_PARSER_CFG			0x1418
-
-#define RT2860_REG_TX_SEC_CNT0				0x1500
-#define RT2860_REG_RX_SEC_CNT0				0x1504
-#define RT2860_REG_CCMP_FC_MUTE				0x1508
-
-#define RT2860_REG_HCCAPSMP_TXOP_HLDR_ADDR0		0x1600
-#define RT2860_REG_HCCAPSMP_TXOP_HLDR_ADDR1		0x1604
-#define RT2860_REG_HCCAPSMP_TXOP_HLDR_ET		0x1608
-#define RT2860_REG_HCCAPSMP_QOS_CFPOLL_RA_DW0		0x160c
-#define RT2860_REG_HCCAPSMP_QOS_CFPOLL_A1_DW1		0x1610
-#define RT2860_REG_HCCAPSMP_QOS_CFPOLL_QC		0x1614
-
-#define RT2860_REG_RX_STA_CNT0				0x1700
-#define RT2860_REG_RX_STA_CNT1				0x1704
-#define RT2860_REG_RX_STA_CNT2				0x1708
-#define RT2860_REG_TX_STA_CNT0				0x170c
-#define RT2860_REG_TX_STA_CNT1				0x1710
-#define RT2860_REG_TX_STA_CNT2				0x1714
-#define RT2860_REG_TX_STA_FIFO				0x1718
-#define RT2860_REG_TX_AGG_CNT				0x171c
-#define RT2860_REG_TX_AGG_CNT0				0x1720
-#define RT2860_REG_TX_AGG_CNT1				0x1724
-#define RT2860_REG_TX_AGG_CNT2				0x1728
-#define RT2860_REG_TX_AGG_CNT3				0x172c
-#define RT2860_REG_TX_AGG_CNT4				0x1730
-#define RT2860_REG_TX_AGG_CNT5				0x1734
-#define RT2860_REG_TX_AGG_CNT6				0x1738
-#define RT2860_REG_TX_AGG_CNT7				0x173c
-#define RT2860_REG_TXRX_MPDU_DEN_CNT			0x1740
-
-#define RT2860_REG_WCID(wcid)				(0x1800 + (wcid) * 8)
-#define RT2860_REG_PKEY(wcid)				(0x4000 + (wcid) * 32)
-#define RT2860_REG_IVEIV(wcid)				(0x6000 + (wcid) * 8)
-#define RT2860_REG_WCID_ATTR(wcid)			(0x6800 + (wcid) * 4)
-#define RT2860_REG_SKEY(vap, kidx)					\
-					(0x6c00 + ((vap) * 4 + (kidx)) * 32)
-#define RT2860_REG_SKEY_MODE(vap)					\
-					(0x7000 + ((vap) / 2) * 4)
-#define RT2860_REG_SKEY_MODE_0_7			0x7000
-
-#define RT2860_REG_MCU_UCODE_BASE			0x2000
-
-#define RT2860_REG_H2M_HOST_CMD				0x0404
-#define RT2860_REG_H2M_MAILBOX				0x7010
-#define RT2860_REG_H2M_MAILBOX_CID			0x7014
-#define RT2860_REG_H2M_MAILBOX_STATUS			0x701c
-#define RT2860_REG_H2M_MAILBOX_BBP_AGENT		0x7028
-
-#define RT2860_REG_BEACON_BASE(vap)					(0x7800 + (vap) * 512)
-
-/* RT3070 registers */
-#define RT3070_RF_CSR_CFG				0x0500
-#define RT3070_EFUSE_CTRL				0x0580
-#define RT3070_EFUSE_DATA0				0x0590
-#define RT3070_EFUSE_DATA1				0x0594
-#define RT3070_EFUSE_DATA2				0x0598
-#define RT3070_EFUSE_DATA3				0x059c
-#define RT3090_OSC_CTRL					0x05a4
-#define RT3070_LDO_CFG0					0x05d4
-#define RT3070_GPIO_SWITCH				0x05dc
-
-#define RT3090_AUX_CTRL					0x010c
-#define RT3070_OPT_14					0x0114
-
-/* possible flags for register RF_CSR_CFG */
-#define RT3070_RF_KICK					(1 << 17)
-#define RT3070_RF_WRITE					(1 << 16)
-
-/* possible flags for register EFUSE_CTRL */
-#define RT3070_SEL_EFUSE				(1 << 31)
-#define RT3070_EFSROM_KICK				(1 << 30)
-#define RT3070_EFSROM_AIN_MASK				0x03ff0000
-#define RT3070_EFSROM_AIN_SHIFT				16
-#define RT3070_EFSROM_MODE_MASK				0x000000c0
-#define RT3070_EFUSE_AOUT_MASK				0x0000003f
-
-/* possible flags for RT3020 RF register 1 */
-#define RT3070_RF_BLOCK					(1 << 0)
-#define RT3070_RX0_PD					(1 << 2)
-#define RT3070_TX0_PD					(1 << 3)
-#define RT3070_RX1_PD					(1 << 4)
-#define RT3070_TX1_PD					(1 << 5)
-#define RT3070_RX2_PD					(1 << 6)
-#define RT3070_TX2_PD					(1 << 7)
-
-/* possible flags for RT3020 RF register 1 */
-#define RT3070_RF_BLOCK					(1 << 0)
-#define RT3070_RX0_PD					(1 << 2)
-#define RT3070_TX0_PD					(1 << 3)
-#define RT3070_RX1_PD					(1 << 4)
-#define RT3070_TX1_PD					(1 << 5)
-#define RT3070_RX2_PD					(1 << 6)
-#define RT3070_TX2_PD					(1 << 7)
-
-/* possible flags for RT3020 RF register 7 */
-#define RT3070_TUNE					(1 << 0)
-
-/* possible flags for RT3020 RF register 15 */
-#define RT3070_TX_LO2					(1 << 3)
-
-/* possible flags for RT3020 RF register 17 */
-#define RT3070_TX_LO1					(1 << 3)
-
-/* possible flags for RT3020 RF register 20 */
-#define RT3070_RX_LO1					(1 << 3)
-
-/* possible flags for RT3020 RF register 21 */
-#define RT3070_RX_LO2					(1 << 3)
-#define RT3070_RX_CTB					(1 << 7)
-
-/* possible flags for RT3020 RF register 22 */
-#define RT3070_BB_LOOPBACK				(1 << 0)
-
-/* possible flags for RT3053 RF register 1 */
-#define RT3593_VCO					(1 << 0)
-
-/* possible flags for RT3053 RF register 2 */
-#define RT3593_RESCAL					(1 << 7)
-
-/* possible flags for RT3053 RF register 3 */
-#define RT3593_VCOCAL					(1 << 7)
-
-/* possible flags for RT3053 RF register 6 */
-#define RT3593_VCO_IC					(1 << 6)
-
-/* possible flags for RT3053 RF register 20 */
-#define RT3593_LDO_PLL_VC_MASK				0x0e
-#define RT3593_LDO_RF_VC_MASK				0xe0
-
-/* possible flags for RT3053 RF register 22 */
-#define RT3593_CP_IC_MASK				0xe0
-#define RT3593_CP_IC_SHIFT				5
-
-/* possible flags for RT3053 RF register 46 */
-#define RT3593_RX_CTB					(1 << 5)
-
-#define RT3090_DEF_LNA					10
-
-
-#define RT2860_REG_RF_R1				0
-#define RT2860_REG_RF_R2				1
-#define RT2860_REG_RF_R3				2
-#define RT2860_REG_RF_R4				3
-
-/*
- * RT2860_REG_EEPROM_CSR flags
- */
-#define RT2860_REG_EERL					(1 << 7)
-#define RT2860_REG_EEDO					(1 << 3)
-#define RT2860_REG_EEDI					(1 << 2)
-#define RT2860_REG_EECS					(1 << 1)
-#define RT2860_REG_EESK					(1 << 0)
-#define RT2860_REG_EEOP_READ				0x6
-
-/*
- * RT2860_REG_SCHDMA_INT_STATUS
- * RT2860_REG_SCHDMA_INT_MASK flags
- */
-#define RT2860_REG_INT_TX_COHERENT			(1 << 17)
-#define RT2860_REG_INT_RX_COHERENT			(1 << 16)
-#define RT2860_REG_INT_GP_TIMER				(1 << 15)
-#define RT2860_REG_INT_AUTO_WAKEUP			(1 << 14)
-#define RT2860_REG_INT_FIFO_STA_FULL			(1 << 13)
-#define RT2860_REG_INT_PRE_TBTT				(1 << 12)
-#define RT2860_REG_INT_TBTT				(1 << 11)
-#define RT2860_REG_INT_TXRX_COHERENT			(1 << 10)
-#define RT2860_REG_INT_MCU_CMD				(1 << 9)
-#define RT2860_REG_INT_TX_MGMT_DONE			(1 << 8)
-#define RT2860_REG_INT_TX_HCCA_DONE			(1 << 7)
-#define RT2860_REG_INT_TX_AC3_DONE			(1 << 6)
-#define RT2860_REG_INT_TX_AC2_DONE			(1 << 5)
-#define RT2860_REG_INT_TX_AC1_DONE			(1 << 4)
-#define RT2860_REG_INT_TX_AC0_DONE			(1 << 3)
-#define RT2860_REG_INT_RX_DONE				(1 << 2)
-#define RT2860_REG_INT_TX_DELAY_DONE			(1 << 1)
-#define RT2860_REG_INT_RX_DELAY_DONE			(1 << 0)
-
-/*
- * RT2860_REG_SCHDMA_WPDMA_GLO_CFG flags
- */
-#define RT2860_REG_TX_WB_DDONE				(1 << 6)
-#define RT2860_REG_RX_DMA_BUSY				(1 << 3)
-#define RT2860_REG_RX_DMA_ENABLE			(1 << 2)
-#define RT2860_REG_TX_DMA_BUSY				(1 << 1)
-#define RT2860_REG_TX_DMA_ENABLE			(1 << 0)
-#define RT2860_REG_WPDMA_BT_SIZE_SHIFT			4
-#define RT2860_REG_WPDMA_BT_SIZE16			0
-#define RT2860_REG_WPDMA_BT_SIZE32			1
-#define RT2860_REG_WPDMA_BT_SIZE64			2
-#define RT2860_REG_WPDMA_BT_SIZE128			3
-
-/*
- * RT2860_REG_SCHDMA_WPDMA_RST_IDX flags
- */
-#define RT2860_REG_RST_IDX_RX						(1 << 16)
-#define RT2860_REG_RST_IDX_TX_MGMT					(1 << 5)
-#define RT2860_REG_RST_IDX_TX_HCCA					(1 << 4)
-#define RT2860_REG_RST_IDX_TX_AC3					(1 << 3)
-#define RT2860_REG_RST_IDX_TX_AC2					(1 << 2)
-#define RT2860_REG_RST_IDX_TX_AC1					(1 << 1)
-#define RT2860_REG_RST_IDX_TX_AC0					(1 << 0)
-
-/*
- * RT2860_REG_SCHDMA_DELAY_INT_CFG flags
- */
-#define RT2860_REG_INT_TX_DELAY_ENABLE				(1 << 31)
-#define RT2860_REG_INT_TX_MAX_PINT_SHIFT			24
-#define RT2860_REG_INT_TX_MAX_PINT_MASK				0x7
-#define RT2860_REG_INT_TX_MAX_PTIME_SHIFT			16
-#define RT2860_REG_INT_TX_MAX_PTIME_MASK			0x8
-#define RT2860_REG_INT_RX_DELAY_ENABLE				(1 << 15)
-#define RT2860_REG_INT_RX_MAX_PINT_SHIFT			8
-#define RT2860_REG_INT_RX_MAX_PINT_MASK				0x7
-#define RT2860_REG_INT_RX_MAX_PTIME_SHIFT			0
-#define RT2860_REG_INT_RX_MAX_PTIME_MASK			0x8
-
-/*
- * RT2860_REG_PBF_SYS_CTRL flags
- */
-#define RT2860_REG_HST_PM_SEL						(1 << 16)
-#define RT2860_REG_MCU_READY						(1 << 7)
-#define RT2860_REG_MCU_RESET						(1 << 0)
-
-/*
- * RT2860_REG_PBF_TXRXQ_PCNT flags
- */
-#define RT2860_REG_RXQ_PCNT_SHIFT					24
-#define RT2860_REG_RXQ_PCNT_MASK					0xff
-#define RT2860_REG_TX2Q_PCNT_SHIFT					16
-#define RT2860_REG_TX2Q_PCNT_MASK					0xff
-#define RT2860_REG_TX1Q_PCNT_SHIFT					8
-#define RT2860_REG_TX1Q_PCNT_MASK					0xff
-#define RT2860_REG_TX0Q_PCNT_SHIFT					0
-#define RT2860_REG_TX0Q_PCNT_MASK					0xff
-
-/*
- * RT2860_REG_SYS_CTRL flags
- */
-#define RT2860_REG_RX_ENABLE						(1 << 3)
-#define RT2860_REG_TX_ENABLE						(1 << 2)
-#define RT2860_REG_BBP_HRST							(1 << 1)
-#define RT2860_REG_MAC_SRST							(1 << 0)
-
-/*
- * RT2872_REG_RF_CSR_CFG flags
- */
-#define RT2872_REG_RF_CSR_BUSY						(1 << 17)
-#define RT2872_REG_RF_CSR_KICK						(1 << 17)
-#define RT2872_REG_RF_CSR_WRITE						(1 << 16)
-#define RT2872_REG_RF_ID_SHIFT						8
-#define RT2872_REG_RF_ID_MASK						0x1f
-#define RT2872_REG_RF_VAL_SHIFT						0
-#define RT2872_REG_RF_VAL_MASK						0xff
-
-/*
- * RT2860_REG_BBP_CSR_CFG flags
- */
-#define RT2860_REG_BBP_RW_MODE_PARALLEL					(1 << 19)
-#define RT2860_REG_BBP_PAR_DUR						(1 << 19)
-#define RT2860_REG_BBP_CSR_BUSY						(1 << 17)
-#define RT2860_REG_BBP_CSR_KICK						(1 << 17)
-#define RT2860_REG_BBP_CSR_READ						(1 << 16)
-#define RT2860_REG_BBP_REG_SHIFT					8
-#define RT2860_REG_BBP_REG_MASK						0xff
-#define RT2860_REG_BBP_VAL_SHIFT					0
-#define RT2860_REG_BBP_VAL_MASK						0xff
-
-/*
- * RT2860_REG_RF_CSR_CFG0 flags
- */
-#define RT2860_REG_RF_BUSY							(1 << 31)
-
-/*
- * RT2860_REG_BCN_TIME_CFG flags
- */
-#define RT2860_REG_BCN_TX_ENABLE					(1 << 20)
-#define RT2860_REG_TBTT_TIMER_ENABLE				(1 << 19)
-#define RT2860_REG_TSF_TIMER_ENABLE					(1 << 16)
-#define RT2860_REG_TSF_SYNC_MODE_SHIFT				17
-#define RT2860_REG_TSF_SYNC_MODE_MASK				0x3
-#define RT2860_REG_TSF_SYNC_MODE_DISABLE			0
-#define RT2860_REG_TSF_SYNC_MODE_STA				1
-#define RT2860_REG_TSF_SYNC_MODE_IBSS				2
-#define RT2860_REG_TSF_SYNC_MODE_HOSTAP				3
-
-/*
- * RT2860_REG_STATUS_CFG flags
- */
-#define RT2860_REG_STATUS_RX_BUSY					(1 << 1)
-#define RT2860_REG_STATUS_TX_BUSY					(1 << 0)
-
-/*
- * RT2860_REG_TX_PIN_CFG flags
- */
-#define RT2860_REG_TRSW_ENABLE						(1 << 18)
-#define RT2860_REG_RFTR_ENABLE						(1 << 16)
-#define RT2860_REG_LNA_PE_G1_ENABLE					(1 << 11)
-#define RT2860_REG_LNA_PE_A1_ENABLE					(1 << 10)
-#define RT2860_REG_LNA_PE_G0_ENABLE					(1 << 9)
-#define RT2860_REG_LNA_PE_A0_ENABLE					(1 << 8)
-#define RT2860_REG_PA_PE_G1_ENABLE					(1 << 3)
-#define RT2860_REG_PA_PE_A1_ENABLE					(1 << 2)
-#define RT2860_REG_PA_PE_G0_ENABLE					(1 << 1)
-#define RT2860_REG_PA_PE_A0_ENABLE					(1 << 0)
-
-/*
- * RT2860_REG_TX_BAND_CFG flags
- */
-#define RT2860_REG_TX_BAND_BG						(1 << 2)
-#define RT2860_REG_TX_BAND_A						(1 << 1)
-#define RT2860_REG_TX_BAND_HT40_ABOVE				(1 << 0)
-#define RT2860_REG_TX_BAND_HT40_BELOW				(0 << 0)
-
-/*
- * RT2860_REG_TX_RTS_CFG flags
- */
-#define RT2860_REG_TX_RTS_THRESHOLD_SHIFT			8
-#define RT2860_REG_TX_RTS_THRESHOLD_MASK			0xffff
-
-/*
- * RT2860_REG_TX_CCK_PROT_CFG
- * RT2860_REG_TX_OFDM_PROT_CFG
- * RT2860_REG_TX_MM20_PROT_CFG
- * RT2860_REG_TX_MM40_PROT_CFG
- * RT2860_REG_TX_GF20_PROT_CFG
- * RT2860_REG_TX_GF40_PROT_CFG flags
- */
-#define RT2860_REG_RTSTH_ENABLE						(1 << 26)
-#define RT2860_REG_TXOP_ALLOW_GF40					(1 << 25)
-#define RT2860_REG_TXOP_ALLOW_GF20					(1 << 24)
-#define RT2860_REG_TXOP_ALLOW_MM40					(1 << 23)
-#define RT2860_REG_TXOP_ALLOW_MM20					(1 << 22)
-#define RT2860_REG_TXOP_ALLOW_OFDM					(1 << 21)
-#define RT2860_REG_TXOP_ALLOW_CCK					(1 << 20)
-#define RT2860_REG_TXOP_ALLOW_ALL					(0x3f << 20)
-#define RT2860_REG_PROT_NAV_NONE					(0 << 18)
-#define RT2860_REG_PROT_NAV_SHORT					(1 << 18)
-#define RT2860_REG_PROT_NAV_LONG					(2 << 18)
-#define RT2860_REG_PROT_CTRL_NONE					(0 << 16)
-#define RT2860_REG_PROT_CTRL_RTS_CTS				(1 << 16)
-#define RT2860_REG_PROT_CTRL_CTS					(2 << 16)
-#define RT2860_REG_PROT_PHYMODE_SHIFT				14
-#define RT2860_REG_PROT_PHYMODE_MASK				0x3
-#define RT2860_REG_PROT_PHYMODE_CCK					0
-#define RT2860_REG_PROT_PHYMODE_OFDM				1
-#define RT2860_REG_PROT_MCS_SHIFT					0
-#define RT2860_REG_PROT_MCS_MASK					0x7f
-
-/*
- * RT2860_REG_RX_FILTER_CFG flags
- */
-#define RT2860_REG_RX_FILTER_DROP_CTRL_RSV			(1 << 16)
-#define RT2860_REG_RX_FILTER_DROP_BAR				(1 << 15)
-#define RT2860_REG_RX_FILTER_DROP_BA				(1 << 14)
-#define RT2860_REG_RX_FILTER_DROP_PSPOLL			(1 << 13)
-#define RT2860_REG_RX_FILTER_DROP_RTS				(1 << 12)
-#define RT2860_REG_RX_FILTER_DROP_CTS				(1 << 11)
-#define RT2860_REG_RX_FILTER_DROP_ACK				(1 << 10)
-#define RT2860_REG_RX_FILTER_DROP_CFEND				(1 << 9)
-#define RT2860_REG_RX_FILTER_DROP_CFACK				(1 << 8)
-#define RT2860_REG_RX_FILTER_DROP_DUPL				(1 << 7)
-#define RT2860_REG_RX_FILTER_DROP_BCAST				(1 << 6)
-#define RT2860_REG_RX_FILTER_DROP_MCAST				(1 << 5)
-#define RT2860_REG_RX_FILTER_DROP_VER_ERR			(1 << 4)
-#define RT2860_REG_RX_FILTER_DROP_NOT_MYBSS			(1 << 3)
-#define RT2860_REG_RX_FILTER_DROP_UC_NOME			(1 << 2)
-#define RT2860_REG_RX_FILTER_DROP_PHY_ERR			(1 << 1)
-#define RT2860_REG_RX_FILTER_DROP_CRC_ERR			(1 << 0)
-
-/*
- * RT2860_REG_AUTO_RSP_CFG flags
- */
-#define RT2860_REG_CCK_SHORT_ENABLE					(1 << 4)
-
-/*
- * RT2860_REG_TX_STA_FIFO flags
- */
-#define RT2860_REG_TX_STA_FIFO_MCS_SHIFT			16
-#define RT2860_REG_TX_STA_FIFO_MCS_MASK				0x7f
-#define RT2860_REG_TX_STA_FIFO_WCID_SHIFT			8
-#define RT2860_REG_TX_STA_FIFO_WCID_MASK			0xff
-#define RT2860_REG_TX_STA_FIFO_PID_SHIFT			1
-#define RT2860_REG_TX_STA_FIFO_PID_MASK				0xf
-#define RT2860_REG_TX_STA_FIFO_ACK_REQ				(1 << 7)
-#define RT2860_REG_TX_STA_FIFO_AGG					(1 << 6)
-#define RT2860_REG_TX_STA_FIFO_TX_OK				(1 << 5)
-#define RT2860_REG_TX_STA_FIFO_VALID				(1 << 0)
-
-/*
- * RT2860_REG_WCID_ATTR flags
- */
-#define RT2860_REG_VAP_SHIFT						4
-#define RT2860_REG_VAP_MASK							0x7
-#define RT2860_REG_CIPHER_MODE_SHIFT				1
-#define RT2860_REG_CIPHER_MODE_MASK					0x7
-#define RT2860_REG_CIPHER_MODE_NONE					0
-#define RT2860_REG_CIPHER_MODE_WEP40				1
-#define RT2860_REG_CIPHER_MODE_WEP104				2
-#define RT2860_REG_CIPHER_MODE_TKIP					3
-#define RT2860_REG_CIPHER_MODE_AES_CCMP				4
-#define RT2860_REG_CIPHER_MODE_CKIP40				5
-#define RT2860_REG_CIPHER_MODE_CKIP104				6
-#define RT2860_REG_CIPHER_MODE_CKIP128				7
-#define RT2860_REG_PKEY_ENABLE						(1 << 0)
-
-/*
- * RT2860_REG_H2M_MAILBOX flags
- */
-#define RT2860_REG_H2M_BUSY							(1 << 24)
-#define RT2860_REG_H2M_TOKEN_POWERSAVE				1
-#define RT2860_REG_H2M_TOKEN_RADIOOFF				2
-#define RT2860_REG_H2M_TOKEN_WAKEUP					3
-#define RT2860_REG_H2M_TOKEN_NO_INTR				0xff
-
-/*
- * RT2860_REG_H2M_MAILBOX_CID flags
- */
-#define RT2860_REG_H2M_CID0_SHIFT					0
-#define RT2860_REG_H2M_CID1_SHIFT					8
-#define RT2860_REG_H2M_CID2_SHIFT					16
-#define RT2860_REG_H2M_CID3_SHIFT					24
-#define RT2860_REG_H2M_CID_MASK						0xff
-
-#endif /* #ifndef _RT2860_REG_H_ */
=======================================
--- /rt2860ucode.h	Tue Mar 13 05:46:45 2012
+++ /dev/null
@@ -1,2104 +0,0 @@
-
-/*
- Copyright (c) 2007, Ralink Technology Corporation
- All rights reserved.
-
- Redistribution.  Redistribution and use in binary form, without
- modification, are permitted provided that the following conditions are
- met:
-
- 	* Redistributions must reproduce the above copyright notice and the
- 	following disclaimer in the documentation and/or other materials
- 	provided with the distribution.
- 	* Neither the name of Ralink Technology Corporation nor the names of its
- 	suppliers may be used to endorse or promote products derived from this
- 	software without specific prior written permission.
- 	* No reverse engineering, decompilation, or disassembly of this software
- 	is permitted.
-
- Limited patent license. Ralink Technology Corporation grants a world-wide,
- royalty-free, non-exclusive license under patents it now or hereafter
- owns or controls to make, have made, use, import, offer to sell and
- sell ("Utilize") this software, but solely to the extent that any
- such patent is necessary to Utilize the software alone, or in
- combination with an operating system licensed under an approved Open
- Source license as listed by the Open Source Initiative at
- http://opensource.org/licenses.  The patent license shall not apply to
- any other combinations which include this software.  No hardware per
- se is licensed hereunder.
-
- DISCLAIMER.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- DAMAGE.
-*/
-
-#ifndef _RT2860_UCODE_H_
-#define _RT2860_UCODE_H_
-
-/*
- * RT2860 microcode v26
- */
-static const uint8_t rt2860_ucode[] =
-{
-	0x02, 0x03, 0x5E, 0x02,
-	0x02, 0xB1, 0x22, 0x22,
-	0xFF, 0xFF, 0xFF, 0x02,
-	0x01, 0x82, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0x02,
-	0x00, 0x1E, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0x02,
-	0x01, 0x33, 0xC0, 0xE0,
-	0xC0, 0xF0, 0xC0, 0x83,
-	0xC0, 0x82, 0xC0, 0xD0,
-	0x75, 0xD0, 0x18, 0xC2,
-	0xAF, 0x30, 0x45, 0x03,
-	0x12, 0x10, 0x09, 0x90,
-	0x04, 0x16, 0xE0, 0x30,
-	0xE3, 0x03, 0x74, 0x08,
-	0xF0, 0x90, 0x04, 0x14,
-	0xE0, 0x20, 0xE7, 0x03,
-	0x02, 0x00, 0xCB, 0x74,
-	0x80, 0xF0, 0x90, 0x70,
-	0x12, 0xE0, 0xF5, 0x2F,
-	0x90, 0x04, 0x04, 0xE0,
-	0x24, 0xCF, 0x60, 0x30,
-	0x14, 0x60, 0x42, 0x24,
-	0xE2, 0x60, 0x47, 0x14,
-	0x60, 0x55, 0x24, 0x21,
-	0x70, 0x60, 0xE5, 0x55,
-	0x24, 0xFE, 0x60, 0x07,
-	0x14, 0x60, 0x08, 0x24,
-	0x02, 0x70, 0x08, 0x7D,
-	0x01, 0x80, 0x28, 0x7D,
-	0x02, 0x80, 0x24, 0x90,
-	0x70, 0x10, 0xE0, 0xF5,
-	0x50, 0x85, 0x2F, 0x40,
-	0xD2, 0x01, 0x80, 0x3E,
-	0xE5, 0x55, 0x64, 0x03,
-	0x60, 0x04, 0xE5, 0x55,
-	0x70, 0x04, 0x7D, 0x02,
-	0x80, 0x09, 0x85, 0x2F,
-	0x41, 0xD2, 0x02, 0x80,
-	0x29, 0xAD, 0x55, 0xAF,
-	0x2F, 0x12, 0x02, 0x8D,
-	0x80, 0x20, 0x90, 0x70,
-	0x10, 0xE0, 0xF5, 0x47,
-	0x90, 0x70, 0x11, 0xE0,
-	0xF5, 0x44, 0x12, 0x10,
-	0x25, 0x80, 0x06, 0x90,
-	0x70, 0x10, 0xE0, 0xF5,
-	0x45, 0xE4, 0xFD, 0xAF,
-	0x2F, 0x12, 0x02, 0x8D,
-	0xD2, 0x04, 0x90, 0x70,
-	0x13, 0xE4, 0xF0, 0xD2,
-	0xAF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
-	0xD0, 0xE0, 0xF8, 0xD0,
-	0xD0, 0xD0, 0x82, 0xD0,
-	0x83, 0xD0, 0xF0, 0xD0,
-	0xE0, 0x32, 0xC0, 0xE0,
-	0xC0, 0xF0, 0xC0, 0x83,
-	0xC0, 0x82, 0xC0, 0xD0,
-	0x75, 0xD0, 0x10, 0xC2,
-	0xAF, 0x30, 0x45, 0x03,
-	0x12, 0x10, 0x0C, 0x30,
-	0x58, 0x0A, 0xE5, 0x54,
-	0x60, 0x04, 0x15, 0x54,
-	0x80, 0x02, 0xC2, 0x58,
-	0x30, 0x59, 0x0A, 0xE5,
-	0x50, 0x60, 0x04, 0x15,
-	0x50, 0x80, 0x02, 0xC2,
-	0x59, 0xD5, 0x53, 0x07,
-	0x30, 0x60, 0x04, 0x15,
-	0x46, 0xD2, 0x04, 0x30,
-	0x45, 0x03, 0x12, 0x10,
-	0x0F, 0xC2, 0x8D, 0xD2,
-	0xAF, 0xD0, 0xD0, 0xD0,
-	0x82, 0xD0, 0x83, 0xD0,
-	0xF0, 0xD0, 0xE0, 0x32,
-	0x12, 0x02, 0xD3, 0x30,
-	0x45, 0x03, 0x12, 0x10,
-	0x03, 0x30, 0x01, 0x06,
-	0x20, 0x09, 0x03, 0x12,
-	0x10, 0x1C, 0x30, 0x02,
-	0x06, 0x20, 0x0A, 0x03,
-	0x12, 0x10, 0x1F, 0x30,
-	0x03, 0x06, 0x20, 0x0B,
-	0x03, 0x12, 0x10, 0x1F,
-	0x30, 0x04, 0x06, 0x20,
-	0x0C, 0x03, 0x12, 0x10,
-	0x22, 0x20, 0x13, 0x09,
-	0x20, 0x11, 0x06, 0xE5,
-	0x2B, 0x45, 0x2C, 0x60,
-	0x03, 0xD3, 0x80, 0x01,
-	0xC3, 0x92, 0xA9, 0x12,
-	0x02, 0xEC, 0x80, 0xBF,
-	0xC2, 0x43, 0xD2, 0x45,
-	0xE4, 0xF5, 0x20, 0xF5,
-	0x21, 0xF5, 0x53, 0xF5,
-	0x46, 0xF5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, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
-	0xFF, 0xFF, 0xFF, 0xFF,
***The diff for this file has been truncated for email.***
=======================================
--- /rt2860var.h	Tue Mar 13 06:05:03 2012
+++ /dev/null
@@ -1,771 +0,0 @@
-/*-
- * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar at gmail.com>
- * Copyright (c) 2009 Damien Bergamini <damien.bergamini at 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.
- */
-
-#ifndef _RT2860VAR_H_
-#define _RT2860VAR_H_
-
-#include <sys/param.h>
-#include <sys/sysctl.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/taskqueue.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/endian.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-#include <net/if_types.h>
-
-#include <net80211/ieee80211_var.h>
-#include <net80211/ieee80211_input.h>
-#include <net80211/ieee80211_radiotap.h>
-#include <net80211/ieee80211_regdomain.h>
-
-#ifdef RT2860_DEBUG
-
-enum
-{
-	RT2860_DEBUG_EEPROM =	0x00000001,
-	RT2860_DEBUG_RX =	0x00000002,
-	RT2860_DEBUG_TX =	0x00000004,
-	RT2860_DEBUG_INTR =	0x00000008,
-	RT2860_DEBUG_STATE =	0x00000010,
-	RT2860_DEBUG_CHAN =	0x00000020,
-	RT2860_DEBUG_NODE =	0x00000040,
-	RT2860_DEBUG_KEY =	0x00000080,
-	RT2860_DEBUG_PROT =	0x00000100,
-	RT2860_DEBUG_WME =	0x00000200,
-	RT2860_DEBUG_BEACON =	0x00000400,
-	RT2860_DEBUG_BA =	0x00000800,
-	RT2860_DEBUG_STATS =	0x00001000,
-	RT2860_DEBUG_RATE =	0x00002000,
-	RT2860_DEBUG_PERIODIC =	0x00004000,
-	RT2860_DEBUG_WATCHDOG =	0x00008000,
-	RT2860_DEBUG_RX_CRYPT = 0x00010000,
-	RT2860_DEBUG_TX_CRYPT = 0x00020000,
-	RT2860_DEBUG_ANY = 0xffffffff
-};
-
-#define RT2860_DPRINTF(sc, m, fmt, ...)		\
-    do { if ((sc)->debug & (m)) printf(fmt, __VA_ARGS__); } while (0)
-
-#else
-
-#define RT2860_DPRINTF(sc, m, fmt, ...)
-
-#endif /* #ifdef RT2860_DEBUG */
-
-#define RT2860_RXDESC_SDL0_DDONE			(1 << 15)
-
-#define RT2860_RXDESC_FLAGS_LAST_AMSDU			(1 << 19)
-#define RT2860_RXDESC_FLAGS_CIPHER_ALG			(1 << 18)
-#define RT2860_RXDESC_FLAGS_PLCP_RSSIL			(1 << 17)
-#define RT2860_RXDESC_FLAGS_DECRYPTED			(1 << 16)
-#define RT2860_RXDESC_FLAGS_AMPDU			(1 << 15)
-#define RT2860_RXDESC_FLAGS_L2PAD			(1 << 14)
-#define RT2860_RXDESC_FLAGS_RSSI			(1 << 13)
-#define RT2860_RXDESC_FLAGS_HTC				(1 << 12)
-#define RT2860_RXDESC_FLAGS_AMSDU			(1 << 11)
-#define RT2860_RXDESC_FLAGS_CRC_ERR			(1 << 8)
-#define RT2860_RXDESC_FLAGS_MYBSS			(1 << 7)
-#define RT2860_RXDESC_FLAGS_BCAST			(1 << 6)
-#define RT2860_RXDESC_FLAGS_MCAST			(1 << 5)
-#define RT2860_RXDESC_FLAGS_U2M				(1 << 4)
-#define RT2860_RXDESC_FLAGS_FRAG			(1 << 3)
-#define RT2860_RXDESC_FLAGS_NULL_DATA			(1 << 2)
-#define RT2860_RXDESC_FLAGS_DATA			(1 << 1)
-#define RT2860_RXDESC_FLAGS_BA				(1 << 0)
-
-#define RT2860_RXDESC_FLAGS_CIPHER_ERR_SHIFT		9
-#define RT2860_RXDESC_FLAGS_CIPHER_ERR_MASK		0x3
-#define RT2860_RXDESC_FLAGS_CIPHER_ERR_NONE		0
-#define RT2860_RXDESC_FLAGS_CIPHER_ERR_ICV		1
-#define RT2860_RXDESC_FLAGS_CIPHER_ERR_MIC		2
-#define RT2860_RXDESC_FLAGS_CIPHER_ERR_INVALID_KEY	3
-
-#define RT2860_RXDESC_FLAGS_PLCP_SIGNAL_SHIFT		20
-#define RT2860_RXDESC_FLAGS_PLCP_SIGNAL_MASK		0xfff
-
-struct rt2860_rxdesc
-{
-	uint32_t sdp0;
-	uint16_t sdl1;
-	uint16_t sdl0;
-	uint32_t sdp1;
-	uint32_t flags;
-} __packed;
-
-#define RT2860_TXDESC_SDL1_BURST						(1 << 15)
-#define RT2860_TXDESC_SDL1_LASTSEG						(1 << 14)
-
-#define RT2860_TXDESC_SDL0_DDONE						(1 << 15)
-#define RT2860_TXDESC_SDL0_LASTSEG						(1 << 14)
-
-#define RT2860_TXDESC_FLAGS_SHIFT						0
-#define RT2860_TXDESC_FLAGS_MASK						0xf9
-#define RT2860_TXDESC_FLAGS_WI_VALID					(1 << 0)
-
-#define RT2860_TXDESC_QSEL_SHIFT						1
-#define RT2860_TXDESC_QSEL_MASK							0x3
-#define RT2860_TXDESC_QSEL_MGMT							0
-#define RT2860_TXDESC_QSEL_HCCA							1
-#define RT2860_TXDESC_QSEL_EDCA							2
-
-struct rt2860_txdesc
-{
-	uint32_t sdp0;
-	uint16_t sdl1;
-	uint16_t sdl0;
-	uint32_t sdp1;
-	uint8_t	reserved[3];
-	uint8_t qsel_flags;
-} __packed;
-
-#define RT2860_TXWI_FLAGS_SHIFT					0
-#define RT2860_TXWI_FLAGS_MASK					0x1f
-#define RT2860_TXWI_FLAGS_AMPDU					(1 << 4)
-#define RT2860_TXWI_FLAGS_TS					(1 << 3)
-#define RT2860_TXWI_FLAGS_CFACK					(1 << 2)
-#define RT2860_TXWI_FLAGS_MIMOPS				(1 << 1)
-#define RT2860_TXWI_FLAGS_FRAG					(1 << 0)
-
-#define RT2860_TXWI_MPDU_DENSITY_SHIFT			5
-#define RT2860_TXWI_MPDU_DENSITY_MASK			0x7
-
-#define RT2860_TXWI_TXOP_SHIFT					0
-#define RT2860_TXWI_TXOP_MASK					0x3
-#define RT2860_TXWI_TXOP_HT						0
-#define RT2860_TXWI_TXOP_PIFS					1
-#define RT2860_TXWI_TXOP_SIFS					2
-#define RT2860_TXWI_TXOP_BACKOFF				3
-
-#define RT2860_TXWI_MCS_SHIFT					0
-#define RT2860_TXWI_MCS_MASK					0x7f
-#define RT2860_TXWI_MCS_SHOTPRE					(1 << 3)
-
-#define RT2860_TXWI_BW_SHIFT					7
-#define RT2860_TXWI_BW_MASK						0x1
-#define RT2860_TXWI_BW_20						0
-#define RT2860_TXWI_BW_40						1
-
-#define RT2860_TXWI_SHORTGI_SHIFT				0
-#define RT2860_TXWI_SHORTGI_MASK				0x1
-
-#define RT2860_TXWI_STBC_SHIFT					1
-#define RT2860_TXWI_STBC_MASK					0x3
-
-#define RT2860_TXWI_IFS_SHIFT					3
-#define RT2860_TXWI_IFS_MASK					0x1
-
-#define RT2860_TXWI_PHYMODE_SHIFT				6
-#define RT2860_TXWI_PHYMODE_MASK				0x3
-#define RT2860_TXWI_PHYMODE_CCK					0
-#define RT2860_TXWI_PHYMODE_OFDM				1
-#define RT2860_TXWI_PHYMODE_HT_MIXED			2
-#define RT2860_TXWI_PHYMODE_HT_GF				3
-
-#define RT2860_TXWI_XFLAGS_SHIFT				0
-#define RT2860_TXWI_XFLAGS_MASK					0x3
-#define RT2860_TXWI_XFLAGS_NSEQ					(1 << 1)
-#define RT2860_TXWI_XFLAGS_ACK					(1 << 0)
-
-#define RT2860_TXWI_BAWIN_SIZE_SHIFT			2
-#define RT2860_TXWI_BAWIN_SIZE_MASK				0x3f
-
-#define RT2860_TXWI_MPDU_LEN_SHIFT				0
-#define RT2860_TXWI_MPDU_LEN_MASK				0xfff
-
-#define RT2860_TXWI_PID_SHIFT					12
-#define RT2860_TXWI_PID_MASK					0xf
-
-struct rt2860_txwi
-{
-	uint8_t mpdu_density_flags;
-	uint8_t txop;
-	uint8_t bw_mcs;
-	uint8_t phymode_ifs_stbc_shortgi;
-	uint8_t bawin_size_xflags;
-	uint8_t wcid;
-	uint16_t pid_mpdu_len;
-	uint32_t iv;
-	uint32_t eiv;
-} __packed;
-
-#define RT2860_RXWI_KEYIDX_SHIFT			0
-#define RT2860_RXWI_KEYIDX_MASK				0x3
-
-#define RT2860_RXWI_BSSIDX_SHIFT			2
-#define RT2860_RXWI_BSSIDX_MASK				0x7
-
-#define RT2860_RXWI_UDF_SHIFT				5
-#define RT2860_RXWI_UDF_MASK				0x7
-
-#define RT2860_RXWI_SIZE_SHIFT				0
-#define RT2860_RXWI_SIZE_MASK				0xfff
-
-#define RT2860_RXWI_TID_SHIFT				12
-#define RT2860_RXWI_TID_MASK				0xf
-
-#define RT2860_RXWI_FRAG_SHIFT				0
-#define RT2860_RXWI_FRAG_MASK				0xf
-
-#define RT2860_RXWI_SEQ_SHIFT				4
-#define RT2860_RXWI_SEQ_MASK				0xfff
-
-#define RT2860_RXWI_MCS_SHIFT				0
-#define RT2860_RXWI_MCS_MASK				0x7f
-#define RT2860_RXWI_MCS_SHOTPRE				(1 << 3)
-
-#define RT2860_RXWI_BW_SHIFT				7
-#define RT2860_RXWI_BW_MASK					0x1
-#define RT2860_RXWI_BW_20					0
-#define RT2860_RXWI_BW_40					1
-
-#define RT2860_RXWI_SHORTGI_SHIFT			0
-#define RT2860_RXWI_SHORTGI_MASK			0x1
-
-#define RT2860_RXWI_STBC_SHIFT				1
-#define RT2860_RXWI_STBC_MASK				0x3
-
-#define RT2860_RXWI_PHYMODE_SHIFT			6
-#define RT2860_RXWI_PHYMODE_MASK			0x3
-#define RT2860_RXWI_PHYMODE_CCK				0
-#define RT2860_RXWI_PHYMODE_OFDM			1
-#define RT2860_RXWI_PHYMODE_HT_MIXED		2
-#define RT2860_RXWI_PHYMODE_HT_GF			3
-
-struct rt2860_rxwi
-{
-	uint8_t wcid;
-	uint8_t udf_bssidx_keyidx;
-	uint16_t tid_size;
-	uint16_t seq_frag;
-	uint8_t bw_mcs;
-	uint8_t phymode_stbc_shortgi;
-	uint8_t rssi[3];
-	uint8_t reserved1;
-	uint8_t snr[2];
-	uint16_t reserved2;
-} __packed;
-
-#define RT2860_AMRR_MIN_SUCCESS_THRESHOLD	 		1
-#define RT2860_AMRR_MAX_SUCCESS_THRESHOLD			15
-
-struct rt2860_amrr
-{
-	int ntxpath;
-
-	unsigned int min_success_threshold;
-	unsigned int max_success_threshold;
-
-	int	interval;
-};
-
-struct rt2860_amrr_node
-{
-	struct rt2860_amrr *amrr;
-
-	int	rate_index;
-
-	int	ticks;
-
-	unsigned int txcnt;
-	unsigned int success;
-	unsigned int success_threshold;
-	unsigned int recovery;
-	unsigned int retrycnt;
-};
-
-#define RT2860_SOFTC_LOCK(sc)				mtx_lock(&(sc)->sc_mtx)
-#define RT2860_SOFTC_UNLOCK(sc)				\
-		mtx_unlock(&(sc)->sc_mtx)
-#define	RT2860_SOFTC_ASSERT_LOCKED(sc)			\
-		mtx_assert(&(sc)->sc_mtx, MA_OWNED)
-
-#define RT2860_SOFTC_TX_RING_LOCK(ring)			mtx_lock(&(ring)->lock)
-#define RT2860_SOFTC_TX_RING_UNLOCK(ring)		\
-		mtx_unlock(&(ring)->lock)
-#define	RT2860_SOFTC_TX_RING_ASSERT_LOCKED(ring)	\
-		mtx_assert(&(ring)->lock, MA_OWNED)
-
-#define RT2860_SOFTC_FLAGS_UCODE_LOADED			(1 << 0)
-#define RT2860_SOFTC_LED_OFF_COUNT			3
-#define RT2860_SOFTC_RSSI_OFF_COUNT			3
-#define RT2860_SOFTC_LNA_GAIN_COUNT			4
-#define RT2860_SOFTC_TXPOW_COUNT			50
-#define RT2860_SOFTC_TXPOW_RATE_COUNT			5
-#define RT2860_SOFTC_TSSI_COUNT				9
-#define RT2860_SOFTC_BBP_EEPROM_COUNT			8
-#define RT2860_SOFTC_RSSI_COUNT				3
-#define RT2860_SOFTC_STAID_COUNT			64
-#define RT2860_SOFTC_TX_RING_COUNT			6
-#define RT2860_SOFTC_RX_RING_DATA_COUNT			128
-#define RT2860_SOFTC_MAX_SCATTER			10
-#define RT2860_SOFTC_TX_RING_DATA_COUNT			256
-#define RT2860_SOFTC_TX_RING_DESC_COUNT					\
-	(RT2860_SOFTC_TX_RING_DATA_COUNT * RT2860_SOFTC_MAX_SCATTER)
-
-#define RT2860_SOFTC_RX_RADIOTAP_PRESENT				\
-	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
-	 (1 << IEEE80211_RADIOTAP_RATE) |				\
-	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
-	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |			\
-	 (1 << IEEE80211_RADIOTAP_ANTENNA) |				\
-	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |			\
-	 (1 << IEEE80211_RADIOTAP_XCHANNEL))
-
-#define RT2860_SOFTC_TX_RADIOTAP_PRESENT				\
-	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
-	 (1 << IEEE80211_RADIOTAP_RATE) |				\
-	 (1 << IEEE80211_RADIOTAP_XCHANNEL))
-
-struct rt2860_softc_rx_data
-{
-	bus_dmamap_t dma_map;
-	struct mbuf *m;
-};
-
-struct rt2860_softc_rx_ring
-{
-	bus_dma_tag_t desc_dma_tag;
-	bus_dmamap_t desc_dma_map;
-	bus_addr_t desc_phys_addr;
-	struct rt2860_rxdesc *desc;
-	bus_dma_tag_t data_dma_tag;
-	bus_dmamap_t spare_dma_map;
-	struct rt2860_softc_rx_data data[RT2860_SOFTC_RX_RING_DATA_COUNT];
-	int cur;
-};
-
-struct rt2860_softc_tx_data
-{
-	bus_dmamap_t dma_map;
-	struct ieee80211_node *ni;
-	struct mbuf *m;
-};
-
-struct rt2860_softc_tx_ring
-{
-	struct mtx lock;
-	bus_dma_tag_t desc_dma_tag;
-	bus_dmamap_t desc_dma_map;
-	bus_addr_t desc_phys_addr;
-	struct rt2860_txdesc *desc;
-	int desc_queued;
-	int desc_cur;
-	int desc_next;
-	bus_dma_tag_t seg0_dma_tag;
-	bus_dmamap_t seg0_dma_map;
-	bus_addr_t seg0_phys_addr;
-	uint8_t *seg0;
-	bus_dma_tag_t data_dma_tag;
-	struct rt2860_softc_tx_data data[RT2860_SOFTC_TX_RING_DATA_COUNT];
-	int data_queued;
-	int data_cur;
-	int data_next;
-	int qid;
-};
-
-struct rt2860_softc_node
-{
-	struct ieee80211_node ni;
-
-	uint8_t staid;
-
-	uint8_t last_rssi[RT2860_SOFTC_RSSI_COUNT];
-	int8_t last_rssi_dbm[RT2860_SOFTC_RSSI_COUNT];
-};
-
-struct rt2860_softc_vap
-{
-	struct ieee80211vap	vap;
-
-	struct ieee80211_beacon_offsets beacon_offsets;
-	struct mbuf *beacon_mbuf;
-	struct rt2860_txwi beacon_txwi;
-
-	struct rt2860_amrr amrr;
-
-	int	(*newstate)(struct ieee80211vap *vap,
-		enum ieee80211_state nstate, int arg);
-};
-
-struct rt2860_softc_rx_radiotap_header
-{
-	struct ieee80211_radiotap_header ihdr;
-	uint8_t	flags;
-	uint8_t	rate;
-	int8_t dbm_antsignal;
-	int8_t dbm_antnoise;
-	uint8_t	antenna;
-	uint8_t	antsignal;
-	uint8_t pad[2];
-	uint32_t chan_flags;
-	uint16_t chan_freq;
-	uint8_t chan_ieee;
-	int8_t chan_maxpow;
-} __packed;
-
-struct rt2860_softc_tx_radiotap_header
-{
-	struct ieee80211_radiotap_header ihdr;
-	uint8_t flags;
-	uint8_t	rate;
-	uint8_t pad[2];
-	uint32_t chan_flags;
-	uint16_t chan_freq;
-	uint8_t chan_ieee;
-	int8_t chan_maxpow;
-} __packed;
-
-struct rt2860_softc
-{
-	struct ifnet			*sc_ifp;
-	device_t			sc_dev;
-	bus_space_tag_t			sc_st;
-	bus_space_handle_t		sc_sh;
-
-	struct mtx			sc_mtx;
-
-	struct callout			watchdog_ch;
-
-	int				sc_tx_timer;
-	int                             sc_invalid;
-	int				sc_debug;
-/*
- * The same in both up to here
- * ------------------------------------------------
- */
-	int			id;
-	uint32_t 		flags;
-	int			mem_rid; /* XXX: bus glue handle res */
-	struct resource		*mem;
-
-	int			irq_rid;
-	struct resource 	*irq;
-	void 			*irqh;
-
-	int			if_flags;
-
-	int			nvaps;
-	int			napvaps;
-	int nadhocvaps;
-	int nstavaps;
-	int nwdsvaps;
-
-	void (*node_cleanup)(struct ieee80211_node *ni);
-
-	int (*recv_action)(struct ieee80211_node *ni,
-		const struct ieee80211_frame *wh,
-		const uint8_t *frm, const uint8_t *efrm);
-
-	int (*send_action)(struct ieee80211_node *ni,
-		int cat, int act, void *sa);
-
-	int (*addba_response)(struct ieee80211_node *ni,
-		struct ieee80211_tx_ampdu *tap,
-		int status, int baparamset, int batimeout);
-
-	void (*addba_stop)(struct ieee80211_node *ni,
-		struct ieee80211_tx_ampdu *tap);
-
-	int (*ampdu_rx_start)(struct ieee80211_node *ni,
-		struct ieee80211_rx_ampdu *rap,
-		int baparamset, int batimeout, int baseqctl);
-
-	void (*ampdu_rx_stop)(struct ieee80211_node *ni,
-		struct ieee80211_rx_ampdu *rap);
-
-	struct rt2860_amrr_node amrr_node[RT2860_SOFTC_STAID_COUNT];
-
-	uint32_t mac_rev;
-	uint8_t eeprom_addr_num;
-	uint16_t eeprom_rev;
-	uint8_t rf_rev;
-
-	uint8_t mac_addr[IEEE80211_ADDR_LEN];
-
-	uint8_t ntxpath;
-	uint8_t nrxpath;
-
-	int hw_radio_cntl;
-	int tx_agc_cntl;
-	int ext_lna_2ghz;
-	int ext_lna_5ghz;
-
-	uint8_t country_2ghz;
-	uint8_t country_5ghz;
-
-	uint8_t rf_freq_off;
-
-	uint8_t led_cntl;
-	uint16_t led_off[RT2860_SOFTC_LED_OFF_COUNT];
-
-	int8_t rssi_off_2ghz[RT2860_SOFTC_RSSI_OFF_COUNT];
-	int8_t rssi_off_5ghz[RT2860_SOFTC_RSSI_OFF_COUNT];
-
-	int8_t lna_gain[RT2860_SOFTC_LNA_GAIN_COUNT];
-
-	int8_t txpow1[RT2860_SOFTC_TXPOW_COUNT];
-	int8_t txpow2[RT2860_SOFTC_TXPOW_COUNT];
-
-	int8_t txpow_rate_delta_2ghz;
-	int8_t txpow_rate_delta_5ghz;
-	uint32_t txpow_rate_20mhz[RT2860_SOFTC_TXPOW_RATE_COUNT];
-	uint32_t txpow_rate_40mhz_2ghz[RT2860_SOFTC_TXPOW_RATE_COUNT];
-	uint32_t txpow_rate_40mhz_5ghz[RT2860_SOFTC_TXPOW_RATE_COUNT];
-
-	int tx_agc_cntl_2ghz;
-	int tx_agc_cntl_5ghz;
-
-	uint8_t tssi_2ghz[RT2860_SOFTC_TSSI_COUNT];
-	uint8_t tssi_step_2ghz;
-	uint8_t tssi_5ghz[RT2860_SOFTC_TSSI_COUNT];
-	uint8_t tssi_step_5ghz;
-
-	struct
-	{
-		uint8_t	val;
-		uint8_t	reg;
-	} __packed bbp_eeprom[RT2860_SOFTC_BBP_EEPROM_COUNT], rf[10];
-
-	uint16_t powersave_level;
-
-	uint8_t staid_mask[RT2860_SOFTC_STAID_COUNT / NBBY];
-
-	uint32_t intr_enable_mask;
-	uint32_t intr_disable_mask;
-	uint32_t intr_pending_mask;
-
-	struct task rx_done_task;
-	int rx_process_limit;
-
-	struct task tx_done_task;
-
-	struct task fifo_sta_full_task;
-
-	struct task periodic_task;
-	struct callout periodic_ch;
-	unsigned long periodic_round;
-
-	struct taskqueue *taskqueue;
-
-	struct rt2860_softc_rx_ring rx_ring;
-
-	struct rt2860_softc_tx_ring tx_ring[RT2860_SOFTC_TX_RING_COUNT];
-	int tx_ring_mgtqid;
-
-	struct callout tx_watchdog_ch;
-	int tx_timer;
-
-	struct rt2860_softc_rx_radiotap_header rxtap;
-	struct rt2860_softc_tx_radiotap_header txtap;
-
-	/* statistic counters */
-
-	unsigned long interrupts;
-	unsigned long tx_coherent_interrupts;
-	unsigned long rx_coherent_interrupts;
-	unsigned long txrx_coherent_interrupts;
-	unsigned long fifo_sta_full_interrupts;
-	unsigned long rx_interrupts;
-	unsigned long tx_interrupts[RT2860_SOFTC_TX_RING_COUNT];
-
-	unsigned long tx_data_queue_full[RT2860_SOFTC_TX_RING_COUNT];
-
-	unsigned long tx_watchdog_timeouts;
-
-	unsigned long tx_defrag_packets;
-
-	unsigned long no_tx_desc_avail;
-
-	unsigned long rx_mbuf_alloc_errors;
-	unsigned long rx_mbuf_dmamap_errors;
-
-	unsigned long tx_queue_not_empty[2];
-
-	unsigned long tx_beacons;
-	unsigned long tx_noretryok;
-	unsigned long tx_retryok;
-	unsigned long tx_failed;
-	unsigned long tx_underflows;
-	unsigned long tx_zerolen;
-	unsigned long tx_nonagg;
-	unsigned long tx_agg;
-	unsigned long tx_ampdu;
-	unsigned long tx_mpdu_zero_density;
-	unsigned long tx_ampdu_sessions;
-
-	unsigned long rx_packets;
-	unsigned long rx_ampdu;
-	unsigned long rx_ampdu_retries;
-	unsigned long rx_mpdu_zero_density;
-	unsigned long rx_ampdu_sessions;
-	unsigned long rx_amsdu;
-	unsigned long rx_crc_errors;
-	unsigned long rx_phy_errors;
-	unsigned long rx_false_ccas;
-	unsigned long rx_plcp_errors;
-	unsigned long rx_dup_packets;
-	unsigned long rx_fifo_overflows;
-	unsigned long rx_cipher_no_errors;
-	unsigned long rx_cipher_icv_errors;
-	unsigned long rx_cipher_mic_errors;
-	unsigned long rx_cipher_invalid_key_errors;
-
-	int tx_stbc;
-
-	uint8_t rf24_20mhz;
-	uint8_t	rf24_40mhz;
-	uint8_t	patch_dac;
-	uint8_t	txmixgain_2ghz;
-	uint8_t	txmixgain_5ghz;
-
-#ifdef RT2860_DEBUG
-	int debug;
-#endif
-};
-
-#define RT2860_EEPROM_VERSION				0x0002
-#define RT2860_EEPROM_ADDRESS01				0x0004
-#define RT2860_EEPROM_ADDRESS23				0x0006
-#define RT2860_EEPROM_ADDRESS45				0x0008
-#define RT2860_EEPROM_POWERSAVE_LEVEL			0x0022
-#define RT2860_EEPROM_ANTENNA				0x0034
-#define RT2860_EEPROM_NIC_CONFIG			0x0036
-#define RT2860_EEPROM_COUNTRY				0x0038
-#define RT2860_EEPROM_RF_FREQ_OFF			0x003a
-#define RT2860_EEPROM_LED1_OFF				0x003c
-#define RT2860_EEPROM_LED2_OFF				0x003e
-#define RT2860_EEPROM_LED3_OFF				0x0040
-#define RT2860_EEPROM_LNA_GAIN				0x0044
-#define RT2860_EEPROM_RSSI_OFF_2GHZ_BASE		0x0046
-#define RT2860_EEPROM_RSSI2_OFF_2GHZ_BASE		0x0048
-#define RT2860_EEPROM_RSSI_OFF_5GHZ_BASE		0x004a
-#define RT2860_EEPROM_RSSI2_OFF_5GHZ_BASE		0x004c
-#define RT2860_EEPROM_TXPOW_RATE_DELTA			0x0050
-#define RT2860_EEPROM_TXPOW1_2GHZ_BASE			0x0052
-#define RT2860_EEPROM_TXPOW2_2GHZ_BASE			0x0060
-#define RT2860_EEPROM_TSSI_2GHZ_BASE			0x006e
-#define RT2860_EEPROM_TXPOW1_5GHZ_BASE			0x0078
-#define RT2860_EEPROM_TXPOW2_5GHZ_BASE			0x00a6
-#define RT2860_EEPROM_TSSI_5GHZ_BASE			0x00d4
-#define RT2860_EEPROM_TXPOW_RATE_BASE			0x00de
-#define RT2860_EEPROM_BBP_BASE				0x00f0
-#define RT3071_EEPROM_RF_BASE				0x0082
-
-#define RT2860_EEPROM_RF_2820				1 /* 2.4GHz 2T3R */
-#define RT2860_EEPROM_RF_2850				2 /* 2.4/5GHz 2T3R */
-#define RT2860_EEPROM_RF_2720				3 /* 2.4GHz 1T2R */
-#define RT2860_EEPROM_RF_2750				4 /* 2.4G/5GHz 1T2R */
-#define RT2860_EEPROM_RF_3020				5 /* 2.4G 1T1R */
-#define RT2860_EEPROM_RF_2020				6 /* 2.4G B/G */
-#define RT2860_EEPROM_RF_3021				7 /* 2.4G 1T2R */
-#define RT2860_EEPROM_RF_3022				8 /* 2.4G 2T2R */
-#define RT2860_EEPROM_RF_3052				9 /* 2.4G/5G 2T2R */
-#define RT2860_EEPROM_RF_2853				10 /* 2.4G.5G 3T3R */
-#define RT2860_EEPROM_RF_3320				11 /* 2.4G 1T1R with
-							    * PA RT3350,
-							    * RT3370,
-							    * RT3390
-							    */
-#define RT2860_EEPROM_RF_3322				12 /* 2.4G 2T2R with
-							    * PA RT3352,
-							    * RT3371, RT3372,
-							    * RT3391, RT3392
-							    */
-#define RT2860_EEPROM_RF_3053				13 /* 2.4G/5G 3T3R
-							    * RT3883,RT3563,
-							    * RT3573,RT3593,
-							    * RT3662
-							    */
-#define RT2860_EEPROM_RF_3853				13 /* 2.4G/5G 3T3R
-							    * RT3883, RT3563,
-							    * RT3573, RT3593,
-							    * RT3662
-							    */
-
-/*
- * RT2860_EEPROM_NIC_CONFIG flags
- */
-#define RT2860_EEPROM_EXT_LNA_5GHZ			(1 << 3)
-#define RT2860_EEPROM_EXT_LNA_2GHZ			(1 << 2)
-#define RT2860_EEPROM_TX_AGC_CNTL			(1 << 1)
-#define RT2860_EEPROM_HW_RADIO_CNTL			(1 << 0)
-
-#define RT2860_EEPROM_LED_POLARITY			(1 << 7)
-#define RT2860_EEPROM_LED_MODE_MASK			0x7f
-
-#define RT2860_EEPROM_LED_CNTL_DEFAULT			0x01
-#define RT2860_EEPROM_LED1_OFF_DEFAULT			0x5555
-#define RT2860_EEPROM_LED2_OFF_DEFAULT			0x2221
-#define RT2860_EEPROM_LED3_OFF_DEFAULT			0xa9f8
-
-#define RT2860_EEPROM_RSSI_OFF_MIN			-10
-#define RT2860_EEPROM_RSSI_OFF_MAX			10
-
-#define RT2860_EEPROM_TXPOW_2GHZ_MIN			0
-#define RT2860_EEPROM_TXPOW_2GHZ_MAX			31
-#define RT2860_EEPROM_TXPOW_2GHZ_DEFAULT		5
-#define RT2860_EEPROM_TXPOW_5GHZ_MIN			-7
-#define RT2860_EEPROM_TXPOW_5GHZ_MAX			15
-#define RT2860_EEPROM_TXPOW_5GHZ_DEFAULT		5
-
-#define RT2860_IO_MCU_CMD_SLEEP				0x30
-#define RT2860_IO_MCU_CMD_WAKEUP			0x31
-#define RT2860_IO_MCU_CMD_RADIOOFF			0x35
-#define RT2860_IO_MCU_CMD_LEDS				0x50
-#define RT2860_IO_MCU_CMD_LED_BRIGHTNESS		0x51
-#define RT2860_IO_MCU_CMD_LED1				0x52
-#define RT2860_IO_MCU_CMD_LED2				0x53
-#define RT2860_IO_MCU_CMD_LED3				0x54
-#define RT2860_IO_MCU_CMD_BOOT				0x72
-#define RT2860_IO_MCU_CMD_BBP				0x80
-#define RT2860_IO_MCU_CMD_POWERSAVE_LEVEL		0x83
-
-#define RT2860_LED_CMD_RADIO_OFF			0
-#define RT2860_LED_CMD_RADIO_ON				(1 << 5)
-#define RT2860_LED_CMD_LINK_2GHZ			(1 << 6)
-#define RT2860_LED_CMD_LINK_5GHZ			(1 << 7)
-
-/*
- * Global function prototypes, used in bus depended interfaces
- */
-
-int rt2860_attach(device_t, int);
-int rt2860_detach(void *);
-void rt2860_shutdown(void *);
-void rt2860_suspend(void *);
-void rt2860_resume(void *);
-void rt2860_intr(void *arg);
-
-
-#endif /* #ifndef _RT2860VAR_H_ */
-


More information about the Zrouter-src-freebsd mailing list