[U-Boot] [PATCH 3/3] [RFC] Make i2c commands usable before relocation to SDRAM

Peter Tyser ptyser at xes-inc.com
Fri Aug 15 23:16:44 CEST 2008


Signed-off-by: Peter Tyser <ptyser at xes-inc.com>
---
 common/cmd_i2c.c |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 1f32646..ae7ed90 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -129,6 +129,8 @@ static int
 mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]);
 extern int cmd_get_data_size(char* arg, int default_size);
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /*
  * Syntax:
  *	imd {i2c_chip} {addr}{.0, .1, .2} {len}
@@ -144,9 +146,11 @@ int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	/* We use the last specified parameters, unless new ones are
 	 * entered.
 	 */
-	chip   = i2c_dp_last_chip;
-	addr   = i2c_dp_last_addr;
-	alen   = i2c_dp_last_alen;
+	if (gd->flags & GD_FLG_RELOC) {
+		chip   = i2c_dp_last_chip;
+		addr   = i2c_dp_last_addr;
+		alen   = i2c_dp_last_alen;
+	}
 	length = i2c_dp_last_length;
 
 	if (argc < 3) {
@@ -227,10 +231,12 @@ int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		nbytes -= linebytes;
 	} while (nbytes > 0);
 
-	i2c_dp_last_chip   = chip;
-	i2c_dp_last_addr   = addr;
-	i2c_dp_last_alen   = alen;
-	i2c_dp_last_length = length;
+	if (gd->flags & GD_FLG_RELOC) {
+		i2c_dp_last_chip   = chip;
+		i2c_dp_last_addr   = addr;
+		i2c_dp_last_alen   = alen;
+		i2c_dp_last_length = length;
+	}
 
 	return 0;
 }
@@ -432,9 +438,11 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[])
 	 * We use the last specified parameters, unless new ones are
 	 * entered.
 	 */
-	chip = i2c_mm_last_chip;
-	addr = i2c_mm_last_addr;
-	alen = i2c_mm_last_alen;
+	if (gd->flags & GD_FLG_RELOC) {
+		chip = i2c_mm_last_chip;
+		addr = i2c_mm_last_addr;
+		alen = i2c_mm_last_alen;
+	}
 
 	if ((flag & CMD_FLAG_REPEAT) == 0) {
 		/*
@@ -529,9 +537,11 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[])
 		}
 	} while (nbytes);
 
-	i2c_mm_last_chip = chip;
-	i2c_mm_last_addr = addr;
-	i2c_mm_last_alen = alen;
+	if (gd->flags & GD_FLG_RELOC) {
+		i2c_mm_last_chip = chip;
+		i2c_mm_last_addr = addr;
+		i2c_mm_last_alen = alen;
+	}
 
 	return 0;
 }
-- 
1.5.4.3




More information about the U-Boot mailing list