[U-Boot] [PATCH 15/37] board: ge: convert vpd to use i2c eeprom
Robert Beckett
bob.beckett at collabora.com
Tue Oct 15 15:53:28 UTC 2019
convert vpd reader to use DM i2c eeprom driver.
remove old VPD definitions.
Signed-off-by: Robert Beckett <bob.beckett at collabora.com>
---
board/ge/bx50v3/Kconfig | 2 --
board/ge/common/Kconfig | 14 --------------
board/ge/common/vpd_reader.c | 37 ++++++++++++++++++++++--------------
board/ge/mx53ppd/Kconfig | 2 --
configs/ge_bx50v3_defconfig | 5 ++---
configs/mx53ppd_defconfig | 3 ---
6 files changed, 25 insertions(+), 38 deletions(-)
delete mode 100644 board/ge/common/Kconfig
diff --git a/board/ge/bx50v3/Kconfig b/board/ge/bx50v3/Kconfig
index 05938560ab..993b055930 100644
--- a/board/ge/bx50v3/Kconfig
+++ b/board/ge/bx50v3/Kconfig
@@ -15,6 +15,4 @@ config SYS_SOC
config SYS_CONFIG_NAME
default "ge_bx50v3"
-source "board/ge/common/Kconfig"
-
endif
diff --git a/board/ge/common/Kconfig b/board/ge/common/Kconfig
deleted file mode 100644
index 637b264954..0000000000
--- a/board/ge/common/Kconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-config SYS_VPD_EEPROM_I2C_ADDR
- hex "I2C address of the EEPROM device used for VPD"
- help
- VPD = Vital Product Data
-
-config SYS_VPD_EEPROM_I2C_BUS
- int "I2C bus of the EEPROM device used for VPD."
-
-config SYS_VPD_EEPROM_SIZE
- int "Size in bytes of the EEPROM device used for VPD"
-
-config SYS_VPD_EEPROM_I2C_ADDR_LEN
- int "Number of bytes to use for VPD EEPROM address"
- default 1
diff --git a/board/ge/common/vpd_reader.c b/board/ge/common/vpd_reader.c
index 12410d9b71..4df411cf10 100644
--- a/board/ge/common/vpd_reader.c
+++ b/board/ge/common/vpd_reader.c
@@ -8,6 +8,9 @@
#include <i2c.h>
#include <linux/bch.h>
#include <stdlib.h>
+#include <dm/uclass.h>
+#include <i2c_eeprom.h>
+#include <hexdump.h>
/* BCH configuration */
@@ -200,28 +203,34 @@ int read_vpd(struct vpd_cache *cache,
int (*process_block)(struct vpd_cache *, u8 id, u8 version,
u8 type, size_t size, u8 const *data))
{
- static const size_t size = CONFIG_SYS_VPD_EEPROM_SIZE;
-
- int res;
+ struct udevice *dev;
+ int ret;
u8 *data;
- unsigned int current_i2c_bus = i2c_get_bus_num();
+ int size;
+
+ ret = uclass_get_device_by_name(UCLASS_I2C_EEPROM, "vpd", &dev);
+ if (ret)
+ return ret;
- res = i2c_set_bus_num(CONFIG_SYS_VPD_EEPROM_I2C_BUS);
- if (res < 0)
- return res;
+ size = i2c_eeprom_size(dev);
+ if (size < 0) {
+ printf("Unable to get size of eeprom: %d\n", ret);
+ return ret;
+ }
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)
- res = vpd_reader(size, data, cache, process_block);
+ ret = i2c_eeprom_read(dev, 0, data, size);
+ if (ret) {
+ free(data);
+ return ret;
+ }
+
+ ret = vpd_reader(size, data, cache, process_block);
free(data);
- i2c_set_bus_num(current_i2c_bus);
- return res;
+ return ret;
}
diff --git a/board/ge/mx53ppd/Kconfig b/board/ge/mx53ppd/Kconfig
index bebb2fab01..6dc3818cb7 100644
--- a/board/ge/mx53ppd/Kconfig
+++ b/board/ge/mx53ppd/Kconfig
@@ -13,6 +13,4 @@ config SYS_SOC
config SYS_CONFIG_NAME
default "mx53ppd"
-source "board/ge/common/Kconfig"
-
endif
diff --git a/configs/ge_bx50v3_defconfig b/configs/ge_bx50v3_defconfig
index ff16b2c4f0..937b6af9fa 100644
--- a/configs/ge_bx50v3_defconfig
+++ b/configs/ge_bx50v3_defconfig
@@ -1,9 +1,6 @@
CONFIG_ARM=y
CONFIG_ARCH_MX6=y
CONFIG_SYS_TEXT_BASE=0x17800000
-CONFIG_SYS_VPD_EEPROM_I2C_ADDR=0x50
-CONFIG_SYS_VPD_EEPROM_I2C_BUS=4
-CONFIG_SYS_VPD_EEPROM_SIZE=1024
CONFIG_TARGET_GE_BX50V3=y
CONFIG_NR_DRAM_BANKS=1
CONFIG_SYS_BOOTCOUNT_ADDR=0x7000A000
@@ -46,6 +43,8 @@ CONFIG_DM_I2C_COMPAT=y
CONFIG_SYS_I2C_MXC=y
CONFIG_I2C_MUX=y
CONFIG_I2C_MUX_PCA954x=y
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
CONFIG_DM_MMC=y
CONFIG_SUPPORT_EMMC_BOOT=y
CONFIG_FSL_USDHC=y
diff --git a/configs/mx53ppd_defconfig b/configs/mx53ppd_defconfig
index b8cb599491..1de43b7126 100644
--- a/configs/mx53ppd_defconfig
+++ b/configs/mx53ppd_defconfig
@@ -2,9 +2,6 @@ CONFIG_ARM=y
CONFIG_ARCH_MX5=y
CONFIG_SYS_TEXT_BASE=0x77800000
CONFIG_TARGET_MX53PPD=y
-CONFIG_SYS_VPD_EEPROM_I2C_ADDR=0x50
-CONFIG_SYS_VPD_EEPROM_I2C_BUS=2
-CONFIG_SYS_VPD_EEPROM_SIZE=1024
CONFIG_NR_DRAM_BANKS=2
CONFIG_SYS_BOOTCOUNT_ADDR=0x7000A000
CONFIG_FIT=y
--
2.20.1
More information about the U-Boot
mailing list