summaryrefslogtreecommitdiff
path: root/board/ge/mx53ppd
diff options
context:
space:
mode:
authorDenis Zalevskiy <denis.zalevskiy@ge.com>2018-10-17 10:33:30 +0200
committerStefano Babic <sbabic@denx.de>2019-01-01 14:12:18 +0100
commit4dcbccf794a330895ee2aeba6964a94b33c60eda (patch)
treee6df99bc24071ed9cf066063a3a033dd29bd3269 /board/ge/mx53ppd
parent4c552083503f49f37412972a3b4ea895cffd948e (diff)
board: ge: Move VPD reading to the vpd_reader
Merge functionality duplicated in bx50v3 and mx53ppd: the logic is the same except that process_vpd is called at different phases. Also read_vpd could end up in error, so there is no VPD data in this case - it shouldn't be processed. Signed-off-by: Denis Zalevskiy <denis.zalevskiy@ge.com> Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Diffstat (limited to 'board/ge/mx53ppd')
-rw-r--r--board/ge/mx53ppd/mx53ppd.c38
1 files changed, 7 insertions, 31 deletions
diff --git a/board/ge/mx53ppd/mx53ppd.c b/board/ge/mx53ppd/mx53ppd.c
index 3fa53ffe0a..f0c8abf0bb 100644
--- a/board/ge/mx53ppd/mx53ppd.c
+++ b/board/ge/mx53ppd/mx53ppd.c
@@ -321,36 +321,6 @@ static void process_vpd(struct vpd_cache *vpd)
eth_env_set_enetaddr("ethaddr", vpd->mac1);
}
-static int read_vpd(void)
-{
- struct vpd_cache vpd;
- int res;
- static const int size = CONFIG_SYS_VPD_EEPROM_SIZE;
- u8 *data;
- unsigned int current_i2c_bus = i2c_get_bus_num();
-
- res = i2c_set_bus_num(CONFIG_SYS_VPD_EEPROM_I2C_BUS);
- if (res < 0)
- return res;
-
- data = malloc(size);
- if (!data)
- return -ENOMEM;
-
- res = i2c_read(CONFIG_SYS_VPD_EEPROM_I2C_ADDR, 0,
- CONFIG_SYS_VPD_EEPROM_I2C_ADDR_LEN, data, size);
- if (res == 0) {
- memset(&vpd, 0, sizeof(vpd));
- vpd_reader(size, data, &vpd, vpd_callback);
- process_vpd(&vpd);
- }
-
- free(data);
-
- i2c_set_bus_num(current_i2c_bus);
- return res;
-}
-
int board_init(void)
{
gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
@@ -383,8 +353,14 @@ int misc_init_r(void)
int board_late_init(void)
{
int res;
+ struct vpd_cache vpd;
- read_vpd();
+ memset(&vpd, 0, sizeof(vpd));
+ res = read_vpd(&vpd, vpd_callback);
+ if (!res)
+ process_vpd(&vpd);
+ else
+ printf("Can't read VPD");
res = clock_1GHz();
if (res != 0)