From: Eugen Hristev Date: Thu, 7 May 2020 08:53:18 +0000 (+0300) Subject: misc: i2c_eeprom: implement different probe test eeprom offset X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=b24dc83f156604f253ef6521776444188c5bff9b;p=u-boot.git misc: i2c_eeprom: implement different probe test eeprom offset Because of this commit : 5ae84860b0 ("misc: i2c_eeprom: verify that the chip is functional at probe()") at probe time, each eeprom is tested for read at offset 0. The Atmel AT24MAC402 eeprom has different mapping. One i2c slave address is used for the lower 0x80 bytes and another i2c slave address is used for the upper 0x80 bytes. Because of this basically the i2c master sees 2 different slaves. We need the upper bytes because we read the unique MAC address from this EEPROM area. However this implies that our slave address will return error on reads from address 0x0 to 0x80. To solve this, implemented an offset field inside platform data that is by default 0 (as it is used now), but can be changed in the compatible table. The probe function will now read at this offset and use it, instead of blindly checking offset 0. This will fix the regression noticed on these EEPROMs since the commit abovementioned that introduces the probe failed issue. Signed-off-by: Eugen Hristev Reviewed-by: Heiko Schocher --- diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c index ed23a62384..45c34d388c 100644 --- a/drivers/misc/i2c_eeprom.c +++ b/drivers/misc/i2c_eeprom.c @@ -18,6 +18,7 @@ struct i2c_eeprom_drv_data { u32 pagesize; /* page size in bytes */ u32 addr_offset_mask; /* bits in addr used for offset overflow */ u32 offset_len; /* size in bytes of offset */ + u32 start_offset; /* valid start offset inside memory, by default 0 */ }; int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf, int size) @@ -148,7 +149,11 @@ static int i2c_eeprom_std_probe(struct udevice *dev) i2c_set_chip_addr_offset_mask(dev, data->addr_offset_mask); /* Verify that the chip is functional */ - ret = i2c_eeprom_read(dev, 0, &test_byte, 1); + /* + * Not all eeproms start from offset 0. Valid offset is available + * in the platform data struct. + */ + ret = i2c_eeprom_read(dev, data->start_offset, &test_byte, 1); if (ret) return -ENODEV; @@ -216,6 +221,7 @@ static const struct i2c_eeprom_drv_data atmel24mac402_data = { .pagesize = 16, .addr_offset_mask = 0, .offset_len = 1, + .start_offset = 0x80, }; static const struct i2c_eeprom_drv_data atmel24c32_data = {