提交 a937fd16 编写于 作者: I Igor Grinberg 提交者: Tom Rini

compulab: refactor board revision handling

Move board revision handling code to a common location
for further reuse.
Signed-off-by: NIgor Grinberg <grinberg@compulab.co.il>
Reviewed-by: NTom Rini <trini@ti.com>
上级 52d84869
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <asm/ehci-omap.h> #include <asm/ehci-omap.h>
#include <asm/gpio.h> #include <asm/gpio.h>
#include "../common/common.h"
#include "../common/eeprom.h" #include "../common/eeprom.h"
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
...@@ -154,34 +155,18 @@ int board_init(void) ...@@ -154,34 +155,18 @@ int board_init(void)
return 0; return 0;
} }
static u32 cm_t3x_rev;
/* /*
* Routine: get_board_rev * Routine: get_board_rev
* Description: read system revision * Description: read system revision
*/ */
u32 get_board_rev(void) u32 get_board_rev(void)
{ {
if (!cm_t3x_rev) return cl_eeprom_get_board_rev();
cm_t3x_rev = cl_eeprom_get_board_rev();
return cm_t3x_rev;
}; };
/*
* Routine: misc_init_r
* Description: display die ID
*/
int misc_init_r(void) int misc_init_r(void)
{ {
u32 board_rev = get_board_rev(); cl_print_pcb_info();
u32 rev_major = board_rev / 100;
u32 rev_minor = board_rev - (rev_major * 100);
if ((rev_minor / 10) * 10 == rev_minor)
rev_minor = rev_minor / 10;
printf("PCB: %u.%u\n", rev_major, rev_minor);
dieid_num_r(); dieid_num_r();
return 0; return 0;
......
...@@ -6,5 +6,6 @@ ...@@ -6,5 +6,6 @@
# SPDX-License-Identifier: GPL-2.0+ # SPDX-License-Identifier: GPL-2.0+
# #
obj-$(CONFIG_SYS_I2C) += eeprom.o obj-y += common.o
obj-$(CONFIG_LCD) += omap3_display.o obj-$(CONFIG_SYS_I2C) += eeprom.o
obj-$(CONFIG_LCD) += omap3_display.o
/*
* (C) Copyright 2014 CompuLab, Ltd. <www.compulab.co.il>
*
* Authors: Igor Grinberg <grinberg@compulab.co.il>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <asm/bootm.h>
#include "common.h"
#include "eeprom.h"
void cl_print_pcb_info(void)
{
u32 board_rev = get_board_rev();
u32 rev_major = board_rev / 100;
u32 rev_minor = board_rev - (rev_major * 100);
if ((rev_minor / 10) * 10 == rev_minor)
rev_minor = rev_minor / 10;
printf("PCB: %u.%u\n", rev_major, rev_minor);
}
/*
* (C) Copyright 2014 CompuLab, Ltd. <www.compulab.co.il>
*
* Authors: Igor Grinberg <grinberg@compulab.co.il>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef _CL_COMMON_
#define _CL_COMMON_
void cl_print_pcb_info(void);
#endif /* _CL_COMMON_ */
...@@ -109,23 +109,27 @@ int cl_eeprom_read_mac_addr(uchar *buf) ...@@ -109,23 +109,27 @@ int cl_eeprom_read_mac_addr(uchar *buf)
return cl_eeprom_read(offset, buf, 6); return cl_eeprom_read(offset, buf, 6);
} }
static u32 board_rev;
/* /*
* Routine: cl_eeprom_get_board_rev * Routine: cl_eeprom_get_board_rev
* Description: read system revision from eeprom * Description: read system revision from eeprom
*/ */
u32 cl_eeprom_get_board_rev(void) u32 cl_eeprom_get_board_rev(void)
{ {
u32 rev = 0;
char str[5]; /* Legacy representation can contain at most 4 digits */ char str[5]; /* Legacy representation can contain at most 4 digits */
uint offset = BOARD_REV_OFFSET_LEGACY; uint offset = BOARD_REV_OFFSET_LEGACY;
if (board_rev)
return board_rev;
if (cl_eeprom_setup_layout()) if (cl_eeprom_setup_layout())
return 0; return 0;
if (cl_eeprom_layout != LAYOUT_LEGACY) if (cl_eeprom_layout != LAYOUT_LEGACY)
offset = BOARD_REV_OFFSET; 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; return 0;
/* /*
...@@ -133,9 +137,9 @@ u32 cl_eeprom_get_board_rev(void) ...@@ -133,9 +137,9 @@ u32 cl_eeprom_get_board_rev(void)
* representation. i.e. for rev 1.00: 0x100 --> 0x64 * representation. i.e. for rev 1.00: 0x100 --> 0x64
*/ */
if (cl_eeprom_layout == LAYOUT_LEGACY) { if (cl_eeprom_layout == LAYOUT_LEGACY) {
sprintf(str, "%x", rev); sprintf(str, "%x", board_rev);
rev = simple_strtoul(str, NULL, 10); board_rev = simple_strtoul(str, NULL, 10);
} }
return rev; return board_rev;
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册