Skip to contentSkip to conversation

cmd_eeprom: I2C updates

PATCH New Heiko Schocher 2 participants 2 messages Jan 7, 2010 – Jan 17, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cmd_eeprom: I2C updates

- CONFIG_ENV_EEPROM_IS_ON_I2C
define this, if you have I2C and SPI activated, and your EEPROM, which holds the environment, is on the I2C bus.

- CONFIG_I2C_ENV_EEPROM_BUS
if you have an Environment on an EEPROM reached over I2C muxes, you can now define, how to reach this EEPROM.

---
 README              |   13 ++++++++++
 common/cmd_eeprom.c |   14 ++++++----
 common/env_eeprom.c |   66 +++++++++++++++++++++++++++++++++++++++++++++++----
 include/common.h    |    2 +
 4 files changed, 84 insertions(+), 11 deletions(-)
README +13 -0
index 22e35c3..7affe10 100644
@@ -2447,6 +2447,19 @@ to save the current settings.
 	- CONFIG_SYS_EEPROM_SIZE:
 	  The size in bytes of the EEPROM device.
 
+	- CONFIG_ENV_EEPROM_IS_ON_I2C
+	  define this, if you have I2C and SPI activated, and your
+	  EEPROM, which holds the environment, is on the I2C bus.
+
+	- CONFIG_I2C_ENV_EEPROM_BUS
+	  if you have an Environment on an EEPROM reached over
+	  I2C muxes, you can define here, how to reach this
+	  EEPROM. For example:
+
+	  #define CONFIG_I2C_ENV_EEPROM_BUS       "pca9547:70:d\0"
+
+	  EEPROM which holds the environment, is reached over
+	  a pca9547 i2c mux with address 0x70, channel 3.
 
 - CONFIG_ENV_IS_IN_DATAFLASH:
 
common/cmd_eeprom.c +8 -6
index 102efaf..519b510 100644
@@ -79,7 +79,7 @@ int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 		ulong cnt  = simple_strtoul (argv[4], NULL, 16);
 #endif /* CONFIG_SYS_I2C_MULTI_EEPROMS */
 
-# ifndef CONFIG_SPI
+# if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
 		eeprom_init ();
 # endif /* !CONFIG_SPI */
 
@@ -118,7 +118,7 @@ int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  *   0x00000nxx for EEPROM address selectors and page number at n.
  */
 
-#ifndef CONFIG_SPI
+#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
 #error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2
 #endif
@@ -176,7 +176,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
 			len = maxlen;
 #endif
 
-#ifdef CONFIG_SPI
+#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
 		spi_read (addr, alen, buffer, len);
 #else
 		if (i2c_read (addr[0], offset, alen-1, buffer, len) != 0)
@@ -272,7 +272,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 			len = maxlen;
 #endif
 
-#ifdef CONFIG_SPI
+#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
 		spi_write (addr, alen, buffer, len);
 #else
 #if defined(CONFIG_SYS_EEPROM_X40430)
@@ -374,7 +374,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 	return rcode;
 }
 
-#ifndef CONFIG_SPI
+#if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
 int
 eeprom_probe (unsigned dev_addr, unsigned offset)
 {
@@ -403,7 +403,8 @@ eeprom_probe (unsigned dev_addr, unsigned offset)
 
 void eeprom_init  (void)
 {
-#if defined(CONFIG_SPI)
+
+#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
 	spi_init_f ();
 #endif
 #if defined(CONFIG_HARD_I2C) || \
@@ -411,6 +412,7 @@ void eeprom_init  (void)
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
 }
+
 /*-----------------------------------------------------------------------
  */
 
common/env_eeprom.c +61 -5

107 lines not on this page · raw message

include/common.h +2 -0
index 07897f6..2424356 100644
@@ -336,7 +336,9 @@ extern void  pic_write (uchar reg, uchar val);
 #if defined(CONFIG_SPI) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR)
 # define CONFIG_SYS_DEF_EEPROM_ADDR 0
 #else
+#if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
 # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
+#endif
 #endif /* CONFIG_SPI || !defined(CONFIG_SYS_I2C_EEPROM_ADDR) */
 
 #if defined(CONFIG_SPI)
Signature · 5 lines
1.6.2.5

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#1 lore raw

PATCH 1/2 cmd_eeprom: I2C updates

Dear Heiko Schocher,

Quoted 9 lines · In message <[email protected]> you wrote:

- CONFIG_ENV_EEPROM_IS_ON_I2C
define this, if you have I2C and SPI activated, and your EEPROM, which holds the environment, is on the I2C bus.

- CONFIG_I2C_ENV_EEPROM_BUS
if you have an Environment on an EEPROM reached over I2C muxes, you can now define, how to reach this EEPROM.

Quoted 7 lines
---
 README              |   13 ++++++++++
 common/cmd_eeprom.c |   14 ++++++----
 common/env_eeprom.c |   66 +++++++++++++++++++++++++++++++++++++++++++++++----
 include/common.h    |    2 +
 4 files changed, 84 insertions(+), 11 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The whole world is about three drinks behind."     - Humphrey Bogart