Commit bd7720d3 authored by Juan David González Cobas's avatar Juan David González Cobas

Merge branch fast-eeprom-read

parents ed648eaf 17744637
......@@ -51,9 +51,7 @@ 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);
presence = GLD_CSR_FMC_PRESENT_R(presence) & (1<<fmc->slot_id);
printk("presence: 0x%08x\n", presence);
return presence;
}
......@@ -178,33 +176,31 @@ void mi2c_scan(struct fmc_device *fmc)
}
}
/* FIXME: this is very inefficient: read several bytes in a row instead */
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);
}
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