summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>2001-08-18 16:15:40 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>2001-08-18 16:15:40 +0000
commit81cbd7cc4adab8da46d16f115a2ff1c1100d32f8 (patch)
treea0333bd9742e02cc3688b42f8e376bb7c6e729a7
parent4cbd011292f901d241cd3710eb7bcfff692b6be4 (diff)
Add MII routines to support the ASIX AX88190 MAC controller; from NetBSD.
-rw-r--r--sys/conf/files6
-rw-r--r--sys/dev/ic/ax88190.c192
-rw-r--r--sys/dev/ic/ax88190reg.h70
-rw-r--r--sys/dev/ic/ax88190var.h53
4 files changed, 320 insertions, 1 deletions
diff --git a/sys/conf/files b/sys/conf/files
index df6579563ad..54912ad8a15 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.220 2001/08/09 14:32:59 deraadt Exp $
+# $OpenBSD: files,v 1.221 2001/08/18 16:15:39 aaron Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -54,6 +54,7 @@ define pdq # DEC FDDI chipset
define dp8390nic # 8390-family Ethernet controllers
define rtl80x9 # RealTek 8019/8029 NE2000-compatible
define dl10019 # DL10019/10022-family Ethernet controllers
+define ax88190 # AX88190-family Ethernet controllers
# a wscons output device; used later, but needs to be near the top for
# common file (e.g. vga) definitions.
@@ -203,6 +204,9 @@ file dev/ic/ne2000.c ne
# D-Link DL10019/10022 NE2000-compatible network interface subroutines
file dev/ic/dl10019.c dl10019
+# ASIX AX88190 NE2000-compatible network interface subroutines
+file dev/ic/ax88190.c ax88190
+
# Intel i82596/i82586 Ethernet Controller
device ie: ether, ifnet, ifmedia
file dev/ic/i82596.c ie & (ie_pci | ie_eisa | ie_gsc)
diff --git a/sys/dev/ic/ax88190.c b/sys/dev/ic/ax88190.c
new file mode 100644
index 00000000000..9e3acfc87fb
--- /dev/null
+++ b/sys/dev/ic/ax88190.c
@@ -0,0 +1,192 @@
+/* $OpenBSD: ax88190.c,v 1.1 2001/08/18 16:15:39 aaron Exp $ */
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Enami Tsugutomo.
+ *
+ * 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 <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
+#include <net/if_media.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/if_ether.h>
+#endif
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/mii/miivar.h>
+#include <dev/mii/mii.h>
+#include <dev/mii/mii_bitbang.h>
+
+#include <dev/ic/dp8390reg.h>
+#include <dev/ic/dp8390var.h>
+
+#include <dev/ic/ne2000reg.h>
+#include <dev/ic/ne2000var.h>
+
+#include <dev/ic/ax88190reg.h>
+#include <dev/ic/ax88190var.h>
+
+int ax88190_mii_readreg(struct device *, int, int);
+void ax88190_mii_writereg(struct device *, int, int, int);
+void ax88190_mii_statchg(struct device *);
+
+/*
+ * MII bit-bang glue.
+ */
+u_int32_t ax88190_mii_bitbang_read(struct device *);
+void ax88190_mii_bitbang_write(struct device *, u_int32_t);
+
+const struct mii_bitbang_ops ax88190_mii_bitbang_ops = {
+ ax88190_mii_bitbang_read,
+ ax88190_mii_bitbang_write,
+ {
+ AX88190_MEMR_MDO, /* MII_BIT_MDO */
+ AX88190_MEMR_MDI, /* MII_BIT_MDI */
+ AX88190_MEMR_MDC, /* MII_BIT_MDC */
+ 0, /* MII_BIT_DIR_HOST_PHY */
+ AX88190_MEMR_MDIR, /* MII_BIT_DIR_PHY_HOST */
+ }
+};
+
+void
+ax88190_media_init(struct dp8390_softc *sc)
+{
+ struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+
+ sc->sc_mii.mii_ifp = ifp;
+ sc->sc_mii.mii_readreg = ax88190_mii_readreg;
+ sc->sc_mii.mii_writereg = ax88190_mii_writereg;
+ sc->sc_mii.mii_statchg = ax88190_mii_statchg;
+ ifmedia_init(&sc->sc_mii.mii_media, 0, dp8390_mediachange,
+ dp8390_mediastatus);
+
+ mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
+ MII_OFFSET_ANY, 0);
+
+ if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+ ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0,
+ NULL);
+ ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
+ } else
+ ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
+}
+
+void
+ax88190_media_fini(struct dp8390_softc *sc)
+{
+ mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
+}
+
+int
+ax88190_mediachange(struct dp8390_softc *sc)
+{
+ mii_mediachg(&sc->sc_mii);
+ return (0);
+}
+
+void
+ax88190_mediastatus(struct dp8390_softc *sc, struct ifmediareq *ifmr)
+{
+ mii_pollstat(&sc->sc_mii);
+ ifmr->ifm_status = sc->sc_mii.mii_media_status;
+ ifmr->ifm_active = sc->sc_mii.mii_media_active;
+}
+
+void
+ax88190_init_card(struct dp8390_softc *sc)
+{
+ mii_mediachg(&sc->sc_mii);
+}
+
+void
+ax88190_stop_card(struct dp8390_softc *sc)
+{
+ mii_down(&sc->sc_mii);
+}
+
+u_int32_t
+ax88190_mii_bitbang_read(self)
+ struct device *self;
+{
+ struct ne2000_softc *sc = (void *)self;
+
+ return (bus_space_read_1(sc->sc_asict, sc->sc_asich, AX88190_MEMR));
+}
+
+void
+ax88190_mii_bitbang_write(self, val)
+ struct device *self;
+ u_int32_t val;
+{
+ struct ne2000_softc *sc = (void *)self;
+
+ bus_space_write_1(sc->sc_asict, sc->sc_asich, AX88190_MEMR, val);
+}
+
+int
+ax88190_mii_readreg(self, phy, reg)
+ struct device *self;
+ int phy, reg;
+{
+ return (mii_bitbang_readreg(self, &ax88190_mii_bitbang_ops, phy, reg));
+}
+
+void
+ax88190_mii_writereg(self, phy, reg, val)
+ struct device *self;
+ int phy, reg, val;
+{
+ mii_bitbang_writereg(self, &ax88190_mii_bitbang_ops, phy, reg, val);
+}
+
+void
+ax88190_mii_statchg(self)
+ struct device *self;
+{
+ /* XXX */
+}
diff --git a/sys/dev/ic/ax88190reg.h b/sys/dev/ic/ax88190reg.h
new file mode 100644
index 00000000000..6ed333d126e
--- /dev/null
+++ b/sys/dev/ic/ax88190reg.h
@@ -0,0 +1,70 @@
+/* $OpenBSD: ax88190reg.h,v 1.1 2001/08/18 16:15:39 aaron Exp $ */
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Enami Tsugutomo.
+ *
+ * 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.
+ */
+
+#ifndef _DEV_IC_AX88190REG_H_
+#define _DEV_IC_AX88190REG_H_
+
+#define AX88190_MEMR 0x04 /* MII/EEPROM/ Management Register */
+#define AX88190_MEMR_MDC 0x01 /* MII Clock */
+#define AX88190_MEMR_MDIR 0x02 /* MII STA MDIO signal direction
+ assert -> input */
+#define AX88190_MEMR_MDI 0x04 /* MII Data In */
+#define AX88190_MEMR_MDO 0x08 /* MII Data Out */
+#define AX88190_MEMR_EECS 0x10 /* EEPROM Chip Select */
+#define AX88190_MEMR_EEI 0x20 /* EEPROM Data In */
+#define AX88190_MEMR_EEO 0x40 /* EEPROM Data Out */
+#define AX88190_MEMR_EECLK 0x80 /* EEPROM Clock */
+
+/*
+ * Offset of LAN IOBASE0 and IOBASE1, and its size.
+ */
+#define AX88190_LAN_IOBASE 0x3ca
+#define AX88190_LAN_IOSIZE 4
+
+/*
+ * Offset of NODE ID in SRAM memory of ASIX AX88190.
+ */
+#define AX88190_NODEID_OFFSET 0x400
+
+/*
+ * Start of SRAM buffer.
+ */
+#define AX88190_BUFFER_START 0x800
+
+#endif /* _DEV_IC_AX88190REG_H_ */
diff --git a/sys/dev/ic/ax88190var.h b/sys/dev/ic/ax88190var.h
new file mode 100644
index 00000000000..c186e34b885
--- /dev/null
+++ b/sys/dev/ic/ax88190var.h
@@ -0,0 +1,53 @@
+/* $OpenBSD: ax88190var.h,v 1.1 2001/08/18 16:15:39 aaron Exp $ */
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Enami Tsugutomo.
+ *
+ * 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.
+ */
+
+#ifndef _DEV_IC_AX88190VAR_H_
+#define _DEV_IC_AX88190VAR_H_
+
+#ifdef _KERNEL
+void ax88190_media_init(struct dp8390_softc *);
+void ax88190_media_fini(struct dp8390_softc *);
+
+int ax88190_mediachange(struct dp8390_softc *);
+void ax88190_mediastatus(struct dp8390_softc *, struct ifmediareq *ifmr);
+void ax88190_init_card(struct dp8390_softc *);
+void ax88190_stop_card(struct dp8390_softc *);
+#endif /* _KERNEL */
+
+#endif /* _DEV_IC_AX88190VAR_H_ */