Fix logic for selection of CONFIG_SYS_DEF_EEPROM_ADDR
PATCH 1/1 Fix logic for selection of CONFIG_SYS_DEF_EEPROM_ADDR
A board with CONFIG_SPI and CONFIG_ENV_EEPROM_IS_ON_I2C will get:
#define CONFIG_SYS_DEF_EEPROM_ADDR 0
Instead of the expected:
#define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
As a result, the "eeprom" command is unusable because it calls i2c_read() and i2c_write() but always uses an address of 0x00.
This fixes the logic for that particular case, hopefully without breaking any other board configurations.
--- include/common.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
include/common.h +3 -3
@@ -402,13 +402,13 @@ extern void pic_write (uchar reg, uchar val);* Set this up regardless of board * type, to prevent errors. */ -#if defined(CONFIG_SPI ) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR ) +#if defined(CONFIG_SPI ) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C ) +# define CONFIG_SYS_DEF_EEPROM_ADDR 0 +#elif !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 )extern void spi_init_f (void );
Signature · 1 line
1.7.7.3
Moffett
PATCH 1/1 Fix logic for selection of CONFIG_SYS_DEF_EEPROM_ADDR
Any comments on this patch?
If not, could it please be applied/merged? It fixes a definite bug on the HWW-1U-1A board.
Cheers,
Kyle Moffett
--
Curious about my work on the Debian powerpcspe port? I'm keeping a blog here: http://pureperl.blogspot.com/
Quoted 42 lines · Kyle Moffett
A board with
CONFIG_SPIandCONFIG_ENV_EEPROM_IS_ON_I2Cwill get:
#defineCONFIG_SYS_DEF_EEPROM_ADDR0Instead of the expected:
#defineCONFIG_SYS_DEF_EEPROM_ADDRCONFIG_SYS_I2C_EEPROM_ADDRAs a result, the "eeprom" command is unusable because it calls
i2c_read()andi2c_write()but always uses an address of0x00.This fixes the logic for that particular case, hopefully without breaking any other board configurations.
Signed-off-by Kyle Moffett <[email protected]>Cc Heiko Schocher <[email protected]>---
include/common.h| 6 +++---1 files changed, 3 insertions(+), 3 deletions(-)include/common.h +3
-3@@ -402,13 +402,13 @@ extern void pic_write (uchar reg, uchar val);* Set this up regardless of board * type, to prevent errors. */ -#if defined(CONFIG_SPI ) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR ) +#if defined(CONFIG_SPI ) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C ) +# define CONFIG_SYS_DEF_EEPROM_ADDR 0 +#elif !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 )extern void spi_init_f (void );Signature · 1 line
1.7.7.3
PATCH 1/1 Fix logic for selection of CONFIG_SYS_DEF_EEPROM_ADDR
In reply to Kyle MoffettDear Kyle Moffett,
Quoted 8 lines · In message <[email protected]> you…
A board with
CONFIG_SPIandCONFIG_ENV_EEPROM_IS_ON_I2Cwill get:
#defineCONFIG_SYS_DEF_EEPROM_ADDR0Instead of the expected:
#defineCONFIG_SYS_DEF_EEPROM_ADDRCONFIG_SYS_I2C_EEPROM_ADDRAs a result, the "eeprom" command is unusable because it calls
i2c_read()andi2c_write()but always uses an address of0x00.
...
include/common.h extern void pic_write (uchar reg, uchar val); · line 406
Quoted 3 lines
include/common.h +2
-1-#if defined(CONFIG_SPI ) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR ) +#if defined(CONFIG_SPI ) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C ) +# define CONFIG_SYS_DEF_EEPROM_ADDR 0
That should probably rather be
# define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_SPI_EEPROM_ADDR
instead?
include/common.h extern void pic_write (uchar reg, uchar val); · line 411
Quoted 7 lines
include/common.h +1
-2+#elif !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) */
All this code should be moved out of common.h.
Actually all users of CONFIG_SYS_DEF_EEPROM_ADDR (if they don't even define this variable directly in their private code) only use I2C, so they should probably rather use CONFIG_SYS_I2C_EEPROM_ADDR instead (board/w7o/w7o.c, board/w7o/cmd_vpd.c, board/w7o/vpd.c, board/mpl/common/common_util.c)
Only common/cmd_eeprom.c, common/env_eeprom.c appear to support both I2C and SPI.
Best regards,
Wolfgang Denk
Signature · 6 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
"Do we define evil as the absence of goodness? It seems only logical
that shit happens--we discover this by the process of elimination."
-- Larry Wall