This could avoid executing the code that only applies to i.MX platforms.

The bus_i2c_init() is called before relocation and will assgin value
to a static variable. If U-Boot is then still running in a flash
device, it's theoretically not allowed to write data to flash without
an erasing operation. For i.MX platforms, the U-Boot is always running
in DDR.

Actually it causes asynchronous error when the ARM64 system error
report is enabled and the flash write protect is set.

Signed-off-by: Gong Qianyu <qianyu.g...@freescale.com>
---
V2:
 - Modified the commit title and message.
 - Used a condition to avoid executing the code.

 board/freescale/ls1043ardb/ls1043ardb.c |  1 +
 drivers/i2c/mxc_i2c.c                   | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/board/freescale/ls1043ardb/ls1043ardb.c 
b/board/freescale/ls1043ardb/ls1043ardb.c
index cdd50d6..ba4ef1e 100644
--- a/board/freescale/ls1043ardb/ls1043ardb.c
+++ b/board/freescale/ls1043ardb/ls1043ardb.c
@@ -12,6 +12,7 @@
 #include <asm/arch/soc.h>
 #include <hwconfig.h>
 #include <ahci.h>
+#include <environment.h>
 #include <mmc.h>
 #include <scsi.h>
 #include <fm_eth.h>
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index fa4c82f..b2d15c9 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -581,8 +581,16 @@ void bus_i2c_init(int index, int speed, int unused,
                return;
        }
 
-       mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn;
-       mxc_i2c_buses[index].idle_bus_data = idle_bus_data;
+       /*
+        * Warning: Be careful to allow the assignment to a static
+        * variable here. This function could be called while U-Boot is
+        * still running in flash memory. So such assignment is equal
+        * to write data to flash without erasing.
+        */
+       if (idle_bus_fn)
+               mxc_i2c_buses[index].idle_bus_fn = idle_bus_fn;
+       if (idle_bus_data)
+               mxc_i2c_buses[index].idle_bus_data = idle_bus_data;
 
        ret = enable_i2c_clk(1, index);
        if (ret < 0) {
-- 
2.1.0.27.g96db324

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to