Module Name:    src
Committed By:   msaitoh
Date:           Wed May  8 04:05:46 UTC 2013

Modified Files:
        src/sys/dev/pci: if_bge.c if_bgereg.h

Log Message:
 Check the hardware config words and print them. This change only read them
and print the values.


To generate a diff of this commit:
cvs rdiff -u -r1.240 -r1.241 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/if_bgereg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.240 src/sys/dev/pci/if_bge.c:1.241
--- src/sys/dev/pci/if_bge.c:1.240	Wed May  8 03:13:35 2013
+++ src/sys/dev/pci/if_bge.c	Wed May  8 04:05:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.240 2013/05/08 03:13:35 msaitoh Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.241 2013/05/08 04:05:46 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.240 2013/05/08 03:13:35 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.241 2013/05/08 04:05:46 msaitoh Exp $");
 
 #include "vlan.h"
 
@@ -3260,7 +3260,7 @@ bge_attach(device_t parent, device_t sel
 	pci_chipset_tag_t	pc;
 	pci_intr_handle_t	ih;
 	const char		*intrstr = NULL;
-	uint32_t		hwcfg = 0;
+	uint32_t 		hwcfg, hwcfg2, hwcfg3, hwcfg4;
 	uint32_t		command;
 	struct ifnet		*ifp;
 	uint32_t		misccfg;
@@ -3593,6 +3593,33 @@ bge_attach(device_t parent, device_t sel
 		}
 	}
 
+	/*
+	 * Read the hardware config word in the first 32k of NIC internal
+	 * memory, or fall back to the config word in the EEPROM.
+	 * Note: on some BCM5700 cards, this value appears to be unset.
+	 */
+	hwcfg = hwcfg2 = hwcfg3 = hwcfg4 = 0;
+	if (bge_readmem_ind(sc, BGE_SRAM_DATA_SIG) ==
+	    BGE_SRAM_DATA_SIG_MAGIC) {
+		uint32_t tmp;
+
+		hwcfg = bge_readmem_ind(sc, BGE_SRAM_DATA_CFG);
+		tmp = bge_readmem_ind(sc, BGE_SRAM_DATA_VER) >>
+		    BGE_SRAM_DATA_VER_SHIFT;
+		if ((0 < tmp) && (tmp < 0x100))
+			hwcfg2 = bge_readmem_ind(sc, BGE_SRAM_DATA_CFG_2);
+		if (sc->bge_flags & BGE_PCIE)
+			hwcfg3 = bge_readmem_ind(sc, BGE_SRAM_DATA_CFG_3);
+		if (BGE_ASICREV(sc->bge_chipid == BGE_ASICREV_BCM5785))
+			hwcfg4 = bge_readmem_ind(sc, BGE_SRAM_DATA_CFG_4);
+	} else if (!(sc->bge_flags & BGE_NO_EEPROM)) {
+		bge_read_eeprom(sc, (void *)&hwcfg,
+		    BGE_EE_HWCFG_OFFSET, sizeof(hwcfg));
+		hwcfg = be32toh(hwcfg);
+	}
+	aprint_normal_dev(sc->bge_dev, "HW config %08x, %08x, %08x, %08x\n",
+	    hwcfg, hwcfg2, hwcfg3, hwcfg4);
+
 #if 0
 	/*
 	 * Reset NVRAM before bge_reset(). It's required to acquire NVRAM
@@ -3758,20 +3785,11 @@ bge_attach(device_t parent, device_t sel
 
 	/*
 	 * Figure out what sort of media we have by checking the hardware
-	 * config word in the first 32k of NIC internal memory, or fall back to
-	 * the config word in the EEPROM. Note: on some BCM5700 cards,
-	 * this value appears to be unset. If that's the case, we have to rely
-	 * on identifying the NIC by its PCI subsystem ID, as we do below for
-	 * the SysKonnect SK-9D41.
+	 * config word.  Note: on some BCM5700 cards, this value appears to be
+	 * unset. If that's the case, we have to rely on identifying the NIC
+	 * by its PCI subsystem ID, as we do below for the SysKonnect SK-9D41.
+	 * The SysKonnect SK-9D41 is a 1000baseSX card.
 	 */
