summaryrefslogtreecommitdiff
path: root/board/compulab/common/eeprom.c
diff options
context:
space:
mode:
authorIgor Grinberg <grinberg@compulab.co.il>2014-11-03 11:32:18 +0200
committerTom Rini <trini@ti.com>2014-11-06 11:04:40 -0500
commita937fd1682625b1f87b555e2af9117fcb2999d7c (patch)
tree6f39f972c9387f7af48fde11ecc941829debba62 /board/compulab/common/eeprom.c
parent52d848695c36d2b6ce688d1403653653e82583b4 (diff)
downloadu-boot-imx-a937fd1682625b1f87b555e2af9117fcb2999d7c.zip
u-boot-imx-a937fd1682625b1f87b555e2af9117fcb2999d7c.tar.gz
u-boot-imx-a937fd1682625b1f87b555e2af9117fcb2999d7c.tar.bz2
compulab: refactor board revision handling
Move board revision handling code to a common location for further reuse. Signed-off-by: Igor Grinberg <grinberg@compulab.co.il> Reviewed-by: Tom Rini <trini@ti.com>
Diffstat (limited to 'board/compulab/common/eeprom.c')
-rw-r--r--board/compulab/common/eeprom.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/board/compulab/common/eeprom.c b/board/compulab/common/eeprom.c
index 2df3ada..a45e7be 100644
--- a/board/compulab/common/eeprom.c
+++ b/board/compulab/common/eeprom.c
@@ -109,23 +109,27 @@ int cl_eeprom_read_mac_addr(uchar *buf)
return cl_eeprom_read(offset, buf, 6);
}
+static u32 board_rev;
+
/*
* Routine: cl_eeprom_get_board_rev
* Description: read system revision from eeprom
*/
u32 cl_eeprom_get_board_rev(void)
{
- u32 rev = 0;
char str[5]; /* Legacy representation can contain at most 4 digits */
uint offset = BOARD_REV_OFFSET_LEGACY;
+ if (board_rev)
+ return board_rev;
+
if (cl_eeprom_setup_layout())
return 0;
if (cl_eeprom_layout != LAYOUT_LEGACY)
offset = BOARD_REV_OFFSET;
- if (cl_eeprom_read(offset, (uchar *)&rev, BOARD_REV_SIZE))
+ if (cl_eeprom_read(offset, (uchar *)&board_rev, BOARD_REV_SIZE))
return 0;
/*
@@ -133,9 +137,9 @@ u32 cl_eeprom_get_board_rev(void)
* representation. i.e. for rev 1.00: 0x100 --> 0x64
*/
if (cl_eeprom_layout == LAYOUT_LEGACY) {
- sprintf(str, "%x", rev);
- rev = simple_strtoul(str, NULL, 10);
+ sprintf(str, "%x", board_rev);
+ board_rev = simple_strtoul(str, NULL, 10);
}
- return rev;
+ return board_rev;
};