Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pcmcia Add malo@pcmcia.
details: https://anonhg.NetBSD.org/src/rev/8270feb4a020
branches: trunk
changeset: 781183:8270feb4a020
user: kiyohara <kiyohara%NetBSD.org@localhost>
date: Sat Aug 25 08:20:03 2012 +0000
description:
Add malo@pcmcia.
diffstat:
sys/dev/pcmcia/files.pcmcia | 6 +-
sys/dev/pcmcia/if_malo_pcmcia.c | 2148 ++++++++++++++++++++++++++++++++++++
sys/dev/pcmcia/if_malo_pcmciareg.h | 85 +
sys/dev/pcmcia/if_malo_pcmciavar.h | 395 ++++++
4 files changed, 2633 insertions(+), 1 deletions(-)
diffs (truncated from 2657 to 300 lines):
diff -r d2b502909772 -r 8270feb4a020 sys/dev/pcmcia/files.pcmcia
--- a/sys/dev/pcmcia/files.pcmcia Fri Aug 24 20:28:19 2012 +0000
+++ b/sys/dev/pcmcia/files.pcmcia Sat Aug 25 08:20:03 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.pcmcia,v 1.57 2008/09/30 16:51:45 jmcneill Exp $
+# $NetBSD: files.pcmcia,v 1.58 2012/08/25 08:20:03 kiyohara Exp $
#
# Config.new file and device description for machine-independent PCMCIA code.
# Included by ports that need it.
@@ -140,3 +140,7 @@
device btbc: btbus, bluetooth
attach btbc at pcmcia
file dev/pcmcia/btbc.c btbc
+
+# Marvell 88W8385
+attach malo at pcmcia with malo_pcmcia
+file dev/pcmcia/if_malo_pcmcia.c malo_pcmcia
diff -r d2b502909772 -r 8270feb4a020 sys/dev/pcmcia/if_malo_pcmcia.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pcmcia/if_malo_pcmcia.c Sat Aug 25 08:20:03 2012 +0000
@@ -0,0 +1,2148 @@
+/* $NetBSD: if_malo_pcmcia.c,v 1.1 2012/08/25 08:20:03 kiyohara Exp $ */
+/* $OpenBSD: if_malo.c,v 1.65 2009/03/29 21:53:53 sthen Exp $ */
+
+/*
+ * Copyright (c) 2007 Marcus Glocker <mglocker%openbsd.org@localhost>
+ *
+ * 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>
+__KERNEL_RCSID(0, "$NetBSD: if_malo_pcmcia.c,v 1.1 2012/08/25 08:20:03 kiyohara Exp $");
+
+#ifdef _MODULE
+#include <sys/module.h>
+#endif
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/condvar.h>
+#include <sys/device.h>
+#include <sys/intr.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/mutex.h>
+#include <sys/pmf.h>
+#include <sys/proc.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/systm.h>
+
+#include <net/bpf.h>
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_ether.h>
+#include <net/if_media.h>
+#include <net/if_llc.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/firmload.h>
+
+#include <dev/pcmcia/pcmciareg.h>
+#include <dev/pcmcia/pcmciavar.h>
+#include <dev/pcmcia/pcmciadevs.h>
+
+#include <dev/pcmcia/if_malo_pcmciavar.h>
+#include <dev/pcmcia/if_malo_pcmciareg.h>
+
+/*
+ * Driver for the Marvell 88W8385 chip (Compact Flash).
+ */
+
+#ifdef CMALO_DEBUG
+int cmalo_d = 1;
+#define DPRINTF(l, x...) do { if ((l) <= cmalo_d) printf(x); } while (0)
+#else
+#define DPRINTF(l, x...)
+#endif
+
+static int malo_pcmcia_match(device_t, cfdata_t, void *);
+static void malo_pcmcia_attach(device_t, device_t, void *);
+static int malo_pcmcia_detach(device_t, int);
+static int malo_pcmcia_activate(device_t, devact_t);
+
+static int malo_pcmcia_validate_config(struct pcmcia_config_entry *);
+
+static int malo_pcmcia_enable(struct malo_softc *);
+static void malo_pcmcia_disable(struct malo_softc *);
+
+static void cmalo_attach(void *);
+static void cmalo_detach(void *);
+static int cmalo_intr(void *);
+
+static void cmalo_start(struct ifnet *);
+static int cmalo_ioctl(struct ifnet *, u_long, void *);
+static int cmalo_init(struct ifnet *);
+static void cmalo_watchdog(struct ifnet *);
+static int cmalo_media_change(struct ifnet *);
+static int cmalo_newstate(struct ieee80211com *, enum ieee80211_state,
+ int);
+
+static int firmware_load(const char *, const char *, uint8_t **, size_t *);
+static int cmalo_fw_alloc(struct malo_softc *);
+static void cmalo_fw_free(struct malo_softc *);
+static int cmalo_fw_load_helper(struct malo_softc *);
+static int cmalo_fw_load_main(struct malo_softc *);
+
+static void cmalo_stop(struct malo_softc *);
+static void cmalo_intr_mask(struct malo_softc *, int);
+static void cmalo_rx(struct malo_softc *);
+static int cmalo_tx(struct malo_softc *, struct mbuf *);
+static void cmalo_tx_done(struct malo_softc *);
+static void cmalo_event(struct malo_softc *);
+static void cmalo_select_network(struct malo_softc *);
+static void cmalo_reflect_network(struct malo_softc *);
+static int cmalo_wep(struct malo_softc *);
+static int cmalo_rate2bitmap(int);
+
+static void cmalo_hexdump(void *, int);
+static int cmalo_cmd_get_hwspec(struct malo_softc *);
+static int cmalo_cmd_rsp_hwspec(struct malo_softc *);
+static int cmalo_cmd_set_reset(struct malo_softc *);
+static int cmalo_cmd_set_scan(struct malo_softc *);
+static int cmalo_cmd_rsp_scan(struct malo_softc *);
+static int cmalo_parse_elements(struct malo_softc *, uint8_t *, int, int);
+static int cmalo_cmd_set_auth(struct malo_softc *);
+static int cmalo_cmd_set_wep(struct malo_softc *, uint16_t,
+ struct ieee80211_key *);
+static int cmalo_cmd_set_snmp(struct malo_softc *, uint16_t);
+static int cmalo_cmd_set_radio(struct malo_softc *, uint16_t);
+static int cmalo_cmd_set_channel(struct malo_softc *, uint16_t);
+static int cmalo_cmd_set_txpower(struct malo_softc *, int16_t);
+static int cmalo_cmd_set_antenna(struct malo_softc *, uint16_t);
+static int cmalo_cmd_set_macctrl(struct malo_softc *);
+static int cmalo_cmd_set_macaddr(struct malo_softc *, uint8_t *);
+static int cmalo_cmd_set_assoc(struct malo_softc *);
+static int cmalo_cmd_rsp_assoc(struct malo_softc *);
+static int cmalo_cmd_set_rate(struct malo_softc *, int);
+static int cmalo_cmd_request(struct malo_softc *, uint16_t, int);
+static int cmalo_cmd_response(struct malo_softc *);
+
+/*
+ * PCMCIA bus.
+ */
+struct malo_pcmcia_softc {
+ struct malo_softc sc_malo;
+
+ struct pcmcia_function *sc_pf;
+ struct pcmcia_io_handle sc_pcioh;
+ int sc_io_window;
+ void *sc_ih;
+};
+
+CFATTACH_DECL_NEW(malo_pcmcia, sizeof(struct malo_pcmcia_softc),
+ malo_pcmcia_match, malo_pcmcia_attach, malo_pcmcia_detach,
+ malo_pcmcia_activate);
+
+
+static int
+malo_pcmcia_match(device_t parent, cfdata_t match, void *aux)
+{
+ struct pcmcia_attach_args *pa = aux;
+
+ if (pa->manufacturer == PCMCIA_VENDOR_AMBICOM &&
+ pa->product == PCMCIA_PRODUCT_AMBICOM_WL54CF)
+ return 1;
+
+ return 0;
+}
+
+static void
+malo_pcmcia_attach(device_t parent, device_t self, void *aux)
+{
+ struct malo_pcmcia_softc *psc = device_private(self);
+ struct malo_softc *sc = &psc->sc_malo;
+ struct pcmcia_attach_args *pa = aux;
+ struct pcmcia_config_entry *cfe;
+ int error;
+
+ sc->sc_dev = self;
+ psc->sc_pf = pa->pf;
+
+ error = pcmcia_function_configure(pa->pf, malo_pcmcia_validate_config);
+ if (error) {
+ aprint_error_dev(self, "configure failed, error=%d\n", error);
+ return;
+ }
+
+ malo_pcmcia_enable(sc);
+
+ cfe = pa->pf->cfe;
+ sc->sc_iot = cfe->iospace[0].handle.iot;
+ sc->sc_ioh = cfe->iospace[0].handle.ioh;
+
+ cmalo_attach(sc);
+ if (!(sc->sc_flags & MALO_DEVICE_ATTACHED))
+ goto fail;
+
+ if (pmf_device_register(self, NULL, NULL))
+ pmf_class_network_register(self, &sc->sc_if);
+ else
+ aprint_error_dev(self, "couldn't establish power handler\n");
+
+fail:
+ malo_pcmcia_disable(sc);
+
+ if (sc->sc_flags & MALO_DEVICE_ATTACHED)
+ return;
+
+ pcmcia_function_unconfigure(pa->pf);
+ return;
+}
+
+static int
+malo_pcmcia_detach(device_t dev, int flags)
+{
+ struct malo_pcmcia_softc *psc = device_private(dev);
+ struct malo_softc *sc = &psc->sc_malo;
+
+ cmalo_detach(sc);
+ malo_pcmcia_disable(sc);
+ pcmcia_function_unconfigure(psc->sc_pf);
+
+ return 0;
+}
+
+static int
+malo_pcmcia_activate(device_t dev, devact_t act)
+{
+ struct malo_pcmcia_softc *psc = device_private(dev);
+ struct malo_softc *sc = &psc->sc_malo;
+ struct ifnet *ifp = &sc->sc_if;
+ int s;
+
+ s = splnet();
+ switch (act) {
+ case DVACT_DEACTIVATE:
+ if_deactivate(ifp);
+ break;
+ default:
+ return EOPNOTSUPP;
+ }
+ splx(s);
+
+ return 0;
+}
+
+
+int
+malo_pcmcia_validate_config(struct pcmcia_config_entry *cfe)
+{
+
+ if (cfe->iftype != PCMCIA_IFTYPE_IO || cfe->num_iospace != 1)
+ return EINVAL;
+ /* Some cards have a memory space, but we don't use it. */
+ cfe->num_memspace = 0;
+ return 0;
+}
+
+
+static int
+malo_pcmcia_enable(struct malo_softc *sc)
+{
+ struct malo_pcmcia_softc *psc = (struct malo_pcmcia_softc *)sc;
+
+ /* establish interrupt */
+ psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, cmalo_intr, sc);
+ if (psc->sc_ih == NULL) {
+ aprint_error(": can't establish interrupt\n");
+ return -1;
+ }
+
+ if (pcmcia_function_enable(psc->sc_pf)) {
+ aprint_error(": can't enable function\n");
+ pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
+ return -1;
+ }
+ sc->sc_flags |= MALO_DEVICE_ENABLED;
+
+ return 0;
+}
+
+static void
+malo_pcmcia_disable(struct malo_softc *sc)
+{
+ struct malo_pcmcia_softc *psc = (struct malo_pcmcia_softc *)sc;
+
Home |
Main Index |
Thread Index |
Old Index