Lines Matching +full:- +full:e

2  * Copyright 2006, 2008-2009, 2011 Freescale Semiconductor
7 * SPDX-License-Identifier: GPL-2.0+
21 /* some boards with non-256-bytes EEPROM have special define */
22 /* for MAX_NUM_PORTS in board-specific file */
36 u8 id[4]; /* 0x00 - 0x03 EEPROM Tag 'CCID' */
39 u8 sn[10]; /* 0x06 - 0x0F Serial Number*/
40 u8 errata[2]; /* 0x10 - 0x11 Errata Level */
41 u8 date[6]; /* 0x12 - 0x17 Build Date */
42 u8 res_0[40]; /* 0x18 - 0x3f Reserved */
45 u8 mac[MAX_NUM_PORTS][6]; /* 0x42 - 0x71 MAC addresses */
49 u8 id[4]; /* 0x00 - 0x03 EEPROM Tag 'NXID' */
50 u8 sn[12]; /* 0x04 - 0x0F Serial Number */
51 u8 errata[5]; /* 0x10 - 0x14 Errata Level */
52 u8 date[6]; /* 0x15 - 0x1a Build Date */
54 u32 version; /* 0x1c - 0x1f NXID Version */
55 u8 tempcal[8]; /* 0x20 - 0x27 Temperature Calibration Factors */
56 u8 tempcalsys[2]; /* 0x28 - 0x29 System Temperature Calibration Factors */
58 u8 res_1[21]; /* 0x2b - 0x3f Reserved */
61 u8 mac[MAX_NUM_PORTS][6]; /* 0x42 - 0xa1 MAC addresses */
62 u8 res_2[90]; /* 0xa2 - 0xfb Reserved */
63 u32 crc; /* 0xfc - 0xff CRC32 checksum */
65 } e; variable
72 #define is_valid ((e.id[0] == 'N') || (e.id[1] == 'X') || \
73 (e.id[2] == 'I') || (e.id[3] == 'D'))
78 #define is_valid ((e.id[0] == 'C') || (e.id[1] == 'C') || \
79 (e.id[2] == 'I') || (e.id[3] == 'D'))
83 * show_eeprom - display the contents of the EEPROM
92 printf("ID: %c%c%c%c v%u\n", e.id[0], e.id[1], e.id[2], e.id[3], in show_eeprom()
93 be32_to_cpu(e.version)); in show_eeprom()
95 printf("ID: %c%c%c%c\n", e.id[0], e.id[1], e.id[2], e.id[3]); in show_eeprom()
99 printf("SN: %s\n", e.sn); in show_eeprom()
103 printf("Errata: %s\n", e.errata); in show_eeprom()
106 e.errata[0] ? e.errata[0] : '.', in show_eeprom()
107 e.errata[1] ? e.errata[1] : '.'); in show_eeprom()
112 e.date[0], e.date[1], e.date[2], in show_eeprom()
113 e.date[3] & 0x7F, e.date[4], e.date[5], in show_eeprom()
114 e.date[3] & 0x80 ? "PM" : ""); in show_eeprom()
117 for (i = 0; i < min(e.mac_count, (u8)MAX_NUM_PORTS); i++) { in show_eeprom()
119 u8 *p = e.mac[i]; in show_eeprom()
125 crc = crc32(0, (void *)&e, sizeof(e) - 4); in show_eeprom()
127 if (crc == be32_to_cpu(e.crc)) in show_eeprom()
128 printf("CRC: %08x\n", be32_to_cpu(e.crc)); in show_eeprom()
131 be32_to_cpu(e.crc), crc); in show_eeprom()
134 printf("EEPROM dump: (0x%x bytes)\n", sizeof(e)); in show_eeprom()
135 for (i = 0; i < sizeof(e); i++) { in show_eeprom()
138 printf("%02X ", ((u8 *)&e)[i]); in show_eeprom()
139 if (((i % 16) == 15) || (i == sizeof(e) - 1)) in show_eeprom()
146 * read_eeprom - read the EEPROM into memory
164 (void *)&e, sizeof(e)); in read_eeprom()
180 * update_crc - update the CRC
189 crc = crc32(0, (void *)&e, sizeof(e) - 4); in update_crc()
190 e.crc = cpu_to_be32(crc); in update_crc()
194 * prog_eeprom - write the EEPROM from memory
207 e.res_0 = 0xFF; in prog_eeprom()
208 memset(e.res_1, 0xFF, sizeof(e.res_1)); in prog_eeprom()
210 memset(e.res_0, 0xFF, sizeof(e.res_0)); in prog_eeprom()
224 for (i = 0, p = &e; i < sizeof(e); i += 8, p += 8) { in prog_eeprom()
226 p, min((int)(sizeof(e) - i), 8)); in prog_eeprom()
238 if (!ret && memcmp(&e, &e2, sizeof(e))) in prog_eeprom()
239 ret = -1; in prog_eeprom()
249 return -1; in prog_eeprom()
257 * h2i - converts hex character into a number
259 * This function takes a hexadecimal character (e.g. '7' or 'C') and returns
265 return p - '0'; in h2i()
268 return (p - 'A') + 10; in h2i()
271 return (p - 'a') + 10; in h2i()
277 * set_date - stores the build date into the EEPROM
280 * (2-digit year, 2-digit month, etc), converts it to a 6-byte BCD string,
293 e.date[i] = h2i(string[2 * i]) << 4 | h2i(string[2 * i + 1]); in set_date()
299 * set_mac_address - stores a MAC address into the EEPROM
302 * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number) and
316 e.mac[index][i] = simple_strtoul(p, &p, 16); in set_mac_address()
342 memcpy(e.id, "NXID", sizeof(e.id)); in do_mac()
343 e.version = cpu_to_be32(NXID_VERSION); in do_mac()
345 memcpy(e.id, "CCID", sizeof(e.id)); in do_mac()
372 memset(e.sn, 0, sizeof(e.sn)); in do_mac()
373 strncpy((char *)e.sn, argv[2], sizeof(e.sn) - 1); in do_mac()
376 case 'e': /* errata */ in do_mac()
378 memset(e.errata, 0, 5); in do_mac()
379 strncpy((char *)e.errata, argv[2], 4); in do_mac()
381 e.errata[0] = argv[2][0]; in do_mac()
382 e.errata[1] = argv[2][1]; in do_mac()
390 e.mac_count = simple_strtoul(argv[2], NULL, 16); in do_mac()
405 * mac_read_from_eeprom - read the MAC addresses from EEPROM
411 * This ensures that any user-saved variables are never overwritten.
415 * For NXID v1 EEPROMs, we support loading and up-converting the older NXID v0
434 e.id[0], e.id[1], e.id[2], e.id[3]); in mac_read_from_eeprom()
443 if (e.version == 0) in mac_read_from_eeprom()
447 crc = crc32(0, (void *)&e, crc_offset); in mac_read_from_eeprom()
448 crcp = (void *)&e + crc_offset; in mac_read_from_eeprom()
450 printf("CRC mismatch (%08x != %08x)\n", crc, be32_to_cpu(e.crc)); in mac_read_from_eeprom()
460 if (e.version == 0) in mac_read_from_eeprom()
461 memset(e.mac[8], 0xff, 6); in mac_read_from_eeprom()
464 for (i = 0; i < min(e.mac_count, (u8)MAX_NUM_PORTS); i++) { in mac_read_from_eeprom()
465 if (memcmp(&e.mac[i], "\0\0\0\0\0\0", 6) && in mac_read_from_eeprom()
466 memcmp(&e.mac[i], "\xFF\xFF\xFF\xFF\xFF\xFF", 6)) { in mac_read_from_eeprom()
471 e.mac[i][0], in mac_read_from_eeprom()
472 e.mac[i][1], in mac_read_from_eeprom()
473 e.mac[i][2], in mac_read_from_eeprom()
474 e.mac[i][3], in mac_read_from_eeprom()
475 e.mac[i][4], in mac_read_from_eeprom()
476 e.mac[i][5]); in mac_read_from_eeprom()
479 * (i.e. have not yet been set) in mac_read_from_eeprom()
487 printf("%c%c%c%c v%u\n", e.id[0], e.id[1], e.id[2], e.id[3], in mac_read_from_eeprom()
488 be32_to_cpu(e.version)); in mac_read_from_eeprom()
490 printf("%c%c%c%c\n", e.id[0], e.id[1], e.id[2], e.id[3]); in mac_read_from_eeprom()
496 * that at boot time, U-Boot will still say "NXID v0". in mac_read_from_eeprom()
498 if (e.version == 0) { in mac_read_from_eeprom()
499 e.version = cpu_to_be32(NXID_VERSION); in mac_read_from_eeprom()
510 * get_cpu_board_revision - get the CPU board revision on 85xx boards
518 * variable i2c_bus_num must be compile-time initialized to CONFIG_SYS_SPD_BUS_NUM,
519 * so that the SPD code will work. This means that all pre-relocation I2C
527 u32 id; /* 0x00 - 0x03 EEPROM Tag 'CCID' */ in get_cpu_board_revision()