-	if (bge_readmem_ind(sc, BGE_SRAM_DATA_SIG) == BGE_SRAM_DATA_SIG_MAGIC) {
-		hwcfg = bge_readmem_ind(sc, BGE_SRAM_DATA_CFG);
-	} else if (!(sc->bge_flags & BGE_NO_EEPROM)) {
-		bge_read_eeprom(sc, (void *)&hwcfg,
-		    BGE_EE_HWCFG_OFFSET, sizeof(hwcfg));
-		hwcfg = be32toh(hwcfg);
-	}
-	/* The SysKonnect SK-9D41 is a 1000baseSX card. */
 	if (PCI_PRODUCT(pa->pa_id) == SK_SUBSYSID_9D41 ||
 	    (hwcfg & BGE_HWCFG_MEDIA) == BGE_MEDIA_FIBER) {
 		if (BGE_IS_5714_FAMILY(sc))

Index: src/sys/dev/pci/if_bgereg.h
diff -u src/sys/dev/pci/if_bgereg.h:1.75 src/sys/dev/pci/if_bgereg.h:1.76
--- src/sys/dev/pci/if_bgereg.h:1.75	Sun Apr 21 19:59:40 2013
+++ src/sys/dev/pci/if_bgereg.h	Wed May  8 04:05:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bgereg.h,v 1.75 2013/04/21 19:59:40 msaitoh Exp $	*/
+/*	$NetBSD: if_bgereg.h,v 1.76 2013/05/08 04:05:46 msaitoh Exp $	*/
 /*
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2001
@@ -75,12 +75,16 @@
 #define	BGE_SRAM_FW_MB			0x00000B50
 #define	BGE_SRAM_DATA_SIG		0x00000B54
 #define	BGE_SRAM_DATA_CFG		0x00000B58
+#define	BGE_SRAM_DATA_VER		0x00000B5C
 #define	BGE_SRAM_FW_CMD_MB		0x00000B78
 #define	BGE_SRAM_FW_CMD_LEN_MB		0x00000B7C
 #define	BGE_SRAM_FW_CMD_DATA_MB		0x00000B80
 #define	BGE_SRAM_FW_DRV_STATE_MB	0x00000C04
 #define	BGE_SRAM_MAC_ADDR_HIGH_MB	0x00000C14
 #define	BGE_SRAM_MAC_ADDR_LOW_MB	0x00000C18
+#define	BGE_SRAM_DATA_CFG_2		0x00000D38
+#define	BGE_SRAM_DATA_CFG_3		0x00000D3C
+#define	BGE_SRAM_DATA_CFG_4		0x00000D60
 #define BGE_SOFTWARE_GENCOMM_END	0x00000FFF
 #define BGE_UNMAPPED			0x00001000
 #define BGE_UNMAPPED_END		0x00001FFF
@@ -104,6 +108,9 @@
 #define	BGE_FW_DRV_STATE_UNLOAD_DONE	0x80000002
 #define	BGE_FW_DRV_STATE_SUSPEND	0x00000004
 
+/* SRAM data version */
+#define	BGE_SRAM_DATA_VER_SHIFT		16
+
 /* Mappings for internal memory configuration */
 #define BGE_STD_RX_RINGS		0x00006000
 #define BGE_STD_RX_RINGS_END		0x00006FFF
@@ -2361,6 +2368,7 @@ struct bge_status_block {
 #define BGE_HWCFG_PHYLED_MODE		0x0000000C
 #define BGE_HWCFG_MEDIA			0x00000030
 #define	BGE_HWCFG_ASF			0x00000080
+#define	BGE_HWCFG_EEPROM_WP		0x00000100
 
 #define BGE_VOLTAGE_1POINT3		0x00000000
 #define BGE_VOLTAGE_1POINT8		0x00000001

Reply via email to