Lines Matching +full:save +full:- +full:mac +full:- +full:address

1 // SPDX-License-Identifier: GPL-2.0+
4 * Copyright 2006, 2008-2009, 2011 Freescale Semiconductor
33 u8 id[4]; /* 0x00 - 0x03 EEPROM Tag 'NXID' */
34 u8 sn[12]; /* 0x04 - 0x0F Serial Number */
35 u8 errata[5]; /* 0x10 - 0x14 Errata Level */
36 u8 date[6]; /* 0x15 - 0x1a Build Date */
38 u32 version; /* 0x1c - 0x1f NXID Version */
39 u8 tempcal[8]; /* 0x20 - 0x27 Temperature Calibration Factors */
40 u8 tempcalsys[2]; /* 0x28 - 0x29 System Temperature Calibration Factors */
42 u8 res_1[21]; /* 0x2b - 0x3f Reserved */
43 u8 mac_count; /* 0x40 Number of MAC addresses */
44 u8 mac_flag; /* 0x41 MAC table flags */
45 u8 mac[MAX_NUM_PORTS][6]; /* 0x42 - x MAC addresses */ member
59 static int eeprom_bus_num = -1;
74 * show_eeprom - display the contents of the EEPROM
102 /* Show MAC addresses */ in show_eeprom()
104 u8 *p = e.mac[i]; in show_eeprom()
110 crc = crc32(0, (void *)&e, sizeof(e) - 4); in show_eeprom()
124 if (((i % 16) == 15) || (i == sizeof(e) - 1)) in show_eeprom()
131 * read_eeprom - read the EEPROM into memory
140 return -1; in read_eeprom()
153 /* Fixed address of ID field */ in read_eeprom()
168 * update_crc - update the CRC
182 * prog_eeprom - write the EEPROM from memory
193 return -1; in prog_eeprom()
211 p, min((int)(sizeof(e) - i), 8)); in prog_eeprom()
224 ret = -1; in prog_eeprom()
232 return -1; in prog_eeprom()
240 * h2i - converts hex character into a number
248 return p - '0'; in h2i()
251 return (p - 'A') + 10; in h2i()
254 return (p - 'a') + 10; in h2i()
260 * set_date - stores the build date into the EEPROM
263 * (2-digit year, 2-digit month, etc), converts it to a 6-byte BCD string,
271 printf("Usage: mac date YYMMDDhhmmss\n"); in set_date()
282 * set_mac_address - stores a MAC address into the EEPROM
284 * This function takes a pointer to MAC address string
285 * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number) and
286 * stores it in one of the MAC address fields of the EEPROM local copy.
294 printf("Usage: mac <n> XX:XX:XX:XX:XX:XX\n"); in set_mac_address()
299 e.mac[index][i] = simple_strtoul(p, &p, 16); in set_mac_address()
337 case 's': /* save */ in do_mac()
352 strncpy((char *)e.sn, argv[2], sizeof(e.sn) - 1); in do_mac()
363 case 'p': /* MAC table size */ in do_mac()
367 case '0' ... '9': /* "mac 0" through "mac 22" */ in do_mac()
379 int address, int mac_bus) in mac_read_from_generic_eeprom() argument
383 unsigned char mac[6]; in mac_read_from_generic_eeprom() local
389 ret = i2c_read(chip, address, 1, mac, 6); in mac_read_from_generic_eeprom()
395 mac[0], in mac_read_from_generic_eeprom()
396 mac[1], in mac_read_from_generic_eeprom()
397 mac[2], in mac_read_from_generic_eeprom()
398 mac[3], in mac_read_from_generic_eeprom()
399 mac[4], in mac_read_from_generic_eeprom()
400 mac[5]); in mac_read_from_generic_eeprom()
402 printf("MAC: %s\n", ethaddr); in mac_read_from_generic_eeprom()
422 * mac_read_from_eeprom - read the MAC addresses from EEPROM
424 * This function reads the MAC addresses from EEPROM and sets the
428 * This ensures that any user-saved variables are never overwritten.
432 * For NXID v1 EEPROMs, we support loading and up-converting the older NXID v0
433 * format. In a v0 EEPROM, there are only eight MAC addresses and the CRC is
464 * MAC address #9 in v1 occupies the same position as the CRC in v0. in mac_read_from_eeprom_common()
465 * Erase it so that it's not mistaken for a MAC address. We'll in mac_read_from_eeprom_common()
469 memset(e.mac[8], 0xff, 6); in mac_read_from_eeprom_common()
472 if (memcmp(&e.mac[i], "\0\0\0\0\0\0", 6) && in mac_read_from_eeprom_common()
473 memcmp(&e.mac[i], "\xFF\xFF\xFF\xFF\xFF\xFF", 6)) { in mac_read_from_eeprom_common()
478 e.mac[i][0], in mac_read_from_eeprom_common()
479 e.mac[i][1], in mac_read_from_eeprom_common()
480 e.mac[i][2], in mac_read_from_eeprom_common()
481 e.mac[i][3], in mac_read_from_eeprom_common()
482 e.mac[i][4], in mac_read_from_eeprom_common()
483 e.mac[i][5]); in mac_read_from_eeprom_common()