tg3: Add some VPD preprocessor constants
This patch cleans up the VPD code by creating preprocessor definitions and using them in the place of hardcoded constants. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Reviewed-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b703df6f62
commit
141518c958
|
@ -12433,7 +12433,7 @@ skip_phy_reset:
|
||||||
|
|
||||||
static void __devinit tg3_read_partno(struct tg3 *tp)
|
static void __devinit tg3_read_partno(struct tg3 *tp)
|
||||||
{
|
{
|
||||||
unsigned char vpd_data[256]; /* in little-endian format */
|
unsigned char vpd_data[TG3_NVM_VPD_LEN]; /* in little-endian format */
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
u32 magic;
|
u32 magic;
|
||||||
|
|
||||||
|
@ -12442,14 +12442,14 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
|
||||||
goto out_not_found;
|
goto out_not_found;
|
||||||
|
|
||||||
if (magic == TG3_EEPROM_MAGIC) {
|
if (magic == TG3_EEPROM_MAGIC) {
|
||||||
for (i = 0; i < 256; i += 4) {
|
for (i = 0; i < TG3_NVM_VPD_LEN; i += 4) {
|
||||||
u32 tmp;
|
u32 tmp;
|
||||||
|
|
||||||
/* The data is in little-endian format in NVRAM.
|
/* The data is in little-endian format in NVRAM.
|
||||||
* Use the big-endian read routines to preserve
|
* Use the big-endian read routines to preserve
|
||||||
* the byte order as it exists in NVRAM.
|
* the byte order as it exists in NVRAM.
|
||||||
*/
|
*/
|
||||||
if (tg3_nvram_read_be32(tp, 0x100 + i, &tmp))
|
if (tg3_nvram_read_be32(tp, TG3_NVM_VPD_OFF + i, &tmp))
|
||||||
goto out_not_found;
|
goto out_not_found;
|
||||||
|
|
||||||
memcpy(&vpd_data[i], &tmp, sizeof(tmp));
|
memcpy(&vpd_data[i], &tmp, sizeof(tmp));
|
||||||
|
@ -12458,7 +12458,7 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
|
||||||
int vpd_cap;
|
int vpd_cap;
|
||||||
|
|
||||||
vpd_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_VPD);
|
vpd_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_VPD);
|
||||||
for (i = 0; i < 256; i += 4) {
|
for (i = 0; i < TG3_NVM_VPD_LEN; i += 4) {
|
||||||
u32 tmp, j = 0;
|
u32 tmp, j = 0;
|
||||||
__le32 v;
|
__le32 v;
|
||||||
u16 tmp16;
|
u16 tmp16;
|
||||||
|
@ -12483,7 +12483,7 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now parse and find the part number. */
|
/* Now parse and find the part number. */
|
||||||
for (i = 0; i < 254; ) {
|
for (i = 0; i < TG3_NVM_VPD_LEN - 2; ) {
|
||||||
unsigned char val = vpd_data[i];
|
unsigned char val = vpd_data[i];
|
||||||
unsigned int block_end;
|
unsigned int block_end;
|
||||||
|
|
||||||
|
@ -12502,7 +12502,7 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
|
||||||
(vpd_data[i + 2] << 8)));
|
(vpd_data[i + 2] << 8)));
|
||||||
i += 3;
|
i += 3;
|
||||||
|
|
||||||
if (block_end > 256)
|
if (block_end > TG3_NVM_VPD_LEN)
|
||||||
goto out_not_found;
|
goto out_not_found;
|
||||||
|
|
||||||
while (i < (block_end - 2)) {
|
while (i < (block_end - 2)) {
|
||||||
|
@ -12511,7 +12511,8 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
|
||||||
int partno_len = vpd_data[i + 2];
|
int partno_len = vpd_data[i + 2];
|
||||||
|
|
||||||
i += 3;
|
i += 3;
|
||||||
if (partno_len > 24 || (partno_len + i) > 256)
|
if (partno_len > TG3_BPN_SIZE ||
|
||||||
|
(partno_len + i) > TG3_NVM_VPD_LEN)
|
||||||
goto out_not_found;
|
goto out_not_found;
|
||||||
|
|
||||||
memcpy(tp->board_part_number,
|
memcpy(tp->board_part_number,
|
||||||
|
|
|
@ -1821,6 +1821,11 @@
|
||||||
|
|
||||||
#define TG3_OTP_DEFAULT 0x286c1640
|
#define TG3_OTP_DEFAULT 0x286c1640
|
||||||
|
|
||||||
|
|
||||||
|
/* Hardware Legacy NVRAM layout */
|
||||||
|
#define TG3_NVM_VPD_OFF 0x100
|
||||||
|
#define TG3_NVM_VPD_LEN 256
|
||||||
|
|
||||||
/* Hardware Selfboot NVRAM layout */
|
/* Hardware Selfboot NVRAM layout */
|
||||||
#define TG3_NVM_HWSB_CFG1 0x00000004
|
#define TG3_NVM_HWSB_CFG1 0x00000004
|
||||||
#define TG3_NVM_HWSB_CFG1_MAJMSK 0xf8000000
|
#define TG3_NVM_HWSB_CFG1_MAJMSK 0xf8000000
|
||||||
|
@ -2893,8 +2898,9 @@ struct tg3 {
|
||||||
u32 led_ctrl;
|
u32 led_ctrl;
|
||||||
u32 phy_otp;
|
u32 phy_otp;
|
||||||
|
|
||||||
char board_part_number[24];
|
#define TG3_BPN_SIZE 24
|
||||||
#define TG3_VER_SIZE 32
|
char board_part_number[TG3_BPN_SIZE];
|
||||||
|
#define TG3_VER_SIZE ETHTOOL_FWVERS_LEN
|
||||||
char fw_ver[TG3_VER_SIZE];
|
char fw_ver[TG3_VER_SIZE];
|
||||||
u32 nic_sram_data_cfg;
|
u32 nic_sram_data_cfg;
|
||||||
u32 pci_clock_ctrl;
|
u32 pci_clock_ctrl;
|
||||||
|
|
|
@ -49,13 +49,14 @@ static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
|
||||||
return (ep->speed_hi << 16) | ep->speed;
|
return (ep->speed_hi << 16) | ep->speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ETHTOOL_FWVERS_LEN 32
|
||||||
#define ETHTOOL_BUSINFO_LEN 32
|
#define ETHTOOL_BUSINFO_LEN 32
|
||||||
/* these strings are set to whatever the driver author decides... */
|
/* these strings are set to whatever the driver author decides... */
|
||||||
struct ethtool_drvinfo {
|
struct ethtool_drvinfo {
|
||||||
__u32 cmd;
|
__u32 cmd;
|
||||||
char driver[32]; /* driver short name, "tulip", "eepro100" */
|
char driver[32]; /* driver short name, "tulip", "eepro100" */
|
||||||
char version[32]; /* driver version string */
|
char version[32]; /* driver version string */
|
||||||
char fw_version[32]; /* firmware version string, if applicable */
|
char fw_version[ETHTOOL_FWVERS_LEN]; /* firmware version string */
|
||||||
char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
|
char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
|
||||||
/* For PCI devices, use pci_name(pci_dev). */
|
/* For PCI devices, use pci_name(pci_dev). */
|
||||||
char reserved1[32];
|
char reserved1[32];
|
||||||
|
|
Loading…
Reference in New Issue