All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command
@ 2015-11-10 19:53 Marek Vasut
  2015-11-10 19:53 ` [U-Boot] [PATCH 02/17] eeprom: Shuffle code around Marek Vasut
                   ` (17 more replies)
  0 siblings, 18 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

From: Andreas Bie?mann <andreas.devel@googlemail.com>

This rewrite uses lately promoted eeprom_init(int) function to choose the
right I2C bus when writing data to the EEPROM.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 board/corscience/tricorder/tricorder-eeprom.c | 36 +++++++--------------------
 1 file changed, 9 insertions(+), 27 deletions(-)

diff --git a/board/corscience/tricorder/tricorder-eeprom.c b/board/corscience/tricorder/tricorder-eeprom.c
index 1c74a0f..340a009 100644
--- a/board/corscience/tricorder/tricorder-eeprom.c
+++ b/board/corscience/tricorder/tricorder-eeprom.c
@@ -77,17 +77,13 @@ static int handle_eeprom_v1(struct tricorder_eeprom *eeprom)
 
 int tricorder_get_eeprom(int addr, struct tricorder_eeprom *eeprom)
 {
-#ifdef CONFIG_SYS_EEPROM_BUS_NUM
 	unsigned int bus = i2c_get_bus_num();
 	i2c_set_bus_num(CONFIG_SYS_EEPROM_BUS_NUM);
-#endif
 
 	memset(eeprom, 0, TRICORDER_EEPROM_SIZE);
 
 	i2c_read(addr, 0, 2, (unsigned char *)eeprom, TRICORDER_EEPROM_SIZE);
-#ifdef CONFIG_SYS_EEPROM_BUS_NUM
 	i2c_set_bus_num(bus);
-#endif
 
 	if (be32_to_cpu(eeprom->magic) != TRICORDER_EEPROM_MAGIC) {
 		warn_wrong_value("magic", TRICORDER_EEPROM_MAGIC,
@@ -138,9 +134,6 @@ int tricorder_eeprom_write(unsigned devaddr, const char *name,
 	int ret;
 	unsigned char *p;
 	int i;
-#ifdef CONFIG_SYS_EEPROM_BUS_NUM
-	unsigned int bus;
-#endif
 
 	memset(eeprom, 0, TRICORDER_EEPROM_SIZE);
 	memset(eeprom_verify, 0, TRICORDER_EEPROM_SIZE);
@@ -172,33 +165,23 @@ int tricorder_eeprom_write(unsigned devaddr, const char *name,
 	print_buffer(0, &eeprom, 1, sizeof(eeprom), 16);
 #endif
 
-#ifdef CONFIG_SYS_EEPROM_BUS_NUM
-	bus = i2c_get_bus_num();
-	i2c_set_bus_num(CONFIG_SYS_EEPROM_BUS_NUM);
-#endif
+	eeprom_init(CONFIG_SYS_EEPROM_BUS_NUM);
 
-	/* do page write to the eeprom */
-	for (i = 0, p = (unsigned char *)&eeprom;
-	     i < sizeof(eeprom);
-	     i += 32, p += 32) {
-		ret = i2c_write(devaddr, i, CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
-				p, min(sizeof(eeprom) - i, 32));
-		if (ret)
-			break;
-		udelay(5000); /* 5ms write cycle timing */
-	}
+	ret = eeprom_write(devaddr, 0, (unsigned char *)&eeprom,
+			TRICORDER_EEPROM_SIZE);
+	if (ret)
+		printf("Tricorder: Could not write EEPROM content!\n");
 
-	ret = i2c_read(devaddr, 0, 2, (unsigned char *)&eeprom_verify,
+	ret = eeprom_read(devaddr, 0, (unsigned char *)&eeprom_verify,
 			TRICORDER_EEPROM_SIZE);
+	if (ret)
+		printf("Tricorder: Could not read EEPROM content!\n");
 
 	if (memcmp(&eeprom, &eeprom_verify, sizeof(eeprom)) != 0) {
 		printf("Tricorder: Could not verify EEPROM content!\n");
 		ret = 1;
 	}
 
-#ifdef CONFIG_SYS_EEPROM_BUS_NUM
-	i2c_set_bus_num(bus);
-#endif
 	return ret;
 }
 
@@ -206,7 +189,7 @@ int do_tricorder_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	if (argc == 3) {
 		ulong dev_addr = simple_strtoul(argv[2], NULL, 16);
-		eeprom_init();
+
 		if (strcmp(argv[1], "read") == 0) {
 			int rcode;
 
@@ -220,7 +203,6 @@ int do_tricorder_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		char *version = argv[4];
 		char *serial = argv[5];
 		char *interface = NULL;
-		eeprom_init();
 
 		if (argc == 7)
 			interface = argv[6];
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 02/17] eeprom: Shuffle code around
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:26   ` Heiko Schocher
  2015-11-22 15:53   ` [U-Boot] [U-Boot,02/17] " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 03/17] eeprom: Zap CONFIG_SYS_I2C_MULTI_EEPROMS Marek Vasut
                   ` (16 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Just move the code around so that the forward declarations are not
necessary. Also zap a few checkpatch issues where applicable and
zap the use of #ifdef CONFIG_CMD_EEPROM in the code, since this is
always true.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 168 ++++++++++++++++++++++------------------------------
 1 file changed, 70 insertions(+), 98 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index e9904cd..4335079 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -25,94 +25,55 @@
 #include <command.h>
 #include <i2c.h>
 
-extern void eeprom_init  (void);
-extern int  eeprom_read  (unsigned dev_addr, unsigned offset,
-			  uchar *buffer, unsigned cnt);
-extern int  eeprom_write (unsigned dev_addr, unsigned offset,
-			  uchar *buffer, unsigned cnt);
-#if defined(CONFIG_SYS_EEPROM_WREN)
-extern int eeprom_write_enable (unsigned dev_addr, int state);
+#ifndef	CONFIG_SYS_I2C_SPEED
+#define	CONFIG_SYS_I2C_SPEED	50000
 #endif
 
-
+/* Maximum number of times to poll for acknowledge after write */
 #if defined(CONFIG_SYS_EEPROM_X40430)
-	/* Maximum number of times to poll for acknowledge after write */
 #define MAX_ACKNOWLEDGE_POLLS	10
 #endif
 
-/* ------------------------------------------------------------------------- */
-
-#if defined(CONFIG_CMD_EEPROM)
-static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-	const char *const fmt =
-		"\nEEPROM @0x%lX %s: addr %08lx  off %04lx  count %ld ... ";
-
-#if defined(CONFIG_SYS_I2C_MULTI_EEPROMS)
-	if (argc == 6) {
-		ulong dev_addr = simple_strtoul (argv[2], NULL, 16);
-		ulong addr = simple_strtoul (argv[3], NULL, 16);
-		ulong off  = simple_strtoul (argv[4], NULL, 16);
-		ulong cnt  = simple_strtoul (argv[5], NULL, 16);
-#else
-	if (argc == 5) {
-		ulong dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
-		ulong addr = simple_strtoul (argv[2], NULL, 16);
-		ulong off  = simple_strtoul (argv[3], NULL, 16);
-		ulong cnt  = simple_strtoul (argv[4], NULL, 16);
-#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
-
-# if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
-		eeprom_init ();
-# endif /* !CONFIG_SPI */
-
-		if (strcmp (argv[1], "read") == 0) {
-			int rcode;
-
-			printf (fmt, dev_addr, argv[1], addr, off, cnt);
-
-			rcode = eeprom_read (dev_addr, off, (uchar *) addr, cnt);
-
-			puts ("done\n");
-			return rcode;
-		} else if (strcmp (argv[1], "write") == 0) {
-			int rcode;
-
-			printf (fmt, dev_addr, argv[1], addr, off, cnt);
-
-			rcode = eeprom_write (dev_addr, off, (uchar *) addr, cnt);
-
-			puts ("done\n");
-			return rcode;
-		}
-	}
-
-	return CMD_RET_USAGE;
-}
-#endif
-
-/*-----------------------------------------------------------------------
- *
+/*
  * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
  *   0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
  *
  * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 (8-bit EEPROM page address) offset is
  *   0x00000nxx for EEPROM address selectors and page number at n.
  */
-
 #if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
-#if !defined(CONFIG_SYS_I2C_EEPROM_ADDR_LEN) || CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1 || CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2
+#if !defined(CONFIG_SYS_I2C_EEPROM_ADDR_LEN) || \
+    (CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1) || \
+    (CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2)
 #error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2
 #endif
 #endif
 
+#if defined(CONFIG_SYS_EEPROM_WREN)
+extern int eeprom_write_enable (unsigned dev_addr, int state);
+#endif
+
+void eeprom_init(void)
+{
+	/* SPI EEPROM */
+#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
+	spi_init_f ();
+#endif
+
+	/* I2C EEPROM */
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
+}
+
 int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
 {
 	unsigned end = offset + cnt;
 	unsigned blk_off;
 	int rcode = 0;
 
-	/* Read data until done or would cross a page boundary.
+	/*
+	 * Read data until done or would cross a page boundary.
 	 * We must write the address again when changing pages
 	 * because the next page may be in a different device.
 	 */
@@ -174,15 +135,6 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
 	return rcode;
 }
 
-/*-----------------------------------------------------------------------
- *
- * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
- *   0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
- *
- * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 (8-bit EEPROM page address) offset is
- *   0x00000nxx for EEPROM address selectors and page number at n.
- */
-
 int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
 {
 	unsigned end = offset + cnt;
@@ -200,7 +152,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 #if defined(CONFIG_SYS_EEPROM_WREN)
 	eeprom_write_enable (dev_addr,1);
 #endif
-	/* Write data until done or would cross a write page boundary.
+	/*
+	 * Write data until done or would cross a write page boundary.
 	 * We must write the address again when changing pages
 	 * because the address counter only increments within a page.
 	 */
@@ -363,8 +316,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 }
 
 #if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
-int
-eeprom_probe (unsigned dev_addr, unsigned offset)
+int eeprom_probe(unsigned dev_addr, unsigned offset)
 {
 	unsigned char chip;
 
@@ -382,30 +334,52 @@ eeprom_probe (unsigned dev_addr, unsigned offset)
 }
 #endif
 
-/*-----------------------------------------------------------------------
- * Set default values
- */
-#ifndef	CONFIG_SYS_I2C_SPEED
-#define	CONFIG_SYS_I2C_SPEED	50000
-#endif
-
-void eeprom_init  (void)
+static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
+	const char *const fmt =
+		"\nEEPROM @0x%lX %s: addr %08lx  off %04lx  count %ld ... ";
 
-#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
-	spi_init_f ();
-#endif
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
-	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
-#endif
-}
+#if defined(CONFIG_SYS_I2C_MULTI_EEPROMS)
+	if (argc == 6) {
+		ulong dev_addr = simple_strtoul (argv[2], NULL, 16);
+		ulong addr = simple_strtoul (argv[3], NULL, 16);
+		ulong off  = simple_strtoul (argv[4], NULL, 16);
+		ulong cnt  = simple_strtoul (argv[5], NULL, 16);
+#else
+	if (argc == 5) {
+		ulong dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
+		ulong addr = simple_strtoul (argv[2], NULL, 16);
+		ulong off  = simple_strtoul (argv[3], NULL, 16);
+		ulong cnt  = simple_strtoul (argv[4], NULL, 16);
+#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
 
-/*-----------------------------------------------------------------------
- */
+# if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
+		eeprom_init ();
+# endif /* !CONFIG_SPI */
 
-/***************************************************/
+		if (strcmp (argv[1], "read") == 0) {
+			int rcode;
+
+			printf (fmt, dev_addr, argv[1], addr, off, cnt);
 
-#if defined(CONFIG_CMD_EEPROM)
+			rcode = eeprom_read (dev_addr, off, (uchar *) addr, cnt);
+
+			puts ("done\n");
+			return rcode;
+		} else if (strcmp (argv[1], "write") == 0) {
+			int rcode;
+
+			printf (fmt, dev_addr, argv[1], addr, off, cnt);
+
+			rcode = eeprom_write (dev_addr, off, (uchar *) addr, cnt);
+
+			puts ("done\n");
+			return rcode;
+		}
+	}
+
+	return CMD_RET_USAGE;
+}
 
 #ifdef CONFIG_SYS_I2C_MULTI_EEPROMS
 U_BOOT_CMD(
@@ -424,5 +398,3 @@ U_BOOT_CMD(
 	"       - read/write `cnt' bytes at EEPROM offset `off'"
 )
 #endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
-
-#endif
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 03/17] eeprom: Zap CONFIG_SYS_I2C_MULTI_EEPROMS
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
  2015-11-10 19:53 ` [U-Boot] [PATCH 02/17] eeprom: Shuffle code around Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:26   ` Heiko Schocher
  2015-11-22 15:53   ` [U-Boot] [U-Boot, " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 04/17] eeprom: Zap CONFIG_SYS_EEPROM_X40430 Marek Vasut
                   ` (15 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

This option only complicates the code unnecessarily, just use
CONFIG_SYS_DEF_EEPROM_ADDR as the default address if there are
only five arguments to eeprom {read/write} if this is defined.
If CONFIG_SYS_DEF_EEPROM_ADDR is not defined, we mandate all
six arguments.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c             | 69 ++++++++++++++++++-----------------------
 include/configs/BSC9131RDB.h    |  1 -
 include/configs/BSC9132QDS.h    |  1 -
 include/configs/C29XPCIE.h      |  1 -
 include/configs/P1010RDB.h      |  1 -
 include/configs/PMC440.h        |  1 -
 include/configs/TQM834x.h       |  1 -
 include/configs/acadia.h        |  1 -
 include/configs/am335x_evm.h    |  1 -
 include/configs/am43xx_evm.h    |  1 -
 include/configs/axs101.h        |  1 -
 include/configs/bamboo.h        |  1 -
 include/configs/canyonlands.h   |  1 -
 include/configs/icon.h          |  1 -
 include/configs/intip.h         |  1 -
 include/configs/katmai.h        |  1 -
 include/configs/km/km-powerpc.h |  1 -
 include/configs/km/km_arm.h     |  1 -
 include/configs/luan.h          |  1 -
 include/configs/m28evk.h        |  1 -
 include/configs/motionpro.h     |  1 -
 include/configs/p1_p2_rdb_pc.h  |  1 -
 include/configs/p1_twr.h        |  1 -
 include/configs/pcm051.h        |  1 -
 include/configs/pengwyn.h       |  1 -
 include/configs/sequoia.h       |  1 -
 include/configs/t3corp.h        |  1 -
 include/configs/tricorder.h     |  1 -
 include/configs/walnut.h        |  1 -
 include/configs/yosemite.h      |  1 -
 30 files changed, 30 insertions(+), 68 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 4335079..0b59bea 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -338,50 +338,50 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	const char *const fmt =
 		"\nEEPROM @0x%lX %s: addr %08lx  off %04lx  count %ld ... ";
+	char * const *args = &argv[2];
+	int rcode;
+	ulong dev_addr, addr, off, cnt;
+
+	switch (argc) {
+#ifdef CONFIG_SYS_DEF_EEPROM_ADDR
+	case 5:
+		dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
+		break;
+#endif
+	case 6:
+		dev_addr = simple_strtoul(*args++, NULL, 16);
+		break;
+	default:
+		return CMD_RET_USAGE;
+	}
 
-#if defined(CONFIG_SYS_I2C_MULTI_EEPROMS)
-	if (argc == 6) {
-		ulong dev_addr = simple_strtoul (argv[2], NULL, 16);
-		ulong addr = simple_strtoul (argv[3], NULL, 16);
-		ulong off  = simple_strtoul (argv[4], NULL, 16);
-		ulong cnt  = simple_strtoul (argv[5], NULL, 16);
-#else
-	if (argc == 5) {
-		ulong dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
-		ulong addr = simple_strtoul (argv[2], NULL, 16);
-		ulong off  = simple_strtoul (argv[3], NULL, 16);
-		ulong cnt  = simple_strtoul (argv[4], NULL, 16);
-#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
+	addr = simple_strtoul(*args++, NULL, 16);
+	off = simple_strtoul(*args++, NULL, 16);
+	cnt = simple_strtoul(*args++, NULL, 16);
 
 # if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
-		eeprom_init ();
+	eeprom_init ();
 # endif /* !CONFIG_SPI */
 
-		if (strcmp (argv[1], "read") == 0) {
-			int rcode;
-
-			printf (fmt, dev_addr, argv[1], addr, off, cnt);
-
-			rcode = eeprom_read (dev_addr, off, (uchar *) addr, cnt);
+	if (strcmp (argv[1], "read") == 0) {
+		printf(fmt, dev_addr, argv[1], addr, off, cnt);
 
-			puts ("done\n");
-			return rcode;
-		} else if (strcmp (argv[1], "write") == 0) {
-			int rcode;
+		rcode = eeprom_read(dev_addr, off, (uchar *) addr, cnt);
 
-			printf (fmt, dev_addr, argv[1], addr, off, cnt);
+		puts ("done\n");
+		return rcode;
+	} else if (strcmp (argv[1], "write") == 0) {
+		printf(fmt, dev_addr, argv[1], addr, off, cnt);
 
-			rcode = eeprom_write (dev_addr, off, (uchar *) addr, cnt);
+		rcode = eeprom_write(dev_addr, off, (uchar *) addr, cnt);
 
-			puts ("done\n");
-			return rcode;
-		}
+		puts ("done\n");
+		return rcode;
 	}
 
 	return CMD_RET_USAGE;
 }
 
-#ifdef CONFIG_SYS_I2C_MULTI_EEPROMS
 U_BOOT_CMD(
 	eeprom,	6,	1,	do_eeprom,
 	"EEPROM sub-system",
@@ -389,12 +389,3 @@ U_BOOT_CMD(
 	"eeprom write devaddr addr off cnt\n"
 	"       - read/write `cnt' bytes from `devaddr` EEPROM at offset `off'"
 )
-#else /* One EEPROM */
-U_BOOT_CMD(
-	eeprom,	5,	1,	do_eeprom,
-	"EEPROM sub-system",
-	"read  addr off cnt\n"
-	"eeprom write addr off cnt\n"
-	"       - read/write `cnt' bytes at EEPROM offset `off'"
-)
-#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
diff --git a/include/configs/BSC9131RDB.h b/include/configs/BSC9131RDB.h
index 2754016..193ffbc 100644
--- a/include/configs/BSC9131RDB.h
+++ b/include/configs/BSC9131RDB.h
@@ -267,7 +267,6 @@ extern unsigned long get_sdram_size(void);
 
 /* I2C EEPROM */
 #define CONFIG_CMD_EEPROM
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
diff --git a/include/configs/BSC9132QDS.h b/include/configs/BSC9132QDS.h
index 54dcf3b..4b0e5f1 100644
--- a/include/configs/BSC9132QDS.h
+++ b/include/configs/BSC9132QDS.h
@@ -463,7 +463,6 @@ combinations. this should be removed later
 
 /* enable read and write access to EEPROM */
 #define CONFIG_CMD_EEPROM
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
diff --git a/include/configs/C29XPCIE.h b/include/configs/C29XPCIE.h
index 94f991b..c76d05f 100644
--- a/include/configs/C29XPCIE.h
+++ b/include/configs/C29XPCIE.h
@@ -420,7 +420,6 @@
 /* I2C EEPROM */
 /* enable read and write access to EEPROM */
 #define CONFIG_CMD_EEPROM
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
diff --git a/include/configs/P1010RDB.h b/include/configs/P1010RDB.h
index 81b0855..8a137d0 100644
--- a/include/configs/P1010RDB.h
+++ b/include/configs/P1010RDB.h
@@ -660,7 +660,6 @@ extern unsigned long get_sdram_size(void);
 #endif
 /* enable read and write access to EEPROM */
 #define CONFIG_CMD_EEPROM
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
diff --git a/include/configs/PMC440.h b/include/configs/PMC440.h
index 0227649..26a1444 100644
--- a/include/configs/PMC440.h
+++ b/include/configs/PMC440.h
@@ -159,7 +159,6 @@
 #define CONFIG_SYS_I2C_PPC4XX_SPEED_1		400000
 #define CONFIG_SYS_I2C_PPC4XX_SLAVE_1		0x7F
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR		0x54
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		2
diff --git a/include/configs/TQM834x.h b/include/configs/TQM834x.h
index 0b046d1..9f6bd0f 100644
--- a/include/configs/TQM834x.h
+++ b/include/configs/TQM834x.h
@@ -183,7 +183,6 @@
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		2	/* 16 bit */
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	5	/* 32 bytes/write */
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	12	/* 10ms +/- 20% */
-#define CONFIG_SYS_I2C_MULTI_EEPROMS		/* more than one eeprom */
 
 /* I2C RTC */
 #define CONFIG_RTC_DS1337			/* use ds1337 rtc via i2c */
diff --git a/include/configs/acadia.h b/include/configs/acadia.h
index 4dd5720..2f53d73 100644
--- a/include/configs/acadia.h
+++ b/include/configs/acadia.h
@@ -120,7 +120,6 @@
  *----------------------------------------------------------------------*/
 #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index d58816d..a4b8e0f 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -213,7 +213,6 @@
 #define CONFIG_ENV_EEPROM_IS_ON_I2C
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* Main EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 
 /* PMIC support */
 #define CONFIG_POWER_TPS65217
diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h
index d93e3e7..5821137 100644
--- a/include/configs/am43xx_evm.h
+++ b/include/configs/am43xx_evm.h
@@ -36,7 +36,6 @@
 #define CONFIG_ENV_EEPROM_IS_ON_I2C
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* Main EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 
 /* Power */
 #define CONFIG_POWER
diff --git a/include/configs/axs101.h b/include/configs/axs101.h
index 450291c..e921f19 100644
--- a/include/configs/axs101.h
+++ b/include/configs/axs101.h
@@ -91,7 +91,6 @@
 /*
  * EEPROM configuration
  */
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR		(0xA8 >> 1)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
 #define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW	1
diff --git a/include/configs/bamboo.h b/include/configs/bamboo.h
index 6ba4aaf..5b8b22f 100644
--- a/include/configs/bamboo.h
+++ b/include/configs/bamboo.h
@@ -139,7 +139,6 @@
  *----------------------------------------------------------------------*/
 #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
diff --git a/include/configs/canyonlands.h b/include/configs/canyonlands.h
index ed790cc..e136824 100644
--- a/include/configs/canyonlands.h
+++ b/include/configs/canyonlands.h
@@ -248,7 +248,6 @@
  *----------------------------------------------------------------------*/
 #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR		(0xa8>>1)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	3
diff --git a/include/configs/icon.h b/include/configs/icon.h
index bbe9b59..d9a3671 100644
--- a/include/configs/icon.h
+++ b/include/configs/icon.h
@@ -107,7 +107,6 @@
 
 #define CONFIG_SYS_SPD_BUS_NUM	0	/* The I2C bus for SPD		*/
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
diff --git a/include/configs/intip.h b/include/configs/intip.h
index a676a20..60c9e2c 100644
--- a/include/configs/intip.h
+++ b/include/configs/intip.h
@@ -214,7 +214,6 @@
  */
 #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR		(0xa8>>1)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	3
diff --git a/include/configs/katmai.h b/include/configs/katmai.h
index fa72eb0..664896b 100644
--- a/include/configs/katmai.h
+++ b/include/configs/katmai.h
@@ -109,7 +109,6 @@
 #define IIC0_BOOTPROM_ADDR	0x50
 #define IIC0_ALT_BOOTPROM_ADDR	0x54
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0x50)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
diff --git a/include/configs/km/km-powerpc.h b/include/configs/km/km-powerpc.h
index eb85a74..2b0b9dc 100644
--- a/include/configs/km/km-powerpc.h
+++ b/include/configs/km/km-powerpc.h
@@ -21,7 +21,6 @@
 #define CONFIG_KM_COMMON_ETH_INIT
 
 /* EEprom support 24C08, 24C16, 24C64 */
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	3  /* 8 Byte write page */
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	10
diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h
index b89af53..798c9a7 100644
--- a/include/configs/km/km_arm.h
+++ b/include/configs/km/km_arm.h
@@ -215,7 +215,6 @@ int get_scl(void);
 #define	CONFIG_SYS_I2C_SOFT_SPEED	100000
 
 /* EEprom support 24C128, 24C256 valid for environment eeprom */
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	6 /* 64 Byte write page */
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	10
diff --git a/include/configs/luan.h b/include/configs/luan.h
index 15e4a7e..e22d0e8 100644
--- a/include/configs/luan.h
+++ b/include/configs/luan.h
@@ -119,7 +119,6 @@
  *----------------------------------------------------------------------*/
 #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
diff --git a/include/configs/m28evk.h b/include/configs/m28evk.h
index 29c60b7..f9fc66f 100644
--- a/include/configs/m28evk.h
+++ b/include/configs/m28evk.h
@@ -92,7 +92,6 @@
 
 /* EEPROM */
 #ifdef CONFIG_CMD_EEPROM
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
 #endif
 
diff --git a/include/configs/motionpro.h b/include/configs/motionpro.h
index 97c614b..a8cf201 100644
--- a/include/configs/motionpro.h
+++ b/include/configs/motionpro.h
@@ -285,7 +285,6 @@
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	1	/* 2 bytes per write cycle */
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	5	/* 2ms/cycle + 3ms extra */
-#define CONFIG_SYS_I2C_MULTI_EEPROMS		1	/* 2 EEPROMs (addr:50,52) */
 
 /*
  * RTC configuration
diff --git a/include/configs/p1_p2_rdb_pc.h b/include/configs/p1_p2_rdb_pc.h
index 433c409..e039af4 100644
--- a/include/configs/p1_p2_rdb_pc.h
+++ b/include/configs/p1_p2_rdb_pc.h
@@ -701,7 +701,6 @@
 
 /* enable read and write access to EEPROM */
 #define CONFIG_CMD_EEPROM
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
diff --git a/include/configs/p1_twr.h b/include/configs/p1_twr.h
index d83daa0..3089969 100644
--- a/include/configs/p1_twr.h
+++ b/include/configs/p1_twr.h
@@ -262,7 +262,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 
 /* enable read and write access to EEPROM */
 #define CONFIG_CMD_EEPROM
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
diff --git a/include/configs/pcm051.h b/include/configs/pcm051.h
index 275e952..64cfd81 100644
--- a/include/configs/pcm051.h
+++ b/include/configs/pcm051.h
@@ -115,7 +115,6 @@
 #define CONFIG_ENV_EEPROM_IS_ON_I2C
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* Main EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 
 #define CONFIG_SYS_BAUDRATE_TABLE	{ 110, 300, 600, 1200, 2400, \
 4800, 9600, 14400, 19200, 28800, 38400, 56000, 57600, 115200 }
diff --git a/include/configs/pengwyn.h b/include/configs/pengwyn.h
index ccb5dd3..b057539 100644
--- a/include/configs/pengwyn.h
+++ b/include/configs/pengwyn.h
@@ -112,7 +112,6 @@
 #define CONFIG_ENV_EEPROM_IS_ON_I2C
 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 
 /* SPL */
 #define CONFIG_SPL_POWER_SUPPORT
diff --git a/include/configs/sequoia.h b/include/configs/sequoia.h
index 1f1beea..f32459b 100644
--- a/include/configs/sequoia.h
+++ b/include/configs/sequoia.h
@@ -151,7 +151,6 @@
  */
 #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
diff --git a/include/configs/t3corp.h b/include/configs/t3corp.h
index 502e795..7942865 100644
--- a/include/configs/t3corp.h
+++ b/include/configs/t3corp.h
@@ -307,7 +307,6 @@
  */
 #define CONFIG_SYS_I2C_PPC4XX_SPEED_0			400000
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR		(0xa8>>1)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	3
diff --git a/include/configs/tricorder.h b/include/configs/tricorder.h
index 02b0e63..e453151 100644
--- a/include/configs/tricorder.h
+++ b/include/configs/tricorder.h
@@ -112,7 +112,6 @@
  
 
 /* EEPROM */
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_CMD_EEPROM
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
 #define CONFIG_SYS_EEPROM_BUS_NUM	1
diff --git a/include/configs/walnut.h b/include/configs/walnut.h
index 8b803a2..dd6b519 100644
--- a/include/configs/walnut.h
+++ b/include/configs/walnut.h
@@ -80,7 +80,6 @@
  */
 #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
diff --git a/include/configs/yosemite.h b/include/configs/yosemite.h
index 8508a80..0cffab8 100644
--- a/include/configs/yosemite.h
+++ b/include/configs/yosemite.h
@@ -122,7 +122,6 @@
  *----------------------------------------------------------------------*/
 #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
 
-#define CONFIG_SYS_I2C_MULTI_EEPROMS
 #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 04/17] eeprom: Zap CONFIG_SYS_EEPROM_X40430
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
  2015-11-10 19:53 ` [U-Boot] [PATCH 02/17] eeprom: Shuffle code around Marek Vasut
  2015-11-10 19:53 ` [U-Boot] [PATCH 03/17] eeprom: Zap CONFIG_SYS_I2C_MULTI_EEPROMS Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:27   ` Heiko Schocher
  2015-11-22 15:53   ` [U-Boot] [U-Boot,04/17] " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 05/17] eeprom: Zap eeprom_probe() Marek Vasut
                   ` (14 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Now that the only user of CONFIG_SYS_EEPROM_X40430 was removed,
remove this unused code from cmd_eeprom.c

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 94 -----------------------------------------------------
 1 file changed, 94 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 0b59bea..266f954 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -29,11 +29,6 @@
 #define	CONFIG_SYS_I2C_SPEED	50000
 #endif
 
-/* Maximum number of times to poll for acknowledge after write */
-#if defined(CONFIG_SYS_EEPROM_X40430)
-#define MAX_ACKNOWLEDGE_POLLS	10
-#endif
-
 /*
  * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
  *   0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
@@ -141,14 +136,6 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 	unsigned blk_off;
 	int rcode = 0;
 
-#if defined(CONFIG_SYS_EEPROM_X40430)
-	uchar	contr_r_addr[2];
-	uchar	addr_void[2];
-	uchar	contr_reg[2];
-	uchar	ctrl_reg_v;
-	int	i;
-#endif
-
 #if defined(CONFIG_SYS_EEPROM_WREN)
 	eeprom_write_enable (dev_addr,1);
 #endif
@@ -213,88 +200,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 #if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
 		spi_write (addr, alen, buffer, len);
 #else
-#if defined(CONFIG_SYS_EEPROM_X40430)
-		/* Get the value of the control register.
-		 * Set current address (internal pointer in the x40430)
-		 * to 0x1ff.
-		 */
-		contr_r_addr[0] = 9;
-		contr_r_addr[1] = 0xff;
-		addr_void[0]    = 0;
-		addr_void[1]    = addr[1];
-#ifdef CONFIG_SYS_I2C_EEPROM_ADDR
-		contr_r_addr[0] |= CONFIG_SYS_I2C_EEPROM_ADDR;
-		addr_void[0]    |= CONFIG_SYS_I2C_EEPROM_ADDR;
-#endif
-		contr_reg[0] = 0xff;
-		if (i2c_read (contr_r_addr[0], contr_r_addr[1], 1, contr_reg, 1) != 0) {
-			rcode = 1;
-		}
-		ctrl_reg_v = contr_reg[0];
 
-		/* Are any of the eeprom blocks write protected?
-		 */
-		if (ctrl_reg_v & 0x18) {
-			ctrl_reg_v &= ~0x18;   /* reset block protect bits  */
-			ctrl_reg_v |=  0x02;   /* set write enable latch    */
-			ctrl_reg_v &= ~0x04;   /* clear RWEL                */
-
-			/* Set write enable latch.
-			 */
-			contr_reg[0] = 0x02;
-			if (i2c_write (contr_r_addr[0], 0xff, 1, contr_reg, 1) != 0) {
-				rcode = 1;
-			}
-
-			/* Set register write enable latch.
-			 */
-			contr_reg[0] = 0x06;
-			if (i2c_write (contr_r_addr[0], 0xFF, 1, contr_reg, 1) != 0) {
-				rcode = 1;
-			}
-
-			/* Modify ctrl register.
-			 */
-			contr_reg[0] = ctrl_reg_v;
-			if (i2c_write (contr_r_addr[0], 0xFF, 1, contr_reg, 1) != 0) {
-				rcode = 1;
-			}
-
-			/* The write (above) is an operation on NV memory.
-			 * These can take some time (~5ms), and the device
-			 * will not respond to further I2C messages till
-			 * it's completed the write.
-			 * So poll device for an I2C acknowledge.
-			 * When we get one we know we can continue with other
-			 * operations.
-			 */
-			contr_reg[0] = 0;
-			for (i = 0; i < MAX_ACKNOWLEDGE_POLLS; i++) {
-				if (i2c_read (addr_void[0], addr_void[1], 1, contr_reg, 1) == 0)
-					break;	/* got ack */
-#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS)
-				udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
-#endif
-			}
-			if (i == MAX_ACKNOWLEDGE_POLLS) {
-				puts ("EEPROM poll acknowledge failed\n");
-				rcode = 1;
-			}
-		}
-
-		/* Is the write enable latch on?.
-		 */
-		else if (!(ctrl_reg_v & 0x02)) {
-			/* Set write enable latch.
-			 */
-			contr_reg[0] = 0x02;
-			if (i2c_write (contr_r_addr[0], 0xFF, 1, contr_reg, 1) != 0) {
-			       rcode = 1;
-			}
-		}
-		/* Write is enabled ... now write eeprom value.
-		 */
-#endif
 #if defined(CONFIG_SYS_I2C_EEPROM_BUS)
 		i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS);
 #endif
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 05/17] eeprom: Zap eeprom_probe()
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (2 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 04/17] eeprom: Zap CONFIG_SYS_EEPROM_X40430 Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:27   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot,05/17] " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 06/17] eeprom: Zap CONFIG_SPI_X Marek Vasut
                   ` (13 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Remove this function as it's no longer used.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 19 -------------------
 include/common.h    |  3 ---
 2 files changed, 22 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 266f954..ea1d447 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -221,25 +221,6 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 	return rcode;
 }
 
-#if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
-int eeprom_probe(unsigned dev_addr, unsigned offset)
-{
-	unsigned char chip;
-
-	/* Probe the chip address
-	 */
-#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X)
-	chip = offset >> 8;		/* block number */
-#else
-	chip = offset >> 16;		/* block number */
-#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */
-
-	chip |= dev_addr;		/* insert device address */
-
-	return (i2c_probe (chip));
-}
-#endif
-
 static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	const char *const fmt =
diff --git a/include/common.h b/include/common.h
index 09a131d..ceb1ad3 100644
--- a/include/common.h
+++ b/include/common.h
@@ -476,9 +476,6 @@ void	fdc_hw_init   (void);
 
 /* $(BOARD)/eeprom.c */
 void eeprom_init  (void);
-#ifndef CONFIG_SPI
-int  eeprom_probe (unsigned dev_addr, unsigned offset);
-#endif
 int  eeprom_read  (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
 int  eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 06/17] eeprom: Zap CONFIG_SPI_X
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (3 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 05/17] eeprom: Zap eeprom_probe() Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:27   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot,06/17] " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 07/17] eeprom: Pull out the I/O code Marek Vasut
                   ` (12 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

This macro is no longer used, so just reap it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Heiko Schocher <hs@denx.de>
---
 README              | 5 -----
 common/cmd_eeprom.c | 8 ++++----
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/README b/README
index ef8d437..8fb81e9 100644
--- a/README
+++ b/README
@@ -2705,11 +2705,6 @@ CBFS (Coreboot Filesystem) support
 		Enables the driver for SPI controller on SuperH. Currently
 		only SH7757 is supported.
 
-		CONFIG_SPI_X
-
-		Enables extended (16-bit) SPI EEPROM addressing.
-		(symmetrical to CONFIG_I2C_X)
-
 		CONFIG_SOFT_SPI
 
 		Enables a software (bit-bang) SPI driver rather than
diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index ea1d447..728606e 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -78,7 +78,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
 		unsigned maxlen;
 #endif
 
-#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X)
+#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1
 		uchar addr[2];
 
 		blk_off = offset & 0xFF;	/* block offset */
@@ -95,7 +95,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
 		addr[1] = offset >>  8;		/* upper address octet */
 		addr[2] = blk_off;		/* lower address octet */
 		alen	= 3;
-#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */
+#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */
 
 		addr[0] |= dev_addr;		/* insert device address */
 
@@ -151,7 +151,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 		unsigned maxlen;
 #endif
 
-#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X)
+#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1
 		uchar addr[2];
 
 		blk_off = offset & 0xFF;	/* block offset */
@@ -168,7 +168,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 		addr[1] = offset >>  8;		/* upper address octet */
 		addr[2] = blk_off;		/* lower address octet */
 		alen	= 3;
-#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */
+#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */
 
 		addr[0] |= dev_addr;		/* insert device address */
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 07/17] eeprom: Pull out the I/O code
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (4 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 06/17] eeprom: Zap CONFIG_SPI_X Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:27   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot,07/17] " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 08/17] eeprom: Pull out address computation Marek Vasut
                   ` (11 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Pull out the code which does the I2C or SPI read/write, so that
the beefy ifdef around it is contained in a single function.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 50 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 19 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 728606e..7797d0e 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -61,6 +61,34 @@ void eeprom_init(void)
 #endif
 }
 
+static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
+			   uchar *buffer, unsigned len, bool read)
+{
+	int ret = 0;
+
+	/* SPI */
+#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
+	if (read)
+		spi_read(addr, alen, buffer, len);
+	else
+		spi_write(addr, alen, buffer, len);
+#else	/* I2C */
+
+#if defined(CONFIG_SYS_I2C_EEPROM_BUS)
+	i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS);
+#endif
+
+	if (read)
+		ret = i2c_read(addr[0], offset, alen - 1, buffer, len);
+	else
+		ret = i2c_write(addr[0], offset, alen - 1, buffer, len);
+
+	if (ret)
+		ret = 1;
+#endif
+	return ret;
+}
+
 int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
 {
 	unsigned end = offset + cnt;
@@ -114,15 +142,8 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
 			len = maxlen;
 #endif
 
-#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
-		spi_read (addr, alen, buffer, len);
-#else
-#if defined(CONFIG_SYS_I2C_EEPROM_BUS)
-		i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS);
-#endif
-		if (i2c_read(addr[0], offset, alen - 1, buffer, len))
-			rcode = 1;
-#endif
+		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 1);
+
 		buffer += len;
 		offset += len;
 	}
