Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Add support for the 3c555, 556 and 556B MiniPCI card...



details:   https://anonhg.NetBSD.org/src/rev/6028d80a321a
branches:  trunk
changeset: 497096:6028d80a321a
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Tue Sep 19 01:15:06 2000 +0000

description:
Add support for the 3c555, 556 and 556B MiniPCI cards. Based on the
cardbus code and the FreeBSD xl driver.

diffstat:

 sys/dev/ic/elinkxl.c    |  44 +++++++++++++++++++++-----------------------
 sys/dev/ic/elinkxlreg.h |  11 ++++++++++-
 sys/dev/ic/elinkxlvar.h |  10 +++++++---
 sys/dev/pci/if_ex_pci.c |  49 +++++++++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 85 insertions(+), 29 deletions(-)

diffs (232 lines):

diff -r b4f0e3ade7ea -r 6028d80a321a sys/dev/ic/elinkxl.c
--- a/sys/dev/ic/elinkxl.c      Tue Sep 19 01:12:48 2000 +0000
+++ b/sys/dev/ic/elinkxl.c      Tue Sep 19 01:15:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elinkxl.c,v 1.39 2000/08/31 08:42:29 haya Exp $        */
+/*     $NetBSD: elinkxl.c,v 1.40 2000/09/19 01:15:28 fvdl Exp $        */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -215,16 +215,14 @@
        printf("%s: MAC address %s\n", sc->sc_dev.dv_xname,
            ether_sprintf(macaddr));
 
