mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-28 01:51:33 +00:00
FSL: Fix common EEPROM_data structure definition
- Fix EEPROM_data structure definition according to System EEPROM Data Format. - Read MAC addresses from EEPROM to ethXaddr before saving ethXaddr to bd->bi_ethaddr. Signed-off-by: Haiying Wang <Haiying.Wang@freescale.com>
This commit is contained in:
parent
6bee764bd6
commit
d59feffb42
3 changed files with 78 additions and 47 deletions
|
@ -28,16 +28,19 @@
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned char id[4]; /* 0x0000 - 0x0003 */
|
u8 id[4]; /* 0x0000 - 0x0003 EEPROM Tag */
|
||||||
unsigned char sn[12]; /* 0x0004 - 0x000F */
|
u8 sn[12]; /* 0x0004 - 0x000F Serial Number */
|
||||||
unsigned char errata[5]; /* 0x0010 - 0x0014 */
|
u8 errata[5]; /* 0x0010 - 0x0014 Errata Level */
|
||||||
unsigned char date[7]; /* 0x0015 - 0x001a */
|
u8 date[6]; /* 0x0015 - 0x001a Build Date */
|
||||||
unsigned char res_1[37]; /* 0x001b - 0x003f */
|
u8 res_0; /* 0x001b Reserved */
|
||||||
unsigned char tab_size; /* 0x0040 */
|
u8 version[4]; /* 0x001c - 0x001f Version */
|
||||||
unsigned char tab_flag; /* 0x0041 */
|
u8 tempcal[8]; /* 0x0020 - 0x0027 Temperature Calibration Factors*/
|
||||||
unsigned char mac[8][6]; /* 0x0042 - 0x0071 */
|
u8 tempcalsys[2]; /* 0x0028 - 0x0029 System Temperature Calibration Factors*/
|
||||||
unsigned char res_2[126]; /* 0x0072 - 0x00ef */
|
u8 res_1[22]; /* 0x0020 - 0x003f Reserved */
|
||||||
unsigned int crc; /* 0x00f0 - 0x00f3 crc32 checksum */
|
u8 mac_size; /* 0x0040 Mac table size */
|
||||||
|
u8 mac_flag; /* 0x0041 Mac table flags */
|
||||||
|
u8 mac[8][6]; /* 0x0042 - 0x0071 Mac addresses */
|
||||||
|
u32 crc; /* 0x0072 crc32 checksum */
|
||||||
} EEPROM_data;
|
} EEPROM_data;
|
||||||
|
|
||||||
static EEPROM_data mac_data;
|
static EEPROM_data mac_data;
|
||||||
|
@ -45,28 +48,57 @@ static EEPROM_data mac_data;
|
||||||
int mac_show(void)
|
int mac_show(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
u8 mac_size;
|
||||||
unsigned char ethaddr[8][18];
|
unsigned char ethaddr[8][18];
|
||||||
|
unsigned char enetvar[32];
|
||||||
|
|
||||||
printf("ID %c%c%c%c\n",
|
/* Show EEPROM tagID,
|
||||||
mac_data.id[0],
|
* always the four characters 'NXID'.
|
||||||
mac_data.id[1],
|
*/
|
||||||
mac_data.id[2],
|
printf("ID ");
|
||||||
mac_data.id[3]);
|
for (i = 0; i < 4; i++)
|
||||||
printf("Errata %c%c%c%c%c\n",
|
printf("%c", mac_data.id[i]);
|
||||||
mac_data.errata[0],
|
printf("\n");
|
||||||
mac_data.errata[1],
|
|
||||||
mac_data.errata[2],
|
/* Show Serial number,
|
||||||
mac_data.errata[3],
|
* 0 to 11 charaters of errata information.
|
||||||
mac_data.errata[4]);
|
*/
|
||||||
printf("Date %c%c%c%c%c%c%c\n",
|
printf("SN ");
|
||||||
|
for (i = 0; i < 12; i++)
|
||||||
|
printf("%c", mac_data.sn[i]);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
/* Show Errata Level,
|
||||||
|
* 0 to 4 characters of errata information.
|
||||||
|
*/
|
||||||
|
printf("Errata ");
|
||||||
|
for (i = 0; i < 5; i++)
|
||||||
|
printf("%c", mac_data.errata[i]);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
/* Show Build Date,
|
||||||
|
* BCD date values, as YYMMDDhhmmss.
|
||||||
|
*/
|
||||||
|
printf("Date 20%02x\/%02x\/%02x %02x:%02x:%02x\n",
|
||||||
mac_data.date[0],
|
mac_data.date[0],
|
||||||
mac_data.date[1],
|
mac_data.date[1],
|
||||||
mac_data.date[2],
|
mac_data.date[2],
|
||||||
mac_data.date[3],
|
mac_data.date[3],
|
||||||
mac_data.date[4],
|
mac_data.date[4],
|
||||||
mac_data.date[5],
|
mac_data.date[5]);
|
||||||
mac_data.date[6]);
|
|
||||||
for (i = 0; i < 8; i++) {
|
/* Show MAC table size,
|
||||||
|
* Value from 0 to 7 indicating how many MAC
|
||||||
|
* addresses are stored in the system EEPROM.
|
||||||
|
*/
|
||||||
|
if((mac_data.mac_size > 0) && (mac_data.mac_size <= 8))
|
||||||
|
mac_size = mac_data.mac_size;
|
||||||
|
else
|
||||||
|
mac_size = 8; /* Set the max size */
|
||||||
|
printf("MACSIZE %x\n", mac_size);
|
||||||
|
|
||||||
|
/* Show Mac addresses */
|
||||||
|
for (i = 0; i < mac_size; i++) {
|
||||||
sprintf((char *)ethaddr[i],
|
sprintf((char *)ethaddr[i],
|
||||||
"%02x:%02x:%02x:%02x:%02x:%02x",
|
"%02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
mac_data.mac[i][0],
|
mac_data.mac[i][0],
|
||||||
|
@ -76,12 +108,12 @@ int mac_show(void)
|
||||||
mac_data.mac[i][4],
|
mac_data.mac[i][4],
|
||||||
mac_data.mac[i][5]);
|
mac_data.mac[i][5]);
|
||||||
printf("MAC %d %s\n", i, ethaddr[i]);
|
printf("MAC %d %s\n", i, ethaddr[i]);
|
||||||
}
|
|
||||||
|
|
||||||
setenv("ethaddr", (char *)ethaddr[0]);
|
sprintf((char *)enetvar,
|
||||||
setenv("eth1addr", (char *)ethaddr[1]);
|
i ? "eth%daddr" : "ethaddr", i);
|
||||||
setenv("eth2addr", (char *)ethaddr[2]);
|
setenv((char *)enetvar, (char *)ethaddr[i]);
|
||||||
setenv("eth3addr", (char *)ethaddr[3]);
|
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -120,17 +152,14 @@ int mac_prog(void)
|
||||||
unsigned char dev = ID_EEPROM_ADDR, *ptr;
|
unsigned char dev = ID_EEPROM_ADDR, *ptr;
|
||||||
unsigned char *eeprom_data = (unsigned char *)(&mac_data);
|
unsigned char *eeprom_data = (unsigned char *)(&mac_data);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(mac_data.res_1); i++)
|
mac_data.res_0 = 0;
|
||||||
mac_data.res_1[i] = 0;
|
memset((void *)mac_data.res_1, 0, sizeof(mac_data.res_1));
|
||||||
for (i = 0; i < sizeof(mac_data.res_2); i++)
|
|
||||||
mac_data.res_2[i] = 0;
|
|
||||||
length = sizeof(EEPROM_data);
|
length = sizeof(EEPROM_data);
|
||||||
crc = crc32(crc, eeprom_data, length - 4);
|
crc = crc32(crc, eeprom_data, length - 4);
|
||||||
mac_data.crc = crc;
|
mac_data.crc = crc;
|
||||||
for (i = 0, ptr = eeprom_data; i < length; i += 8, ptr += 8) {
|
for (i = 0, ptr = eeprom_data; i < length; i += 8, ptr += 8) {
|
||||||
ret =
|
ret = i2c_write(dev, i, 1, ptr, min((length - i),8));
|
||||||
i2c_write(dev, i, 1, ptr,
|
|
||||||
(length - i) < 8 ? (length - i) : 8);
|
|
||||||
udelay(5000); /* 5ms write cycle timing */
|
udelay(5000); /* 5ms write cycle timing */
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
|
@ -179,12 +208,13 @@ int do_mac(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'd': /* date */
|
case 'd': /* date */
|
||||||
for (i = 0; i < 7; i++) {
|
mac_val = simple_strtoull(argv[2], NULL, 16);
|
||||||
mac_data.date[i] = argv[2][i];
|
for (i = 0; i < 6; i++) {
|
||||||
|
mac_data.date[i] = (mac_val >> (40 - 8 * i));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'p': /* number of ports */
|
case 'p': /* mac table size */
|
||||||
mac_data.tab_size =
|
mac_data.mac_size =
|
||||||
(unsigned char)simple_strtoul(argv[2], NULL, 16);
|
(unsigned char)simple_strtoul(argv[2], NULL, 16);
|
||||||
break;
|
break;
|
||||||
case '0': /* mac 0 */
|
case '0': /* mac 0 */
|
||||||
|
|
|
@ -33,7 +33,7 @@ U_BOOT_CMD(
|
||||||
"mac - display and program the system ID and MAC addresses in EEPROM\n",
|
"mac - display and program the system ID and MAC addresses in EEPROM\n",
|
||||||
"[read|save|id|num|errata|date|ports|0|1|2|3|4|5|6|7]\n"
|
"[read|save|id|num|errata|date|ports|0|1|2|3|4|5|6|7]\n"
|
||||||
"read\n"
|
"read\n"
|
||||||
" - show content of mac\n"
|
" - show content of EEPROM\n"
|
||||||
"mac save\n"
|
"mac save\n"
|
||||||
" - save to the EEPROM\n"
|
" - save to the EEPROM\n"
|
||||||
"mac id\n"
|
"mac id\n"
|
||||||
|
@ -43,7 +43,7 @@ U_BOOT_CMD(
|
||||||
"mac errata\n"
|
"mac errata\n"
|
||||||
" - program errata data\n"
|
" - program errata data\n"
|
||||||
"mac date\n"
|
"mac date\n"
|
||||||
" - program data date\n"
|
" - program date\n"
|
||||||
"mac ports\n"
|
"mac ports\n"
|
||||||
" - program the number of ports\n"
|
" - program the number of ports\n"
|
||||||
"mac 0\n"
|
"mac 0\n"
|
||||||
|
|
|
@ -835,6 +835,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
|
||||||
#if defined(CONFIG_SC3)
|
#if defined(CONFIG_SC3)
|
||||||
sc3_read_eeprom();
|
sc3_read_eeprom();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CFG_ID_EEPROM
|
||||||
|
mac_read_from_eeprom();
|
||||||
|
#endif
|
||||||
|
|
||||||
s = getenv ("ethaddr");
|
s = getenv ("ethaddr");
|
||||||
#if defined (CONFIG_MBX) || \
|
#if defined (CONFIG_MBX) || \
|
||||||
defined (CONFIG_RPXCLASSIC) || \
|
defined (CONFIG_RPXCLASSIC) || \
|
||||||
|
@ -902,10 +907,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_ID_EEPROM
|
|
||||||
mac_read_from_eeprom();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
|
#if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
|
||||||
defined(CONFIG_TQM8272) || \
|
defined(CONFIG_TQM8272) || \
|
||||||
defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || \
|
defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || \
|
||||||
|
|
Loading…
Add table
Reference in a new issue