Source-Changes-HG archive

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

[src/sommerfeld_i386mp_1]: src/sys/arch/i386/stand/lib/netif Increase the res...



details:   https://anonhg.NetBSD.org/src/rev/f8d4753bd42e
branches:  sommerfeld_i386mp_1
changeset: 482498:f8d4753bd42e
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Feb 19 20:38:29 2002 +0000

description:
Increase the reset delay in ex_reset() as per dev/ic/elinkxl.c
Pointed out by Love <lha%stacken.kth.se@localhost>

diffstat:

 sys/arch/i386/stand/lib/netif/3c90xb.c |  454 +++++++++++++++++++++++++++++++++
 1 files changed, 454 insertions(+), 0 deletions(-)

diffs (truncated from 458 to 300 lines):

diff -r 7a964af3b4aa -r f8d4753bd42e sys/arch/i386/stand/lib/netif/3c90xb.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/lib/netif/3c90xb.c    Tue Feb 19 20:38:29 2002 +0000
@@ -0,0 +1,454 @@
+/* $NetBSD: 3c90xb.c,v 1.8.2.2 2002/02/19 20:38:29 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1999
+ *     Matthias Drochner.  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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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/types.h>
+#include <machine/pio.h>
+
+struct mbuf; /* XXX */
+typedef int bus_dmamap_t; /* XXX */
+#include <dev/ic/elink3reg.h>
+#include <dev/ic/elinkxlreg.h>
+
+#include <lib/libsa/stand.h>
+
+#include <libi386.h>
+#include <pcivar.h>
+
+#if defined(_STANDALONE) && !defined(SUPPORT_NO_NETBSD)
+#include <lib/libkern/libkern.h>
+#include <bootinfo.h>
+#endif
+
+#include "etherdrv.h"
+
+#define RECVBUF_SIZE 1600 /* struct ex_upd + packet */
+
+#ifdef _STANDALONE
+
+static pcihdl_t mytag;
+static char recvbuf[RECVBUF_SIZE];
+#define RECVBUF_PHYS vtophys(recvbuf)
+#define RECVBUF_VIRT ((void *)recvbuf)
+static struct ex_dpd sndbuf;
+#define SNDBUF_PHYS vtophys(&sndbuf)
+#define SNDBUF_VIRT ((void *)&sndbuf)
+
+#else /* !standalone, userspace testing environment */
+
+#define        PCI_MODE1_ENABLE        0x80000000UL
+#define PCIBUSNO 1
+#define PCIDEVNO 4
+static pcihdl_t mytag = PCI_MODE1_ENABLE | (PCIBUSNO << 16) | (PCIDEVNO << 11);
+
+extern caddr_t mapmem __P((int, int));
+void *dmamem; /* virtual */
+#define DMABASE 0x3ffd800
+#define DMASIZE 10240
+#define RECVBUF_PHYS DMABASE
+#define RECVBUF_VIRT dmamem
+#define SNDBUF_PHYS (DMABASE + RECVBUF_SIZE)
+#define SNDBUF_VIRT ((void *)(((char *)dmamem) + RECVBUF_SIZE))
+
+#endif /* _STANDALONE */
+
+
+#define CSR_READ_1(reg) inb(iobase + (reg))
+#define CSR_READ_2(reg) inw(iobase + (reg))
+#define CSR_READ_4(reg) inl(iobase + (reg))
+#define CSR_WRITE_1(reg, val) outb(iobase + (reg), val)
+#define CSR_WRITE_2(reg, val) outw(iobase + (reg), val)
+#define CSR_WRITE_4(reg, val) outl(iobase + (reg), val)
+
+#undef GO_WINDOW
+#define GO_WINDOW(x) CSR_WRITE_2(ELINK_COMMAND, WINDOW_SELECT | x)
+
+static int iobase;
+static u_char myethaddr[6];
+int ether_medium;
+
+static struct {
+       int did;
+       int mii;
+} excards[] = {
+       {0x9005, 0}, /* 3c900b Combo */
+       {0x9055, 1}, /* 3c905b TP */
+       {0x9058, 0}, /* 3c905b Combo */
+       {-1}
+}, *excard;
+
+static struct mtabentry {
+       int address_cfg; /* configured connector */
+       int config_bit; /* connector present */
+       char *name;
+} mediatab[] = { /* indexed by media type - etherdrv.h */
+       {ELINKMEDIA_10BASE_2, ELINK_PCI_BNC, "BNC"},
+       {ELINKMEDIA_10BASE_T, ELINK_PCI_10BASE_T, "UTP"},
+       {ELINKMEDIA_AUI, ELINK_PCI_AUI, "AUI"},
+       {ELINKMEDIA_MII, ELINK_PCI_100BASE_MII, "MII"},
+       {ELINKMEDIA_100BASE_TX, ELINK_PCI_100BASE_TX, "100TX"},
+};
+
+#if defined(_STANDALONE) && !defined(SUPPORT_NO_NETBSD)
+static struct btinfo_netif bi_netif;
+#endif
+
+#define ex_waitcmd() \
+       while (CSR_READ_2(ELINK_STATUS) & COMMAND_IN_PROGRESS);
+
+void ex_reset __P((void));
+u_int16_t ex_read_eeprom __P((int));
+static int ex_eeprom_busy __P((void));
+void ex_init __P((void));
+void ex_set_media __P((void));
+
+void
+ex_reset()
+{
+       CSR_WRITE_2(ELINK_COMMAND, GLOBAL_RESET);
+       delay(100000);
+       ex_waitcmd();
+}
+
+/*
+ * Read EEPROM data.
+ * XXX what to do if EEPROM doesn't unbusy?
+ */
+u_int16_t
+ex_read_eeprom(offset)
+       int offset;
+{
+       u_int16_t data = 0;
+
+       GO_WINDOW(0);
+       if (ex_eeprom_busy())
+               goto out;
+       CSR_WRITE_1(ELINK_W0_EEPROM_COMMAND, READ_EEPROM | (offset & 0x3f));
+       if (ex_eeprom_busy())
+               goto out;
+       data = CSR_READ_2(ELINK_W0_EEPROM_DATA);
+out:
+       return data;
+}
+
+static int
+ex_eeprom_busy()
+{
+       int i = 100;
+
+       while (i--) {
+               if (!(CSR_READ_2(ELINK_W0_EEPROM_COMMAND) & EEPROM_BUSY))
+                       return 0;
+               delay(100);
+       }
+       printf("\nex: eeprom stays busy.\n");
+       return (1);
+}
+
+/*
+ * Bring device up.
+ */
+void
+ex_init()
+{
+       int i;
+
+       ex_waitcmd();
+       EtherStop();
+
+       /*
+        * Set the station address and clear the station mask. The latter
+        * is needed for 90x cards, 0 is the default for 90xB cards.
+        */
+       GO_WINDOW(2);
+       for (i = 0; i < 6; i++) {
+               CSR_WRITE_1(ELINK_W2_ADDR_0 + i,
+                   myethaddr[i]);
+               CSR_WRITE_1(ELINK_W2_RECVMASK_0 + i, 0);
+       }
+
+       GO_WINDOW(3);
+
+       CSR_WRITE_2(ELINK_COMMAND, RX_RESET);
+       ex_waitcmd();
+       CSR_WRITE_2(ELINK_COMMAND, TX_RESET);
+       ex_waitcmd();
+
+       CSR_WRITE_2(ELINK_COMMAND, SET_INTR_MASK | 0); /* disable */
+       CSR_WRITE_2(ELINK_COMMAND, ACK_INTR | 0xff);
+
+       ex_set_media();
+
+       CSR_WRITE_2(ELINK_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL | FIL_BRDCST);
+
+       CSR_WRITE_4(ELINK_DNLISTPTR, 0);
+       CSR_WRITE_2(ELINK_COMMAND, TX_ENABLE);
+
+       CSR_WRITE_4(ELINK_UPLISTPTR, RECVBUF_PHYS);
+       CSR_WRITE_2(ELINK_COMMAND, RX_ENABLE);
+       CSR_WRITE_2(ELINK_COMMAND, ELINK_UPUNSTALL);
+
+       GO_WINDOW(1);
+}
+
+void
+ex_set_media()
+{
+       int config0, config1;
+
+       CSR_WRITE_2(ELINK_W3_MAC_CONTROL, 0);
+
+       if (ether_medium == ETHERMEDIUM_MII)
+               goto setcfg;
+
+       GO_WINDOW(4);
+       CSR_WRITE_2(ELINK_W4_MEDIA_TYPE, 0);
+       CSR_WRITE_2(ELINK_COMMAND, STOP_TRANSCEIVER);
+       delay(800);
+
+       switch (ether_medium) {
+       case ETHERMEDIUM_UTP:
+               CSR_WRITE_2(ELINK_W4_MEDIA_TYPE,
+                           JABBER_GUARD_ENABLE | LINKBEAT_ENABLE);
+               break;
+       case ETHERMEDIUM_BNC:
+               CSR_WRITE_2(ELINK_COMMAND, START_TRANSCEIVER);
+               delay(800);
+               break;
+       case ETHERMEDIUM_AUI:
+               CSR_WRITE_2(ELINK_W4_MEDIA_TYPE, SQE_ENABLE);
+               delay(800);
+               break;
+       case ETHERMEDIUM_100TX:
+               CSR_WRITE_2(ELINK_W4_MEDIA_TYPE, LINKBEAT_ENABLE);
+               break;
+       }
+
+setcfg:
+       GO_WINDOW(3);
+
+       config0 = CSR_READ_2(ELINK_W3_INTERNAL_CONFIG);
+       config1 = CSR_READ_2(ELINK_W3_INTERNAL_CONFIG + 2);
+
+       config1 = config1 & ~CONFIG_MEDIAMASK;
+       config1 |= (mediatab[ether_medium].address_cfg
+                   << CONFIG_MEDIAMASK_SHIFT);
+
+       CSR_WRITE_2(ELINK_W3_INTERNAL_CONFIG, config0);
+       CSR_WRITE_2(ELINK_W3_INTERNAL_CONFIG + 2, config1);
+}
+
+static void
+ex_probemedia()
+{
+       int i, j;
+       struct mtabentry *m;
+
+       /* test for presence of connectors */
+       GO_WINDOW(3);
+       i = CSR_READ_1(ELINK_W3_RESET_OPTIONS);
+       j = (CSR_READ_2(ELINK_W3_INTERNAL_CONFIG + 2) & CONFIG_MEDIAMASK)
+               >> CONFIG_MEDIAMASK_SHIFT;
+       GO_WINDOW(0);
+
+       for(ether_medium = 0, m = mediatab;
+           ether_medium < sizeof(mediatab) / sizeof(mediatab[0]);
+           ether_medium++, m++) {
+               if (j == m->address_cfg) {
+                       if (!(i & m->config_bit)) {
+                               printf("%s not present\n", m->name);
+                               goto bad;
+                       }
+                       printf("using %s\n", m->name);
+                       return;
+               }
+       }
+       printf("unknown connector\n");
+bad:
+       ether_medium = -1;
+}
+
+int
+EtherInit(myadr)



Home | Main Index | Thread Index | Old Index