Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Move all the code that handles the MicroWire EEP...



details:   https://anonhg.NetBSD.org/src/rev/feeda9e27b9b
branches:  trunk
changeset: 553710:feeda9e27b9b
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Oct 20 16:28:23 2003 +0000

description:
Move all the code that handles the MicroWire EEPROM protocol into
a separate function.

diffstat:

 sys/dev/pci/if_wm.c |  64 +++++++++++++++++++++++++++++++---------------------
 1 files changed, 38 insertions(+), 26 deletions(-)

diffs (99 lines):

diff -r 6864d963ef16 -r feeda9e27b9b sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Mon Oct 20 16:24:10 2003 +0000
+++ b/sys/dev/pci/if_wm.c       Mon Oct 20 16:28:23 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.49 2003/10/20 15:34:25 thorpej Exp $       */
+/*     $NetBSD: if_wm.c,v 1.50 2003/10/20 16:28:23 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.49 2003/10/20 15:34:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.50 2003/10/20 16:28:23 thorpej Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -2391,6 +2391,41 @@
 }
 
 /*
+ * wm_read_eeprom_uwire:
+ *
+ *     Read a word from the EEPROM using the MicroWire protocol.
+ */
+static void
+wm_read_eeprom_uwire(struct wm_softc *sc, int word, uint16_t *datap)
+{
+       uint32_t reg, val;
+
+       /* Clear SK and DI. */
+       reg = CSR_READ(sc, WMREG_EECD) & ~(EECD_SK | EECD_DI);
+       CSR_WRITE(sc, WMREG_EECD, reg);
+
+       /* Set CHIP SELECT. */
+       reg |= EECD_CS;
+       CSR_WRITE(sc, WMREG_EECD, reg);
+       delay(2);
+
+       /* Shift in the READ command. */
+       wm_eeprom_sendbits(sc, UWIRE_OPC_READ, 3);
+
+       /* Shift in address. */
+       wm_eeprom_sendbits(sc, word, sc->sc_ee_addrbits);
+
+       /* Shift out the data. */
+       wm_eeprom_recvbits(sc, &val, 16);
+       *datap = val & 0xffff;
+
+       /* Clear CHIP SELECT. */
+       reg = CSR_READ(sc, WMREG_EECD) & ~EECD_CS;
+       CSR_WRITE(sc, WMREG_EECD, reg);
+       delay(2);
+}
+
+/*
  * wm_read_eeprom:
  *
  *     Read data from the serial EEPROM.
@@ -2398,7 +2433,6 @@
 static void
 wm_read_eeprom(struct wm_softc *sc, int word, int wordcnt, uint16_t *data)
 {
-       uint32_t reg, val;
        int i;
 
        for (i = 0; i < wordcnt; i++) {
@@ -2408,29 +2442,7 @@
                        continue;
                }
 
-               /* Clear SK and DI. */
-               reg = CSR_READ(sc, WMREG_EECD) & ~(EECD_SK | EECD_DI);
-               CSR_WRITE(sc, WMREG_EECD, reg);
-
-               /* Set CHIP SELECT. */
-               reg |= EECD_CS;
-               CSR_WRITE(sc, WMREG_EECD, reg);
-               delay(2);
-
-               /* Shift in the READ command. */
-               wm_eeprom_sendbits(sc, UWIRE_OPC_READ, 3);
-
-               /* Shift in address. */
-               wm_eeprom_sendbits(sc, word + i, sc->sc_ee_addrbits);
-
-               /* Shift out the data. */
-               wm_eeprom_recvbits(sc, &val, 16);
-               data[i] = val & 0xffff;
-
-               /* Clear CHIP SELECT. */
-               reg = CSR_READ(sc, WMREG_EECD) & ~EECD_CS;
-               CSR_WRITE(sc, WMREG_EECD, reg);
-               delay(2);
+               wm_read_eeprom_uwire(sc, word + i, &data[i]);
 
                wm_release_eeprom(sc);
        }



Home | Main Index | Thread Index | Old Index