[U-Boot] [PATCH 05/31] ti: common: board_detect: Add function to determine if EEPROM was read

Franklin S Cooper Jr fcooper at ti.com
Thu Mar 2 19:04:09 UTC 2017


When the EEPROM is first read its contents are stored in memory as a
cache to avoid further I2C operations. To determine if the EEPROM was
previously read the easiest way is to check the memory to see if the
EEPROM's magic header value is set. Create a new function that can
determine if the EEPROM was previously read or not without having to
perform a I2C transaction.

Signed-off-by: Franklin S Cooper Jr <fcooper at ti.com>
---
 board/ti/common/board_detect.c | 10 ++++++++++
 board/ti/common/board_detect.h |  9 +++++++++
 2 files changed, 19 insertions(+)

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index 5aaf884..b29807a 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -338,3 +338,13 @@ void __maybe_unused set_board_info_env(char *name)
 	else
 		setenv("board_serial", unknown);
 }
+
+bool __maybe_unused board_ti_was_eeprom_read(void)
+{
+	struct ti_common_eeprom *ep = TI_EEPROM_DATA;
+
+	if (ep->header == TI_EEPROM_HEADER_MAGIC)
+		return true;
+	else
+		return false;
+}
diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h
index eeeacd3..97dc4e4 100644
--- a/board/ti/common/board_detect.h
+++ b/board/ti/common/board_detect.h
@@ -194,6 +194,15 @@ u64 board_ti_get_emif2_size(void);
 void set_board_info_env(char *name);
 
 /**
+ * board_ti_was_eeprom_read() - Check to see if the eeprom contents have been read
+ *
+ * This function is useful to determine if the eeprom has already been read and
+ * its contents have already been loaded into memory. It utiltzes the magic
+ * number that the header value is set to upon successful eeprom read.
+ */
+bool board_ti_was_eeprom_read(void);
+
+/**
  * ti_i2c_eeprom_am_set() - Setup the eeprom data with predefined values
  * @name:	Name of the board
  * @rev:	Revision of the board
-- 
2.10.0



More information about the U-Boot mailing list