Skip to contentSkip to conversation

No subject

DISCUSSION [email protected] 1 participant 1 message Oct 15, 2013

lore
Share & tools
lore
#0 lore raw

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
If "CONFIG_SYS_I2C_EEPROM_ADDR_LEN =3D=3D 1":
addr[0] =3D offset >> 8;

If "CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 1":
addr[0] =3D offset >> 16;

And in both cases then OR with "dev_addr":
addr[0] |=3D dev_addr;
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

In other words it gets both real I2S slave address + MSB bits of offset. But note that "offset" value stays unchanged.

So if you pass both "addr[0]" (which already has MSB bits of "offset") and "offset" itself then you'll get completely incorrect I2C command.

Review int eeprom_write (unsigned dev_addr, unsigned offset,=

Quoted 1 line
(quoted diff) +0 -0
@@ -339,7 +339,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset,=

uchar *buffer, unsigned cn

Quoted 8 lines
(quoted diff) +1 -1
 		/* Write is enabled ... now write eeprom value.
 		 */
 #endif
-		if (i2c_write (addr[0], addr[1], alen-1, buffer, len) !=3D 0)
+		if (i2c_write(addr[0], offset, alen - 1, buffer, len))
 			rcode =3D 1;

=20
#endif

Same goes to "eeprom_write".

Moreover I'd say that this address/offset tricks are very EEPROM-specific and because of this we'd better keep it here and don't modify generic I2C code.

Regards,
Alexey