summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornyan <nyan@FreeBSD.org>2001-07-04 13:00:21 +0000
committernyan <nyan@FreeBSD.org>2001-07-04 13:00:21 +0000
commit497620bac5a53c422f1848241d5df96e19c8f71e (patch)
tree9e2aa991c3b2c116dea316c8fd95067921cb43c2
parent53b01bc71cc702ed3a886222afd9162fc7067c20 (diff)
downloadFreeBSD-src-497620bac5a53c422f1848241d5df96e19c8f71e.zip
FreeBSD-src-497620bac5a53c422f1848241d5df96e19c8f71e.tar.gz
- Don't overwrite inb, inw and outw.
- Move the lance_probe function to if_lnc.c. - Support C-NET(98)S again. Submitted by: chi@bd.mbn.or.jp (Chiharu Shibata) and nyan No response from: Paul Richards
-rw-r--r--sys/conf/files2
-rw-r--r--sys/conf/files.i3861
-rw-r--r--sys/conf/files.pc981
-rw-r--r--sys/dev/lnc/if_lnc.c69
-rw-r--r--sys/dev/lnc/if_lnc_cbus.c315
-rw-r--r--sys/dev/lnc/if_lnc_isa.c27
-rw-r--r--sys/dev/lnc/if_lnc_pc98.c122
-rw-r--r--sys/dev/lnc/if_lnc_pci.c3
-rw-r--r--sys/dev/lnc/if_lncreg.h45
-rw-r--r--sys/dev/lnc/if_lncvar.h32
-rw-r--r--sys/modules/lnc/Makefile10
-rw-r--r--sys/pc98/conf/GENERIC2
12 files changed, 404 insertions, 225 deletions
diff --git a/sys/conf/files b/sys/conf/files
index f083f6e..abd55bc 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -371,8 +371,6 @@ dev/ispfw/ispfw.c optional ispfw
dev/lge/if_lge.c optional lge
dev/lmc/if_lmc.c optional lmc
dev/lnc/if_lnc.c optional lnc
-dev/lnc/if_lnc_isa.c optional lnc isa
-dev/lnc/if_lnc_pc98.c optional lnc isa
dev/lnc/if_lnc_pci.c optional lnc pci
dev/ncv/ncr53c500.c optional ncv
dev/ncv/ncr53c500_pccard.c optional ncv card
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index 02989e5..02fd310 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -107,6 +107,7 @@ dev/kbd/kbd.c optional kbd
dev/kbd/kbd.c optional sc
dev/kbd/kbd.c optional ukbd
dev/kbd/kbd.c optional vt
+dev/lnc/if_lnc_isa.c optional lnc isa
dev/sr/if_sr_isa.c optional sr isa
dev/syscons/schistory.c count sc
dev/syscons/scmouse.c optional sc
diff --git a/sys/conf/files.pc98 b/sys/conf/files.pc98
index 330c201..399a57a 100644
--- a/sys/conf/files.pc98
+++ b/sys/conf/files.pc98
@@ -103,6 +103,7 @@ dev/kbd/kbd.c optional kbd
dev/kbd/kbd.c optional sc
dev/kbd/kbd.c optional ukbd
dev/kbd/kbd.c count pckbd
+dev/lnc/if_lnc_cbus.c optional lnc isa
dev/snc/dp83932.c optional snc
dev/snc/dp83932subr.c optional snc
dev/snc/if_snc.c optional snc
diff --git a/sys/dev/lnc/if_lnc.c b/sys/dev/lnc/if_lnc.c
index 5031065..9028b98 100644
--- a/sys/dev/lnc/if_lnc.c
+++ b/sys/dev/lnc/if_lnc.c
@@ -140,41 +140,52 @@ void lnc_dump_state __P((struct lnc_softc *sc));
void mbuf_dump_chain __P((struct mbuf *m));
#endif
-void write_csr(struct lnc_softc *, u_short, u_short);
-u_short read_csr(struct lnc_softc *, u_short);
-void lnc_release_resources(device_t);
-
u_short
read_csr(struct lnc_softc *sc, u_short port)
{
- bus_space_write_2(sc->lnc_btag, sc->lnc_bhandle, sc->rap, port);
- return(bus_space_read_2(sc->lnc_btag, sc->lnc_bhandle, sc->rdp));
+ lnc_outw(sc->rap, port);
+ return (lnc_inw(sc->rdp));
}
void
write_csr(struct lnc_softc *sc, u_short port, u_short val)
{
- bus_space_write_2(sc->lnc_btag, sc->lnc_bhandle, sc->rap, port);
- bus_space_write_2(sc->lnc_btag, sc->lnc_bhandle, sc->rdp, val);
+ lnc_outw(sc->rap, port);
+ lnc_outw(sc->rdp, val);
}
-#undef inb
-#define inb(port) bus_space_read_1(sc->lnc_btag, sc->lnc_bhandle, port)
-#define inw(port) bus_space_read_2(sc->lnc_btag, sc->lnc_bhandle, port)
-#define outw(port, val) bus_space_write_2(sc->lnc_btag, sc->lnc_bhandle, port, val)
-
static __inline void
write_bcr(struct lnc_softc *sc, u_short port, u_short val)
{
- outw(sc->rap, port);
- outw(sc->bdp, val);
+ lnc_outw(sc->rap, port);
+ lnc_outw(sc->bdp, val);
}
static __inline u_short
read_bcr(struct lnc_softc *sc, u_short port)
{
- outw(sc->rap, port);
- return (inw(sc->bdp));
+ lnc_outw(sc->rap, port);
+ return (lnc_inw(sc->bdp));
+}
+
+int
+lance_probe(struct lnc_softc *sc)
+{
+ write_csr(sc, CSR0, STOP);
+
+ if ((lnc_inw(sc->rdp) & STOP) && ! (read_csr(sc, CSR3))) {
+ /*
+ * Check to see if it's a C-LANCE. For the LANCE the INEA bit
+ * cannot be set while the STOP bit is. This restriction is
+ * removed for the C-LANCE.
+ */
+ write_csr(sc, CSR0, INEA);
+ if (read_csr(sc, CSR0) & INEA)
+ return (C_LANCE);
+ else
+ return (LANCE);
+ } else
+ return (UNKNOWN);
}
static __inline u_long
@@ -613,7 +624,7 @@ lnc_rint(struct lnc_softc *sc)
* here have been dealt with.
*/
- outw(sc->rdp, RINT | INEA);
+ lnc_outw(sc->rdp, RINT | INEA);
}
static __inline void
@@ -848,7 +859,7 @@ lnc_tint(struct lnc_softc *sc)
* the completed transmissions.
*/
- outw(sc->rdp, TINT | INEA);
+ lnc_outw(sc->rdp, TINT | INEA);
}
int
@@ -859,10 +870,14 @@ lnc_attach_common(device_t dev)
int i;
int skip;
- if (sc->nic.ident == BICC) {
+ switch (sc->nic.ident) {
+ case BICC:
+ case CNET98S:
skip = 2;
- } else {
+ break;
+ default:
skip = 1;
+ break;
}
/* Set default mode */
@@ -884,7 +899,7 @@ lnc_attach_common(device_t dev)
/* Extract MAC address from PROM */
for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->arpcom.ac_enaddr[i] = inb(i * skip);
+ sc->arpcom.ac_enaddr[i] = lnc_inb(i * skip);
/*
* XXX -- should check return status of if_attach
@@ -1118,7 +1133,7 @@ lncintr(void *arg)
* we have to include it in any writes that clear other flags.
*/
- while ((csr0 = inw(sc->rdp)) & INTR) {
+ while ((csr0 = lnc_inw(sc->rdp)) & INTR) {
/*
* Clear interrupt flags early to avoid race conditions. The
@@ -1128,8 +1143,8 @@ lncintr(void *arg)
* be missed.
*/
- outw(sc->rdp, csr0);
- /*outw(sc->rdp, IDON | CERR | BABL | MISS | MERR | RINT | TINT | INEA);*/
+ lnc_outw(sc->rdp, csr0);
+ /*lnc_outw(sc->rdp, IDON | CERR | BABL | MISS | MERR | RINT | TINT | INEA);*/
#ifdef notyet
if (csr0 & IDON) {
@@ -1355,7 +1370,7 @@ lnc_start(struct ifnet *ifp)
}
/* Force an immediate poll of the transmit ring */
- outw(sc->rdp, TDMD | INEA);
+ lnc_outw(sc->rdp, TDMD | INEA);
/*
* Set a timer so if the buggy Am7990.h shuts
@@ -1514,7 +1529,7 @@ lnc_dump_state(struct lnc_softc *sc)
read_csr(sc, CSR2), read_csr(sc, CSR3));
/* Set RAP back to CSR0 */
- outw(sc->rap, CSR0);
+ lnc_outw(sc->rap, CSR0);
}
void
diff --git a/sys/dev/lnc/if_lnc_cbus.c b/sys/dev/lnc/if_lnc_cbus.c
new file mode 100644
index 0000000..85be471
--- /dev/null
+++ b/sys/dev/lnc/if_lnc_cbus.c
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 1994-2000
+ * Paul Richards. All rights reserved.
+ *
+ * PC-98 port by Chiharu Shibata & FreeBSD(98) porting team.
+ *
+ * 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,
+ * verbatim and that no modifications are made prior to this
+ * point in the file.
+ * 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 Paul Richards may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``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 PAUL RICHARDS 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/socket.h>
+
+#include <machine/clock.h> /* DELAY() */
+#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/rman.h>
+
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+
+#include <isa/isavar.h>
+
+#include <dev/lnc/if_lncvar.h>
+#include <dev/lnc/if_lncreg.h>
+
+static struct isa_pnp_id lnc_pnp_ids[] = {
+ {0, NULL}
+};
+
+static bus_addr_t lnc_ioaddr_cnet98s[CNET98S_IOSIZE] = {
+ 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007,
+ 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f,
+ 0x400, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407,
+ 0x408, 0x409, 0x40a, 0x40b, 0x40c, 0x40d, 0x40e, 0x40f,
+};
+
+static int
+lnc_legacy_probe(device_t dev)
+{
+ struct lnc_softc *sc = device_get_softc(dev);
+ u_int16_t tmp;
+
+ sc->portrid = 0;
+ sc->portres = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &sc->portrid,
+ lnc_ioaddr_cnet98s, CNET98S_IOSIZE,
+ RF_ACTIVE);
+
+ if (! sc->portres) {
+ device_printf(dev, "Failed to allocate I/O ports\n");
+ lnc_release_resources(dev);
+ return (ENXIO);
+ }
+
+ isa_load_resourcev(sc->portres, lnc_ioaddr_cnet98s, CNET98S_IOSIZE);
+
+ sc->lnc_btag = rman_get_bustag(sc->portres);
+ sc->lnc_bhandle = rman_get_bushandle(sc->portres);
+
+ /* Reset */
+ tmp = lnc_inw(CNET98S_RESET);
+ lnc_outw(CNET98S_RESET, tmp);
+ DELAY(500);
+
+ sc->rap = CNET98S_RAP;
+ sc->rdp = CNET98S_RDP;
+ sc->nic.mem_mode = DMA_FIXED;
+
+ if ((sc->nic.ic = lance_probe(sc))) {
+ sc->nic.ident = CNET98S;
+ device_set_desc(dev, "C-NET(98)S");
+ lnc_release_resources(dev);
+ return (0);
+ } else {
+ lnc_release_resources(dev);
+ return (ENXIO);
+ }
+}
+
+static int
+lnc_isa_probe(device_t dev)
+{
+ int pnp;
+
+ pnp = ISA_PNP_PROBE(device_get_parent(dev), dev, lnc_pnp_ids);
+ if (pnp == ENOENT) {
+ /* It's not a PNP card, see if we support it by probing it */
+ return (lnc_legacy_probe(dev));
+ } else if (pnp == ENXIO) {
+ return (ENXIO);
+ } else {
+ /* Found PNP card we support */
+ return (0);
+ }
+}
+
+static void
+lnc_alloc_callback(void *arg, bus_dma_segment_t *seg, int nseg, int error)
+{
+ /* Do nothing */
+ return;
+}
+
+static int
+lnc_isa_attach(device_t dev)
+{
+ lnc_softc_t *sc = device_get_softc(dev);
+ int err = 0;
+ bus_size_t lnc_mem_size;
+
+ device_printf(dev, "Attaching %s\n", device_get_desc(dev));
+
+ sc->portrid = 0;
+ sc->portres = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &sc->portrid,
+ lnc_ioaddr_cnet98s, CNET98S_IOSIZE,
+ RF_ACTIVE);
+
+ if (! sc->portres) {
+ device_printf(dev, "Failed to allocate I/O ports\n");
+ lnc_release_resources(dev);
+ return (ENXIO);
+ }
+
+ isa_load_resourcev(sc->portres, lnc_ioaddr_cnet98s, CNET98S_IOSIZE);
+
+ sc->lnc_btag = rman_get_bustag(sc->portres);
+ sc->lnc_bhandle = rman_get_bushandle(sc->portres);
+
+ sc->drqrid = 0;
+ sc->drqres = NULL;
+
+ if (isa_get_irq(dev) == -1)
+ bus_set_resource(dev, SYS_RES_IRQ, 0, 6, 1);
+
+ sc->irqrid = 0;
+ sc->irqres = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irqrid, 0, ~0, 1,
+ RF_ACTIVE);
+
+ if (! sc->irqres) {
+ device_printf(dev, "Failed to allocate irq\n");
+ lnc_release_resources(dev);
+ return (ENXIO);
+ }
+
+ err = bus_setup_intr(dev, sc->irqres, INTR_TYPE_NET, lncintr,
+ sc, &sc->intrhand);
+
+ if (err) {
+ device_printf(dev, "Failed to setup irq handler\n");
+ lnc_release_resources(dev);
+ return (err);
+ }
+
+ /* XXX temp setting for nic */
+ sc->nic.mem_mode = DMA_FIXED;
+ sc->nrdre = NRDRE;
+ sc->ntdre = NTDRE;
+
+ if (sc->nic.ident == CNET98S) {
+ sc->rap = CNET98S_RAP;
+ sc->rdp = CNET98S_RDP;
+ } else if (sc->nic.ident == NE2100) {
+ sc->rap = PCNET_RAP;
+ sc->rdp = PCNET_RDP;
+ sc->bdp = PCNET_BDP;
+ } else {
+ sc->rap = BICC_RAP;
+ sc->rdp = BICC_RDP;
+ }
+
+ /* Create a DMA tag describing the ring memory we need */
+
+ lnc_mem_size = ((NDESC(sc->nrdre) + NDESC(sc->ntdre)) *
+ sizeof(struct host_ring_entry));
+
+ lnc_mem_size += (NDESC(sc->nrdre) * RECVBUFSIZE) +
+ (NDESC(sc->ntdre) * TRANSBUFSIZE);
+
+ err = bus_dma_tag_create(NULL, /* parent */
+ 4, /* alignement */
+ 0, /* boundary */
+ BUS_SPACE_MAXADDR_24BIT, /* lowaddr */
+ BUS_SPACE_MAXADDR, /* highaddr */
+ NULL, NULL, /* filter, filterarg */
+ lnc_mem_size, /* segsize */
+ 1, /* nsegments */
+ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
+ 0, /* flags */
+ &sc->dmat);
+
+ if (err) {
+ device_printf(dev, "Can't create DMA tag\n");
+ lnc_release_resources(dev);
+ return (ENOMEM);
+ }
+
+ err = bus_dmamem_alloc(sc->dmat, (void **)&sc->recv_ring,
+ BUS_DMA_NOWAIT, &sc->dmamap);
+
+ if (err) {
+ device_printf(dev, "Couldn't allocate memory\n");
+ lnc_release_resources(dev);
+ return (ENOMEM);
+ }
+
+ err = bus_dmamap_load(sc->dmat, sc->dmamap, sc->recv_ring, lnc_mem_size,
+ lnc_alloc_callback, sc->recv_ring, BUS_DMA_NOWAIT);
+
+ if (err) {
+ device_printf(dev, "Couldn't load DMA map\n");
+ lnc_release_resources(dev);
+ return (ENOMEM);
+ }
+
+ /* Call generic attach code */
+ if (! lnc_attach_common(dev)) {
+ device_printf(dev, "Generic attach code failed\n");
+ lnc_release_resources(dev);
+ return (ENXIO);
+ }
+
+ /*
+ * ISA Configuration
+ *
+ * XXX - Following parameters are Contec C-NET(98)S only.
+ * So, check the Ethernet address here.
+ *
+ * Contec uses 00 80 4c ?? ?? ??
+ */
+ if (sc->arpcom.ac_enaddr[0] == (u_char)0x00 &&
+ sc->arpcom.ac_enaddr[1] == (u_char)0x80 &&
+ sc->arpcom.ac_enaddr[2] == (u_char)0x4c) {
+ lnc_outw(sc->rap, MSRDA);
+ lnc_outw(CNET98S_IDP, 0x0006);
+ lnc_outw(sc->rap, MSWRA);
+ lnc_outw(CNET98S_IDP, 0x0006);
+#ifdef DIAGNOSTIC
+ lnc_outw(sc->rap, MC);
+ printf("ISACSR2 = %x\n", lnc_inw(CNET98S_IDP));
+#endif
+ lnc_outw(sc->rap, LED1);
+ lnc_outw(CNET98S_IDP, LED_PSE | LED_XMTE);
+ lnc_outw(sc->rap, LED2);
+ lnc_outw(CNET98S_IDP, LED_PSE | LED_RCVE);
+ lnc_outw(sc->rap, LED3);
+ lnc_outw(CNET98S_IDP, LED_PSE | LED_COLE);
+ }
+
+ return (0);
+}
+
+static int
+lnc_isa_detach(device_t dev)
+{
+ lnc_softc_t *sc = device_get_softc(dev);
+ int s = splimp();
+
+ ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
+ splx(s);
+
+ lnc_stop(sc);
+ lnc_release_resources(dev);
+
+ return (0);
+}
+
+static device_method_t lnc_isa_methods[] = {
+/* DEVMETHOD(device_identify, lnc_isa_identify), */
+ DEVMETHOD(device_probe, lnc_isa_probe),
+ DEVMETHOD(device_attach, lnc_isa_attach),
+ DEVMETHOD(device_detach, lnc_isa_detach),
+#ifdef notyet
+ DEVMETHOD(device_suspend, lnc_isa_suspend),
+ DEVMETHOD(device_resume, lnc_isa_resume),
+ DEVMETHOD(device_shutdown, lnc_isa_shutdown),
+#endif
+ { 0, 0 }
+};
+
+static driver_t lnc_isa_driver = {
+ "lnc",
+ lnc_isa_methods,
+ sizeof(struct lnc_softc),
+};
+
+DRIVER_MODULE(if_lnc, isa, lnc_isa_driver, lnc_devclass, 0, 0);
diff --git a/sys/dev/lnc/if_lnc_isa.c b/sys/dev/lnc/if_lnc_isa.c
index a82ff5a..c973494 100644
--- a/sys/dev/lnc/if_lnc_isa.c
+++ b/sys/dev/lnc/if_lnc_isa.c
@@ -37,8 +37,6 @@
#include <sys/malloc.h>
#include <sys/socket.h>
-#include <machine/bus_memio.h>
-#include <machine/bus_pio.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
@@ -56,31 +54,6 @@ static struct isa_pnp_id lnc_pnp_ids[] = {
{0, NULL}
};
-extern void write_csr(struct lnc_softc *, u_short, u_short);
-extern u_short read_csr(struct lnc_softc *, u_short);
-extern void lnc_release_resources(device_t);
-
-static int
-lance_probe(struct lnc_softc *sc)
-{
- write_csr(sc, CSR0, STOP);
-
- if ((bus_space_read_2(sc->lnc_btag, sc->lnc_bhandle, sc->rdp) & STOP) &&
- ! (read_csr(sc, CSR3))) {
- /*
- * Check to see if it's a C-LANCE. For the LANCE the INEA bit
- * cannot be set while the STOP bit is. This restriction is
- * removed for the C-LANCE.
- */
- write_csr(sc, CSR0, INEA);
- if (read_csr(sc, CSR0) & INEA)
- return (C_LANCE);
- else
- return (LANCE);
- } else
- return (UNKNOWN);
-}
-
static int
lnc_legacy_probe(device_t dev)
{
diff --git a/sys/dev/lnc/if_lnc_pc98.c b/sys/dev/lnc/if_lnc_pc98.c
deleted file mode 100644
index 9284a46..0000000
--- a/sys/dev/lnc/if_lnc_pc98.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*-
- * Copyright (c) 2000
- * Paul Richards. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 Paul Richards may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``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 PAUL RICHARDS 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.
- *
- * $FreeBSD$
- */
-
-#ifdef notyet
-
-#ifdef PC98
-
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/systm.h>
-
-#include <machine/clock.h>
-
-#include <net/ethernet.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_types.h>
-
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-
-#include <i386/isa/isa_device.h>
-
-#include <dev/lnc/if_lncvar.h>
-#include <dev/lnc/if_lncreg.h>
-
-int pcnet_probe __P((lnc_softc_t *sc));
-int cnet98s_probe __P((lnc_softc_t *sc, unsigned iobase));
-
-int
-cnet98s_probe(lnc_softc_t *sc, unsigned iobase)
-{
- int i;
- ushort tmp;
-
- sc->rap = iobase + CNET98S_RAP;
- sc->rdp = iobase + CNET98S_RDP;
-
- /* Reset */
- tmp = inw(iobase + CNET98S_RESET);
- outw(iobase + CNET98S_RESET, tmp);
- DELAY(500);
-
- sc->nic.ic = pcnet_probe(sc);
- if ((sc->nic.ic == UNKNOWN) || (sc->nic.ic > PCnet_32)) {
- return (0);
- }
-
- sc->nic.ident = CNET98S;
- sc->nic.mem_mode = DMA_FIXED;
-
- /* XXX - For now just use the defines */
- sc->nrdre = NRDRE;
- sc->ntdre = NTDRE;
-
- /* Extract MAC address from PROM */
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- sc->arpcom.ac_enaddr[i] = inb(iobase + (i * 2));
- }
-
- /*
- * ISA Configuration
- *
- * XXX - Following parameters are Contec C-NET(98)S only.
- * So, check the Ethernet address here.
- *
- * Contec uses 00 80 4c ?? ?? ??
- */
- if (sc->arpcom.ac_enaddr[0] == (u_char)0x00
- && sc->arpcom.ac_enaddr[1] == (u_char)0x80
- && sc->arpcom.ac_enaddr[2] == (u_char)0x4c) {
- outw(sc->rap, MSRDA);
- outw(iobase + CNET98S_IDP, 0x0006);
- outw(sc->rap, MSWRA);
- outw(iobase + CNET98S_IDP, 0x0006);
-#ifdef DIAGNOSTIC
- outw(sc->rap, MC);
- printf("ISACSR2 = %x\n", inw(iobase + CNET98S_IDP));
-#endif
- outw(sc->rap, LED1);
- outw(iobase + CNET98S_IDP, LED_PSE | LED_XMTE);
- outw(sc->rap, LED2);
- outw(iobase + CNET98S_IDP, LED_PSE | LED_RCVE);
- outw(sc->rap, LED3);
- outw(iobase + CNET98S_IDP, LED_PSE | LED_COLE);
- }
-
- return (CNET98S_IOSIZE);
-}
-
-#endif
-
-#endif /* notyet */
diff --git a/sys/dev/lnc/if_lnc_pci.c b/sys/dev/lnc/if_lnc_pci.c
index e19a756..00d7ab8 100644
--- a/sys/dev/lnc/if_lnc_pci.c
+++ b/sys/dev/lnc/if_lnc_pci.c
@@ -36,8 +36,6 @@
#include <sys/malloc.h>
#include <sys/kernel.h>
-#include <machine/bus_memio.h>
-#include <machine/bus_pio.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/bus.h>
@@ -122,7 +120,6 @@ lnc_pci_attach(device_t dev)
if (err)
device_printf(dev, "Cannot setup irq handler\n");
- sc->iobase = rman_get_start(sc->portres);
sc->lnc_btag = rman_get_bustag(sc->portres);
sc->lnc_bhandle = rman_get_bushandle(sc->portres);
diff --git a/sys/dev/lnc/if_lncreg.h b/sys/dev/lnc/if_lncreg.h
index a57d7ff..86e1d8b 100644
--- a/sys/dev/lnc/if_lncreg.h
+++ b/sys/dev/lnc/if_lncreg.h
@@ -84,6 +84,22 @@
#define ACON 0x0002
#define BCON 0x0001
+/* ISA Bus Configuration Registers */
+#define MSRDA 0x0000 /* ISACSR0: Master Mode Read Activity */
+#define MSWRA 0x0001 /* ISACSR1: Master Mode Write Activity */
+#define MC 0x0002 /* ISACSR2: Miscellaneous Configuration */
+
+#define LED1 0x0005 /* ISACSR5: LED1 Status */
+#define LED2 0x0006 /* ISACSR6: LED2 Status */
+#define LED3 0x0007 /* ISACSR7: LED3 Status */
+
+#define LED_PSE 0x0080 /* Pulse Stretcher */
+#define LED_XMTE 0x0010 /* Transmit Status */
+#define LED_RVPOLE 0x0008 /* Receive Polarity */
+#define LED_RCVE 0x0004 /* Receive Status */
+#define LED_JABE 0x0002 /* Jabber */
+#define LED_COLE 0x0001 /* Collision */
+
/* Initialisation block */
struct init_block {
@@ -191,32 +207,3 @@ struct mds {
#define LCAR 0x0800 /* Loss of carrier */
#define RTRY 0x0400 /* Tried 16 times */
#define TDR 0x03FF /* Time domain reflectometry */
-
-/* C-NET(98)S port addresses */
-#define CNET98S_RDP 0x400 /* Register Data Port */
-#define CNET98S_RAP 0x402 /* Register Address Port */
-#define CNET98S_RESET 0x404
-#define CNET98S_IDP 0x406
-#define CNET98S_EEPROM 0x40e
-/*
- * XXX - The I/O address range is fragmented in the C-NET(98)S.
- * This is the number of regs at iobase.
- */
-#define CNET98S_IOSIZE 16 /* # of i/o addresses used. */
-
-/* ISA Bus Configuration Registers */
-/* XXX - Should be in ic/Am7990.h */
-#define MSRDA 0x0000 /* ISACSR0: Master Mode Read Activity */
-#define MSWRA 0x0001 /* ISACSR1: Master Mode Write Activity */
-#define MC 0x0002 /* ISACSR2: Miscellaneous Configuration */
-
-#define LED1 0x0005 /* ISACSR5: LED1 Status */
-#define LED2 0x0006 /* ISACSR6: LED2 Status */
-#define LED3 0x0007 /* ISACSR7: LED3 Status */
-
-#define LED_PSE 0x0080 /* Pulse Stretcher */
-#define LED_XMTE 0x0010 /* Transmit Status */
-#define LED_RVPOLE 0x0008 /* Receive Polarity */
-#define LED_RCVE 0x0004 /* Receive Status */
-#define LED_JABE 0x0002 /* Jabber */
-#define LED_COLE 0x0001 /* Collision */
diff --git a/sys/dev/lnc/if_lncvar.h b/sys/dev/lnc/if_lncvar.h
index 7c4ed70..15df774 100644
--- a/sys/dev/lnc/if_lncvar.h
+++ b/sys/dev/lnc/if_lncvar.h
@@ -76,19 +76,14 @@
/* DEPCA specific defines */
#define DEPCA_ADDR_ROM_SIZE 32
-#ifdef PC98
/* C-NET(98)S port addresses */
-#define CNET98S_RDP 0x400 /* Register Data Port */
-#define CNET98S_RAP 0x402 /* Register Address Port */
-#define CNET98S_RESET 0x404
-#define CNET98S_IDP 0x406
-#define CNET98S_EEPROM 0x40e
-/*
- * XXX - The I/O address range is fragmented in the C-NET(98)S.
- * This is the number of regs at iobase.
- */
-#define CNET98S_IOSIZE 16 /* # of i/o addresses used. */
-#endif
+/* Notice, we can ignore fragmantation by using isa_alloc_resourcev(). */
+#define CNET98S_IOSIZE 32
+#define CNET98S_RDP 0x10 /* Register Data Port */
+#define CNET98S_RAP 0x12 /* Register Address Port */
+#define CNET98S_RESET 0x14
+#define CNET98S_IDP 0x16
+#define CNET98S_EEPROM 0x1e
/* Chip types */
#define LANCE 1 /* Am7990 */
@@ -199,7 +194,6 @@ typedef struct lnc_softc {
int drqrid;
struct resource *portres;
int portrid;
- int iobase;
bus_space_tag_t lnc_btag;
bus_space_handle_t lnc_bhandle;
void *intrhand;
@@ -250,10 +244,22 @@ struct host_ring_entry {
#define RECV_NEXT (sc->recv_ring->base + sc->recv_next)
#define TRANS_NEXT (sc->trans_ring->base + sc->trans_next)
+#define lnc_inb(port) \
+ bus_space_read_1(sc->lnc_btag, sc->lnc_bhandle, (port))
+#define lnc_inw(port) \
+ bus_space_read_2(sc->lnc_btag, sc->lnc_bhandle, (port))
+#define lnc_outw(port, val) \
+ bus_space_write_2(sc->lnc_btag, sc->lnc_bhandle, (port), (val))
+
/* Functional declarations */
+extern int lance_probe __P((struct lnc_softc *));
+extern void lnc_release_resources __P((device_t));
extern int lnc_attach_common __P((device_t));
extern void lnc_stop __P((struct lnc_softc *));
+extern void write_csr __P((struct lnc_softc *, u_short, u_short));
+extern u_short read_csr __P((struct lnc_softc *, u_short));
+
/* Variable declarations */
extern driver_intr_t lncintr;
extern devclass_t lnc_devclass;
diff --git a/sys/modules/lnc/Makefile b/sys/modules/lnc/Makefile
index a9b823b..fdc56c4 100644
--- a/sys/modules/lnc/Makefile
+++ b/sys/modules/lnc/Makefile
@@ -3,10 +3,18 @@
.PATH: ${.CURDIR}/../../dev/lnc
KMOD= if_lnc
-SRCS= if_lnc.c if_lnc_pci.c if_lnc_isa.c if_lnc_pc98.c
+SRCS= if_lnc.c if_lnc_pci.c
+.if ${MACHINE} == "pc98"
+SRCS+= if_lnc_cbus.c
+.else
+SRCS+= if_lnc_isa.c
+.endif
SRCS+= opt_inet.h device_if.h bus_if.h isa_if.h pci_if.h
#SRCS+= miibus_if.h
CFLAGS+= -g -I${.CURDIR}/../../dev/lnc
+.if ${MACHINE} == "pc98"
+CFLAGS+= -DPC98
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/pc98/conf/GENERIC b/sys/pc98/conf/GENERIC
index 04f4b99..d6e9ad3 100644
--- a/sys/pc98/conf/GENERIC
+++ b/sys/pc98/conf/GENERIC
@@ -175,7 +175,7 @@ device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards
device ep # Etherlink III based cards
options FE_8BIT_SUPPORT # LAC-98 support
device fe # Fujitsu MB8696x based cards
-#device lnc
+device lnc # C-NET(98)S
device sn # SMC's 9000 series of ethernet chips
device snc
device xe # Xircom pccard ethernet
OpenPOWER on IntegriCloud