@@ -197,17 +218,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 			len = maxlen;
 #endif
 
-#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
-		spi_write (addr, alen, buffer, len);
-#else
+		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 0);
 
-#if defined(CONFIG_SYS_I2C_EEPROM_BUS)
-		i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS);
-#endif
-		if (i2c_write(addr[0], offset, alen - 1, buffer, len))
-			rcode = 1;
-
-#endif
 		buffer += len;
 		offset += len;
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 08/17] eeprom: Pull out address computation
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (5 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 07/17] eeprom: Pull out the I/O code Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:28   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot,08/17] " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 09/17] eeprom: Make eeprom_write_enable() weak Marek Vasut
                   ` (10 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Pull out the code computing the EEPROM address into separate function
so that it's not duplicated.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 64 ++++++++++++++++++++++-------------------------------
 1 file changed, 26 insertions(+), 38 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 7797d0e..5979993 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -61,6 +61,28 @@ void eeprom_init(void)
 #endif
 }
 
+static int eeprom_addr(unsigned dev_addr, unsigned offset, uchar *addr)
+{
+	unsigned blk_off;
+	int alen;
+
+	blk_off = offset & 0xff;	/* block offset */
+#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1
+	addr[0] = offset >> 8;		/* block number */
+	addr[1] = blk_off;		/* block offset */
+	alen = 2;
+#else
+	addr[0] = offset >> 16;		/* block number */
+	addr[1] = offset >>  8;		/* upper address octet */
+	addr[2] = blk_off;		/* lower address octet */
+	alen = 3;
+#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */
+
+	addr[0] |= dev_addr;		/* insert device address */
+
+	return alen;
+}
+
 static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
 			   uchar *buffer, unsigned len, bool read)
 {
@@ -94,6 +116,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
 	unsigned end = offset + cnt;
 	unsigned blk_off;
 	int rcode = 0;
+	uchar addr[3];
 
 	/*
 	 * Read data until done or would cross a page boundary.
@@ -106,26 +129,8 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
 		unsigned maxlen;
 #endif
 
-#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1
-		uchar addr[2];
-
-		blk_off = offset & 0xFF;	/* block offset */
-
-		addr[0] = offset >> 8;		/* block number */
-		addr[1] = blk_off;		/* block offset */
-		alen	= 2;
-#else
-		uchar addr[3];
-
 		blk_off = offset & 0xFF;	/* block offset */
-
-		addr[0] = offset >> 16;		/* block number */
-		addr[1] = offset >>  8;		/* upper address octet */
-		addr[2] = blk_off;		/* lower address octet */
-		alen	= 3;
-#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */
-
-		addr[0] |= dev_addr;		/* insert device address */
+		alen = eeprom_addr(dev_addr, offset, addr);
 
 		len = end - offset;
 
@@ -156,6 +161,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 	unsigned end = offset + cnt;
 	unsigned blk_off;
 	int rcode = 0;
+	uchar addr[3];
 
 #if defined(CONFIG_SYS_EEPROM_WREN)
 	eeprom_write_enable (dev_addr,1);
@@ -172,26 +178,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 		unsigned maxlen;
 #endif
 
-#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1
-		uchar addr[2];
-
 		blk_off = offset & 0xFF;	/* block offset */
-
-		addr[0] = offset >> 8;		/* block number */
-		addr[1] = blk_off;		/* block offset */
-		alen	= 2;
-#else
-		uchar addr[3];
-
-		blk_off = offset & 0xFF;	/* block offset */
-
-		addr[0] = offset >> 16;		/* block number */
-		addr[1] = offset >>  8;		/* upper address octet */
-		addr[2] = blk_off;		/* lower address octet */
-		alen	= 3;
-#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */
-
-		addr[0] |= dev_addr;		/* insert device address */
+		alen = eeprom_addr(dev_addr, offset, addr);
 
 		len = end - offset;
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 09/17] eeprom: Make eeprom_write_enable() weak
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (6 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 08/17] eeprom: Pull out address computation Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:28   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 10/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS Marek Vasut
                   ` (9 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Make this function weak and implement it's weak implementation
so that the boards can just reimplement it. This zaps the horrid
CONFIG_SYS_EEPROM_WREN macro.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 5979993..040ab5f 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -44,9 +44,10 @@
 #endif
 #endif
 
-#if defined(CONFIG_SYS_EEPROM_WREN)
-extern int eeprom_write_enable (unsigned dev_addr, int state);
-#endif
+__weak int eeprom_write_enable(unsigned dev_addr, int state)
+{
+	return 0;
+}
 
 void eeprom_init(void)
 {
@@ -163,9 +164,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 	int rcode = 0;
 	uchar addr[3];
 
-#if defined(CONFIG_SYS_EEPROM_WREN)
-	eeprom_write_enable (dev_addr,1);
-#endif
+	eeprom_write_enable(dev_addr, 1);
+
 	/*
 	 * Write data until done or would cross a write page boundary.
 	 * We must write the address again when changing pages
@@ -215,9 +215,9 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 		udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
 #endif
 	}
-#if defined(CONFIG_SYS_EEPROM_WREN)
-	eeprom_write_enable (dev_addr,0);
-#endif
+
+	eeprom_write_enable(dev_addr, 0);
+
 	return rcode;
 }
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 10/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (7 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 09/17] eeprom: Make eeprom_write_enable() weak Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:28   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 11/17] eeprom: Suck the ifdef into eeprom_init() Marek Vasut
                   ` (8 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Pull this macro to the beginning of the cmd_eeprom.c and remove
another nasty ifdef from the code. Note that this is legal, since
udelay(0) changes the behavior only such that it pings the WDT if
WDT is enabled and otherwise does not wait.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 040ab5f..8451d63 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -29,6 +29,10 @@
 #define	CONFIG_SYS_I2C_SPEED	50000
 #endif
 
+#ifndef CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS
+#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	0
+#endif
+
 /*
  * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
  *   0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
@@ -211,9 +215,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 		buffer += len;
 		offset += len;
 
-#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS)
 		udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
-#endif
 	}
 
 	eeprom_write_enable(dev_addr, 0);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 11/17] eeprom: Suck the ifdef into eeprom_init()
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (8 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 10/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:28   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 12/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_BITS Marek Vasut
                   ` (7 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Just suck the ugly ifdef around eeprom_init() call into eeprom_init()
function itself. This puts all of the ifdef mess into one place.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 8451d63..c38c534 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -57,7 +57,7 @@ void eeprom_init(void)
 {
 	/* SPI EEPROM */
 #if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
-	spi_init_f ();
+	spi_init_f();
 #endif
 
 	/* I2C EEPROM */
@@ -248,9 +248,7 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	off = simple_strtoul(*args++, NULL, 16);
 	cnt = simple_strtoul(*args++, NULL, 16);
 
-# if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
-	eeprom_init ();
-# endif /* !CONFIG_SPI */
+	eeprom_init();
 
 	if (strcmp (argv[1], "read") == 0) {
 		printf(fmt, dev_addr, argv[1], addr, off, cnt);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 12/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_BITS
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (9 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 11/17] eeprom: Suck the ifdef into eeprom_init() Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:29   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 13/17] eeprom: Pull out transfer length computation Marek Vasut
                   ` (6 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Implement default value of 8 for this macro and pull out all of
this macro out of the code. The default value of 8 actually does
implement exactly the same behavior as the previous code which
was in the #else clause of the ifdef.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index c38c534..162a05c 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -33,6 +33,13 @@
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	0
 #endif
 
+#ifndef CONFIG_SYS_EEPROM_PAGE_WRITE_BITS
+#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	8
+#endif
+
+#define	EEPROM_PAGE_SIZE	(1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
+#define	EEPROM_PAGE_OFFSET(x)	((x) & (EEPROM_PAGE_SIZE - 1))
+
 /*
  * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
  *   0x000nxxxx for EEPROM address selectors@n, offset xxxx in EEPROM.
@@ -194,15 +201,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 		 */
 #if !defined(CONFIG_SYS_I2C_FRAM)
 
-#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
-
-#define	EEPROM_PAGE_SIZE	(1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
-#define	EEPROM_PAGE_OFFSET(x)	((x) & (EEPROM_PAGE_SIZE - 1))
-
 		maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off);
-#else
-		maxlen = 0x100 - blk_off;
-#endif
+
 		if (maxlen > I2C_RXTX_LEN)
 			maxlen = I2C_RXTX_LEN;
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 13/17] eeprom: Pull out transfer length computation
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (10 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 12/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_BITS Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:31   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 14/17] eeprom: Pull out the RW loop Marek Vasut
                   ` (5 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Pull out the code which computes the length of the transfer
into separate code and clean it up a little. This again trims
down the code duplication.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 66 ++++++++++++++++++++---------------------------------
 1 file changed, 25 insertions(+), 41 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 162a05c..b39ca5d 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -95,6 +95,29 @@ static int eeprom_addr(unsigned dev_addr, unsigned offset, uchar *addr)
 	return alen;
 }
 
+static int eeprom_len(unsigned offset, unsigned end)
+{
+	unsigned len = end - offset;
+
+	/*
+	 * For a FRAM device there is no limit on the number of the
+	 * bytes that can be ccessed with the single read or write
+	 * operation.
+	 */
+#if !defined(CONFIG_SYS_I2C_FRAM)
+	unsigned blk_off = offset & 0xff;
+	unsigned maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off);
+
+	if (maxlen > I2C_RXTX_LEN)
+		maxlen = I2C_RXTX_LEN;
+
+	if (len > maxlen)
+		len = maxlen;
+#endif
+
+	return len;
+}
+
 static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
 			   uchar *buffer, unsigned len, bool read)
 {
@@ -126,7 +149,6 @@ static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
 int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
 {
 	unsigned end = offset + cnt;
-	unsigned blk_off;
 	int rcode = 0;
 	uchar addr[3];
 
@@ -137,27 +159,10 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
 	 */
 	while (offset < end) {
 		unsigned alen, len;
-#if !defined(CONFIG_SYS_I2C_FRAM)
-		unsigned maxlen;
-#endif
 
-		blk_off = offset & 0xFF;	/* block offset */
 		alen = eeprom_addr(dev_addr, offset, addr);
 
-		len = end - offset;
-
-		/*
-		 * For a FRAM device there is no limit on the number of the
-		 * bytes that can be ccessed with the single read or write
-		 * operation.
-		 */
-#if !defined(CONFIG_SYS_I2C_FRAM)
-		maxlen = 0x100 - blk_off;
-		if (maxlen > I2C_RXTX_LEN)
-			maxlen = I2C_RXTX_LEN;
-		if (len > maxlen)
-			len = maxlen;
-#endif
+		len = eeprom_len(offset, end);
 
 		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 1);
 
@@ -171,7 +176,6 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
 int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
 {
 	unsigned end = offset + cnt;
-	unsigned blk_off;
 	int rcode = 0;
 	uchar addr[3];
 
@@ -185,30 +189,10 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 
 	while (offset < end) {
 		unsigned alen, len;
-#if !defined(CONFIG_SYS_I2C_FRAM)
-		unsigned maxlen;
-#endif
 
-		blk_off = offset & 0xFF;	/* block offset */
 		alen = eeprom_addr(dev_addr, offset, addr);
 
-		len = end - offset;
-
-		/*
-		 * For a FRAM device there is no limit on the number of the
-		 * bytes that can be accessed with the single read or write
-		 * operation.
-		 */
-#if !defined(CONFIG_SYS_I2C_FRAM)
-
-		maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off);
-
-		if (maxlen > I2C_RXTX_LEN)
-			maxlen = I2C_RXTX_LEN;
-
-		if (len > maxlen)
-			len = maxlen;
-#endif
+		len = eeprom_len(offset, end);
 
 		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 0);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 14/17] eeprom: Pull out the RW loop
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (11 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 13/17] eeprom: Pull out transfer length computation Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:31   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot,14/17] " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 15/17] eeprom: Add bus argument to eeprom_init() Marek Vasut
                   ` (4 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Unify the code for doing read/write into single function, since the
code for both the read and write is almost identical. This again
trims down the code duplication.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 51 +++++++++++++++++++++------------------------------
 1 file changed, 21 insertions(+), 30 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index b39ca5d..d0942ef 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -146,38 +146,44 @@ static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
 	return ret;
 }
 
-int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
+static int eeprom_rw(unsigned dev_addr, unsigned offset, uchar *buffer,
+		     unsigned cnt, bool read)
 {
 	unsigned end = offset + cnt;
+	unsigned alen, len;
 	int rcode = 0;
 	uchar addr[3];
 
-	/*
-	 * Read data until done or would cross a page boundary.
-	 * We must write the address again when changing pages
-	 * because the next page may be in a different device.
-	 */
 	while (offset < end) {
-		unsigned alen, len;
-
 		alen = eeprom_addr(dev_addr, offset, addr);
 
 		len = eeprom_len(offset, end);
 
-		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 1);
+		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, read);
 
 		buffer += len;
 		offset += len;
+
+		if (!read)
+			udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
 	}
 
 	return rcode;
 }
 
-int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
+int eeprom_read(unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
 {
-	unsigned end = offset + cnt;
-	int rcode = 0;
-	uchar addr[3];
+	/*
+	 * Read data until done or would cross a page boundary.
+	 * We must write the address again when changing pages
+	 * because the next page may be in a different device.
+	 */
+	return eeprom_rw(dev_addr, offset, buffer, cnt, 1);
+}
+
+int eeprom_write(unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
+{
+	int ret;
 
 	eeprom_write_enable(dev_addr, 1);
 
@@ -186,25 +192,10 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 	 * We must write the address again when changing pages
 	 * because the address counter only increments within a page.
 	 */
-
-	while (offset < end) {
-		unsigned alen, len;
-
-		alen = eeprom_addr(dev_addr, offset, addr);
-
-		len = eeprom_len(offset, end);
-
-		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 0);
-
-		buffer += len;
-		offset += len;
-
-		udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
-	}
+	ret = eeprom_rw(dev_addr, offset, buffer, cnt, 1);
 
 	eeprom_write_enable(dev_addr, 0);
-
-	return rcode;
+	return ret;
 }
 
 static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 15/17] eeprom: Add bus argument to eeprom_init()
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (12 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 14/17] eeprom: Pull out the RW loop Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:32   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 16/17] eeprom: Add support for selecting i2c bus Marek Vasut
                   ` (3 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Add bus argument to eeprom_init(), so that it can select
the I2C bus number on which the eeprom resides. Any negative
value of the $bus argument will preserve the old behavior.
This is in place so that old code does not randomly break.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 6 ++++--
 common/env_eeprom.c | 4 ++--
 include/common.h    | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index d0942ef..9247036 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -60,7 +60,7 @@ __weak int eeprom_write_enable(unsigned dev_addr, int state)
 	return 0;
 }
 
