Skip to content

Commit

Permalink
[TG3]: Improve NVRAM sizing.
Browse files Browse the repository at this point in the history
This patch changes the NVRAM sizing procedure so that the driver can
take advantage of devices with 1:1 NVRAM strapping configurations.  This
is useful in cases where the traditional NVRAM sizing method fails.  In
the event that the flash size cannot be determined, the largest known
NVRAM size is used.  The patch also removes support for 5755 NVRAM
devices that are not supported by Broadcom and adds explicit sizing for
this device.

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>
  • Loading branch information
Matt Carlson authored and David S. Miller committed May 5, 2007
1 parent c13e371 commit 989a9d2
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions drivers/net/tg3.c
Original file line number Diff line number Diff line change
Expand Up @@ -9286,7 +9286,7 @@ static void __devinit tg3_get_nvram_size(struct tg3 *tp)
return;
}
}
tp->nvram_size = 0x20000;
tp->nvram_size = 0x80000;
}

static void __devinit tg3_get_nvram_info(struct tg3 *tp)
Expand Down Expand Up @@ -9405,33 +9405,31 @@ static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp)

static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp)
{
u32 nvcfg1;
u32 nvcfg1, protect = 0;

nvcfg1 = tr32(NVRAM_CFG1);

/* NVRAM protection for TPM */
if (nvcfg1 & (1 << 27))
if (nvcfg1 & (1 << 27)) {
tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM;
protect = 1;
}

switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) {
case FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ:
case FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ:
tp->nvram_jedecnum = JEDEC_ATMEL;
tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE;

nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS;
tw32(NVRAM_CFG1, nvcfg1);
break;
case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED:
nvcfg1 &= NVRAM_CFG1_5752VENDOR_MASK;
switch (nvcfg1) {
case FLASH_5755VENDOR_ATMEL_FLASH_1:
case FLASH_5755VENDOR_ATMEL_FLASH_2:
case FLASH_5755VENDOR_ATMEL_FLASH_3:
case FLASH_5755VENDOR_ATMEL_FLASH_4:
tp->nvram_jedecnum = JEDEC_ATMEL;
tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
tp->tg3_flags2 |= TG3_FLG2_FLASH;
tp->nvram_pagesize = 264;
if (nvcfg1 == FLASH_5755VENDOR_ATMEL_FLASH_1)
tp->nvram_size = (protect ? 0x3e200 : 0x80000);
else if (nvcfg1 == FLASH_5755VENDOR_ATMEL_FLASH_2)
tp->nvram_size = (protect ? 0x1f200 : 0x40000);
else
tp->nvram_size = (protect ? 0x1f200 : 0x20000);
break;
case FLASH_5752VENDOR_ST_M45PE10:
case FLASH_5752VENDOR_ST_M45PE20:
Expand All @@ -9440,6 +9438,12 @@ static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp)
tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
tp->tg3_flags2 |= TG3_FLG2_FLASH;
tp->nvram_pagesize = 256;
if (nvcfg1 == FLASH_5752VENDOR_ST_M45PE10)
tp->nvram_size = (protect ? 0x10000 : 0x20000);
else if (nvcfg1 == FLASH_5752VENDOR_ST_M45PE20)
tp->nvram_size = (protect ? 0x10000 : 0x40000);
else
tp->nvram_size = (protect ? 0x20000 : 0x80000);
break;
}
}
Expand Down Expand Up @@ -9515,6 +9519,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
}
tg3_enable_nvram_access(tp);

tp->nvram_size = 0;

if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
tg3_get_5752_nvram_info(tp);
else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
Expand All @@ -9526,7 +9532,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
else
tg3_get_nvram_info(tp);

tg3_get_nvram_size(tp);
if (tp->nvram_size == 0)
tg3_get_nvram_size(tp);

tg3_disable_nvram_access(tp);
tg3_nvram_unlock(tp);
Expand Down

0 comments on commit 989a9d2

Please sign in to comment.