aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2008-11-21 20:19:41 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-21 20:19:41 -0500
commitdfe00d7d890134f9cafda49e3e60e6ce27af91ed (patch)
treedc46d1b8a8896763787a29eb0025ba1fe7a6ec39 /drivers
parent6833c043f9fc03696fde623914c4a0277df2a0bc (diff)
tg3: Extract FW ver from alt NVRAM formats
This patch extracts the bootcode firmware version from the alternate selfboot patch NVRAM format. This format is used on the 5784, 5761 and some newer devices. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/tg3.c51
-rw-r--r--drivers/net/tg3.h11
2 files changed, 61 insertions, 1 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 6972fe5ccbf6..2b70b0f6f60b 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -11951,6 +11951,51 @@ static int __devinit tg3_fw_img_is_valid(struct tg3 *tp, u32 offset)
11951 return 1; 11951 return 1;
11952} 11952}
11953 11953
11954static void __devinit tg3_read_sb_ver(struct tg3 *tp, u32 val)
11955{
11956 u32 offset, major, minor, build;
11957
11958 tp->fw_ver[0] = 's';
11959 tp->fw_ver[1] = 'b';
11960 tp->fw_ver[2] = '\0';
11961
11962 if ((val & TG3_EEPROM_SB_FORMAT_MASK) != TG3_EEPROM_SB_FORMAT_1)
11963 return;
11964
11965 switch (val & TG3_EEPROM_SB_REVISION_MASK) {
11966 case TG3_EEPROM_SB_REVISION_0:
11967 offset = TG3_EEPROM_SB_F1R0_EDH_OFF;
11968 break;
11969 case TG3_EEPROM_SB_REVISION_2:
11970 offset = TG3_EEPROM_SB_F1R2_EDH_OFF;
11971 break;
11972 case TG3_EEPROM_SB_REVISION_3:
11973 offset = TG3_EEPROM_SB_F1R3_EDH_OFF;
11974 break;
11975 default:
11976 return;
11977 }
11978
11979 if (tg3_nvram_read_swab(tp, offset, &val))
11980 return;
11981
11982 build = (val & TG3_EEPROM_SB_EDH_BLD_MASK) >>
11983 TG3_EEPROM_SB_EDH_BLD_SHFT;
11984 major = (val & TG3_EEPROM_SB_EDH_MAJ_MASK) >>
11985 TG3_EEPROM_SB_EDH_MAJ_SHFT;
11986 minor = val & TG3_EEPROM_SB_EDH_MIN_MASK;
11987
11988 if (minor > 99 || build > 26)
11989 return;
11990
11991 snprintf(&tp->fw_ver[2], 30, " v%d.%02d", major, minor);
11992
11993 if (build > 0) {
11994 tp->fw_ver[8] = 'a' + build - 1;
11995 tp->fw_ver[9] = '\0';
11996 }
11997}
11998
11954static void __devinit tg3_read_fw_ver(struct tg3 *tp) 11999static void __devinit tg3_read_fw_ver(struct tg3 *tp)
11955{ 12000{
11956 u32 val, offset, start; 12001 u32 val, offset, start;
@@ -11960,8 +12005,12 @@ static void __devinit tg3_read_fw_ver(struct tg3 *tp)
11960 if (tg3_nvram_read_swab(tp, 0, &val)) 12005 if (tg3_nvram_read_swab(tp, 0, &val))
11961 return; 12006 return;
11962 12007
11963 if (val != TG3_EEPROM_MAGIC) 12008 if (val != TG3_EEPROM_MAGIC) {
12009 if ((val & TG3_EEPROM_MAGIC_FW_MSK) == TG3_EEPROM_MAGIC_FW)
12010 tg3_read_sb_ver(tp, val);
12011
11964 return; 12012 return;
12013 }
11965 12014
11966 if (tg3_nvram_read_swab(tp, 0xc, &offset) || 12015 if (tg3_nvram_read_swab(tp, 0xc, &offset) ||
11967 tg3_nvram_read_swab(tp, 0x4, &start)) 12016 tg3_nvram_read_swab(tp, 0x4, &start))
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index eba62e2074ca..42f60ef4fa39 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -1747,6 +1747,17 @@
1747#define TG3_NVM_DIRTYPE_SHIFT 24 1747#define TG3_NVM_DIRTYPE_SHIFT 24
1748#define TG3_NVM_DIRTYPE_ASFINI 1 1748#define TG3_NVM_DIRTYPE_ASFINI 1
1749 1749
1750#define TG3_EEPROM_SB_F1R0_EDH_OFF 0x10
1751#define TG3_EEPROM_SB_F1R2_EDH_OFF 0x14
1752#define TG3_EEPROM_SB_F1R2_MBA_OFF 0x10
1753#define TG3_EEPROM_SB_F1R3_EDH_OFF 0x18
1754#define TG3_EEPROM_SB_EDH_MAJ_MASK 0x00000700
1755#define TG3_EEPROM_SB_EDH_MAJ_SHFT 8
1756#define TG3_EEPROM_SB_EDH_MIN_MASK 0x000000ff
1757#define TG3_EEPROM_SB_EDH_BLD_MASK 0x0000f800
1758#define TG3_EEPROM_SB_EDH_BLD_SHFT 11
1759
1760
1750/* 32K Window into NIC internal memory */ 1761/* 32K Window into NIC internal memory */
1751#define NIC_SRAM_WIN_BASE 0x00008000 1762#define NIC_SRAM_WIN_BASE 0x00008000
1752 1763