Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Atmel AT76C50XX usb 802.11b wifi dongle driver f...
details: https://anonhg.NetBSD.org/src/rev/0b28dfebdbb8
branches: trunk
changeset: 573257:0b28dfebdbb8
user: joff <joff%NetBSD.org@localhost>
date: Mon Jan 24 01:17:03 2005 +0000
description:
Atmel AT76C50XX usb 802.11b wifi dongle driver from OpenBSD.
diffstat:
sys/dev/usb/if_atu.c | 2199 +++++++++++++++++++++++++++++++++++++++++++++++
sys/dev/usb/if_atureg.h | 449 +++++++++
2 files changed, 2648 insertions(+), 0 deletions(-)
diffs (truncated from 2656 to 300 lines):
diff -r 49f7ee85e7aa -r 0b28dfebdbb8 sys/dev/usb/if_atu.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/usb/if_atu.c Mon Jan 24 01:17:03 2005 +0000
@@ -0,0 +1,2199 @@
+/* $NetBSD: if_atu.c,v 1.1 2005/01/24 01:17:03 joff Exp $ */
+/* $OpenBSD: if_atu.c,v 1.48 2004/12/30 01:53:21 dlg Exp $ */
+/*
+ * Copyright (c) 2003, 2004
+ * Daan Vreeken <Danovitsch%Vitsch.net@localhost>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Daan Vreeken.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Daan Vreeken 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 Daan Vreeken OR THE VOICES IN HIS HEAD
+ * 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.
+ */
+
+/*
+ * Atmel AT76c503 / AT76c503a / AT76c505 / AT76c505a USB WLAN driver
+ * version 0.5 - 2004-08-03
+ *
+ * Originally written by Daan Vreeken <Danovitsch @ Vitsch . net>
+ * http://vitsch.net/bsd/atuwi
+ *
+ * Contributed to by :
+ * Chris Whitehouse, Alistair Phillips, Peter Pilka, Martijn van Buul,
+ * Suihong Liang, Arjan van Leeuwen, Stuart Walsh
+ *
+ * Ported to OpenBSD by Theo de Raadt and David Gwynne.
+ * Ported to NetBSD by Jesse Off
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.1 2005/01/24 01:17:03 joff Exp $");
+
+#include "bpfilter.h"
+
+#include <sys/param.h>
+#include <sys/sockio.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/kthread.h>
+#include <sys/queue.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include <dev/usb/usbdivar.h>
+
+#include <dev/usb/usbdevs.h>
+
+#include <dev/microcode/atmel/atmel_intersil_fw.h>
+#include <dev/microcode/atmel/atmel_rfmd2958-smc_fw.h>
+#include <dev/microcode/atmel/atmel_rfmd2958_fw.h>
+#include <dev/microcode/atmel/atmel_rfmd_fw.h>
+
+#if NBPFILTER > 0
+#define BPF_MTAP(ifp, m) bpf_mtap((ifp)->if_bpf, (m))
+#include <net/bpf.h>
+#endif
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_ether.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#endif
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#ifdef USB_DEBUG
+#define ATU_DEBUG
+#endif
+
+#include <dev/usb/if_atureg.h>
+
+#ifdef ATU_DEBUG
+#define DPRINTF(x) do { if (atudebug) printf x; } while (0)
+#define DPRINTFN(n,x) do { if (atudebug>(n)) printf x; } while (0)
+int atudebug = 1;
+#else
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
+#endif
+
+/*
+ * Various supported device vendors/products/radio type.
+ */
+struct atu_type atu_devs[] = {
+ { USB_VENDOR_ATMEL, USB_PRODUCT_ATMEL_BW002,
+ RadioRFMD, ATU_NO_QUIRK },
+ { USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5D6050,
+ RadioRFMD, ATU_NO_QUIRK },
+ { USB_VENDOR_ATMEL, USB_PRODUCT_ATMEL_AT76C503A,
+ RadioIntersil, ATU_NO_QUIRK },
+ { USB_VENDOR_LEXAR, USB_PRODUCT_LEXAR_2662WAR,
+ RadioRFMD, ATU_NO_QUIRK },
+ { USB_VENDOR_LINKSYS2, USB_PRODUCT_LINKSYS2_WUSB11,
+ RadioRFMD, ATU_NO_QUIRK },
+ { USB_VENDOR_LINKSYS3, USB_PRODUCT_LINKSYS3_WUSB11V28,
+ RadioRFMD2958, ATU_NO_QUIRK },
+ { USB_VENDOR_NETGEAR2, USB_PRODUCT_NETGEAR2_MA101B,
+ RadioRFMD, ATU_NO_QUIRK },
+ { USB_VENDOR_ACERP, USB_PRODUCT_ACERP_AWL400,
+ RadioRFMD, ATU_NO_QUIRK },
+ { USB_VENDOR_ATMEL, USB_PRODUCT_ATMEL_WL1130,
+ RadioRFMD2958, ATU_NO_QUIRK },
+ { USB_VENDOR_LINKSYS3, USB_PRODUCT_LINKSYS3_WUSB11V28,
+ RadioRFMD2958, ATU_NO_QUIRK },
+ { USB_VENDOR_AINCOMM, USB_PRODUCT_AINCOMM_AWU2000B,
+ RadioRFMD2958, ATU_NO_QUIRK },
+ /* SMC2662 V.4 */
+ { USB_VENDOR_ATMEL, USB_PRODUCT_ATMEL_AT76C505A,
+ RadioRFMD2958_SMC, ATU_QUIRK_NO_REMAP | ATU_QUIRK_FW_DELAY },
+ { USB_VENDOR_ACERP, USB_PRODUCT_ACERP_AWL300,
+ RadioIntersil, ATU_NO_QUIRK },
+};
+
+struct atu_radfirm {
+ enum atu_radio_type atur_type;
+ unsigned char *atur_internal;
+ size_t atur_internal_sz;
+ unsigned char *atur_external;
+ size_t atur_external_sz;
+} atu_radfirm[] = {
+ { RadioRFMD,
+ atmel_fw_rfmd_int, sizeof(atmel_fw_rfmd_int),
+ atmel_fw_rfmd_ext, sizeof(atmel_fw_rfmd_ext) },
+ { RadioRFMD2958,
+ atmel_fw_rfmd2958_int, sizeof(atmel_fw_rfmd2958_int),
+ atmel_fw_rfmd2958_ext, sizeof(atmel_fw_rfmd2958_ext) },
+ { RadioRFMD2958_SMC,
+ atmel_fw_rfmd2958_smc_int, sizeof(atmel_fw_rfmd2958_smc_int),
+ atmel_fw_rfmd2958_smc_ext, sizeof(atmel_fw_rfmd2958_smc_ext) },
+ { RadioIntersil,
+ atmel_fw_intersil_int, sizeof(atmel_fw_intersil_int),
+ atmel_fw_intersil_ext, sizeof(atmel_fw_intersil_ext) }
+};
+
+int atu_newbuf(struct atu_softc *, struct atu_chain *, struct mbuf *);
+void atu_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
+void atu_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
+void atu_start(struct ifnet *);
+int atu_ioctl(struct ifnet *, u_long, caddr_t);
+int atu_init(struct ifnet *);
+void atu_stop(struct ifnet *, int);
+void atu_watchdog(struct ifnet *);
+usbd_status atu_usb_request(struct atu_softc *sc, u_int8_t type,
+ u_int8_t request, u_int16_t value, u_int16_t index,
+ u_int16_t length, u_int8_t *data);
+int atu_send_command(struct atu_softc *sc, u_int8_t *command, int size);
+int atu_get_cmd_status(struct atu_softc *sc, u_int8_t cmd,
+ u_int8_t *status);
+int atu_wait_completion(struct atu_softc *sc, u_int8_t cmd,
+ u_int8_t *status);
+int atu_send_mib(struct atu_softc *sc, u_int8_t type,
+ u_int8_t size, u_int8_t index, void *data);
+int atu_get_mib(struct atu_softc *sc, u_int8_t type,
+ u_int8_t size, u_int8_t index, u_int8_t *buf);
+#if 0
+int atu_start_ibss(struct atu_softc *sc);
+#endif
+int atu_start_scan(struct atu_softc *sc);
+int atu_switch_radio(struct atu_softc *sc, int state);
+int atu_initial_config(struct atu_softc *sc);
+int atu_join(struct atu_softc *sc, struct ieee80211_node *node);
+int8_t atu_get_dfu_state(struct atu_softc *sc);
+u_int8_t atu_get_opmode(struct atu_softc *sc, u_int8_t *mode);
+void atu_internal_firmware(struct device *);
+void atu_external_firmware(struct device *);
+int atu_get_card_config(struct atu_softc *sc);
+int atu_media_change(struct ifnet *ifp);
+void atu_media_status(struct ifnet *ifp, struct ifmediareq *req);
+int atu_tx_list_init(struct atu_softc *);
+int atu_rx_list_init(struct atu_softc *);
+void atu_xfer_list_free(struct atu_softc *sc, struct atu_chain *ch,
+ int listlen);
+int atu_set_wepkey(struct atu_softc *sc, int nr, u_int8_t *key, int len);
+
+#ifdef ATU_DEBUG
+void atu_debug_print(struct atu_softc *sc);
+#endif
+
+void atu_task(void *);
+int atu_newstate(struct ieee80211com *, enum ieee80211_state, int);
+int atu_tx_start(struct atu_softc *, struct ieee80211_node *,
+ struct atu_chain *, struct mbuf *);
+void atu_complete_attach(struct atu_softc *);
+u_int8_t atu_calculate_padding(int);
+
+USB_DECLARE_DRIVER(atu);
+
+usbd_status
+atu_usb_request(struct atu_softc *sc, u_int8_t type,
+ u_int8_t request, u_int16_t value, u_int16_t index, u_int16_t length,
+ u_int8_t *data)
+{
+ usb_device_request_t req;
+ usbd_xfer_handle xfer;
+ usbd_status err;
+ int total_len = 0, s;
+
+ req.bmRequestType = type;
+ req.bRequest = request;
+ USETW(req.wValue, value);
+ USETW(req.wIndex, index);
+ USETW(req.wLength, length);
+
+#ifdef ATU_DEBUG
+ if (atudebug) {
+ DPRINTFN(20, ("%s: req=%02x val=%02x ind=%02x "
+ "len=%02x\n", USBDEVNAME(sc->atu_dev), request,
+ value, index, length));
+ }
+#endif /* ATU_DEBUG */
+
+ s = splnet();
+
+ xfer = usbd_alloc_xfer(sc->atu_udev);
+ usbd_setup_default_xfer(xfer, sc->atu_udev, 0, 500000, &req, data,
+ length, USBD_SHORT_XFER_OK, 0);
+
+ err = usbd_sync_transfer(xfer);
+
+ usbd_get_xfer_status(xfer, NULL, NULL, &total_len, NULL);
+
+#ifdef ATU_DEBUG
+ if (atudebug) {
+ if (type & UT_READ) {
+ DPRINTFN(20, ("%s: transfered 0x%x bytes in\n",
+ USBDEVNAME(sc->atu_dev), total_len));
+ } else {
+ if (total_len != length)
+ DPRINTF(("%s: wrote only %x bytes\n",
+ USBDEVNAME(sc->atu_dev), total_len));
+ }
+ }
+#endif /* ATU_DEBUG */
+
+ usbd_free_xfer(xfer);
+
+ splx(s);
+ return(err);
+}
+
+int
+atu_send_command(struct atu_softc *sc, u_int8_t *command, int size)
+{
+ return atu_usb_request(sc, UT_WRITE_VENDOR_DEVICE, 0x0e, 0x0000,
+ 0x0000, size, command);
+}
+
+int
+atu_get_cmd_status(struct atu_softc *sc, u_int8_t cmd, u_int8_t *status)
+{
+ /*
+ * all other drivers (including Windoze) request 40 bytes of status
+ * and get a short-xfer of just 6 bytes. we can save 34 bytes of
+ * buffer if we just request those 6 bytes in the first place :)
+ */
+ /*
+ return atu_usb_request(sc, UT_READ_VENDOR_INTERFACE, 0x22, cmd,
+ 0x0000, 40, status);
+ */
+ return atu_usb_request(sc, UT_READ_VENDOR_INTERFACE, 0x22, cmd,
+ 0x0000, 6, status);
+}
+
+int
Home |
Main Index |
Thread Index |
Old Index