aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Reichel <sebastian.reichel@collabora.com>2020-09-02 19:31:45 +0200
committerStefano Babic <sbabic@denx.de>2020-11-01 15:58:47 +0100
commitdef6f53d21652e7c5339bfbf8b23e79c0c2560b2 (patch)
treeee59a10fd670e77c2d4faa052e91afd86e5bb590
parent987b8f614c066478aeb9b4ad869613ec23835fbc (diff)
downloadu-boot-def6f53d21652e7c5339bfbf8b23e79c0c2560b2.zip
u-boot-def6f53d21652e7c5339bfbf8b23e79c0c2560b2.tar.gz
u-boot-def6f53d21652e7c5339bfbf8b23e79c0c2560b2.tar.bz2
board: ge: common: vpd: separate I2C specific code
This separates the I2C specific code from the generic GE vital product data code, so that the generic parts can be used on hardware with VPD stored in SPI flash memory. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-rw-r--r--board/ge/bx50v3/bx50v3.c2
-rw-r--r--board/ge/common/vpd_reader.c12
-rw-r--r--board/ge/common/vpd_reader.h23
-rw-r--r--board/ge/mx53ppd/mx53ppd.c2
4 files changed, 27 insertions, 12 deletions
diff --git a/board/ge/bx50v3/bx50v3.c b/board/ge/bx50v3/bx50v3.c
index c6b0af8..8a38ac5 100644
--- a/board/ge/bx50v3/bx50v3.c
+++ b/board/ge/bx50v3/bx50v3.c
@@ -429,7 +429,7 @@ static void set_confidx(const struct vpd_cache* vpd)
int board_init(void)
{
- if (!read_vpd(&vpd, vpd_callback)) {
+ if (!read_i2c_vpd(&vpd, vpd_callback)) {
int ret, rescan;
vpd.is_read = true;
diff --git a/board/ge/common/vpd_reader.c b/board/ge/common/vpd_reader.c
index d42b00d..421fee5 100644
--- a/board/ge/common/vpd_reader.c
+++ b/board/ge/common/vpd_reader.c
@@ -110,9 +110,9 @@ static const size_t HEADER_BLOCK_ECC_LEN = 4;
static const u8 ECC_BLOCK_ID = 0xFF;
-static int vpd_reader(size_t size, u8 *data, struct vpd_cache *userdata,
- int (*fn)(struct vpd_cache *, u8 id, u8 version, u8 type,
- size_t size, u8 const *data))
+int vpd_reader(size_t size, u8 *data, struct vpd_cache *userdata,
+ int (*fn)(struct vpd_cache *, u8 id, u8 version, u8 type,
+ size_t size, u8 const *data))
{
if (size < HEADER_BLOCK_LEN || !data || !fn)
return -EINVAL;
@@ -200,9 +200,9 @@ static int vpd_reader(size_t size, u8 *data, struct vpd_cache *userdata,
}
}
-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))
+int read_i2c_vpd(struct vpd_cache *cache,
+ int (*process_block)(struct vpd_cache *, u8 id, u8 version,
+ u8 type, size_t size, u8 const *data))
{
struct udevice *dev;
int ret;
diff --git a/board/ge/common/vpd_reader.h b/board/ge/common/vpd_reader.h
index 3045b7e..0c51dc5 100644
--- a/board/ge/common/vpd_reader.h
+++ b/board/ge/common/vpd_reader.h
@@ -16,7 +16,22 @@ struct vpd_cache;
*
* Returns Non-zero on error. Negative numbers encode errno.
*/
-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));
+int read_i2c_vpd(struct vpd_cache *cache,
+ int (*process_block)(struct vpd_cache *, u8 id, u8 version,
+ u8 type, size_t size, u8 const *data));
+
+/*
+ * Read VPD from given data, verify content, call callback for each vital
+ * product data block.
+ *
+ * size: size of the raw VPD data in bytes
+ * data: raw VPD data read from device
+ * cache: structure used by process block to store VPD information
+ * process_block: callback called for each VPD data block
+ *
+ * Returns Non-zero on error. Negative numbers encode errno.
+ */
+
+int vpd_reader(size_t size, u8 *data, struct vpd_cache *cache,
+ int (*process_block)(struct vpd_cache *, u8 id, u8 version, u8 type,
+ size_t size, u8 const *data));
diff --git a/board/ge/mx53ppd/mx53ppd.c b/board/ge/mx53ppd/mx53ppd.c
index 2e9d389..ef68973 100644
--- a/board/ge/mx53ppd/mx53ppd.c
+++ b/board/ge/mx53ppd/mx53ppd.c
@@ -225,7 +225,7 @@ int board_late_init(void)
struct vpd_cache vpd;
memset(&vpd, 0, sizeof(vpd));
- res = read_vpd(&vpd, vpd_callback);
+ res = read_i2c_vpd(&vpd, vpd_callback);
if (!res)
process_vpd(&vpd);
else