-void eeprom_init(void)
+void eeprom_init(int bus)
 {
 	/* SPI EEPROM */
 #if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
@@ -69,6 +69,8 @@ void eeprom_init(void)
 
 	/* I2C EEPROM */
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
+	if (bus >= 0)
+		i2c_set_bus_num(bus);
 	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
 }
@@ -223,7 +225,7 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	off = simple_strtoul(*args++, NULL, 16);
 	cnt = simple_strtoul(*args++, NULL, 16);
 
-	eeprom_init();
+	eeprom_init(-1);
 
 	if (strcmp (argv[1], "read") == 0) {
 		printf(fmt, dev_addr, argv[1], addr, off, cnt);
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index eea169d..72b1373 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -91,7 +91,7 @@ void env_relocate_spec(void)
 	uchar rdbuf[64], flags[2];
 	int i, crc_ok[2] = {0, 0};
 
-	eeprom_init();	/* prepare for EEPROM read/write */
+	eeprom_init(-1);	/* prepare for EEPROM read/write */
 
 	off_env[0] = CONFIG_ENV_OFFSET;
 	off_env[1] = CONFIG_ENV_OFFSET_REDUND;
@@ -154,7 +154,7 @@ void env_relocate_spec(void)
 	ulong crc, len, new;
 	uchar rdbuf[64];
 
-	eeprom_init();	/* prepare for EEPROM read/write */
+	eeprom_init(-1);	/* prepare for EEPROM read/write */
 
 	/* read old CRC */
 	eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR,
diff --git a/include/common.h b/include/common.h
index ceb1ad3..39ba5c9 100644
--- a/include/common.h
+++ b/include/common.h
@@ -475,7 +475,7 @@ void	reset_phy     (void);
 void	fdc_hw_init   (void);
 
 /* $(BOARD)/eeprom.c */
-void eeprom_init  (void);
+void eeprom_init  (int bus);
 int  eeprom_read  (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
 int  eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 16/17] eeprom: Add support for selecting i2c bus
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (13 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 15/17] eeprom: Add bus argument to eeprom_init() Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:32   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  2015-11-10 19:53 ` [U-Boot] [PATCH 17/17] eeprom: Clean up checkpatch issues Marek Vasut
                   ` (2 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Add additional parameter into the eeprom command to select
the I2C bus on which the eeprom resides.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 9247036..13c946e 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -207,14 +207,21 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	char * const *args = &argv[2];
 	int rcode;
 	ulong dev_addr, addr, off, cnt;
+	int bus_addr;
 
 	switch (argc) {
 #ifdef CONFIG_SYS_DEF_EEPROM_ADDR
 	case 5:
+		bus_addr = -1;
 		dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
 		break;
 #endif
 	case 6:
+		bus_addr = -1;
+		dev_addr = simple_strtoul(*args++, NULL, 16);
+		break;
+	case 7:
+		bus_addr = simple_strtoul(*args++, NULL, 16);
 		dev_addr = simple_strtoul(*args++, NULL, 16);
 		break;
 	default:
@@ -225,7 +232,7 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	off = simple_strtoul(*args++, NULL, 16);
 	cnt = simple_strtoul(*args++, NULL, 16);
 
-	eeprom_init(-1);
+	eeprom_init(bus_addr);
 
 	if (strcmp (argv[1], "read") == 0) {
 		printf(fmt, dev_addr, argv[1], addr, off, cnt);
@@ -247,9 +254,9 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 }
 
 U_BOOT_CMD(
-	eeprom,	6,	1,	do_eeprom,
+	eeprom,	7,	1,	do_eeprom,
 	"EEPROM sub-system",
-	"read  devaddr addr off cnt\n"
-	"eeprom write devaddr addr off cnt\n"
+	"read  <bus> <devaddr> addr off cnt\n"
+	"eeprom write <bus> <devaddr> addr off cnt\n"
 	"       - read/write `cnt' bytes from `devaddr` EEPROM at offset `off'"
 )
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 17/17] eeprom: Clean up checkpatch issues
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (14 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 16/17] eeprom: Add support for selecting i2c bus Marek Vasut
@ 2015-11-10 19:53 ` Marek Vasut
  2015-11-16 11:32   ` Heiko Schocher
  2015-11-22 15:55   ` [U-Boot] [U-Boot,17/17] " Tom Rini
  2015-11-16 11:26 ` [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Heiko Schocher
  2015-11-22 15:53 ` [U-Boot] [U-Boot, " Tom Rini
  17 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2015-11-10 19:53 UTC (permalink / raw)
  To: u-boot

Cosmetic fixes to the file, make it checkpatch clean.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 13c946e..376c57d 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -49,8 +49,8 @@
  */
 #if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
 #if !defined(CONFIG_SYS_I2C_EEPROM_ADDR_LEN) || \
-    (CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1) || \
-    (CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2)
+	(CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1) || \
+	(CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2)
 #error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2
 #endif
 #endif
@@ -183,7 +183,8 @@ int eeprom_read(unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
 	return eeprom_rw(dev_addr, offset, buffer, cnt, 1);
 }
 
-int eeprom_write(unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
+int eeprom_write(unsigned dev_addr, unsigned offset,
+		 uchar *buffer, unsigned cnt)
 {
 	int ret;
 
@@ -234,19 +235,19 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	eeprom_init(bus_addr);
 
-	if (strcmp (argv[1], "read") == 0) {
+	if (strcmp(argv[1], "read") == 0) {
 		printf(fmt, dev_addr, argv[1], addr, off, cnt);
 
-		rcode = eeprom_read(dev_addr, off, (uchar *) addr, cnt);
+		rcode = eeprom_read(dev_addr, off, (uchar *)addr, cnt);
 
-		puts ("done\n");
+		puts("done\n");
 		return rcode;
-	} else if (strcmp (argv[1], "write") == 0) {
+	} else if (strcmp(argv[1], "write") == 0) {
 		printf(fmt, dev_addr, argv[1], addr, off, cnt);
 
-		rcode = eeprom_write(dev_addr, off, (uchar *) addr, cnt);
+		rcode = eeprom_write(dev_addr, off, (uchar *)addr, cnt);
 
-		puts ("done\n");
+		puts("done\n");
 		return rcode;
 	}
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (15 preceding siblings ...)
  2015-11-10 19:53 ` [U-Boot] [PATCH 17/17] eeprom: Clean up checkpatch issues Marek Vasut
@ 2015-11-16 11:26 ` Heiko Schocher
  2015-11-22 15:53 ` [U-Boot] [U-Boot, " Tom Rini
  17 siblings, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:26 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> From: Andreas Bie?mann <andreas.devel@googlemail.com>
>
> This rewrite uses lately promoted eeprom_init(int) function to choose the
> right I2C bus when writing data to the EEPROM.
>
> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   board/corscience/tricorder/tricorder-eeprom.c | 36 +++++++--------------------
>   1 file changed, 9 insertions(+), 27 deletions(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

Thanks for this cleanup! ... eeprom code is really ugly ...

bye,
Heiko
>
> diff --git a/board/corscience/tricorder/tricorder-eeprom.c b/board/corscience/tricorder/tricorder-eeprom.c
> index 1c74a0f..340a009 100644
> --- a/board/corscience/tricorder/tricorder-eeprom.c
> +++ b/board/corscience/tricorder/tricorder-eeprom.c
> @@ -77,17 +77,13 @@ static int handle_eeprom_v1(struct tricorder_eeprom *eeprom)
>
>   int tricorder_get_eeprom(int addr, struct tricorder_eeprom *eeprom)
>   {
> -#ifdef CONFIG_SYS_EEPROM_BUS_NUM
>   	unsigned int bus = i2c_get_bus_num();
>   	i2c_set_bus_num(CONFIG_SYS_EEPROM_BUS_NUM);
> -#endif
>
>   	memset(eeprom, 0, TRICORDER_EEPROM_SIZE);
>
>   	i2c_read(addr, 0, 2, (unsigned char *)eeprom, TRICORDER_EEPROM_SIZE);
> -#ifdef CONFIG_SYS_EEPROM_BUS_NUM
>   	i2c_set_bus_num(bus);
> -#endif
>
>   	if (be32_to_cpu(eeprom->magic) != TRICORDER_EEPROM_MAGIC) {
>   		warn_wrong_value("magic", TRICORDER_EEPROM_MAGIC,
> @@ -138,9 +134,6 @@ int tricorder_eeprom_write(unsigned devaddr, const char *name,
>   	int ret;
>   	unsigned char *p;
>   	int i;
> -#ifdef CONFIG_SYS_EEPROM_BUS_NUM
> -	unsigned int bus;
> -#endif
>
>   	memset(eeprom, 0, TRICORDER_EEPROM_SIZE);
>   	memset(eeprom_verify, 0, TRICORDER_EEPROM_SIZE);
> @@ -172,33 +165,23 @@ int tricorder_eeprom_write(unsigned devaddr, const char *name,
>   	print_buffer(0, &eeprom, 1, sizeof(eeprom), 16);
>   #endif
>
> -#ifdef CONFIG_SYS_EEPROM_BUS_NUM
> -	bus = i2c_get_bus_num();
> -	i2c_set_bus_num(CONFIG_SYS_EEPROM_BUS_NUM);
> -#endif
> +	eeprom_init(CONFIG_SYS_EEPROM_BUS_NUM);
>
> -	/* do page write to the eeprom */
> -	for (i = 0, p = (unsigned char *)&eeprom;
> -	     i < sizeof(eeprom);
> -	     i += 32, p += 32) {
> -		ret = i2c_write(devaddr, i, CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
> -				p, min(sizeof(eeprom) - i, 32));
> -		if (ret)
> -			break;
> -		udelay(5000); /* 5ms write cycle timing */
> -	}
> +	ret = eeprom_write(devaddr, 0, (unsigned char *)&eeprom,
> +			TRICORDER_EEPROM_SIZE);
> +	if (ret)
> +		printf("Tricorder: Could not write EEPROM content!\n");
>
> -	ret = i2c_read(devaddr, 0, 2, (unsigned char *)&eeprom_verify,
> +	ret = eeprom_read(devaddr, 0, (unsigned char *)&eeprom_verify,
>   			TRICORDER_EEPROM_SIZE);
> +	if (ret)
> +		printf("Tricorder: Could not read EEPROM content!\n");
>
>   	if (memcmp(&eeprom, &eeprom_verify, sizeof(eeprom)) != 0) {
>   		printf("Tricorder: Could not verify EEPROM content!\n");
>   		ret = 1;
>   	}
>
> -#ifdef CONFIG_SYS_EEPROM_BUS_NUM
> -	i2c_set_bus_num(bus);
> -#endif
>   	return ret;
>   }
>
> @@ -206,7 +189,7 @@ int do_tricorder_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
>   {
>   	if (argc == 3) {
>   		ulong dev_addr = simple_strtoul(argv[2], NULL, 16);
> -		eeprom_init();
> +
>   		if (strcmp(argv[1], "read") == 0) {
>   			int rcode;
>
> @@ -220,7 +203,6 @@ int do_tricorder_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
>   		char *version = argv[4];
>   		char *serial = argv[5];
>   		char *interface = NULL;
> -		eeprom_init();
>
>   		if (argc == 7)
>   			interface = argv[6];
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 02/17] eeprom: Shuffle code around
  2015-11-10 19:53 ` [U-Boot] [PATCH 02/17] eeprom: Shuffle code around Marek Vasut
@ 2015-11-16 11:26   ` Heiko Schocher
  2015-11-22 15:53   ` [U-Boot] [U-Boot,02/17] " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:26 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Just move the code around so that the forward declarations are not
> necessary. Also zap a few checkpatch issues where applicable and
> zap the use of #ifdef CONFIG_CMD_EEPROM in the code, since this is
> always true.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 168 ++++++++++++++++++++++------------------------------
>   1 file changed, 70 insertions(+), 98 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index e9904cd..4335079 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -25,94 +25,55 @@
>   #include <command.h>
>   #include <i2c.h>
>
> -extern void eeprom_init  (void);
> -extern int  eeprom_read  (unsigned dev_addr, unsigned offset,
> -			  uchar *buffer, unsigned cnt);
> -extern int  eeprom_write (unsigned dev_addr, unsigned offset,
> -			  uchar *buffer, unsigned cnt);
> -#if defined(CONFIG_SYS_EEPROM_WREN)
> -extern int eeprom_write_enable (unsigned dev_addr, int state);
> +#ifndef	CONFIG_SYS_I2C_SPEED
> +#define	CONFIG_SYS_I2C_SPEED	50000
>   #endif
>
> -
> +/* Maximum number of times to poll for acknowledge after write */
>   #if defined(CONFIG_SYS_EEPROM_X40430)
> -	/* Maximum number of times to poll for acknowledge after write */
>   #define MAX_ACKNOWLEDGE_POLLS	10
>   #endif
>
> -/* ------------------------------------------------------------------------- */
> -
> -#if defined(CONFIG_CMD_EEPROM)
> -static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> -{
> -	const char *const fmt =
> -		"\nEEPROM @0x%lX %s: addr %08lx  off %04lx  count %ld ... ";
> -
> -#if defined(CONFIG_SYS_I2C_MULTI_EEPROMS)
> -	if (argc == 6) {
> -		ulong dev_addr = simple_strtoul (argv[2], NULL, 16);
> -		ulong addr = simple_strtoul (argv[3], NULL, 16);
> -		ulong off  = simple_strtoul (argv[4], NULL, 16);
> -		ulong cnt  = simple_strtoul (argv[5], NULL, 16);
> -#else
> -	if (argc == 5) {
> -		ulong dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
> -		ulong addr = simple_strtoul (argv[2], NULL, 16);
> -		ulong off  = simple_strtoul (argv[3], NULL, 16);
> -		ulong cnt  = simple_strtoul (argv[4], NULL, 16);
> -#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
> -
> -# if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> -		eeprom_init ();
> -# endif /* !CONFIG_SPI */
> -
> -		if (strcmp (argv[1], "read") == 0) {
> -			int rcode;
> -
> -			printf (fmt, dev_addr, argv[1], addr, off, cnt);
> -
> -			rcode = eeprom_read (dev_addr, off, (uchar *) addr, cnt);
> -
> -			puts ("done\n");
> -			return rcode;
> -		} else if (strcmp (argv[1], "write") == 0) {
> -			int rcode;
> -
> -			printf (fmt, dev_addr, argv[1], addr, off, cnt);
> -
> -			rcode = eeprom_write (dev_addr, off, (uchar *) addr, cnt);
> -
> -			puts ("done\n");
> -			return rcode;
> -		}
> -	}
> -
> -	return CMD_RET_USAGE;
> -}
> -#endif
> -
> -/*-----------------------------------------------------------------------
> - *
> +/*
>    * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
>    *   0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
>    *
>    * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 (8-bit EEPROM page address) offset is
>    *   0x00000nxx for EEPROM address selectors and page number at n.
>    */
> -
>   #if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> -#if !defined(CONFIG_SYS_I2C_EEPROM_ADDR_LEN) || CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1 || CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2
> +#if !defined(CONFIG_SYS_I2C_EEPROM_ADDR_LEN) || \
> +    (CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1) || \
> +    (CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2)
>   #error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2
>   #endif
>   #endif
>
> +#if defined(CONFIG_SYS_EEPROM_WREN)
> +extern int eeprom_write_enable (unsigned dev_addr, int state);
> +#endif
> +
> +void eeprom_init(void)
> +{
> +	/* SPI EEPROM */
> +#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> +	spi_init_f ();
> +#endif
> +
> +	/* I2C EEPROM */
> +#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
> +	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
> +#endif
> +}
> +
>   int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
>   {
>   	unsigned end = offset + cnt;
>   	unsigned blk_off;
>   	int rcode = 0;
>
> -	/* Read data until done or would cross a page boundary.
> +	/*
> +	 * Read data until done or would cross a page boundary.
>   	 * We must write the address again when changing pages
>   	 * because the next page may be in a different device.
>   	 */
> @@ -174,15 +135,6 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
>   	return rcode;
>   }
>
> -/*-----------------------------------------------------------------------
> - *
> - * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
> - *   0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
> - *
> - * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 (8-bit EEPROM page address) offset is
> - *   0x00000nxx for EEPROM address selectors and page number at n.
> - */
> -
>   int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
>   {
>   	unsigned end = offset + cnt;
> @@ -200,7 +152,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   #if defined(CONFIG_SYS_EEPROM_WREN)
>   	eeprom_write_enable (dev_addr,1);
>   #endif
> -	/* Write data until done or would cross a write page boundary.
> +	/*
> +	 * Write data until done or would cross a write page boundary.
>   	 * We must write the address again when changing pages
>   	 * because the address counter only increments within a page.
>   	 */
> @@ -363,8 +316,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   }
>
>   #if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> -int
> -eeprom_probe (unsigned dev_addr, unsigned offset)
> +int eeprom_probe(unsigned dev_addr, unsigned offset)
>   {
>   	unsigned char chip;
>
> @@ -382,30 +334,52 @@ eeprom_probe (unsigned dev_addr, unsigned offset)
>   }
>   #endif
>
> -/*-----------------------------------------------------------------------
> - * Set default values
> - */
> -#ifndef	CONFIG_SYS_I2C_SPEED
> -#define	CONFIG_SYS_I2C_SPEED	50000
> -#endif
> -
> -void eeprom_init  (void)
> +static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>   {
> +	const char *const fmt =
> +		"\nEEPROM @0x%lX %s: addr %08lx  off %04lx  count %ld ... ";
>
> -#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> -	spi_init_f ();
> -#endif
> -#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
> -	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
> -#endif
> -}
> +#if defined(CONFIG_SYS_I2C_MULTI_EEPROMS)
> +	if (argc == 6) {
> +		ulong dev_addr = simple_strtoul (argv[2], NULL, 16);
> +		ulong addr = simple_strtoul (argv[3], NULL, 16);
> +		ulong off  = simple_strtoul (argv[4], NULL, 16);
> +		ulong cnt  = simple_strtoul (argv[5], NULL, 16);
> +#else
> +	if (argc == 5) {
> +		ulong dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
> +		ulong addr = simple_strtoul (argv[2], NULL, 16);
> +		ulong off  = simple_strtoul (argv[3], NULL, 16);
> +		ulong cnt  = simple_strtoul (argv[4], NULL, 16);
> +#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
>
> -/*-----------------------------------------------------------------------
> - */
> +# if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> +		eeprom_init ();
> +# endif /* !CONFIG_SPI */
>
> -/***************************************************/
> +		if (strcmp (argv[1], "read") == 0) {
> +			int rcode;
> +
> +			printf (fmt, dev_addr, argv[1], addr, off, cnt);
>
> -#if defined(CONFIG_CMD_EEPROM)
> +			rcode = eeprom_read (dev_addr, off, (uchar *) addr, cnt);
> +
> +			puts ("done\n");
> +			return rcode;
> +		} else if (strcmp (argv[1], "write") == 0) {
> +			int rcode;
> +
> +			printf (fmt, dev_addr, argv[1], addr, off, cnt);
> +
> +			rcode = eeprom_write (dev_addr, off, (uchar *) addr, cnt);
> +
> +			puts ("done\n");
> +			return rcode;
> +		}
> +	}
> +
> +	return CMD_RET_USAGE;
> +}
>
>   #ifdef CONFIG_SYS_I2C_MULTI_EEPROMS
>   U_BOOT_CMD(
> @@ -424,5 +398,3 @@ U_BOOT_CMD(
>   	"       - read/write `cnt' bytes at EEPROM offset `off'"
>   )
>   #endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
> -
> -#endif
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 03/17] eeprom: Zap CONFIG_SYS_I2C_MULTI_EEPROMS
  2015-11-10 19:53 ` [U-Boot] [PATCH 03/17] eeprom: Zap CONFIG_SYS_I2C_MULTI_EEPROMS Marek Vasut
@ 2015-11-16 11:26   ` Heiko Schocher
  2015-11-22 15:53   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:26 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> This option only complicates the code unnecessarily, just use
> CONFIG_SYS_DEF_EEPROM_ADDR as the default address if there are
> only five arguments to eeprom {read/write} if this is defined.
> If CONFIG_SYS_DEF_EEPROM_ADDR is not defined, we mandate all
> six arguments.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c             | 69 ++++++++++++++++++-----------------------
>   include/configs/BSC9131RDB.h    |  1 -
>   include/configs/BSC9132QDS.h    |  1 -
>   include/configs/C29XPCIE.h      |  1 -
>   include/configs/P1010RDB.h      |  1 -
>   include/configs/PMC440.h        |  1 -
>   include/configs/TQM834x.h       |  1 -
>   include/configs/acadia.h        |  1 -
>   include/configs/am335x_evm.h    |  1 -
>   include/configs/am43xx_evm.h    |  1 -
>   include/configs/axs101.h        |  1 -
>   include/configs/bamboo.h        |  1 -
>   include/configs/canyonlands.h   |  1 -
>   include/configs/icon.h          |  1 -
>   include/configs/intip.h         |  1 -
>   include/configs/katmai.h        |  1 -
>   include/configs/km/km-powerpc.h |  1 -
>   include/configs/km/km_arm.h     |  1 -
>   include/configs/luan.h          |  1 -
>   include/configs/m28evk.h        |  1 -
>   include/configs/motionpro.h     |  1 -
>   include/configs/p1_p2_rdb_pc.h  |  1 -
>   include/configs/p1_twr.h        |  1 -
>   include/configs/pcm051.h        |  1 -
>   include/configs/pengwyn.h       |  1 -
>   include/configs/sequoia.h       |  1 -
>   include/configs/t3corp.h        |  1 -
>   include/configs/tricorder.h     |  1 -
>   include/configs/walnut.h        |  1 -
>   include/configs/yosemite.h      |  1 -
>   30 files changed, 30 insertions(+), 68 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 4335079..0b59bea 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -338,50 +338,50 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>   {
>   	const char *const fmt =
>   		"\nEEPROM @0x%lX %s: addr %08lx  off %04lx  count %ld ... ";
> +	char * const *args = &argv[2];
> +	int rcode;
> +	ulong dev_addr, addr, off, cnt;
> +
> +	switch (argc) {
> +#ifdef CONFIG_SYS_DEF_EEPROM_ADDR
> +	case 5:
> +		dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
> +		break;
> +#endif
> +	case 6:
> +		dev_addr = simple_strtoul(*args++, NULL, 16);
> +		break;
> +	default:
> +		return CMD_RET_USAGE;
> +	}
>
> -#if defined(CONFIG_SYS_I2C_MULTI_EEPROMS)
> -	if (argc == 6) {
> -		ulong dev_addr = simple_strtoul (argv[2], NULL, 16);
> -		ulong addr = simple_strtoul (argv[3], NULL, 16);
> -		ulong off  = simple_strtoul (argv[4], NULL, 16);
> -		ulong cnt  = simple_strtoul (argv[5], NULL, 16);
> -#else
> -	if (argc == 5) {
> -		ulong dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
> -		ulong addr = simple_strtoul (argv[2], NULL, 16);
> -		ulong off  = simple_strtoul (argv[3], NULL, 16);
> -		ulong cnt  = simple_strtoul (argv[4], NULL, 16);
> -#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
> +	addr = simple_strtoul(*args++, NULL, 16);
> +	off = simple_strtoul(*args++, NULL, 16);
> +	cnt = simple_strtoul(*args++, NULL, 16);
>
>   # if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> -		eeprom_init ();
> +	eeprom_init ();
>   # endif /* !CONFIG_SPI */
>
> -		if (strcmp (argv[1], "read") == 0) {
> -			int rcode;
> -
> -			printf (fmt, dev_addr, argv[1], addr, off, cnt);
> -
> -			rcode = eeprom_read (dev_addr, off, (uchar *) addr, cnt);
> +	if (strcmp (argv[1], "read") == 0) {
> +		printf(fmt, dev_addr, argv[1], addr, off, cnt);
>
> -			puts ("done\n");
> -			return rcode;
> -		} else if (strcmp (argv[1], "write") == 0) {
> -			int rcode;
> +		rcode = eeprom_read(dev_addr, off, (uchar *) addr, cnt);
>
> -			printf (fmt, dev_addr, argv[1], addr, off, cnt);
> +		puts ("done\n");
> +		return rcode;
> +	} else if (strcmp (argv[1], "write") == 0) {
> +		printf(fmt, dev_addr, argv[1], addr, off, cnt);
>
> -			rcode = eeprom_write (dev_addr, off, (uchar *) addr, cnt);
> +		rcode = eeprom_write(dev_addr, off, (uchar *) addr, cnt);
>
> -			puts ("done\n");
> -			return rcode;
> -		}
> +		puts ("done\n");
> +		return rcode;
>   	}
>
>   	return CMD_RET_USAGE;
>   }
>
> -#ifdef CONFIG_SYS_I2C_MULTI_EEPROMS
>   U_BOOT_CMD(
>   	eeprom,	6,	1,	do_eeprom,
>   	"EEPROM sub-system",
> @@ -389,12 +389,3 @@ U_BOOT_CMD(
>   	"eeprom write devaddr addr off cnt\n"
>   	"       - read/write `cnt' bytes from `devaddr` EEPROM at offset `off'"
>   )
> -#else /* One EEPROM */
> -U_BOOT_CMD(
> -	eeprom,	5,	1,	do_eeprom,
> -	"EEPROM sub-system",
> -	"read  addr off cnt\n"
> -	"eeprom write addr off cnt\n"
> -	"       - read/write `cnt' bytes at EEPROM offset `off'"
> -)
> -#endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
> diff --git a/include/configs/BSC9131RDB.h b/include/configs/BSC9131RDB.h
> index 2754016..193ffbc 100644
> --- a/include/configs/BSC9131RDB.h
> +++ b/include/configs/BSC9131RDB.h
> @@ -267,7 +267,6 @@ extern unsigned long get_sdram_size(void);
>
>   /* I2C EEPROM */
>   #define CONFIG_CMD_EEPROM
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
> diff --git a/include/configs/BSC9132QDS.h b/include/configs/BSC9132QDS.h
> index 54dcf3b..4b0e5f1 100644
> --- a/include/configs/BSC9132QDS.h
> +++ b/include/configs/BSC9132QDS.h
> @@ -463,7 +463,6 @@ combinations. this should be removed later
>
>   /* enable read and write access to EEPROM */
>   #define CONFIG_CMD_EEPROM
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
> diff --git a/include/configs/C29XPCIE.h b/include/configs/C29XPCIE.h
> index 94f991b..c76d05f 100644
> --- a/include/configs/C29XPCIE.h
> +++ b/include/configs/C29XPCIE.h
> @@ -420,7 +420,6 @@
>   /* I2C EEPROM */
>   /* enable read and write access to EEPROM */
>   #define CONFIG_CMD_EEPROM
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
> diff --git a/include/configs/P1010RDB.h b/include/configs/P1010RDB.h
> index 81b0855..8a137d0 100644
> --- a/include/configs/P1010RDB.h
> +++ b/include/configs/P1010RDB.h
> @@ -660,7 +660,6 @@ extern unsigned long get_sdram_size(void);
>   #endif
>   /* enable read and write access to EEPROM */
>   #define CONFIG_CMD_EEPROM
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
> diff --git a/include/configs/PMC440.h b/include/configs/PMC440.h
> index 0227649..26a1444 100644
> --- a/include/configs/PMC440.h
> +++ b/include/configs/PMC440.h
> @@ -159,7 +159,6 @@
>   #define CONFIG_SYS_I2C_PPC4XX_SPEED_1		400000
>   #define CONFIG_SYS_I2C_PPC4XX_SLAVE_1		0x7F
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>
>   #define CONFIG_SYS_I2C_EEPROM_ADDR		0x54
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		2
> diff --git a/include/configs/TQM834x.h b/include/configs/TQM834x.h
> index 0b046d1..9f6bd0f 100644
> --- a/include/configs/TQM834x.h
> +++ b/include/configs/TQM834x.h
> @@ -183,7 +183,6 @@
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		2	/* 16 bit */
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	5	/* 32 bytes/write */
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	12	/* 10ms +/- 20% */
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS		/* more than one eeprom */
>
>   /* I2C RTC */
>   #define CONFIG_RTC_DS1337			/* use ds1337 rtc via i2c */
> diff --git a/include/configs/acadia.h b/include/configs/acadia.h
> index 4dd5720..2f53d73 100644
> --- a/include/configs/acadia.h
> +++ b/include/configs/acadia.h
> @@ -120,7 +120,6 @@
>    *----------------------------------------------------------------------*/
>   #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
> diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
> index d58816d..a4b8e0f 100644
> --- a/include/configs/am335x_evm.h
> +++ b/include/configs/am335x_evm.h
> @@ -213,7 +213,6 @@
>   #define CONFIG_ENV_EEPROM_IS_ON_I2C
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* Main EEPROM */
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>
>   /* PMIC support */
>   #define CONFIG_POWER_TPS65217
> diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h
> index d93e3e7..5821137 100644
> --- a/include/configs/am43xx_evm.h
> +++ b/include/configs/am43xx_evm.h
> @@ -36,7 +36,6 @@
>   #define CONFIG_ENV_EEPROM_IS_ON_I2C
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* Main EEPROM */
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>
>   /* Power */
>   #define CONFIG_POWER
> diff --git a/include/configs/axs101.h b/include/configs/axs101.h
> index 450291c..e921f19 100644
> --- a/include/configs/axs101.h
> +++ b/include/configs/axs101.h
> @@ -91,7 +91,6 @@
>   /*
>    * EEPROM configuration
>    */
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR		(0xA8 >> 1)
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW	1
> diff --git a/include/configs/bamboo.h b/include/configs/bamboo.h
> index 6ba4aaf..5b8b22f 100644
> --- a/include/configs/bamboo.h
> +++ b/include/configs/bamboo.h
> @@ -139,7 +139,6 @@
>    *----------------------------------------------------------------------*/
>   #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
> diff --git a/include/configs/canyonlands.h b/include/configs/canyonlands.h
> index ed790cc..e136824 100644
> --- a/include/configs/canyonlands.h
> +++ b/include/configs/canyonlands.h
> @@ -248,7 +248,6 @@
>    *----------------------------------------------------------------------*/
>   #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR		(0xa8>>1)
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	3
> diff --git a/include/configs/icon.h b/include/configs/icon.h
> index bbe9b59..d9a3671 100644
> --- a/include/configs/icon.h
> +++ b/include/configs/icon.h
> @@ -107,7 +107,6 @@
>
>   #define CONFIG_SYS_SPD_BUS_NUM	0	/* The I2C bus for SPD		*/
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
> diff --git a/include/configs/intip.h b/include/configs/intip.h
> index a676a20..60c9e2c 100644
> --- a/include/configs/intip.h
> +++ b/include/configs/intip.h
> @@ -214,7 +214,6 @@
>    */
>   #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR		(0xa8>>1)
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	3
> diff --git a/include/configs/katmai.h b/include/configs/katmai.h
> index fa72eb0..664896b 100644
> --- a/include/configs/katmai.h
> +++ b/include/configs/katmai.h
> @@ -109,7 +109,6 @@
>   #define IIC0_BOOTPROM_ADDR	0x50
>   #define IIC0_ALT_BOOTPROM_ADDR	0x54
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	(0x50)
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
> diff --git a/include/configs/km/km-powerpc.h b/include/configs/km/km-powerpc.h
> index eb85a74..2b0b9dc 100644
> --- a/include/configs/km/km-powerpc.h
> +++ b/include/configs/km/km-powerpc.h
> @@ -21,7 +21,6 @@
>   #define CONFIG_KM_COMMON_ETH_INIT
>
>   /* EEprom support 24C08, 24C16, 24C64 */
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	3  /* 8 Byte write page */
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	10
> diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h
> index b89af53..798c9a7 100644
> --- a/include/configs/km/km_arm.h
> +++ b/include/configs/km/km_arm.h
> @@ -215,7 +215,6 @@ int get_scl(void);
>   #define	CONFIG_SYS_I2C_SOFT_SPEED	100000
>
>   /* EEprom support 24C128, 24C256 valid for environment eeprom */
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	6 /* 64 Byte write page */
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	10
> diff --git a/include/configs/luan.h b/include/configs/luan.h
> index 15e4a7e..e22d0e8 100644
> --- a/include/configs/luan.h
> +++ b/include/configs/luan.h
> @@ -119,7 +119,6 @@
>    *----------------------------------------------------------------------*/
>   #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
> diff --git a/include/configs/m28evk.h b/include/configs/m28evk.h
> index 29c60b7..f9fc66f 100644
> --- a/include/configs/m28evk.h
> +++ b/include/configs/m28evk.h
> @@ -92,7 +92,6 @@
>
>   /* EEPROM */
>   #ifdef CONFIG_CMD_EEPROM
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
>   #endif
>
> diff --git a/include/configs/motionpro.h b/include/configs/motionpro.h
> index 97c614b..a8cf201 100644
> --- a/include/configs/motionpro.h
> +++ b/include/configs/motionpro.h
> @@ -285,7 +285,6 @@
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	1	/* 2 bytes per write cycle */
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	5	/* 2ms/cycle + 3ms extra */
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS		1	/* 2 EEPROMs (addr:50,52) */
>
>   /*
>    * RTC configuration
> diff --git a/include/configs/p1_p2_rdb_pc.h b/include/configs/p1_p2_rdb_pc.h
> index 433c409..e039af4 100644
> --- a/include/configs/p1_p2_rdb_pc.h
> +++ b/include/configs/p1_p2_rdb_pc.h
> @@ -701,7 +701,6 @@
>
>   /* enable read and write access to EEPROM */
>   #define CONFIG_CMD_EEPROM
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
> diff --git a/include/configs/p1_twr.h b/include/configs/p1_twr.h
> index d83daa0..3089969 100644
> --- a/include/configs/p1_twr.h
> +++ b/include/configs/p1_twr.h
> @@ -262,7 +262,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
>
>   /* enable read and write access to EEPROM */
>   #define CONFIG_CMD_EEPROM
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 5
> diff --git a/include/configs/pcm051.h b/include/configs/pcm051.h
> index 275e952..64cfd81 100644
> --- a/include/configs/pcm051.h
> +++ b/include/configs/pcm051.h
> @@ -115,7 +115,6 @@
>   #define CONFIG_ENV_EEPROM_IS_ON_I2C
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50	/* Main EEPROM */
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>
>   #define CONFIG_SYS_BAUDRATE_TABLE	{ 110, 300, 600, 1200, 2400, \
>   4800, 9600, 14400, 19200, 28800, 38400, 56000, 57600, 115200 }
> diff --git a/include/configs/pengwyn.h b/include/configs/pengwyn.h
> index ccb5dd3..b057539 100644
> --- a/include/configs/pengwyn.h
> +++ b/include/configs/pengwyn.h
> @@ -112,7 +112,6 @@
>   #define CONFIG_ENV_EEPROM_IS_ON_I2C
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>
>   /* SPL */
>   #define CONFIG_SPL_POWER_SUPPORT
> diff --git a/include/configs/sequoia.h b/include/configs/sequoia.h
> index 1f1beea..f32459b 100644
> --- a/include/configs/sequoia.h
> +++ b/include/configs/sequoia.h
> @@ -151,7 +151,6 @@
>    */
>   #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
> diff --git a/include/configs/t3corp.h b/include/configs/t3corp.h
> index 502e795..7942865 100644
> --- a/include/configs/t3corp.h
> +++ b/include/configs/t3corp.h
> @@ -307,7 +307,6 @@
>    */
>   #define CONFIG_SYS_I2C_PPC4XX_SPEED_0			400000
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR		(0xa8>>1)
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	3
> diff --git a/include/configs/tricorder.h b/include/configs/tricorder.h
> index 02b0e63..e453151 100644
> --- a/include/configs/tricorder.h
> +++ b/include/configs/tricorder.h
> @@ -112,7 +112,6 @@
>
>
>   /* EEPROM */
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_CMD_EEPROM
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
>   #define CONFIG_SYS_EEPROM_BUS_NUM	1
> diff --git a/include/configs/walnut.h b/include/configs/walnut.h
> index 8b803a2..dd6b519 100644
> --- a/include/configs/walnut.h
> +++ b/include/configs/walnut.h
> @@ -80,7 +80,6 @@
>    */
>   #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
> diff --git a/include/configs/yosemite.h b/include/configs/yosemite.h
> index 8508a80..0cffab8 100644
> --- a/include/configs/yosemite.h
> +++ b/include/configs/yosemite.h
> @@ -122,7 +122,6 @@
>    *----------------------------------------------------------------------*/
>   #define CONFIG_SYS_I2C_PPC4XX_SPEED_0		400000
>
> -#define CONFIG_SYS_I2C_MULTI_EEPROMS
>   #define CONFIG_SYS_I2C_EEPROM_ADDR	(0xa8>>1)
>   #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 04/17] eeprom: Zap CONFIG_SYS_EEPROM_X40430
  2015-11-10 19:53 ` [U-Boot] [PATCH 04/17] eeprom: Zap CONFIG_SYS_EEPROM_X40430 Marek Vasut
@ 2015-11-16 11:27   ` Heiko Schocher
  2015-11-22 15:53   ` [U-Boot] [U-Boot,04/17] " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:27 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Now that the only user of CONFIG_SYS_EEPROM_X40430 was removed,
> remove this unused code from cmd_eeprom.c
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 94 -----------------------------------------------------
>   1 file changed, 94 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 0b59bea..266f954 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -29,11 +29,6 @@
>   #define	CONFIG_SYS_I2C_SPEED	50000
>   #endif
>
> -/* Maximum number of times to poll for acknowledge after write */
> -#if defined(CONFIG_SYS_EEPROM_X40430)
> -#define MAX_ACKNOWLEDGE_POLLS	10
> -#endif
> -
>   /*
>    * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
>    *   0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
> @@ -141,14 +136,6 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   	unsigned blk_off;
>   	int rcode = 0;
>
> -#if defined(CONFIG_SYS_EEPROM_X40430)
> -	uchar	contr_r_addr[2];
> -	uchar	addr_void[2];
> -	uchar	contr_reg[2];
> -	uchar	ctrl_reg_v;
> -	int	i;
> -#endif
> -
>   #if defined(CONFIG_SYS_EEPROM_WREN)
>   	eeprom_write_enable (dev_addr,1);
>   #endif
> @@ -213,88 +200,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   #if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
>   		spi_write (addr, alen, buffer, len);
>   #else
> -#if defined(CONFIG_SYS_EEPROM_X40430)
> -		/* Get the value of the control register.
> -		 * Set current address (internal pointer in the x40430)
> -		 * to 0x1ff.
> -		 */
> -		contr_r_addr[0] = 9;
> -		contr_r_addr[1] = 0xff;
> -		addr_void[0]    = 0;
> -		addr_void[1]    = addr[1];
> -#ifdef CONFIG_SYS_I2C_EEPROM_ADDR
> -		contr_r_addr[0] |= CONFIG_SYS_I2C_EEPROM_ADDR;
> -		addr_void[0]    |= CONFIG_SYS_I2C_EEPROM_ADDR;
> -#endif
> -		contr_reg[0] = 0xff;
> -		if (i2c_read (contr_r_addr[0], contr_r_addr[1], 1, contr_reg, 1) != 0) {
> -			rcode = 1;
> -		}
> -		ctrl_reg_v = contr_reg[0];
>
> -		/* Are any of the eeprom blocks write protected?
> -		 */
> -		if (ctrl_reg_v & 0x18) {
> -			ctrl_reg_v &= ~0x18;   /* reset block protect bits  */
> -			ctrl_reg_v |=  0x02;   /* set write enable latch    */
> -			ctrl_reg_v &= ~0x04;   /* clear RWEL                */
> -
> -			/* Set write enable latch.
> -			 */
> -			contr_reg[0] = 0x02;
> -			if (i2c_write (contr_r_addr[0], 0xff, 1, contr_reg, 1) != 0) {
> -				rcode = 1;
> -			}
> -
> -			/* Set register write enable latch.
> -			 */
> -			contr_reg[0] = 0x06;
> -			if (i2c_write (contr_r_addr[0], 0xFF, 1, contr_reg, 1) != 0) {
> -				rcode = 1;
> -			}
> -
> -			/* Modify ctrl register.
> -			 */
> -			contr_reg[0] = ctrl_reg_v;
> -			if (i2c_write (contr_r_addr[0], 0xFF, 1, contr_reg, 1) != 0) {
> -				rcode = 1;
> -			}
> -
> -			/* The write (above) is an operation on NV memory.
> -			 * These can take some time (~5ms), and the device
> -			 * will not respond to further I2C messages till
> -			 * it's completed the write.
> -			 * So poll device for an I2C acknowledge.
> -			 * When we get one we know we can continue with other
> -			 * operations.
> -			 */
> -			contr_reg[0] = 0;
> -			for (i = 0; i < MAX_ACKNOWLEDGE_POLLS; i++) {
> -				if (i2c_read (addr_void[0], addr_void[1], 1, contr_reg, 1) == 0)
> -					break;	/* got ack */
> -#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS)
> -				udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
> -#endif
> -			}
> -			if (i == MAX_ACKNOWLEDGE_POLLS) {
> -				puts ("EEPROM poll acknowledge failed\n");
> -				rcode = 1;
> -			}
> -		}
> -
> -		/* Is the write enable latch on?.
> -		 */
> -		else if (!(ctrl_reg_v & 0x02)) {
> -			/* Set write enable latch.
> -			 */
> -			contr_reg[0] = 0x02;
> -			if (i2c_write (contr_r_addr[0], 0xFF, 1, contr_reg, 1) != 0) {
> -			       rcode = 1;
> -			}
> -		}
> -		/* Write is enabled ... now write eeprom value.
> -		 */
> -#endif
>   #if defined(CONFIG_SYS_I2C_EEPROM_BUS)
>   		i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS);
>   #endif
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 05/17] eeprom: Zap eeprom_probe()
  2015-11-10 19:53 ` [U-Boot] [PATCH 05/17] eeprom: Zap eeprom_probe() Marek Vasut
@ 2015-11-16 11:27   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot,05/17] " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:27 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Remove this function as it's no longer used.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 19 -------------------
>   include/common.h    |  3 ---
>   2 files changed, 22 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 266f954..ea1d447 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -221,25 +221,6 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   	return rcode;
>   }
>
> -#if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> -int eeprom_probe(unsigned dev_addr, unsigned offset)
> -{
> -	unsigned char chip;
> -
> -	/* Probe the chip address
> -	 */
> -#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X)
> -	chip = offset >> 8;		/* block number */
> -#else
> -	chip = offset >> 16;		/* block number */
> -#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */
> -
> -	chip |= dev_addr;		/* insert device address */
> -
> -	return (i2c_probe (chip));
> -}
> -#endif
> -
>   static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>   {
>   	const char *const fmt =
> diff --git a/include/common.h b/include/common.h
> index 09a131d..ceb1ad3 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -476,9 +476,6 @@ void	fdc_hw_init   (void);
>
>   /* $(BOARD)/eeprom.c */
>   void eeprom_init  (void);
> -#ifndef CONFIG_SPI
> -int  eeprom_probe (unsigned dev_addr, unsigned offset);
> -#endif
>   int  eeprom_read  (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
>   int  eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
>
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 06/17] eeprom: Zap CONFIG_SPI_X
  2015-11-10 19:53 ` [U-Boot] [PATCH 06/17] eeprom: Zap CONFIG_SPI_X Marek Vasut
@ 2015-11-16 11:27   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot,06/17] " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:27 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> This macro is no longer used, so just reap it.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   README              | 5 -----
>   common/cmd_eeprom.c | 8 ++++----
>   2 files changed, 4 insertions(+), 9 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/README b/README
> index ef8d437..8fb81e9 100644
> --- a/README
> +++ b/README
> @@ -2705,11 +2705,6 @@ CBFS (Coreboot Filesystem) support
>   		Enables the driver for SPI controller on SuperH. Currently
>   		only SH7757 is supported.
>
> -		CONFIG_SPI_X
> -
> -		Enables extended (16-bit) SPI EEPROM addressing.
> -		(symmetrical to CONFIG_I2C_X)
> -
>   		CONFIG_SOFT_SPI
>
>   		Enables a software (bit-bang) SPI driver rather than
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index ea1d447..728606e 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -78,7 +78,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
>   		unsigned maxlen;
>   #endif
>
> -#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X)
> +#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1
>   		uchar addr[2];
>
>   		blk_off = offset & 0xFF;	/* block offset */
> @@ -95,7 +95,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
>   		addr[1] = offset >>  8;		/* upper address octet */
>   		addr[2] = blk_off;		/* lower address octet */
>   		alen	= 3;
> -#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */
> +#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */
>
>   		addr[0] |= dev_addr;		/* insert device address */
>
> @@ -151,7 +151,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   		unsigned maxlen;
>   #endif
>
> -#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X)
> +#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1
>   		uchar addr[2];
>
>   		blk_off = offset & 0xFF;	/* block offset */
> @@ -168,7 +168,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   		addr[1] = offset >>  8;		/* upper address octet */
>   		addr[2] = blk_off;		/* lower address octet */
>   		alen	= 3;
> -#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */
> +#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */
>
>   		addr[0] |= dev_addr;		/* insert device address */
>
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 07/17] eeprom: Pull out the I/O code
  2015-11-10 19:53 ` [U-Boot] [PATCH 07/17] eeprom: Pull out the I/O code Marek Vasut
@ 2015-11-16 11:27   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot,07/17] " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:27 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Pull out the code which does the I2C or SPI read/write, so that
> the beefy ifdef around it is contained in a single function.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 50 +++++++++++++++++++++++++++++++-------------------
>   1 file changed, 31 insertions(+), 19 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 728606e..7797d0e 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -61,6 +61,34 @@ void eeprom_init(void)
>   #endif
>   }
>
> +static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
> +			   uchar *buffer, unsigned len, bool read)
> +{
> +	int ret = 0;
> +
> +	/* SPI */
> +#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> +	if (read)
> +		spi_read(addr, alen, buffer, len);
> +	else
> +		spi_write(addr, alen, buffer, len);
> +#else	/* I2C */
> +
> +#if defined(CONFIG_SYS_I2C_EEPROM_BUS)
> +	i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS);
> +#endif
> +
> +	if (read)
> +		ret = i2c_read(addr[0], offset, alen - 1, buffer, len);
> +	else
> +		ret = i2c_write(addr[0], offset, alen - 1, buffer, len);
> +
> +	if (ret)
> +		ret = 1;
> +#endif
> +	return ret;
> +}
> +
>   int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
>   {
>   	unsigned end = offset + cnt;
> @@ -114,15 +142,8 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
>   			len = maxlen;
>   #endif
>
> -#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> -		spi_read (addr, alen, buffer, len);
> -#else
> -#if defined(CONFIG_SYS_I2C_EEPROM_BUS)
> -		i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS);
> -#endif
> -		if (i2c_read(addr[0], offset, alen - 1, buffer, len))
> -			rcode = 1;
> -#endif
> +		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 1);
> +
>   		buffer += len;
>   		offset += len;
>   	}
> @@ -197,17 +218,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   			len = maxlen;
>   #endif
>
> -#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> -		spi_write (addr, alen, buffer, len);
> -#else
> +		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 0);
>
> -#if defined(CONFIG_SYS_I2C_EEPROM_BUS)
> -		i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS);
> -#endif
> -		if (i2c_write(addr[0], offset, alen - 1, buffer, len))
> -			rcode = 1;
> -
> -#endif
>   		buffer += len;
>   		offset += len;
>
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 08/17] eeprom: Pull out address computation
  2015-11-10 19:53 ` [U-Boot] [PATCH 08/17] eeprom: Pull out address computation Marek Vasut
@ 2015-11-16 11:28   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot,08/17] " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:28 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Pull out the code computing the EEPROM address into separate function
> so that it's not duplicated.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 64 ++++++++++++++++++++++-------------------------------
>   1 file changed, 26 insertions(+), 38 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 7797d0e..5979993 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -61,6 +61,28 @@ void eeprom_init(void)
>   #endif
>   }
>
> +static int eeprom_addr(unsigned dev_addr, unsigned offset, uchar *addr)
> +{
> +	unsigned blk_off;
> +	int alen;
> +
> +	blk_off = offset & 0xff;	/* block offset */
> +#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1
> +	addr[0] = offset >> 8;		/* block number */
> +	addr[1] = blk_off;		/* block offset */
> +	alen = 2;
> +#else
> +	addr[0] = offset >> 16;		/* block number */
> +	addr[1] = offset >>  8;		/* upper address octet */
> +	addr[2] = blk_off;		/* lower address octet */
> +	alen = 3;
> +#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */
> +
> +	addr[0] |= dev_addr;		/* insert device address */
> +
> +	return alen;
> +}
> +
>   static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
>   			   uchar *buffer, unsigned len, bool read)
>   {
> @@ -94,6 +116,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
>   	unsigned end = offset + cnt;
>   	unsigned blk_off;
>   	int rcode = 0;
> +	uchar addr[3];
>
>   	/*
>   	 * Read data until done or would cross a page boundary.
> @@ -106,26 +129,8 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
>   		unsigned maxlen;
>   #endif
>
> -#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1
> -		uchar addr[2];
> -
> -		blk_off = offset & 0xFF;	/* block offset */
> -
> -		addr[0] = offset >> 8;		/* block number */
> -		addr[1] = blk_off;		/* block offset */
> -		alen	= 2;
> -#else
> -		uchar addr[3];
> -
>   		blk_off = offset & 0xFF;	/* block offset */
> -
> -		addr[0] = offset >> 16;		/* block number */
> -		addr[1] = offset >>  8;		/* upper address octet */
> -		addr[2] = blk_off;		/* lower address octet */
> -		alen	= 3;
> -#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */
> -
> -		addr[0] |= dev_addr;		/* insert device address */
> +		alen = eeprom_addr(dev_addr, offset, addr);
>
>   		len = end - offset;
>
> @@ -156,6 +161,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   	unsigned end = offset + cnt;
>   	unsigned blk_off;
>   	int rcode = 0;
> +	uchar addr[3];
>
>   #if defined(CONFIG_SYS_EEPROM_WREN)
>   	eeprom_write_enable (dev_addr,1);
> @@ -172,26 +178,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   		unsigned maxlen;
>   #endif
>
> -#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1
> -		uchar addr[2];
> -
>   		blk_off = offset & 0xFF;	/* block offset */
> -
> -		addr[0] = offset >> 8;		/* block number */
> -		addr[1] = blk_off;		/* block offset */
> -		alen	= 2;
> -#else
> -		uchar addr[3];
> -
> -		blk_off = offset & 0xFF;	/* block offset */
> -
> -		addr[0] = offset >> 16;		/* block number */
> -		addr[1] = offset >>  8;		/* upper address octet */
> -		addr[2] = blk_off;		/* lower address octet */
> -		alen	= 3;
> -#endif	/* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */
> -
> -		addr[0] |= dev_addr;		/* insert device address */
> +		alen = eeprom_addr(dev_addr, offset, addr);
>
>   		len = end - offset;
>
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 09/17] eeprom: Make eeprom_write_enable() weak
  2015-11-10 19:53 ` [U-Boot] [PATCH 09/17] eeprom: Make eeprom_write_enable() weak Marek Vasut
@ 2015-11-16 11:28   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:28 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Make this function weak and implement it's weak implementation
> so that the boards can just reimplement it. This zaps the horrid
> CONFIG_SYS_EEPROM_WREN macro.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 5979993..040ab5f 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -44,9 +44,10 @@
>   #endif
>   #endif
>
> -#if defined(CONFIG_SYS_EEPROM_WREN)
> -extern int eeprom_write_enable (unsigned dev_addr, int state);
> -#endif
> +__weak int eeprom_write_enable(unsigned dev_addr, int state)
> +{
> +	return 0;
> +}
>
>   void eeprom_init(void)
>   {
> @@ -163,9 +164,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   	int rcode = 0;
>   	uchar addr[3];
>
> -#if defined(CONFIG_SYS_EEPROM_WREN)
> -	eeprom_write_enable (dev_addr,1);
> -#endif
> +	eeprom_write_enable(dev_addr, 1);
> +
>   	/*
>   	 * Write data until done or would cross a write page boundary.
>   	 * We must write the address again when changing pages
> @@ -215,9 +215,9 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   		udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
>   #endif
>   	}
> -#if defined(CONFIG_SYS_EEPROM_WREN)
> -	eeprom_write_enable (dev_addr,0);
> -#endif
> +
> +	eeprom_write_enable(dev_addr, 0);
> +
>   	return rcode;
>   }
>
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 10/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS
  2015-11-10 19:53 ` [U-Boot] [PATCH 10/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS Marek Vasut
@ 2015-11-16 11:28   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:28 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Pull this macro to the beginning of the cmd_eeprom.c and remove
> another nasty ifdef from the code. Note that this is legal, since
> udelay(0) changes the behavior only such that it pings the WDT if
> WDT is enabled and otherwise does not wait.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 040ab5f..8451d63 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -29,6 +29,10 @@
>   #define	CONFIG_SYS_I2C_SPEED	50000
>   #endif
>
> +#ifndef CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS
> +#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	0
> +#endif
> +
>   /*
>    * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
>    *   0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
> @@ -211,9 +215,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   		buffer += len;
>   		offset += len;
>
> -#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS)
>   		udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
> -#endif
>   	}
>
>   	eeprom_write_enable(dev_addr, 0);
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 11/17] eeprom: Suck the ifdef into eeprom_init()
  2015-11-10 19:53 ` [U-Boot] [PATCH 11/17] eeprom: Suck the ifdef into eeprom_init() Marek Vasut
@ 2015-11-16 11:28   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:28 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Just suck the ugly ifdef around eeprom_init() call into eeprom_init()
> function itself. This puts all of the ifdef mess into one place.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 8451d63..c38c534 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -57,7 +57,7 @@ void eeprom_init(void)
>   {
>   	/* SPI EEPROM */
>   #if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> -	spi_init_f ();
> +	spi_init_f();
>   #endif
>
>   	/* I2C EEPROM */
> @@ -248,9 +248,7 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>   	off = simple_strtoul(*args++, NULL, 16);
>   	cnt = simple_strtoul(*args++, NULL, 16);
>
> -# if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> -	eeprom_init ();
> -# endif /* !CONFIG_SPI */
> +	eeprom_init();
>
>   	if (strcmp (argv[1], "read") == 0) {
>   		printf(fmt, dev_addr, argv[1], addr, off, cnt);
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 12/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_BITS
  2015-11-10 19:53 ` [U-Boot] [PATCH 12/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_BITS Marek Vasut
@ 2015-11-16 11:29   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:29 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Implement default value of 8 for this macro and pull out all of
> this macro out of the code. The default value of 8 actually does
> implement exactly the same behavior as the previous code which
> was in the #else clause of the ifdef.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index c38c534..162a05c 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -33,6 +33,13 @@
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	0
>   #endif
>
> +#ifndef CONFIG_SYS_EEPROM_PAGE_WRITE_BITS
> +#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	8
> +#endif
> +
> +#define	EEPROM_PAGE_SIZE	(1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
> +#define	EEPROM_PAGE_OFFSET(x)	((x) & (EEPROM_PAGE_SIZE - 1))
> +
>   /*
>    * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
>    *   0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
> @@ -194,15 +201,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   		 */
>   #if !defined(CONFIG_SYS_I2C_FRAM)
>
> -#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
> -
> -#define	EEPROM_PAGE_SIZE	(1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
> -#define	EEPROM_PAGE_OFFSET(x)	((x) & (EEPROM_PAGE_SIZE - 1))
> -
>   		maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off);
> -#else
> -		maxlen = 0x100 - blk_off;
> -#endif
> +
>   		if (maxlen > I2C_RXTX_LEN)
>   			maxlen = I2C_RXTX_LEN;
>
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 13/17] eeprom: Pull out transfer length computation
  2015-11-10 19:53 ` [U-Boot] [PATCH 13/17] eeprom: Pull out transfer length computation Marek Vasut
@ 2015-11-16 11:31   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:31 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Pull out the code which computes the length of the transfer
> into separate code and clean it up a little. This again trims
> down the code duplication.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 66 ++++++++++++++++++++---------------------------------
>   1 file changed, 25 insertions(+), 41 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 162a05c..b39ca5d 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -95,6 +95,29 @@ static int eeprom_addr(unsigned dev_addr, unsigned offset, uchar *addr)
>   	return alen;
>   }
>
> +static int eeprom_len(unsigned offset, unsigned end)
> +{
> +	unsigned len = end - offset;
> +
> +	/*
> +	 * For a FRAM device there is no limit on the number of the
> +	 * bytes that can be ccessed with the single read or write
> +	 * operation.
> +	 */
> +#if !defined(CONFIG_SYS_I2C_FRAM)
> +	unsigned blk_off = offset & 0xff;
> +	unsigned maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off);
> +
> +	if (maxlen > I2C_RXTX_LEN)
> +		maxlen = I2C_RXTX_LEN;
> +
> +	if (len > maxlen)
> +		len = maxlen;
> +#endif
> +
> +	return len;
> +}
> +
>   static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
>   			   uchar *buffer, unsigned len, bool read)
>   {
> @@ -126,7 +149,6 @@ static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
>   int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
>   {
>   	unsigned end = offset + cnt;
> -	unsigned blk_off;
>   	int rcode = 0;
>   	uchar addr[3];
>
> @@ -137,27 +159,10 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
>   	 */
>   	while (offset < end) {
>   		unsigned alen, len;
> -#if !defined(CONFIG_SYS_I2C_FRAM)
> -		unsigned maxlen;
> -#endif
>
> -		blk_off = offset & 0xFF;	/* block offset */
>   		alen = eeprom_addr(dev_addr, offset, addr);
>
> -		len = end - offset;
> -
> -		/*
> -		 * For a FRAM device there is no limit on the number of the
> -		 * bytes that can be ccessed with the single read or write
> -		 * operation.
> -		 */
> -#if !defined(CONFIG_SYS_I2C_FRAM)
> -		maxlen = 0x100 - blk_off;
> -		if (maxlen > I2C_RXTX_LEN)
> -			maxlen = I2C_RXTX_LEN;
> -		if (len > maxlen)
> -			len = maxlen;
> -#endif
> +		len = eeprom_len(offset, end);
>
>   		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 1);
>
> @@ -171,7 +176,6 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
>   int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
>   {
>   	unsigned end = offset + cnt;
> -	unsigned blk_off;
>   	int rcode = 0;
>   	uchar addr[3];
>
> @@ -185,30 +189,10 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>
>   	while (offset < end) {
>   		unsigned alen, len;
> -#if !defined(CONFIG_SYS_I2C_FRAM)
> -		unsigned maxlen;
> -#endif
>
> -		blk_off = offset & 0xFF;	/* block offset */
>   		alen = eeprom_addr(dev_addr, offset, addr);
>
> -		len = end - offset;
> -
> -		/*
> -		 * For a FRAM device there is no limit on the number of the
> -		 * bytes that can be accessed with the single read or write
> -		 * operation.
> -		 */
> -#if !defined(CONFIG_SYS_I2C_FRAM)
> -
> -		maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off);
> -
> -		if (maxlen > I2C_RXTX_LEN)
> -			maxlen = I2C_RXTX_LEN;
> -
> -		if (len > maxlen)
> -			len = maxlen;
> -#endif
> +		len = eeprom_len(offset, end);
>
>   		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 0);
>
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 14/17] eeprom: Pull out the RW loop
  2015-11-10 19:53 ` [U-Boot] [PATCH 14/17] eeprom: Pull out the RW loop Marek Vasut
@ 2015-11-16 11:31   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot,14/17] " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:31 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Unify the code for doing read/write into single function, since the
> code for both the read and write is almost identical. This again
> trims down the code duplication.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 51 +++++++++++++++++++++------------------------------
>   1 file changed, 21 insertions(+), 30 deletions(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index b39ca5d..d0942ef 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -146,38 +146,44 @@ static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
>   	return ret;
>   }
>
> -int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
> +static int eeprom_rw(unsigned dev_addr, unsigned offset, uchar *buffer,
> +		     unsigned cnt, bool read)
>   {
>   	unsigned end = offset + cnt;
> +	unsigned alen, len;
>   	int rcode = 0;
>   	uchar addr[3];
>
> -	/*
> -	 * Read data until done or would cross a page boundary.
> -	 * We must write the address again when changing pages
> -	 * because the next page may be in a different device.
> -	 */
>   	while (offset < end) {
> -		unsigned alen, len;
> -
>   		alen = eeprom_addr(dev_addr, offset, addr);
>
>   		len = eeprom_len(offset, end);
>
> -		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 1);
> +		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, read);
>
>   		buffer += len;
>   		offset += len;
> +
> +		if (!read)
> +			udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
>   	}
>
>   	return rcode;
>   }
>
> -int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
> +int eeprom_read(unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
>   {
> -	unsigned end = offset + cnt;
> -	int rcode = 0;
> -	uchar addr[3];
> +	/*
> +	 * Read data until done or would cross a page boundary.
> +	 * We must write the address again when changing pages
> +	 * because the next page may be in a different device.
> +	 */
> +	return eeprom_rw(dev_addr, offset, buffer, cnt, 1);
> +}
> +
> +int eeprom_write(unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
> +{
> +	int ret;
>
>   	eeprom_write_enable(dev_addr, 1);
>
> @@ -186,25 +192,10 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   	 * We must write the address again when changing pages
>   	 * because the address counter only increments within a page.
>   	 */
> -
> -	while (offset < end) {
> -		unsigned alen, len;
> -
> -		alen = eeprom_addr(dev_addr, offset, addr);
> -
> -		len = eeprom_len(offset, end);
> -
> -		rcode = eeprom_rw_block(offset, addr, alen, buffer, len, 0);
> -
> -		buffer += len;
> -		offset += len;
> -
> -		udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
> -	}
> +	ret = eeprom_rw(dev_addr, offset, buffer, cnt, 1);
>
>   	eeprom_write_enable(dev_addr, 0);
> -
> -	return rcode;
> +	return ret;
>   }
>
>   static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 15/17] eeprom: Add bus argument to eeprom_init()
  2015-11-10 19:53 ` [U-Boot] [PATCH 15/17] eeprom: Add bus argument to eeprom_init() Marek Vasut
@ 2015-11-16 11:32   ` Heiko Schocher
  2015-11-21 13:48     ` Tom Rini
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 1 reply; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:32 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Add bus argument to eeprom_init(), so that it can select
> the I2C bus number on which the eeprom resides. Any negative
> value of the $bus argument will preserve the old behavior.
> This is in place so that old code does not randomly break.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 6 ++++--
>   common/env_eeprom.c | 4 ++--
>   include/common.h    | 2 +-
>   3 files changed, 7 insertions(+), 5 deletions(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index d0942ef..9247036 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -60,7 +60,7 @@ __weak int eeprom_write_enable(unsigned dev_addr, int state)
>   	return 0;
>   }
>
> -void eeprom_init(void)
> +void eeprom_init(int bus)
>   {
>   	/* SPI EEPROM */
>   #if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
> @@ -69,6 +69,8 @@ void eeprom_init(void)
>
>   	/* I2C EEPROM */
>   #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
> +	if (bus >= 0)
> +		i2c_set_bus_num(bus);
>   	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
>   #endif
>   }
> @@ -223,7 +225,7 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>   	off = simple_strtoul(*args++, NULL, 16);
>   	cnt = simple_strtoul(*args++, NULL, 16);
>
> -	eeprom_init();
> +	eeprom_init(-1);
>
>   	if (strcmp (argv[1], "read") == 0) {
>   		printf(fmt, dev_addr, argv[1], addr, off, cnt);
> diff --git a/common/env_eeprom.c b/common/env_eeprom.c
> index eea169d..72b1373 100644
> --- a/common/env_eeprom.c
> +++ b/common/env_eeprom.c
> @@ -91,7 +91,7 @@ void env_relocate_spec(void)
>   	uchar rdbuf[64], flags[2];
>   	int i, crc_ok[2] = {0, 0};
>
> -	eeprom_init();	/* prepare for EEPROM read/write */
> +	eeprom_init(-1);	/* prepare for EEPROM read/write */
>
>   	off_env[0] = CONFIG_ENV_OFFSET;
>   	off_env[1] = CONFIG_ENV_OFFSET_REDUND;
> @@ -154,7 +154,7 @@ void env_relocate_spec(void)
>   	ulong crc, len, new;
>   	uchar rdbuf[64];
>
> -	eeprom_init();	/* prepare for EEPROM read/write */
> +	eeprom_init(-1);	/* prepare for EEPROM read/write */
>
>   	/* read old CRC */
>   	eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR,
> diff --git a/include/common.h b/include/common.h
> index ceb1ad3..39ba5c9 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -475,7 +475,7 @@ void	reset_phy     (void);
>   void	fdc_hw_init   (void);
>
>   /* $(BOARD)/eeprom.c */
> -void eeprom_init  (void);
> +void eeprom_init  (int bus);
>   int  eeprom_read  (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
>   int  eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
>
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 16/17] eeprom: Add support for selecting i2c bus
  2015-11-10 19:53 ` [U-Boot] [PATCH 16/17] eeprom: Add support for selecting i2c bus Marek Vasut
@ 2015-11-16 11:32   ` Heiko Schocher
  2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:32 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Add additional parameter into the eeprom command to select
> the I2C bus on which the eeprom resides.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 15 +++++++++++----
>   1 file changed, 11 insertions(+), 4 deletions(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 9247036..13c946e 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -207,14 +207,21 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>   	char * const *args = &argv[2];
>   	int rcode;
>   	ulong dev_addr, addr, off, cnt;
> +	int bus_addr;
>
>   	switch (argc) {
>   #ifdef CONFIG_SYS_DEF_EEPROM_ADDR
>   	case 5:
> +		bus_addr = -1;
>   		dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
>   		break;
>   #endif
>   	case 6:
> +		bus_addr = -1;
> +		dev_addr = simple_strtoul(*args++, NULL, 16);
> +		break;
> +	case 7:
> +		bus_addr = simple_strtoul(*args++, NULL, 16);
>   		dev_addr = simple_strtoul(*args++, NULL, 16);
>   		break;
>   	default:
> @@ -225,7 +232,7 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>   	off = simple_strtoul(*args++, NULL, 16);
>   	cnt = simple_strtoul(*args++, NULL, 16);
>
> -	eeprom_init(-1);
> +	eeprom_init(bus_addr);
>
>   	if (strcmp (argv[1], "read") == 0) {
>   		printf(fmt, dev_addr, argv[1], addr, off, cnt);
> @@ -247,9 +254,9 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>   }
>
>   U_BOOT_CMD(
> -	eeprom,	6,	1,	do_eeprom,
> +	eeprom,	7,	1,	do_eeprom,
>   	"EEPROM sub-system",
> -	"read  devaddr addr off cnt\n"
> -	"eeprom write devaddr addr off cnt\n"
> +	"read  <bus> <devaddr> addr off cnt\n"
> +	"eeprom write <bus> <devaddr> addr off cnt\n"
>   	"       - read/write `cnt' bytes from `devaddr` EEPROM at offset `off'"
>   )
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 17/17] eeprom: Clean up checkpatch issues
  2015-11-10 19:53 ` [U-Boot] [PATCH 17/17] eeprom: Clean up checkpatch issues Marek Vasut
@ 2015-11-16 11:32   ` Heiko Schocher
  2015-11-22 15:55   ` [U-Boot] [U-Boot,17/17] " Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:32 UTC (permalink / raw)
  To: u-boot

Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Cosmetic fixes to the file, make it checkpatch clean.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 19 ++++++++++---------
>   1 file changed, 10 insertions(+), 9 deletions(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 13c946e..376c57d 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -49,8 +49,8 @@
>    */
>   #if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
>   #if !defined(CONFIG_SYS_I2C_EEPROM_ADDR_LEN) || \
> -    (CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1) || \
> -    (CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2)
> +	(CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1) || \
> +	(CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2)
>   #error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2
>   #endif
>   #endif
> @@ -183,7 +183,8 @@ int eeprom_read(unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
>   	return eeprom_rw(dev_addr, offset, buffer, cnt, 1);
>   }
>
> -int eeprom_write(unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
> +int eeprom_write(unsigned dev_addr, unsigned offset,
> +		 uchar *buffer, unsigned cnt)
>   {
>   	int ret;
>
> @@ -234,19 +235,19 @@ static int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>
>   	eeprom_init(bus_addr);
>
> -	if (strcmp (argv[1], "read") == 0) {
> +	if (strcmp(argv[1], "read") == 0) {
>   		printf(fmt, dev_addr, argv[1], addr, off, cnt);
>
> -		rcode = eeprom_read(dev_addr, off, (uchar *) addr, cnt);
> +		rcode = eeprom_read(dev_addr, off, (uchar *)addr, cnt);
>
> -		puts ("done\n");
> +		puts("done\n");
>   		return rcode;
> -	} else if (strcmp (argv[1], "write") == 0) {
> +	} else if (strcmp(argv[1], "write") == 0) {
>   		printf(fmt, dev_addr, argv[1], addr, off, cnt);
>
> -		rcode = eeprom_write(dev_addr, off, (uchar *) addr, cnt);
> +		rcode = eeprom_write(dev_addr, off, (uchar *)addr, cnt);
>
> -		puts ("done\n");
> +		puts("done\n");
>   		return rcode;
>   	}
>
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [PATCH 15/17] eeprom: Add bus argument to eeprom_init()
  2015-11-16 11:32   ` Heiko Schocher
@ 2015-11-21 13:48     ` Tom Rini
  0 siblings, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-21 13:48 UTC (permalink / raw)
  To: u-boot

On Mon, Nov 16, 2015 at 12:32:18PM +0100, Heiko Schocher wrote:
> Hello Marek,
> 
> Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> >Add bus argument to eeprom_init(), so that it can select
> >the I2C bus number on which the eeprom resides. Any negative
> >value of the $bus argument will preserve the old behavior.
> >This is in place so that old code does not randomly break.
[snip]
> >@@ -69,6 +69,8 @@ void eeprom_init(void)
> >
> >  	/* I2C EEPROM */
> >  #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
> >+	if (bus >= 0)
> >+		i2c_set_bus_num(bus);
> >  	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
> >  #endif
> >  }

Note that we need to wrap this call in CONFIG_SYS_I2C as
CONFIG_HARD_I2C doesn't provide this function.  Fixing up and testing
again locally.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151121/bbb130ac/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot, 01/17] tricorder: rewrite tricordereeprom command
  2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
                   ` (16 preceding siblings ...)
  2015-11-16 11:26 ` [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Heiko Schocher
@ 2015-11-22 15:53 ` Tom Rini
  17 siblings, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:53 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:17PM +0100, Marek Vasut wrote:

> From: Andreas Bie?mann <andreas.devel@googlemail.com>
> 
> This rewrite uses lately promoted eeprom_init(int) function to choose the
> right I2C bus when writing data to the EEPROM.
> 
> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/b48fe37a/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot,02/17] eeprom: Shuffle code around
  2015-11-10 19:53 ` [U-Boot] [PATCH 02/17] eeprom: Shuffle code around Marek Vasut
  2015-11-16 11:26   ` Heiko Schocher
@ 2015-11-22 15:53   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:53 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:18PM +0100, Marek Vasut wrote:

> Just move the code around so that the forward declarations are not
> necessary. Also zap a few checkpatch issues where applicable and
> zap the use of #ifdef CONFIG_CMD_EEPROM in the code, since this is
> always true.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/94feae2e/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot, 03/17] eeprom: Zap CONFIG_SYS_I2C_MULTI_EEPROMS
  2015-11-10 19:53 ` [U-Boot] [PATCH 03/17] eeprom: Zap CONFIG_SYS_I2C_MULTI_EEPROMS Marek Vasut
  2015-11-16 11:26   ` Heiko Schocher
@ 2015-11-22 15:53   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:53 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:19PM +0100, Marek Vasut wrote:

> This option only complicates the code unnecessarily, just use
> CONFIG_SYS_DEF_EEPROM_ADDR as the default address if there are
> only five arguments to eeprom {read/write} if this is defined.
> If CONFIG_SYS_DEF_EEPROM_ADDR is not defined, we mandate all
> six arguments.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/61493f78/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot,04/17] eeprom: Zap CONFIG_SYS_EEPROM_X40430
  2015-11-10 19:53 ` [U-Boot] [PATCH 04/17] eeprom: Zap CONFIG_SYS_EEPROM_X40430 Marek Vasut
  2015-11-16 11:27   ` Heiko Schocher
@ 2015-11-22 15:53   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:53 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:20PM +0100, Marek Vasut wrote:

> Now that the only user of CONFIG_SYS_EEPROM_X40430 was removed,
> remove this unused code from cmd_eeprom.c
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/284a924a/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot,05/17] eeprom: Zap eeprom_probe()
  2015-11-10 19:53 ` [U-Boot] [PATCH 05/17] eeprom: Zap eeprom_probe() Marek Vasut
  2015-11-16 11:27   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:21PM +0100, Marek Vasut wrote:

> Remove this function as it's no longer used.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/5cf52cf2/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot,06/17] eeprom: Zap CONFIG_SPI_X
  2015-11-10 19:53 ` [U-Boot] [PATCH 06/17] eeprom: Zap CONFIG_SPI_X Marek Vasut
  2015-11-16 11:27   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:22PM +0100, Marek Vasut wrote:

