]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/emk/common/vpd.c
3 * Reinhard Meyer, EMK Elektronik GmbH, r.meyer@emk-elektronik.de
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 /*****************************************************************************
27 * read "factory" part of EEPROM and set some environment variables
28 *****************************************************************************/
29 void read_factory_r (void)
31 /* read 'factory' part of EEPROM */
38 /* get length first */
39 addr
= CONFIG_SYS_FACT_OFFSET
;
40 if (eeprom_read (CONFIG_SYS_I2C_FACT_ADDR
, addr
, buf
, 2)) {
42 printf ("cannot read factory configuration\n");
43 printf ("be sure to set ethaddr yourself!\n");
46 length
= buf
[0] + (buf
[1] << 8);
50 if (length
< 20 || length
> CONFIG_SYS_FACT_SIZE
- 2)
56 len
= length
> 80 ? 80 : length
;
57 if (eeprom_read (CONFIG_SYS_I2C_FACT_ADDR
, addr
, buf
, len
))
59 /* mark end of buffer */
61 /* search end of line */
62 for (p
= buf
; *p
&& *p
!= 0x0a; p
++);
66 /* advance to next line start */
69 /*printf ("%s\n", buf); */
70 /* search for our specific entry */
71 if (!strncmp ((char *) buf
, "[RLA/lan/Ethernet] ", 19)) {
72 setenv ("ethaddr", (char *)(buf
+ 19));
73 } else if (!strncmp ((char *) buf
, "[BOARD/SERIAL] ", 15)) {
74 setenv ("serial#", (char *)(buf
+ 15));
75 } else if (!strncmp ((char *) buf
, "[BOARD/TYPE] ", 13)) {
76 setenv ("board_id", (char *)(buf
+ 13));