Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/macppc Add AirMac frontend.



details:   https://anonhg.NetBSD.org/src/rev/0ecbd0e03fa6
branches:  trunk
changeset: 509983:0ecbd0e03fa6
user:      tsubai <tsubai%NetBSD.org@localhost>
date:      Wed May 16 10:56:42 2001 +0000

description:
Add AirMac frontend.

diffstat:

 sys/arch/macppc/conf/GENERIC      |    6 +-
 sys/arch/macppc/conf/files.macppc |    5 +-
 sys/arch/macppc/dev/if_wi_obio.c  |  195 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 203 insertions(+), 3 deletions(-)

diffs (251 lines):

diff -r b86e36d4947a -r 0ecbd0e03fa6 sys/arch/macppc/conf/GENERIC
--- a/sys/arch/macppc/conf/GENERIC      Wed May 16 10:49:18 2001 +0000
+++ b/sys/arch/macppc/conf/GENERIC      Wed May 16 10:56:42 2001 +0000
@@ -1,11 +1,11 @@
-#      $NetBSD: GENERIC,v 1.96 2001/04/04 17:08:07 manu Exp $
+#      $NetBSD: GENERIC,v 1.97 2001/05/16 10:56:42 tsubai Exp $
 #
 #      GENERIC -- everything that's currently supported
 #
 
 include                "arch/macppc/conf/std.macppc"
 
-#ident                 "GENERIC-$Revision: 1.96 $"
+#ident                 "GENERIC-$Revision: 1.97 $"
 
 maxusers       32
 
@@ -187,6 +187,7 @@
 mediabay* at obio?
 wdc*   at mediabay? flags 0
 awacs* at obio?                        # Apple audio device
+wi*    at obio?                        # AirMac
 
 cardslot* at cbb?
 cardbus* at cardslot?
@@ -198,6 +199,7 @@
 mbe*   at pcmcia? function ?           # MB8696x based Ethernet
 ne*    at pcmcia? function ?           # NE2000-compatible Ethernet
 awi*   at pcmcia? function ?           # BayStack 650/660 (802.11FH/DS)
+wi*    at pcmcia? function ?           # Lucent WaveLan IEEE (802.11)
 ex*    at cardbus? dev ? function ?    # 3Com 3C575TX
 tlp*   at cardbus? dev ? function ?    # DECchip 21143
 rtk*   at cardbus? dev ? function ?    # Realtek 8129/8139
diff -r b86e36d4947a -r 0ecbd0e03fa6 sys/arch/macppc/conf/files.macppc
--- a/sys/arch/macppc/conf/files.macppc Wed May 16 10:49:18 2001 +0000
+++ b/sys/arch/macppc/conf/files.macppc Wed May 16 10:56:42 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.macppc,v 1.41 2001/02/27 05:15:04 matt Exp $
+#      $NetBSD: files.macppc,v 1.42 2001/05/16 10:56:43 tsubai Exp $
 #
 # macppc-specific configuration info
 
@@ -184,6 +184,9 @@
 attach wdc at obio with wdc_obio
 file arch/macppc/dev/wdc_obio.c                        wdc_obio
 
+attach wi at obio with wi_obio
+file arch/macppc/dev/if_wi_obio.c              wi_obio
+
 device awacs: audio, auconv, mulaw
 attach awacs at obio
 file arch/macppc/dev/awacs.c                   awacs
