Commit d983e45b authored by Luis Fernando Ruiz's avatar Luis Fernando Ruiz

svec: i2c read eeprom in a single loop.

parent ed648eaf
......@@ -51,9 +51,9 @@ static inline int mezzanine_present(struct fmc_device *fmc)
uint32_t presence;
presence = fmc_readl(fmc, GLD_I2C_CORE_BASE + GLD_REG_CSR);
printk("presence: 0x%08x read from 0x%08x\n", presence, GLD_I2C_CORE_BASE + GLD_REG_CSR);
/*printk("presence: 0x%08x read from 0x%08x\n", presence, GLD_I2C_CORE_BASE + GLD_REG_CSR);*/
presence = GLD_CSR_FMC_PRESENT_R(presence) & (1<<fmc->slot_id);
printk("presence: 0x%08x\n", presence);
/*printk("presence: 0x%08x\n", presence);*/
return presence;
}
......@@ -182,29 +182,29 @@ void mi2c_scan(struct fmc_device *fmc)
int svec_eeprom_read(struct fmc_device *fmc, uint32_t offset,
void *buf, size_t size)
{
int i;
uint8_t *buf8 = buf;
unsigned char c;
int ret = size;
uint8_t *buf8 = buf;
int i2c_addr = fmc->eeprom_addr;
for(i = 0; i < size; i++) {
mi2c_start(fmc);
if(mi2c_put_byte(fmc, i2c_addr << 1) < 0) {
mi2c_stop(fmc);
return -EIO;
}
mi2c_put_byte(fmc, (offset >> 8) & 0xff);
mi2c_put_byte(fmc, offset & 0xff);
offset++;
mi2c_start(fmc);
if(mi2c_put_byte(fmc, i2c_addr << 1) < 0) {
mi2c_stop(fmc);
mi2c_start(fmc);
mi2c_put_byte(fmc, (i2c_addr << 1) | 1);
mi2c_get_byte(fmc, &c, 0);
return -EIO;
}
mi2c_put_byte(fmc, (offset >> 8) & 0xff);
mi2c_put_byte(fmc, offset & 0xff);
mi2c_stop(fmc);
mi2c_start(fmc);
mi2c_put_byte(fmc, (i2c_addr << 1) | 1);
while (size--) {
mi2c_get_byte(fmc, &c, size != 0);
*buf8++ = c;
mi2c_stop(fmc);
/*printk("read 0x%08x, %4i to go\n", c, size);*/
}
return size;
mi2c_stop(fmc);
return ret;
}
int svec_eeprom_write(struct fmc_device *fmc, uint32_t offset,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment