ti: common: board_detect: Add function to determine if EEPROM was read
authorCooper Jr., Franklin <fcooper@ti.com>
Fri, 16 Jun 2017 22:25:08 +0000 (17:25 -0500)
committerTom Rini <trini@konsulko.com>
Mon, 10 Jul 2017 18:25:53 +0000 (14:25 -0400)
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@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
board/ti/common/board_detect.c
board/ti/common/board_detect.h

index bf594cb1ab31ea1327c9df73e175779e5efb65c6..1da5ace9236d7d8d17e0d2c67d99ad9ad7a8ef5f 100644 (file)
@@ -457,3 +457,13 @@ void board_ti_set_ethaddr(int index)
                }
        }
 }
+
+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;
+}
index e8d94844a7a4b1d6e65d0aa14c900232b9835267..893e1ed998d9eafb715fd9f26542f69075dbcc53 100644 (file)
@@ -205,6 +205,15 @@ void set_board_info_env(char *name);
  */
 void board_ti_set_ethaddr(int index);
 
+/**
+ * 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