summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfgsch <fgsch@openbsd.org>1998-11-06 06:32:14 +0000
committerfgsch <fgsch@openbsd.org>1998-11-06 06:32:14 +0000
commite370c91bd798a5784831bb292051cc6de4f4c63f (patch)
treef681f86afb7dee8f9471088b81430e97f3edfec9
parentadd missing const to match prototype in string.h (diff)
downloadwireguard-openbsd-e370c91bd798a5784831bb292051cc6de4f4c63f.tar.xz
wireguard-openbsd-e370c91bd798a5784831bb292051cc6de4f4c63f.zip
Support for RealTek 8019 and 8029 NE2000-compatible network interfaces.
-rw-r--r--sys/conf/files4
-rw-r--r--sys/dev/ic/dp8390reg.h9
-rw-r--r--sys/dev/ic/ne2000.c7
-rw-r--r--sys/dev/ic/ne2000var.h5
-rw-r--r--sys/dev/ic/rtl80x9.c195
-rw-r--r--sys/dev/ic/rtl80x9reg.h163
-rw-r--r--sys/dev/ic/rtl80x9var.h61
-rw-r--r--sys/dev/isa/files.isa4
-rw-r--r--sys/dev/isa/files.isapnp4
-rw-r--r--sys/dev/isa/if_ne_isa.c37
-rw-r--r--sys/dev/isa/if_ne_isapnp.c37
-rw-r--r--sys/dev/pci/files.pci4
-rw-r--r--sys/dev/pci/if_ne_pci.c122
-rw-r--r--sys/dev/pcmcia/files.pcmcia4
-rw-r--r--sys/dev/pcmcia/if_ne_pcmcia.c38
15 files changed, 638 insertions, 56 deletions
diff --git a/sys/conf/files b/sys/conf/files
index 45befc05042..f54a9d926dd 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.96 1998/09/28 02:43:22 jason Exp $
+# $OpenBSD: files,v 1.97 1998/11/06 06:32:14 fgsch Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -35,6 +35,7 @@ define ncr5380sbc # NCR 5380 SCSI Bus Controller
define ncr53c9x # NCR 53c9x or Emulex ESP SCSI Controller
define pdq # DEC FDDI chipset
define dp8390nic # 8390-family Ethernet controllers
+define rtl80x9 # RealTek 8019/8029 NE2000-compatible
# a wscons output device; used later, but needs to be near the top for
# common file (e.g. vga) definitions.
@@ -170,6 +171,7 @@ file dev/ic/ncr53c9x.c ncr53c9x
file dev/ic/pdq.c pdq
file dev/ic/pdq_ifsubr.c pdq
file dev/ic/dp8390.c dp8390nic
+file dev/ic/rtl80x9.c rtl80x9
file dev/mulaw.c mulaw
file dev/vnd.c vnd needs-flag
file dev/rnd.c
diff --git a/sys/dev/ic/dp8390reg.h b/sys/dev/ic/dp8390reg.h
index d024396ad53..3917d88297a 100644
--- a/sys/dev/ic/dp8390reg.h
+++ b/sys/dev/ic/dp8390reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dp8390reg.h,v 1.6 1998/10/04 23:09:56 niklas Exp $ */
+/* $OpenBSD: dp8390reg.h,v 1.7 1998/11/06 06:32:14 fgsch Exp $ */
/* $NetBSD: dp8390reg.h,v 1.3 1997/04/29 04:32:08 scottr Exp $ */
/*
@@ -149,14 +149,15 @@
* 0 0 0
* 0 1 1
* 1 0 2
- * 1 1 reserved
+ * 1 1 3 (only on chips which have extensions to the dp8390)
*/
#define ED_CR_PS0 0x40
#define ED_CR_PS1 0x80
/* bit encoded aliases */
#define ED_CR_PAGE_0 0x00 /* (for consistency) */
-#define ED_CR_PAGE_1 0x40
-#define ED_CR_PAGE_2 0x80
+#define ED_CR_PAGE_1 (ED_CR_PS0)
+#define ED_CR_PAGE_2 (ED_CR_PS1)
+#define ED_CR_PAGE_3 (ED_CR_PS1|ED_CR_PS0)
/*
* Interrupt Status Register (ISR) definitions
diff --git a/sys/dev/ic/ne2000.c b/sys/dev/ic/ne2000.c
index 3df27966112..97c33e106d5 100644
--- a/sys/dev/ic/ne2000.c
+++ b/sys/dev/ic/ne2000.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ne2000.c,v 1.5 1998/10/14 07:34:42 fgsch Exp $ */
+/* $OpenBSD: ne2000.c,v 1.6 1998/11/06 06:32:15 fgsch Exp $ */
/* $NetBSD: ne2000.c,v 1.12 1998/06/10 01:15:50 thorpej Exp $ */
/*-
@@ -103,9 +103,10 @@ struct cfdriver ne_cd = {
};
void
-ne2000_attach(nsc, myea)
+ne2000_attach(nsc, myea, media, nmedia, defmedia)
struct ne2000_softc *nsc;
u_int8_t *myea;
+ int *media, nmedia, defmedia;
{
struct dp8390_softc *dsc = &nsc->sc_dp8390;
bus_space_tag_t nict = dsc->sc_regt;
@@ -252,7 +253,7 @@ ne2000_attach(nsc, myea)
/* Clear any pending interrupts that might have occurred above. */
bus_space_write_1(nict, nich, ED_P0_ISR, 0xff);
- if (dp8390_config(dsc, NULL, 0, 0)) {
+ if (dp8390_config(dsc, media, nmedia, defmedia)) {
printf("%s: setup failed\n", dsc->sc_dev.dv_xname);
return;
}
diff --git a/sys/dev/ic/ne2000var.h b/sys/dev/ic/ne2000var.h
index 3fba7b37e26..3e8d2bd7d38 100644
--- a/sys/dev/ic/ne2000var.h
+++ b/sys/dev/ic/ne2000var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ne2000var.h,v 1.1 1998/09/22 06:38:04 fgsch Exp $ */
+/* $OpenBSD: ne2000var.h,v 1.2 1998/11/06 06:32:15 fgsch Exp $ */
/* $NetBSD: ne2000var.h,v 1.2 1997/10/14 22:54:12 thorpej Exp $ */
/*-
@@ -54,7 +54,8 @@ struct ne2000_softc {
#define NE2000_TYPE_NE1000 1
#define NE2000_TYPE_NE2000 2
-void ne2000_attach __P((struct ne2000_softc *, u_int8_t *));
+void ne2000_attach __P((struct ne2000_softc *, u_int8_t *,
+ int *, int, int));
int ne2000_detect __P((bus_space_tag_t, bus_space_handle_t,
bus_space_tag_t, bus_space_handle_t));
diff --git a/sys/dev/ic/rtl80x9.c b/sys/dev/ic/rtl80x9.c
new file mode 100644
index 00000000000..c9a85d09ca6
--- /dev/null
+++ b/sys/dev/ic/rtl80x9.c
@@ -0,0 +1,195 @@
+/* $OpenBSD: rtl80x9.c,v 1.1 1998/11/06 06:34:36 fgsch Exp $ */
+/* $NetBSD: rtl80x9.c,v 1.1 1998/10/31 00:44:33 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include "bpfilter.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
+#include <sys/syslog.h>
+#include <sys/socket.h>
+#include <sys/device.h>
+
+#include <net/if.h>
+#ifdef __NetBSD__
+#include <net/if_ether.h>
+#endif
+#include <net/if_media.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#ifdef __NetBSD__
+#include <netinet/if_inarp.h>
+#else
+#include <netinet/if_ether.h>
+#endif
+#endif
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcidevs.h>
+
+#include <dev/ic/dp8390reg.h>
+#include <dev/ic/dp8390var.h>
+
+#include <dev/ic/ne2000reg.h>
+#include <dev/ic/ne2000var.h>
+
+#include <dev/ic/rtl80x9reg.h>
+#include <dev/ic/rtl80x9var.h>
+
+int
+rtl80x9_mediachange(dsc)
+ struct dp8390_softc *dsc;
+{
+
+ /*
+ * Current media is already set up. Just reset the interface
+ * to let the new value take hold. The new media will be
+ * set up in ne_pci_rtl8029_init_card() called via dp8390_init().
+ */
+ dp8390_reset(dsc);
+ return (0);
+}
+
+void
+rtl80x9_mediastatus(sc, ifmr)
+ struct dp8390_softc *sc;
+ struct ifmediareq *ifmr;
+{
+#ifdef __NetBSD__
+ struct ifnet *ifp = &sc->sc_ec.ec_if;
+#else
+ struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+#endif
+ u_int8_t cr_proto = sc->cr_proto |
+ ((ifp->if_flags & IFF_RUNNING) ? ED_CR_STA : ED_CR_STP);
+
+ /*
+ * Sigh, can detect which media is being used, but can't
+ * detect if we have link or not.
+ */
+
+ /* Set NIC to page 3 registers. */
+ NIC_PUT(sc->sc_regt, sc->sc_regh, ED_P0_CR, cr_proto | ED_CR_PAGE_3);
+
+ if (NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG0) &
+ RTL3_CONFIG0_BNC)
+ ifmr->ifm_active = IFM_ETHER|IFM_10_2;
+ else {
+ ifmr->ifm_active = IFM_ETHER|IFM_10_T;
+ if (NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3) &
+ RTL3_CONFIG3_FUDUP)
+ ifmr->ifm_active |= IFM_FDX;
+ }
+
+ /* Set NIC to page 0 registers. */
+ NIC_PUT(sc->sc_regt, sc->sc_regh, ED_P0_CR, cr_proto | ED_CR_PAGE_0);
+}
+
+void
+rtl80x9_init_card(sc)
+ struct dp8390_softc *sc;
+{
+ struct ifmedia *ifm = &sc->sc_media;
+#ifdef __NetBSD__
+ struct ifnet *ifp = &sc->sc_ec.ec_if;
+#else
+ struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+#endif
+ u_int8_t cr_proto = sc->cr_proto |
+ ((ifp->if_flags & IFF_RUNNING) ? ED_CR_STA : ED_CR_STP);
+ u_int8_t reg;
+
+ /* Set NIC to page 3 registers. */
+ NIC_PUT(sc->sc_regt, sc->sc_regh, ED_P0_CR, cr_proto | ED_CR_PAGE_3);
+
+ /* First, set basic media type. */
+ reg = NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG2);
+ reg &= ~(RTL3_CONFIG2_PL1|RTL3_CONFIG2_PL0);
+ switch (IFM_SUBTYPE(ifm->ifm_cur->ifm_media)) {
+ case IFM_AUTO:
+ /* Nothing to do; both bits clear == auto-detect. */
+ break;
+
+ case IFM_10_T:
+ reg |= RTL3_CONFIG2_PL0;
+ break;
+
+ case IFM_10_2:
+ reg |= RTL3_CONFIG2_PL1|RTL3_CONFIG2_PL0;
+ break;
+ }
+ NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG2, reg);
+
+ /* Now, set duplex mode. */
+ reg = NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3);
+ if (ifm->ifm_cur->ifm_media & IFM_FDX)
+ reg |= RTL3_CONFIG3_FUDUP;
+ else
+ reg &= ~RTL3_CONFIG3_FUDUP;
+ NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3, reg);
+
+ /* Set NIC to page 0 registers. */
+ NIC_PUT(sc->sc_regt, sc->sc_regh, ED_P0_CR, cr_proto | ED_CR_PAGE_0);
+}
+
+void
+rtl80x9_init_media(sc, mediap, nmediap, defmediap)
+ struct dp8390_softc *sc;
+ int **mediap, *nmediap, *defmediap;
+{
+ static int rtl80x9_media[] = {
+ IFM_ETHER|IFM_AUTO,
+ IFM_ETHER|IFM_10_T,
+ IFM_ETHER|IFM_10_T|IFM_FDX,
+ IFM_ETHER|IFM_10_2,
+ };
+
+ printf("%s: 10base2, 10baseT, 10baseT-FDX, auto, default auto\n",
+ sc->sc_dev.dv_xname);
+
+ *mediap = rtl80x9_media;
+ *nmediap = sizeof(rtl80x9_media) / sizeof(rtl80x9_media[0]);
+ *defmediap = IFM_ETHER|IFM_AUTO;
+}
diff --git a/sys/dev/ic/rtl80x9reg.h b/sys/dev/ic/rtl80x9reg.h
new file mode 100644
index 00000000000..fdc75bc39d8
--- /dev/null
+++ b/sys/dev/ic/rtl80x9reg.h
@@ -0,0 +1,163 @@
+/* $OpenBSD: rtl80x9reg.h,v 1.1 1998/11/06 06:34:36 fgsch Exp $ */
+/* $NetBSD: rtl80x9reg.h,v 1.2 1998/10/31 00:31:43 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Registers on RealTek 8019 and 8029 NE2000-compatible network interfaces.
+ *
+ * Data sheets for these chips can be found at:
+ *
+ * http://www.realtek.com.tw
+ */
+
+#ifndef _DEV_IC_RTL80x9_REG_H_
+#define _DEV_IC_RTL80x9_REG_H_
+
+/*
+ * Page 0 register offsets.
+ */
+#define NERTL_RTL0_8019ID0 0x0a /* 8019 ID Register 0 */
+#define RTL0_8019ID0 'P'
+
+#define NERTL_RTL0_8019ID1 0x0b /* 8019 ID Register 1 */
+#define RTL0_8019ID1 'p'
+
+/*
+ * Page 3 register offsets.
+ */
+#define NERTL_RTL3_EECR 0x01 /* EEPROM Command Register */
+#define RTL3_EECR_EEM1 0x80 /* EEPROM Operating Mode */
+#define RTL3_EECR_EEM0 0x40
+ /* 0 0 Normal operation */
+ /* 0 1 Auto-load */
+ /* 1 0 9346 programming */
+ /* 1 1 Config register write enab */
+#define RTL3_EECR_EECS 0x08 /* EEPROM Chip Select */
+#define RTL3_EECR_EESK 0x04 /* EEPROM Clock */
+#define RTL3_EECR_EEDI 0x02 /* EEPROM Data In */
+#define RTL3_EECR_EEDO 0x01 /* EEPROM Data Out */
+
+#define NERTL_RTL3_BPAGE 0x02 /* BROM Page Regiseter (8019) */
+
+#define NERTL_RTL3_CONFIG0 0x03 /* Configuration 0 (ro) */
+#define RTL3_CONFIG0_JP 0x08 /* jumper mode (8019) */
+#define RTL3_CONFIG0_BNC 0x04 /* BNC is active */
+
+#define NERTL_RTL3_CONFIG1 0x04 /* Configuration 1 (8019) */
+#define RTL3_CONFIG1_IRQEN 0x80 /* IRQ Enable */
+#define RTL3_CONFIG1_IRQS2 0x40 /* IRQ Select */
+#define RTL3_CONFIG1_IRQS1 0x20
+#define RTL3_CONFIG1_IRQS0 0x10
+ /* 0 0 0 int 0 irq 2/9 */
+ /* 0 0 1 int 1 irq 3 */
+ /* 0 1 0 int 2 irq 4 */
+ /* 0 1 1 int 3 irq 5 */
+ /* 1 0 0 int 4 irq 10 */
+ /* 1 0 1 int 5 irq 11 */
+ /* 1 1 0 int 6 irq 12 */
+ /* 1 1 1 int 7 irq 15 */
+#define RTL_CONFIG1_IOS3 0x08 /* I/O base Select */
+#define RTL_CONFIG1_IOS2 0x04
+#define RTL_CONFIG1_IOS1 0x02
+#define RTL_CONFIG1_IOS0 0x01
+ /* 0 0 0 0 0x300 */
+ /* 0 0 0 1 0x320 */
+ /* 0 0 1 0 0x340 */
+ /* 0 0 1 1 0x360 */
+ /* 0 1 0 0 0x380 */
+ /* 0 1 0 1 0x3a0 */
+ /* 0 1 1 0 0x3c0 */
+ /* 0 1 1 1 0x3e0 */
+ /* 1 0 0 0 0x200 */
+ /* 1 0 0 1 0x220 */
+ /* 1 0 1 0 0x240 */
+ /* 1 0 1 1 0x260 */
+ /* 1 1 0 0 0x280 */
+ /* 1 1 0 1 0x2a0 */
+ /* 1 1 1 0 0x2c0 */
+ /* 1 1 1 1 0x2e0 */
+
+#define NERTL_RTL3_CONFIG2 0x05 /* Configuration 2 */
+#define RTL3_CONFIG2_PL1 0x80 /* Network media type */
+#define RTL3_CONFIG2_PL0 0x40
+ /* 0 0 TP/CX auto-detect */
+ /* 0 1 10baseT */
+ /* 1 0 10base5 */
+ /* 1 1 10base2 */
+#define RTL3_CONFIG2_8029FCE 0x20 /* Flow Control Enable */
+#define RTL3_CONFIG2_8029PF 0x10 /* Pause Flag */
+#define RTL3_CONFIG2_8029BS1 0x02 /* Boot Rom Size */
+#define RTL3_CONFIG2_8029BS0 0x01
+ /* 0 0 No Boot Rom */
+ /* 0 1 8k */
+ /* 1 0 16k */
+ /* 1 1 32k */
+#define RTL3_CONFIG2_8019BSELB 0x20 /* BROM disable */
+#define RTL3_CONFIG2_8019BS4 0x10 /* BROM size/base */
+#define RTL3_CONFIG2_8019BS3 0x08
+#define RTL3_CONFIG2_8019BS2 0x04
+#define RTL3_CONFIG2_8019BS1 0x02
+#define RTL3_CONFIG2_8019BS0 0x01
+
+#define NERTL_RTL3_CONFIG3 0x06 /* Configuration 3 */
+#define RTL3_CONFIG3_8019PNP 0x80 /* PnP Mode */
+#define RTL3_CONFIG3_FUDUP 0x40 /* Full Duplex */
+#define RTL3_CONFIG3_LEDS1 0x20 /* LED1/2 pin configuration */
+ /* 0 LED1 == LED_RX, LED2 == LED_TX */
+ /* 1 LED1 == LED_CRS, LED2 == MCSB */
+#define RTL3_CONFIG3_LEDS0 0x10 /* LED0 pin configration */
+ /* 0 LED0 pin == LED_COL */
+ /* 1 LED0 pin == LED_LINK */
+#define RTL3_CONFIG3_SLEEP 0x04 /* Sleep mode */
+#define RTL3_CONFIG3_PWRDN 0x02 /* Power Down */
+#define RTL3_CONFIG3_8019ACTIVEB 0x01 /* inverse of bit 0 in PnP Act Reg */
+
+#define NERTL_RTL3_CSNSAV 0x08 /* CSN Save Register (8019) */
+
+#define NERTL_RTL3_HLTCLK 0x09 /* Halt Clock */
+#define RTL3_HLTCLK_RUNNING 'R' /* clock runs in power down */
+#define RTL3_HLTCLK_HALTED 'H' /* clock halted in power down */
+
+#define NERTL_RTL3_INTR 0x0b /* ISA bus states of INT7-0 (8019) */
+
+#define NERTL_RTL3_8029ID0 0x0e /* ID register 0 */
+
+#define NERTL_RTL3_8029ID1 0x0f /* ID register 1 */
+
+#endif /* _DEV_IC_RTL80x9_REG_H_ */
diff --git a/sys/dev/ic/rtl80x9var.h b/sys/dev/ic/rtl80x9var.h
new file mode 100644
index 00000000000..b158dc4855b
--- /dev/null
+++ b/sys/dev/ic/rtl80x9var.h
@@ -0,0 +1,61 @@
+/* $OpenBSD: rtl80x9var.h,v 1.1 1998/11/06 06:34:36 fgsch Exp $ */
+/* $NetBSD: rtl80x9var.h,v 1.1 1998/10/31 00:44:33 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Definitions on RealTek 8019 and 8029 NE2000-compatible network interfaces.
+ *
+ * Data sheets for these chips can be found at:
+ *
+ * http://www.realtek.com.tw
+ */
+
+#ifndef _DEV_IC_RTL80x9_VAR_H_
+#define _DEV_IC_RTL80x9_VAR_H_
+
+#ifdef _KERNEL
+int rtl80x9_mediachange __P((struct dp8390_softc *));
+void rtl80x9_mediastatus __P((struct dp8390_softc *,
+ struct ifmediareq *));
+void rtl80x9_init_card __P((struct dp8390_softc *));
+void rtl80x9_init_media __P((struct dp8390_softc *, int **,
+ int *, int *));
+#endif /* _KERNEL */
+
+#endif /* _DEV_IC_RTL80x9_VAR_H_ */
diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa
index 56c4d63e957..ae8390bf79c 100644
--- a/sys/dev/isa/files.isa
+++ b/sys/dev/isa/files.isa
@@ -1,4 +1,4 @@
-# $OpenBSD: files.isa,v 1.45 1998/09/28 02:26:50 jason Exp $
+# $OpenBSD: files.isa,v 1.46 1998/11/06 06:32:15 fgsch Exp $
# $NetBSD: files.isa,v 1.21 1996/05/16 03:45:55 mycroft Exp $
#
# Config.new file and device description for machine-independent ISA code.
@@ -220,7 +220,7 @@ file dev/isa/if_le.c le_isa | le_pci
file dev/isa/if_le_isa.c le_isa
# Novell NE1000, NE2000, and clones
-attach ne at isa with ne_isa
+attach ne at isa with ne_isa: rtl80x9
file dev/isa/if_ne_isa.c ne_isa
# SMC91Cxx Ethernet Controllers
diff --git a/sys/dev/isa/files.isapnp b/sys/dev/isa/files.isapnp
index 69ba14f2db4..548511d4d89 100644
--- a/sys/dev/isa/files.isapnp
+++ b/sys/dev/isa/files.isapnp
@@ -1,4 +1,4 @@
-# $OpenBSD: files.isapnp,v 1.8 1998/09/22 06:33:18 fgsch Exp $
+# $OpenBSD: files.isapnp,v 1.9 1998/11/06 06:32:15 fgsch Exp $
# $NetBSD: files.isapnp,v 1.7 1997/10/16 17:16:36 matt Exp $
#
# Config file and device description for machine-independent ISAPnP code.
@@ -30,7 +30,7 @@ file dev/isa/if_le_isapnp.c le_isapnp
attach ep at isapnp with ep_isapnp
file dev/isa/if_ep_isapnp.c ep_isapnp
-attach ne at isapnp with ne_isapnp
+attach ne at isapnp with ne_isapnp: rtl80x9
file dev/isa/if_ne_isapnp.c ne_isapnp
# Yamaha OPL3-SA3
diff --git a/sys/dev/isa/if_ne_isa.c b/sys/dev/isa/if_ne_isa.c
index 94e6144d5ae..ae0093eaefe 100644
--- a/sys/dev/isa/if_ne_isa.c
+++ b/sys/dev/isa/if_ne_isa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ne_isa.c,v 1.1 1998/09/22 06:33:19 fgsch Exp $ */
+/* $OpenBSD: if_ne_isa.c,v 1.2 1998/11/06 06:32:15 fgsch Exp $ */
/* $NetBSD: if_ne_isa.c,v 1.6 1998/07/05 06:49:13 jonathan Exp $ */
/*-
@@ -88,6 +88,9 @@
#include <dev/ic/ne2000reg.h>
#include <dev/ic/ne2000var.h>
+#include <dev/ic/rtl80x9reg.h>
+#include <dev/ic/rtl80x9var.h>
+
#include <dev/isa/isavar.h>
int ne_isa_match __P((struct device *, void *, void *));
@@ -159,10 +162,18 @@ ne_isa_attach(parent, self, aux)
bus_space_handle_t nich;
bus_space_tag_t asict = nict;
bus_space_handle_t asich;
+ void (*npp_init_media) __P((struct dp8390_softc *, int **,
+ int *, int *));
+ int *media, nmedia, defmedia;
const char *typestr;
+ int netype;
printf("\n");
+ npp_init_media = NULL;
+ media = NULL;
+ nmedia = defmedia = 0;
+
/* Map i/o space. */
if (bus_space_map(nict, ia->ia_iobase, NE2000_NPORTS, 0, &nich)) {
printf("%s: can't map i/o space\n", dsc->sc_dev.dv_xname);
@@ -185,13 +196,29 @@ ne_isa_attach(parent, self, aux)
* Detect it again, so we can print some information about the
* interface.
*/
- switch (ne2000_detect(nict, nich, asict, asich)) {
+ netype = ne2000_detect(nict, nich, asict, asich);
+ switch (netype) {
case NE2000_TYPE_NE1000:
typestr = "NE1000";
break;
case NE2000_TYPE_NE2000:
typestr = "NE2000";
+ /*
+ * Check for a RealTek 8019.
+ */
+ bus_space_write_1(nict, nich, ED_P0_CR,
+ ED_CR_PAGE_0 | ED_CR_STP);
+ if (bus_space_read_1(nict, nich, NERTL_RTL0_8019ID0) ==
+ RTL0_8019ID0 &&
+ bus_space_read_1(nict, nich, NERTL_RTL0_8019ID1) ==
+ RTL0_8019ID1) {
+ typestr = "NE2000 (RTL8019)";
+ npp_init_media = rtl80x9_init_media;
+ dsc->sc_mediachange = rtl80x9_mediachange;
+ dsc->sc_mediastatus = rtl80x9_mediastatus;
+ dsc->init_card = rtl80x9_init_card;
+ }
break;
default:
@@ -201,6 +228,10 @@ ne_isa_attach(parent, self, aux)
printf("%s: %s Ethernet\n", dsc->sc_dev.dv_xname, typestr);
+ /* Initialize media, if we have it. */
+ if (npp_init_media != NULL)
+ (*npp_init_media)(dsc, &media, &nmedia, &defmedia);
+
/* This interface is always enabled. */
dsc->sc_enabled = 1;
@@ -208,7 +239,7 @@ ne_isa_attach(parent, self, aux)
* Do generic NE2000 attach. This will read the station address
* from the EEPROM.
*/
- ne2000_attach(nsc, NULL);
+ ne2000_attach(nsc, NULL, media, nmedia, defmedia);
/* Establish the interrupt handler. */
isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
diff --git a/sys/dev/isa/if_ne_isapnp.c b/sys/dev/isa/if_ne_isapnp.c
index b851ad5d084..a49a44bab03 100644
--- a/sys/dev/isa/if_ne_isapnp.c
+++ b/sys/dev/isa/if_ne_isapnp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ne_isapnp.c,v 1.1 1998/09/22 06:33:19 fgsch Exp $ */
+/* $OpenBSD: if_ne_isapnp.c,v 1.2 1998/11/06 06:32:15 fgsch Exp $ */
/* $NetBSD: if_ne_isapnp.c,v 1.7 1998/07/23 19:30:45 christos Exp $ */
/*-
@@ -88,6 +88,9 @@
#include <dev/ic/ne2000reg.h>
#include <dev/ic/ne2000var.h>
+#include <dev/ic/rtl80x9reg.h>
+#include <dev/ic/rtl80x9var.h>
+
#include <dev/isa/isavar.h>
#include <dev/isa/isapnpreg.h>
@@ -132,10 +135,18 @@ ne_isapnp_attach(
bus_space_handle_t nich;
bus_space_tag_t asict;
bus_space_handle_t asich;
+ void (*npp_init_media) __P((struct dp8390_softc *, int **,
+ int *, int *));
+ int *media, nmedia, defmedia;
const char *typestr;
+ int netype;
printf("\n");
+ npp_init_media = NULL;
+ media = NULL;
+ nmedia = defmedia = 0;
+
nict = ipa->ia_iot;
nich = ipa->ipa_io[0].h;
@@ -157,13 +168,29 @@ ne_isapnp_attach(
* Detect it again, so we can print some information about the
* interface.
*/
- switch (ne2000_detect(nict, nich, asict, asich)) {
+ netype = ne2000_detect(nict, nich, asict, asich);
+ switch (netype) {
case NE2000_TYPE_NE1000:
typestr = "NE1000";
break;
case NE2000_TYPE_NE2000:
typestr = "NE2000";
+ /*
+ * Check for a RealTek 8019.
+ */
+ bus_space_write_1(nict, nich, ED_P0_CR,
+ ED_CR_PAGE_0 | ED_CR_STP);
+ if (bus_space_read_1(nict, nich, NERTL_RTL0_8019ID0) ==
+ RTL0_8019ID0 &&
+ bus_space_read_1(nict, nich, NERTL_RTL0_8019ID1) ==
+ RTL0_8019ID1) {
+ typestr = "NE2000 (RTL8019)";
+ npp_init_media = rtl80x9_init_media;
+ dsc->sc_mediachange = rtl80x9_mediachange;
+ dsc->sc_mediastatus = rtl80x9_mediastatus;
+ dsc->init_card = rtl80x9_init_card;
+ }
break;
default:
@@ -173,6 +200,10 @@ ne_isapnp_attach(
printf("%s: %s Ethernet\n", dsc->sc_dev.dv_xname, typestr);
+ /* Initialize media, if we have it. */
+ if (npp_init_media != NULL)
+ (*npp_init_media)(dsc, &media, &nmedia, &defmedia);
+
/* This interface is always enabled. */
dsc->sc_enabled = 1;
@@ -180,7 +211,7 @@ ne_isapnp_attach(
* Do generic NE2000 attach. This will read the station address
* from the EEPROM.
*/
- ne2000_attach(nsc, NULL);
+ ne2000_attach(nsc, NULL, media, nmedia, defmedia);
/* Establish the interrupt handler. */
isc->sc_ih = isa_intr_establish(ipa->ia_ic, ipa->ipa_irq[0].num,
diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci
index ca0c57f02a0..8bbd59cd28a 100644
--- a/sys/dev/pci/files.pci
+++ b/sys/dev/pci/files.pci
@@ -1,4 +1,4 @@
-# $OpenBSD: files.pci,v 1.27 1998/10/10 03:55:05 jason Exp $
+# $OpenBSD: files.pci,v 1.28 1998/11/06 06:32:15 fgsch Exp $
# $NetBSD: files.pci,v 1.20 1996/09/24 17:47:15 christos Exp $
#
# Config.new file and device description for machine-independent PCI code.
@@ -117,5 +117,5 @@ attach tx at pci
file dev/pci/if_tx.c tx
# NE2000-compatible PCI Ethernet cards
-attach ne at pci with ne_pci
+attach ne at pci with ne_pci: rtl80x9
file dev/pci/if_ne_pci.c ne_pci
diff --git a/sys/dev/pci/if_ne_pci.c b/sys/dev/pci/if_ne_pci.c
index 43f3f782d20..1e925c63aa7 100644
--- a/sys/dev/pci/if_ne_pci.c
+++ b/sys/dev/pci/if_ne_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ne_pci.c,v 1.2 1998/09/23 18:46:29 deraadt Exp $ */
+/* $OpenBSD: if_ne_pci.c,v 1.3 1998/11/06 06:32:15 fgsch Exp $ */
/* $NetBSD: if_ne_pci.c,v 1.8 1998/07/05 00:51:24 jonathan Exp $ */
/*-
@@ -75,6 +75,9 @@
#include <dev/ic/ne2000reg.h>
#include <dev/ic/ne2000var.h>
+#include <dev/ic/rtl80x9reg.h>
+#include <dev/ic/rtl80x9var.h>
+
struct ne_pci_softc {
struct ne2000_softc sc_ne2000; /* real "ne2000" softc */
@@ -89,38 +92,78 @@ struct cfattach ne_pci_ca = {
sizeof(struct ne_pci_softc), ne_pci_match, ne_pci_attach
};
-struct ne_pci_compatdev {
- pci_vendor_id_t vendor;
- pci_product_id_t product;
-};
+const struct ne_pci_product {
+ pci_vendor_id_t npp_vendor;
+ pci_product_id_t npp_product;
+ int (*npp_mediachange) __P((struct dp8390_softc *));
+ void (*npp_mediastatus) __P((struct dp8390_softc *,
+ struct ifmediareq *));
+ void (*npp_init_card) __P((struct dp8390_softc *));
+ void (*npp_init_media) __P((struct dp8390_softc *, int **,
+ int *, int *));
+ const char *npp_name;
+} ne_pci_products[] = {
+ { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8029,
+ rtl80x9_mediachange, rtl80x9_mediastatus,
+ rtl80x9_init_card, rtl80x9_init_media,
+ "RealTek 8029" },
+
+ { PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W89C940F,
+ NULL, NULL,
+ NULL, NULL,
+ "Winbond 89C940F" },
+
+ { PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT86C926,
+ NULL, NULL,
+ NULL, NULL,
+ "VIA Technologies VT86C926" },
+
+ { PCI_VENDOR_SURECOM, PCI_PRODUCT_SURECOM_NE34,
+ NULL, NULL,
+ NULL, NULL,
+ "Surecom NE-34" },
+
+ { PCI_VENDOR_NETVIN, PCI_PRODUCT_NETVIN_NV5000,
+ NULL, NULL,
+ NULL, NULL,
+ "NetVin 5000" },
-struct ne_pci_compatdev ne_pci_compatdevs[] = {
- { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8029 },
- { PCI_VENDOR_WINBOND, PCI_PRODUCT_WINBOND_W89C940F },
- { PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT86C926 },
- { PCI_VENDOR_SURECOM, PCI_PRODUCT_SURECOM_NE34 },
- { PCI_VENDOR_NETVIN, PCI_PRODUCT_NETVIN_NV5000 },
/* XXX The following entries need sanity checking in pcidevs */
- { PCI_VENDOR_COMPEX, PCI_PRODUCT_COMPEX_COMPEXE },
- { PCI_VENDOR_WINBOND2, PCI_PRODUCT_WINBOND2_W89C940 },
- { PCI_VENDOR_KTI, PCI_PRODUCT_KTI_KTIE },
- { 0, 0 },
+ { PCI_VENDOR_COMPEX, PCI_PRODUCT_COMPEX_COMPEXE,
+ NULL, NULL,
+ NULL, NULL,
+ "Compex" },
+
+ { PCI_VENDOR_WINBOND2, PCI_PRODUCT_WINBOND2_W89C940,
+ NULL, NULL,
+ NULL, NULL,
+ "ProLAN" },
+
+ { PCI_VENDOR_KTI, PCI_PRODUCT_KTI_KTIE,
+ NULL, NULL,
+ NULL, NULL,
+ "KTI" },
+
+ { 0, 0,
+ NULL, NULL,
+ NULL, NULL,
+ NULL },
};
-int ne_pci_lookup __P((pcireg_t));
+const struct ne_pci_product *ne_pci_lookup __P((struct pci_attach_args *));
-int
-ne_pci_lookup(id)
- pcireg_t id;
+const struct ne_pci_product *
+ne_pci_lookup(pa)
+ struct pci_attach_args *pa;
{
- struct ne_pci_compatdev *nc;
+ const struct ne_pci_product *npp;
- for (nc = ne_pci_compatdevs; nc->vendor != 0; nc++) {
- if (PCI_VENDOR(id) == nc->vendor &&
- PCI_PRODUCT(id) == nc->product)
- return (1);
+ for (npp = ne_pci_products; npp->npp_name != NULL; npp++) {
+ if (PCI_VENDOR(pa->pa_id) == npp->npp_vendor &&
+ PCI_PRODUCT(pa->pa_id) == npp->npp_product)
+ return (npp);
}
- return (0);
+ return (NULL);
}
/*
@@ -136,8 +179,8 @@ ne_pci_match(parent, match, aux)
{
struct pci_attach_args *pa = aux;
- if (ne_pci_lookup(pa->pa_id) != 0)
- return (1);
+ if (ne_pci_lookup(pa) != NULL)
+ return (1);
return (0);
}
@@ -161,8 +204,18 @@ ne_pci_attach(parent, self, aux)
bus_space_tag_t asict;
bus_space_handle_t asich;
const char *intrstr;
+ const struct ne_pci_product *npp;
pci_intr_handle_t ih;
pcireg_t csr;
+ int *media, nmedia, defmedia;
+
+ npp = ne_pci_lookup(pa);
+ if (npp == NULL) {
+ printf("\n");
+ panic("ne_pci_attach: impossible");
+ }
+
+ printf(": %s Ethernet\n", npp->npp_name);
#ifdef __NetBSD__
if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0,
@@ -206,13 +259,24 @@ ne_pci_attach(parent, self, aux)
/* This interface is always enabled. */
dsc->sc_enabled = 1;
- printf("\n");
+ if (npp->npp_init_media != NULL) {
+ (*npp->npp_init_media)(dsc, &media, &nmedia, &defmedia);
+ dsc->sc_mediachange = npp->npp_mediachange;
+ dsc->sc_mediastatus = npp->npp_mediastatus;
+ } else {
+ media = NULL;
+ nmedia = 0;
+ defmedia = 0;
+ }
+
+ /* Always fill in init_card; it might be used for non-media stuff. */
+ dsc->init_card = npp->npp_init_card;
/*
* Do generic NE2000 attach. This will read the station address
* from the EEPROM.
*/
- ne2000_attach(nsc, NULL);
+ ne2000_attach(nsc, NULL, media, nmedia, defmedia);
/* Map and establish the interrupt. */
if (pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
diff --git a/sys/dev/pcmcia/files.pcmcia b/sys/dev/pcmcia/files.pcmcia
index 7e1bc4322d7..f244cc59cec 100644
--- a/sys/dev/pcmcia/files.pcmcia
+++ b/sys/dev/pcmcia/files.pcmcia
@@ -1,4 +1,4 @@
-# $OpenBSD: files.pcmcia,v 1.10 1998/09/22 09:16:36 fgsch Exp $
+# $OpenBSD: files.pcmcia,v 1.11 1998/11/06 06:32:15 fgsch Exp $
# $NetBSD: files.pcmcia,v 1.9 1998/06/21 18:45:41 christos Exp $
#
# Config.new file and device description for machine-independent PCMCIA code.
@@ -18,7 +18,7 @@ file dev/pcmcia/if_ep_pcmcia.c ep_pcmcia
# National Semiconductor DS8390/WD83C690-based boards
# (NE[12]000, and clones)
-attach ne at pcmcia with ne_pcmcia
+attach ne at pcmcia with ne_pcmcia: rtl80x9
file dev/pcmcia/if_ne_pcmcia.c ne_pcmcia
# Adaptec APA-1460 SCSI Host Adapter
diff --git a/sys/dev/pcmcia/if_ne_pcmcia.c b/sys/dev/pcmcia/if_ne_pcmcia.c
index 4f26ea70e7c..8d62b3c8953 100644
--- a/sys/dev/pcmcia/if_ne_pcmcia.c
+++ b/sys/dev/pcmcia/if_ne_pcmcia.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ne_pcmcia.c,v 1.3 1998/11/05 09:12:52 fgsch Exp $ */
+/* $OpenBSD: if_ne_pcmcia.c,v 1.4 1998/11/06 06:32:15 fgsch Exp $ */
/* $NetBSD: if_ne_pcmcia.c,v 1.17 1998/08/15 19:00:04 thorpej Exp $ */
/*
@@ -59,6 +59,9 @@
#include <dev/ic/ne2000reg.h>
#include <dev/ic/ne2000var.h>
+#include <dev/ic/rtl80x9reg.h>
+#include <dev/ic/rtl80x9var.h>
+
int ne_pcmcia_match __P((struct device *, void *, void *));
void ne_pcmcia_attach __P((struct device *, struct device *, void *));
@@ -330,6 +333,14 @@ ne_pcmcia_attach(parent, self, aux)
bus_addr_t offset;
int i, j, mwindow;
u_int8_t myea[6], *enaddr = NULL;
+ void (*npp_init_media) __P((struct dp8390_softc *, int **,
+ int *, int *));
+ int *media, nmedia, defmedia;
+ const char *typestr = "";
+
+ npp_init_media = NULL;
+ media = NULL;
+ nmedia = defmedia = 0;
psc->sc_pf = pa->pf;
cfe = pa->pf->cfe_head.sqh_first;
@@ -470,9 +481,30 @@ ne_pcmcia_attach(parent, self, aux)
}
}
- printf("%s: %s Ethernet\n", dsc->sc_dev.dv_xname, ne_dev->name);
+ /*
+ * Check for a RealTek 8019.
+ */
+ bus_space_write_1(dsc->sc_regt, dsc->sc_regh, ED_P0_CR,
+ ED_CR_PAGE_0 | ED_CR_STP);
+ if (bus_space_read_1(dsc->sc_regt, dsc->sc_regh, NERTL_RTL0_8019ID0)
+ == RTL0_8019ID0 &&
+ bus_space_read_1(dsc->sc_regt, dsc->sc_regh, NERTL_RTL0_8019ID1)
+ == RTL0_8019ID1) {
+ typestr = " (RTL8019)";
+ npp_init_media = rtl80x9_init_media;
+ dsc->sc_mediachange = rtl80x9_mediachange;
+ dsc->sc_mediastatus = rtl80x9_mediastatus;
+ dsc->init_card = rtl80x9_init_card;
+ }
+
+ printf("%s: %s%s Ethernet\n", dsc->sc_dev.dv_xname, ne_dev->name,
+ typestr);
+
+ /* Initialize media, if we have it. */
+ if (npp_init_media != NULL)
+ (*npp_init_media)(dsc, &media, &nmedia, &defmedia);
- ne2000_attach(nsc, enaddr);
+ ne2000_attach(nsc, enaddr, media, nmedia, defmedia);
#if 0
pcmcia_function_disable(pa->pf);