Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Store the number of EEPROM address bits in the s...



details:   https://anonhg.NetBSD.org/src/rev/50007832ca5d
branches:  trunk
changeset: 553491:50007832ca5d
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Oct 17 21:12:48 2003 +0000

description:
Store the number of EEPROM address bits in the softc.

diffstat:

 sys/dev/pci/if_wm.c |  41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)

diffs (109 lines):

diff -r 47e4617de148 -r 50007832ca5d sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Fri Oct 17 21:08:57 2003 +0000
+++ b/sys/dev/pci/if_wm.c       Fri Oct 17 21:12:48 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.43 2003/10/17 20:57:32 thorpej Exp $       */
+/*     $NetBSD: if_wm.c,v 1.44 2003/10/17 21:12:48 thorpej Exp $       */
 
 /*
  * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.43 2003/10/17 20:57:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.44 2003/10/17 21:12:48 thorpej Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -210,6 +210,8 @@
 
        void *sc_ih;                    /* interrupt cookie */
 
+       int sc_ee_addrbits;             /* EEPROM address bits */
+
        struct mii_data sc_mii;         /* MII/media information */
 
        struct callout sc_tick_ch;      /* tick callout */
@@ -582,6 +584,7 @@
        pci_chipset_tag_t pc = pa->pa_pc;
        pci_intr_handle_t ih;
        const char *intrstr = NULL;
+       const char *eetype;
        bus_space_tag_t memt;
        bus_space_handle_t memh;
        bus_dma_segment_t seg;
@@ -591,6 +594,7 @@
        uint8_t enaddr[ETHER_ADDR_LEN];
        uint16_t myea[ETHER_ADDR_LEN / 2], cfg1, cfg2, swdpin;
        pcireg_t preg, memtype;
+       uint32_t reg;
        int pmreg;
 
        callout_init(&sc->sc_tick_ch);
@@ -619,12 +623,6 @@
        }
 
        /*
-        * Some chips require a handshake to access the EEPROM.
-        */
-       if (sc->sc_type >= WM_T_82540)
-               sc->sc_flags |= WM_F_EEPROM_HANDSHAKE;
-
-       /*
         * Map the device.
         */
        memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, WM_PCI_MMBA);
@@ -765,6 +763,25 @@
        wm_reset(sc);
 
        /*
+        * Get some information about the EEPROM.
+        */
+       eetype = "MicroWire";
+       if (sc->sc_type >= WM_T_82540)
+               sc->sc_flags |= WM_F_EEPROM_HANDSHAKE;
+       if (sc->sc_type <= WM_T_82544)
+               sc->sc_ee_addrbits = 6;
+       else if (sc->sc_type <= WM_T_82546_3) {
+               reg = CSR_READ(sc, WMREG_EECD);
+               if (reg & EECD_EE_SIZE)
+                       sc->sc_ee_addrbits = 8;
+               else
+                       sc->sc_ee_addrbits = 6;
+       }
+       aprint_verbose("%s: %u word (%d address bits) %s EEPROM\n",
+           sc->sc_dev.dv_xname, 1U << sc->sc_ee_addrbits,
+           sc->sc_ee_addrbits, eetype);
+
+       /*
         * Read the Ethernet address from the EEPROM.
         */
        wm_read_eeprom(sc, EEPROM_OFF_MACADDR,
@@ -2276,16 +2293,12 @@
 wm_read_eeprom(struct wm_softc *sc, int word, int wordcnt, uint16_t *data)
 {
        uint32_t reg;
-       int i, x, addrbits = 6;
+       int i, x;
 
        for (i = 0; i < wordcnt; i++) {
                if (sc->sc_flags & WM_F_EEPROM_HANDSHAKE) {
                        reg = CSR_READ(sc, WMREG_EECD);
 
-                       /* Get number of address bits. */
-                       if (reg & EECD_EE_SIZE)
-                               addrbits = 8;
-
                        /* Request EEPROM access. */
                        reg |= EECD_EE_REQ;
                        CSR_WRITE(sc, WMREG_EECD, reg);
@@ -2332,7 +2345,7 @@
                }
 
                /* Shift in address. */
-               for (x = addrbits; x > 0; x--) {
+               for (x = sc->sc_ee_addrbits; x > 0; x--) {
                        if ((word + i) & (1 << (x - 1)))
                                reg |= EECD_DI;
                        else



Home | Main Index | Thread Index | Old Index