diff -r b86e36d4947a -r 0ecbd0e03fa6 sys/arch/macppc/dev/if_wi_obio.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/macppc/dev/if_wi_obio.c  Wed May 16 10:56:42 2001 +0000
@@ -0,0 +1,195 @@
+/*     $NetBSD: if_wi_obio.c,v 1.1 2001/05/16 10:56:43 tsubai Exp $    */
+
+/*-
+ * Copyright (c) 2001 Tsubai Masanari.  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. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#include "opt_inet.h"
+
+#include <sys/param.h>
+#include <sys/callout.h>
+#include <sys/device.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+
+#ifdef INET
+#include <net/if.h>
+#include <net/if_ether.h>
+#include <net/if_ieee80211.h>
+#include <net/if_media.h>
+#endif
+
+#include <machine/autoconf.h>
+#include <machine/bus.h>
+
+#include <dev/ic/wi_ieee.h>
+#include <dev/ic/wireg.h>
+#include <dev/ic/wivar.h>
+
+int wi_obio_match(struct device *, struct cfdata *, void *);
+void wi_obio_attach(struct device *, struct device *, void *);
+int wi_obio_enable(struct wi_softc *);
+void wi_obio_disable(struct wi_softc *);
+void wi_obio_powerhook(int, void *);
+void wi_obio_shutdown(void *);
+
+struct wi_obio_softc {
+       struct wi_softc sc_wi;
+       void *sc_powerhook;
+       void *sc_sdhook;
+};
+
+struct cfattach wi_obio_ca = {
+       sizeof(struct wi_obio_softc), wi_obio_match, wi_obio_attach
+};
+
+int
+wi_obio_match(parent, match, aux)
+       struct device *parent;
+       struct cfdata *match;
+       void *aux;
+{
+       struct confargs *ca = aux;
+
+       if (ca->ca_nintr < 4 || ca->ca_nreg < 8)
+               return 0;
+
+       if (strcmp(ca->ca_name, "radio") != 0)
+               return 0;
+
+       return 1;
+}
+
+void
+wi_obio_attach(parent, self, aux)
+       struct device *parent, *self;
+       void *aux;
+{
+       struct wi_obio_softc *sc = (void *)self;
+       struct wi_softc *wisc = &sc->sc_wi;
+       struct confargs *ca = aux;
+
+       printf(" irq %d:", ca->ca_intr[0]);
+       intr_establish(ca->ca_intr[0], IST_LEVEL, IPL_NET, wi_intr, sc);
+
+       wisc->sc_iot =
+           macppc_make_bus_space_tag(ca->ca_baseaddr + ca->ca_reg[0], 0);
+       if (bus_space_map(wisc->sc_iot, 0, ca->ca_reg[1], 0, &wisc->sc_ioh)) {
+               printf(" can't map i/o space\n");
+               return;
+       }
+
+       wisc->sc_enabled = 1;
+       wisc->sc_enable = wi_obio_enable;
+       wisc->sc_disable = wi_obio_disable;
+
+       wisc->sc_ifp = &wisc->sc_ethercom.ec_if;
+       if (wi_attach(wisc)) {
+               printf("%s: failed to attach controller\n", self->dv_xname);
+               return;
+       }
+
+       sc->sc_sdhook = shutdownhook_establish(wi_obio_shutdown, sc);
+       sc->sc_powerhook = powerhook_establish(wi_obio_powerhook, sc);
+
+       /* Disable the card. */
+       wisc->sc_enabled = 0;
+       wi_obio_disable(wisc);
+}
+
+int
+wi_obio_enable(sc)
+       struct wi_softc *sc;
+{
+       const u_int keywest = 0x80000000;       /* XXX */
+       const u_int fcr2 = keywest + 0x40;
+       const u_int gpio = keywest + 0x6a;
+       const u_int extint_gpio = keywest + 0x58;
+       u_int x;
+
+       x = in32rb(fcr2);
+       x |= 0x4;
+       out32rb(fcr2, x);
+
+       /* Enable card slot. */
+       out8(gpio + 0x0f, 5);
+       delay(1000);
+       out8(gpio + 0x0f, 4);
+       delay(1000);
+
+       x = in32rb(fcr2);
+       x &= ~0x8000000;
+
+       out32rb(fcr2, x);
+       /* out8(gpio + 0x10, 4); */
+
+       out8(extint_gpio + 0x0b, 0);
+       out8(extint_gpio + 0x0a, 0x28);
+       out8(extint_gpio + 0x0d, 0x28);
+       out8(gpio + 0x0d, 0x28);
+       out8(gpio + 0x0e, 0x28);
+       out32rb(keywest + 0x1c000, 0);
+
+       /* Initialize the card. */
+       out32rb(keywest + 0x1a3e0, 0x41);
+       x = in32rb(fcr2);
+       x |= 0x8000000;
+       out32rb(fcr2, x);
+
+       return 0;
+}
+
+void
+wi_obio_disable(sc)
+       struct wi_softc *sc;
+{
+       const u_int keywest = 0x80000000;       /* XXX */
+       const u_int fcr2 = keywest + 0x40;
+       u_int x;
+
+       x = in32rb(fcr2);
+       x &= ~0x4;
+       out32rb(fcr2, x);
+       /* out8(gpio + 0x10, 0); */
+}
+
+void
+wi_obio_powerhook(why, arg)
+       int why;
+       void *arg;
+{
+       struct wi_softc *sc = arg;
+
+       wi_power(sc, why);
+}
+
+void
+wi_obio_shutdown(arg)
+       void *arg;
+{
+       struct wi_softc *sc = arg;
+
+       wi_shutdown(sc);
+}



Home | Main Index | Thread Index | Old Index