> This macro is no longer used, so just reap it.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/48cc885b/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot,07/17] eeprom: Pull out the I/O code
  2015-11-10 19:53 ` [U-Boot] [PATCH 07/17] eeprom: Pull out the I/O code Marek Vasut
  2015-11-16 11:27   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:23PM +0100, Marek Vasut wrote:

> Pull out the code which does the I2C or SPI read/write, so that
> the beefy ifdef around it is contained in a single function.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/d719b9af/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot,08/17] eeprom: Pull out address computation
  2015-11-10 19:53 ` [U-Boot] [PATCH 08/17] eeprom: Pull out address computation Marek Vasut
  2015-11-16 11:28   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:24PM +0100, Marek Vasut wrote:

> Pull out the code computing the EEPROM address into separate function
> so that it's not duplicated.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/79184d2e/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot, 09/17] eeprom: Make eeprom_write_enable() weak
  2015-11-10 19:53 ` [U-Boot] [PATCH 09/17] eeprom: Make eeprom_write_enable() weak Marek Vasut
  2015-11-16 11:28   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:25PM +0100, Marek Vasut wrote:

> Make this function weak and implement it's weak implementation
> so that the boards can just reimplement it. This zaps the horrid
> CONFIG_SYS_EEPROM_WREN macro.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/2c247ad0/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot, 10/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS
  2015-11-10 19:53 ` [U-Boot] [PATCH 10/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS Marek Vasut
  2015-11-16 11:28   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:26PM +0100, Marek Vasut wrote:

> Pull this macro to the beginning of the cmd_eeprom.c and remove
> another nasty ifdef from the code. Note that this is legal, since
> udelay(0) changes the behavior only such that it pings the WDT if
> WDT is enabled and otherwise does not wait.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/c107b23e/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot, 11/17] eeprom: Suck the ifdef into eeprom_init()
  2015-11-10 19:53 ` [U-Boot] [PATCH 11/17] eeprom: Suck the ifdef into eeprom_init() Marek Vasut
  2015-11-16 11:28   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:27PM +0100, Marek Vasut wrote:

> Just suck the ugly ifdef around eeprom_init() call into eeprom_init()
> function itself. This puts all of the ifdef mess into one place.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/8b57ffc1/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot, 12/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_BITS
  2015-11-10 19:53 ` [U-Boot] [PATCH 12/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_BITS Marek Vasut
  2015-11-16 11:29   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:28PM +0100, Marek Vasut wrote:

> Implement default value of 8 for this macro and pull out all of
> this macro out of the code. The default value of 8 actually does
> implement exactly the same behavior as the previous code which
> was in the #else clause of the ifdef.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/0f4139a3/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot, 13/17] eeprom: Pull out transfer length computation
  2015-11-10 19:53 ` [U-Boot] [PATCH 13/17] eeprom: Pull out transfer length computation Marek Vasut
  2015-11-16 11:31   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:29PM +0100, Marek Vasut wrote:

> Pull out the code which computes the length of the transfer
> into separate code and clean it up a little. This again trims
> down the code duplication.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/cde76822/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot,14/17] eeprom: Pull out the RW loop
  2015-11-10 19:53 ` [U-Boot] [PATCH 14/17] eeprom: Pull out the RW loop Marek Vasut
  2015-11-16 11:31   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:30PM +0100, Marek Vasut wrote:

> Unify the code for doing read/write into single function, since the
> code for both the read and write is almost identical. This again
> trims down the code duplication.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/0797280d/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot, 15/17] eeprom: Add bus argument to eeprom_init()
  2015-11-10 19:53 ` [U-Boot] [PATCH 15/17] eeprom: Add bus argument to eeprom_init() Marek Vasut
  2015-11-16 11:32   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:31PM +0100, Marek Vasut wrote:

> Add bus argument to eeprom_init(), so that it can select
> the I2C bus number on which the eeprom resides. Any negative
> value of the $bus argument will preserve the old behavior.
> This is in place so that old code does not randomly break.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/d66c9b4a/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot, 16/17] eeprom: Add support for selecting i2c bus
  2015-11-10 19:53 ` [U-Boot] [PATCH 16/17] eeprom: Add support for selecting i2c bus Marek Vasut
  2015-11-16 11:32   ` Heiko Schocher
@ 2015-11-22 15:54   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:54 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:32PM +0100, Marek Vasut wrote:

> Add additional parameter into the eeprom command to select
> the I2C bus on which the eeprom resides.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/bff55239/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [U-Boot] [U-Boot,17/17] eeprom: Clean up checkpatch issues
  2015-11-10 19:53 ` [U-Boot] [PATCH 17/17] eeprom: Clean up checkpatch issues Marek Vasut
  2015-11-16 11:32   ` Heiko Schocher
@ 2015-11-22 15:55   ` Tom Rini
  1 sibling, 0 replies; 52+ messages in thread
