Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci - Check iNVM's image version and print it.
details: https://anonhg.NetBSD.org/src/rev/d7809fb394ad
branches: trunk
changeset: 340475:d7809fb394ad
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Mon Sep 07 15:19:05 2015 +0000
description:
- Check iNVM's image version and print it.
- Update TODO.
diffstat:
sys/dev/pci/if_wm.c | 47 ++++++++++++++++++++++++++++++++++++-----------
sys/dev/pci/if_wmreg.h | 9 ++++++++-
2 files changed, 44 insertions(+), 12 deletions(-)
diffs (122 lines):
diff -r 91f8abdea4df -r d7809fb394ad sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c Mon Sep 07 12:29:19 2015 +0000
+++ b/sys/dev/pci/if_wm.c Mon Sep 07 15:19:05 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.346 2015/08/17 06:16:03 knakahara Exp $ */
+/* $NetBSD: if_wm.c,v 1.347 2015/09/07 15:19:05 msaitoh Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -74,14 +74,16 @@
*
* - Check XXX'ed comments
* - EEE (Energy Efficiency Ethernet)
- * - MSI/MSI-X
+ * - Multi queue
+ * - Image Unique ID
+ * - LPLU other than PCH*
* - Virtual Function
* - Set LED correctly (based on contents in EEPROM)
* - Rework how parameters are loaded from the EEPROM.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.346 2015/08/17 06:16:03 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.347 2015/09/07 15:19:05 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -723,6 +725,7 @@
static int wm_nvm_is_onboard_eeprom(struct wm_softc *);
static int wm_nvm_get_flash_presence_i210(struct wm_softc *);
static int wm_nvm_validate_checksum(struct wm_softc *);
+static void wm_nvm_version_invm(struct wm_softc *);
static void wm_nvm_version(struct wm_softc *);
static int wm_nvm_read(struct wm_softc *, int, int, uint16_t *);
@@ -9753,6 +9756,26 @@
}
static void
+wm_nvm_version_invm(struct wm_softc *sc)
+{
+ uint32_t dword;
+
+ /*
+ * Linux's code to decode version is very strange, so we don't
+ * obey that algorithm and just use word 61 as the document.
+ * Perhaps it's not perfect though...
+ *
+ * Example:
+ *
+ * Word61: 00800030 -> Version 0.6 (I211 spec update notes about 0.6)
+ */
+ dword = CSR_READ(sc, WM_INVM_DATA_REG(61));
+ dword = __SHIFTOUT(dword, INVM_VER_1);
+ sc->sc_nvm_ver_major = __SHIFTOUT(dword, INVM_MAJOR);
+ sc->sc_nvm_ver_minor = __SHIFTOUT(dword, INVM_MINOR);
+}
+
+static void
wm_nvm_version(struct wm_softc *sc)
{
uint16_t major, minor, build, patch;
@@ -9796,12 +9819,12 @@
check_version = true;
break;
case WM_T_I211:
- /* XXX wm_nvm_version_invm(sc); */
- return;
+ wm_nvm_version_invm(sc);
+ goto printver;
case WM_T_I210:
if (!wm_nvm_get_flash_presence_i210(sc)) {
- /* XXX wm_nvm_version_invm(sc); */
- return;
+ wm_nvm_version_invm(sc);
+ goto printver;
}
/* FALLTHROUGH */
case WM_T_I350:
@@ -9824,12 +9847,14 @@
/* Decimal */
minor = (minor / 16) * 10 + (minor % 16);
-
- aprint_verbose(", version %d.%d", major, minor);
+ sc->sc_nvm_ver_major = major;
+ sc->sc_nvm_ver_minor = minor;
+
+printver:
+ aprint_verbose(", version %d.%d", sc->sc_nvm_ver_major,
+ sc->sc_nvm_ver_minor);
if (have_build)
aprint_verbose(".%d", build);
- sc->sc_nvm_ver_major = major;
- sc->sc_nvm_ver_minor = minor;
}
if (check_optionrom) {
wm_nvm_read(sc, NVM_OFF_COMB_VER_PTR, 1, &off);
diff -r 91f8abdea4df -r d7809fb394ad sys/dev/pci/if_wmreg.h
--- a/sys/dev/pci/if_wmreg.h Mon Sep 07 12:29:19 2015 +0000
+++ b/sys/dev/pci/if_wmreg.h Mon Sep 07 15:19:05 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wmreg.h,v 1.78 2015/06/13 15:47:58 msaitoh Exp $ */
+/* $NetBSD: if_wmreg.h,v 1.79 2015/09/07 15:19:05 msaitoh Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -1114,6 +1114,13 @@
#define INVM_AUTOLOAD 0x0a
#define INVM_PLL_WO_VAL 0x0010
+/* Version and Image Type field */
+#define INVM_VER_1 __BITS(12,3)
+#define INVM_VER_2 __BITS(22,13)
+#define INVM_IMGTYPE __BITS(28,23)
+#define INVM_MINOR __BITS(3,0)
+#define INVM_MAJOR __BITS(9,4)
+
/* Word definitions for ID LED Settings */
#define ID_LED_RESERVED_FFFF 0xFFFF
Home |
Main Index |
Thread Index |
Old Index