-       if (sc->intr_ack != NULL) { /* CardBus card specific */
-           GO_WINDOW(2);
-           if (sc->ex_conf & EX_CONF_INV_LED_POLARITY) {
-                   bus_space_write_2(sc->sc_iot, ioh, 12,
-                       0x10|bus_space_read_2(sc->sc_iot, ioh, 12));
-           }
-           if (sc->ex_conf & EX_CONF_PHY_POWER) {
-                   bus_space_write_2(sc->sc_iot, ioh, 12,
-                       0x4000|bus_space_read_2(sc->sc_iot, ioh, 12));
-           }
+       if (sc->ex_conf & (EX_CONF_INV_LED_POLARITY|EX_CONF_PHY_POWER)) {
+               GO_WINDOW(2);
+               val = bus_space_read_2(iot, ioh, ELINK_W2_RESET_OPTIONS);
+               if (sc->ex_conf & EX_CONF_INV_LED_POLARITY)
+                       val |= ELINK_RESET_OPT_LEDPOLAR;
+               if (sc->ex_conf & EX_CONF_PHY_POWER)
+                       val |= ELINK_RESET_OPT_PHYPOWER;
+               bus_space_write_2(iot, ioh, ELINK_W2_RESET_OPTIONS, val);
        }
 
        attach_stage = 0;
@@ -1456,7 +1454,11 @@
 ex_reset(sc)
        struct ex_softc *sc;
 {
-       bus_space_write_2(sc->sc_iot, sc->sc_ioh, ELINK_COMMAND, GLOBAL_RESET);
+       u_int16_t val = GLOBAL_RESET;
+
+       if (sc->ex_conf & EX_CONF_RESETHACK)
+               val |= 0xff;
+       bus_space_write_2(sc->sc_iot, sc->sc_ioh, ELINK_COMMAND, val);
        delay(400);
        ex_waitcmd(sc);
 }
@@ -1653,21 +1655,17 @@
 {
        bus_space_tag_t iot = sc->sc_iot;
        bus_space_handle_t ioh = sc->sc_ioh;
-       u_int16_t data = 0;
+       u_int16_t data = 0, cmd = READ_EEPROM;
+       int off;
+
+       off = sc->ex_conf & EX_CONF_EEPROM_OFF ? 0x30 : 0;
+       cmd = sc->ex_conf & EX_CONF_EEPROM_8BIT ? READ_EEPROM8 : READ_EEPROM;
 
        GO_WINDOW(0);
        if (ex_eeprom_busy(sc))
                goto out;
-       switch (sc->ex_bustype) {
-       case EX_BUS_PCI:
-               bus_space_write_1(iot, ioh, ELINK_W0_EEPROM_COMMAND,
-                   READ_EEPROM | (offset & 0x3f));
-               break;
-       case EX_BUS_CARDBUS:
-               bus_space_write_2(iot, ioh, ELINK_W0_EEPROM_COMMAND,
-                   0x230 + (offset & 0x3f));
-               break;
-       }
+       bus_space_write_2(iot, ioh, ELINK_W0_EEPROM_COMMAND,
+           cmd | (off + (offset & 0x3f)));
        if (ex_eeprom_busy(sc))
                goto out;
        data = bus_space_read_2(iot, ioh, ELINK_W0_EEPROM_DATA);
diff -r b4f0e3ade7ea -r 6028d80a321a sys/dev/ic/elinkxlreg.h
--- a/sys/dev/ic/elinkxlreg.h   Tue Sep 19 01:12:48 2000 +0000
+++ b/sys/dev/ic/elinkxlreg.h   Tue Sep 19 01:15:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elinkxlreg.h,v 1.2 1999/09/01 21:03:03 fvdl Exp $      */
+/*     $NetBSD: elinkxlreg.h,v 1.3 2000/09/19 01:15:28 fvdl Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -47,6 +47,8 @@
 #define EEPROM_MEDIA           0x19    /* Media options (90xB) */
 #define EEPROM_CHECKSUM_ELXL   0x20    /* EEPROM checksum */
 
+#define READ_EEPROM8           0x0200  /* 8 bit EEPROM read command */
+
 /*
  * Flat address space registers (outside the windows)
  */
@@ -103,6 +105,13 @@
 #      define ELINK_MEDIACAP_10BASEFL  0x0080
 
 /*
+ * Reset options for the 90xB
+ */
+#define ELINK_W2_RESET_OPTIONS 0x0c
+#      define ELINK_RESET_OPT_LEDPOLAR 0x0010
+#      define ELINK_RESET_OPT_PHYPOWER 0x4000
+
+/*
  * Window 4, offset 8 is defined for MII/PHY access for EtherLink XL
  * cards.
  */
diff -r b4f0e3ade7ea -r 6028d80a321a sys/dev/ic/elinkxlvar.h
--- a/sys/dev/ic/elinkxlvar.h   Tue Sep 19 01:12:48 2000 +0000
+++ b/sys/dev/ic/elinkxlvar.h   Tue Sep 19 01:15:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elinkxlvar.h,v 1.7 2000/08/24 08:54:31 haya Exp $      */
+/*     $NetBSD: elinkxlvar.h,v 1.8 2000/09/19 01:15:28 fvdl Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -83,8 +83,12 @@
 #define EX_CONF_MII            0x0001  /* has MII bus */
 #define EX_CONF_INTPHY         0x0002  /* has internal PHY */
 #define EX_CONF_90XB           0x0004  /* is 90xB */
-#define EX_CONF_INV_LED_POLARITY       0x0010  /* CardBus: LED polarity */
-#define EX_CONF_PHY_POWER      0x0020  /* CardBus: controllable PHY power */
+#define EX_CONF_INV_LED_POLARITY 0x0010        /* CardBus & MiniPCI: LED polarity */
+#define EX_CONF_PHY_POWER      0x0020  /* CardBus & MiniPCI: PHY power */
+#define EX_CONF_EEPROM_OFF     0x0040  /* EEPROM is offset by 0x30 */
+#define EX_CONF_EEPROM_8BIT    0x0080  /* 8 bit EEPROM */
+#define EX_CONF_PCI_FUNCREG    0x0100  /* Has PCI function registers */
+#define EX_CONF_RESETHACK      0x0200  /* Hack to make reset work on 556B */
 
 
        /*
diff -r b4f0e3ade7ea -r 6028d80a321a sys/dev/pci/if_ex_pci.c
--- a/sys/dev/pci/if_ex_pci.c   Tue Sep 19 01:12:48 2000 +0000
+++ b/sys/dev/pci/if_ex_pci.c   Tue Sep 19 01:15:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ex_pci.c,v 1.13 2000/08/07 04:08:35 billc Exp $     */
+/*     $NetBSD: if_ex_pci.c,v 1.14 2000/09/19 01:15:06 fvdl Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -90,6 +90,12 @@
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcidevs.h>
 
+struct ex_pci_softc {
+       struct ex_softc sc_ex;
+       pci_chipset_tag_t sc_chiptag;
+       pcitag_t sc_pcitag;
+};
+
 /*
  * PCI constants.
  * XXX These should be in a common file!
@@ -97,12 +103,16 @@
 #define PCI_CONN               0x48    /* Connector type */
 #define PCI_CBIO               0x10    /* Configuration Base IO Address */
 #define PCI_POWERCTL           0xe0
+#define PCI_FUNCMEM            0x18
+
+#define PCI_INTRACK            0x00008000
 
 int ex_pci_match __P((struct device *, struct cfdata *, void *));
 void ex_pci_attach __P((struct device *, struct device *, void *));
+void ex_pci_intr_ack __P((struct ex_softc *));
 
 struct cfattach ex_pci_ca = {
-       sizeof(struct ex_softc), ex_pci_match, ex_pci_attach
+       sizeof(struct ex_pci_softc), ex_pci_match, ex_pci_attach
 };
 
 const struct ex_pci_product {
@@ -151,6 +161,23 @@
        { PCI_PRODUCT_3COM_3CSOHO100TX, EX_CONF_90XB,
          "3cSOHO100-TX 10/100 Ethernet" },
 
+       { PCI_PRODUCT_3COM_3C555,
+          EX_CONF_90XB | EX_CONF_MII | EX_CONF_EEPROM_OFF |
+          EX_CONF_EEPROM_8BIT,
+         "3c555 MiniPCI 10/100 Ethernet" },
+
+       { PCI_PRODUCT_3COM_3C556,
+          EX_CONF_90XB | EX_CONF_MII | EX_CONF_EEPROM_OFF |
+          EX_CONF_PCI_FUNCREG | EX_CONF_RESETHACK | EX_CONF_INV_LED_POLARITY |
+          EX_CONF_PHY_POWER | EX_CONF_EEPROM_8BIT,
+         "3c556 MiniPCI 10/100 Ethernet" },
+
+       { PCI_PRODUCT_3COM_3C556B,
+          EX_CONF_90XB | EX_CONF_MII | EX_CONF_EEPROM_OFF |
+          EX_CONF_PCI_FUNCREG | EX_CONF_RESETHACK | EX_CONF_INV_LED_POLARITY |
+          EX_CONF_PHY_POWER,
+         "3c556B MiniPCI 10/100 Ethernet" },
+
        { 0,                            0,
          NULL },
 };
@@ -193,6 +220,7 @@
        void *aux;
 {
        struct ex_softc *sc = (void *)self;
+       struct ex_pci_softc *psc = (void *)self;
        struct pci_attach_args *pa = aux;
        pci_chipset_tag_t pc = pa->pa_pc;
        pci_intr_handle_t ih;
@@ -255,6 +283,13 @@
                printf("%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
                return;
        }
+
+       if (sc->ex_conf & EX_CONF_PCI_FUNCREG) {
+               sc->intr_ack = ex_pci_intr_ack;
+               psc->sc_chiptag = pa->pa_pc;
+               psc->sc_pcitag = pa->pa_tag;
+       }
+
        intrstr = pci_intr_string(pc, ih);
        sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, ex_intr, sc);
        if (sc->sc_ih == NULL) {
@@ -269,3 +304,13 @@
 
        ex_config(sc);
 }
+
+void            
+ex_pci_intr_ack(sc)
+       struct ex_softc *sc;
+{
+       struct ex_pci_softc *psc = (struct ex_pci_softc *)sc;
+        
+       pci_conf_write(psc->sc_chiptag, psc->sc_pcitag, PCI_FUNCMEM + 4,
+           PCI_INTRACK);
+}



Home | Main Index | Thread Index | Old Index