From: Tom Rini @ 2015-11-22 15:55 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 10, 2015 at 08:53:33PM +0100, Marek Vasut wrote:

> Cosmetic fixes to the file, make it checkpatch clean.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151122/2d99adb8/attachment.sig>

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2015-11-22 15:55 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-10 19:53 [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Marek Vasut
2015-11-10 19:53 ` [U-Boot] [PATCH 02/17] eeprom: Shuffle code around Marek Vasut
2015-11-16 11:26   ` Heiko Schocher
2015-11-22 15:53   ` [U-Boot] [U-Boot,02/17] " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 03/17] eeprom: Zap CONFIG_SYS_I2C_MULTI_EEPROMS Marek Vasut
2015-11-16 11:26   ` Heiko Schocher
2015-11-22 15:53   ` [U-Boot] [U-Boot, " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 04/17] eeprom: Zap CONFIG_SYS_EEPROM_X40430 Marek Vasut
2015-11-16 11:27   ` Heiko Schocher
2015-11-22 15:53   ` [U-Boot] [U-Boot,04/17] " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 05/17] eeprom: Zap eeprom_probe() Marek Vasut
2015-11-16 11:27   ` Heiko Schocher
2015-11-22 15:54   ` [U-Boot] [U-Boot,05/17] " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 06/17] eeprom: Zap CONFIG_SPI_X Marek Vasut
2015-11-16 11:27   ` Heiko Schocher
2015-11-22 15:54   ` [U-Boot] [U-Boot,06/17] " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 07/17] eeprom: Pull out the I/O code Marek Vasut
2015-11-16 11:27   ` Heiko Schocher
2015-11-22 15:54   ` [U-Boot] [U-Boot,07/17] " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 08/17] eeprom: Pull out address computation Marek Vasut
2015-11-16 11:28   ` Heiko Schocher
2015-11-22 15:54   ` [U-Boot] [U-Boot,08/17] " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 09/17] eeprom: Make eeprom_write_enable() weak Marek Vasut
2015-11-16 11:28   ` Heiko Schocher
2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 10/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS Marek Vasut
2015-11-16 11:28   ` Heiko Schocher
2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 11/17] eeprom: Suck the ifdef into eeprom_init() Marek Vasut
2015-11-16 11:28   ` Heiko Schocher
2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 12/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_BITS Marek Vasut
2015-11-16 11:29   ` Heiko Schocher
2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 13/17] eeprom: Pull out transfer length computation Marek Vasut
2015-11-16 11:31   ` Heiko Schocher
2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 14/17] eeprom: Pull out the RW loop Marek Vasut
2015-11-16 11:31   ` Heiko Schocher
2015-11-22 15:54   ` [U-Boot] [U-Boot,14/17] " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 15/17] eeprom: Add bus argument to eeprom_init() Marek Vasut
2015-11-16 11:32   ` Heiko Schocher
2015-11-21 13:48     ` Tom Rini
2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 16/17] eeprom: Add support for selecting i2c bus Marek Vasut
2015-11-16 11:32   ` Heiko Schocher
2015-11-22 15:54   ` [U-Boot] [U-Boot, " Tom Rini
2015-11-10 19:53 ` [U-Boot] [PATCH 17/17] eeprom: Clean up checkpatch issues Marek Vasut
2015-11-16 11:32   ` Heiko Schocher
2015-11-22 15:55   ` [U-Boot] [U-Boot,17/17] " Tom Rini
2015-11-16 11:26 ` [U-Boot] [PATCH 01/17] tricorder: rewrite tricordereeprom command Heiko Schocher
2015-11-22 15:53 ` [U-Boot] [U-Boot, " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.