Fix for slow I2C boot on C6678/C6670 EVM's
[keystone-rtos/ibl.git] / src / main / ibliniti2c.c
index 043c6a3ffcd72e9737aa04680e954fa11cb4cffd..0a3db3a7a06998b15771a2816c2cb39aaf6673f7 100644 (file)
 #include "iblinit.h"
 #include <string.h>
 
+#ifndef EXCLUDE_I2C
 /**
  *  @brief
  *      A global value is used to track the read through the i2c during
  *      the program load.
  */
-uint32 i2cReadAddress;
+uint32 i2cReadAddress, i2cBusAddress;
 
 /**
  *  @brief
@@ -60,10 +61,10 @@ void i2cReadBlock (void)
     uint32 v;
 
     for (;;) {
-        while (hwI2cMasterRead (i2cReadAddress & 0xffff,    /* The address on the eeprom of the table */
+        while (hwI2cMasterRead (i2cReadAddress,             /* The address on the eeprom of the table */
                                 4,                          /* The number of bytes to read */
                                 iData,                      /* Where to store the bytes */
-                                i2cReadAddress >> 16,       /* The bus address of the eeprom */
+                                i2cBusAddress,              /* The bus address of the eeprom */
                                 IBL_CFG_I2C_ADDR_DELAY)     /* The delay between sending the address and reading data */
     
              != I2C_RET_OK)  {
@@ -79,10 +80,10 @@ void i2cReadBlock (void)
             continue;
 
 
-        while (hwI2cMasterRead (i2cReadAddress & 0xffff,    /* The address on the eeprom of the table */
+        while (hwI2cMasterRead (i2cReadAddress,             /* The address on the eeprom of the table */
                                 len,                        /* The number of bytes to read */
                                 iData,                      /* Where to store the bytes */
-                                i2cReadAddress >> 16,       /* The bus address of the eeprom */
+                                i2cBusAddress,              /* The bus address of the eeprom */
                                 IBL_CFG_I2C_ADDR_DELAY)     /* The delay between sending the address and reading data */
     
              != I2C_RET_OK)  {
@@ -106,6 +107,7 @@ void i2cReadBlock (void)
 
 
     i2cReadAddress += len;
+    i2cBusAddress = i2cReadAddress >>16;
     
     iFifoIn  = len;
     iFifoOut = 4;    /* The i2c header is effectively removed */
@@ -209,6 +211,7 @@ BOOT_MODULE_FXN_TABLE *iblInitI2c (void)
 
                 }
 
+                i2cBusAddress = i2cReadAddress >>16;
 
                 if (map.length != sizeof(iblBootMap_t))  {
                     iblStatus.mapSizeFail += 1;
@@ -280,3 +283,4 @@ BOOT_MODULE_FXN_TABLE *iblInitI2c (void)
 
 }
 
+#endif /* EXCLUDE_I2C */