# HG changeset patch # User Michael Pavone # Date 1437196593 25200 # Node ID 1b82b282b829921d3930eb94ed86a1f8b319a9e3 # Parent 0565b2c1a03425891535dd1312598b1a1c308eb1 Less broken EEPROM support diff -r 0565b2c1a034 -r 1b82b282b829 romdb.c --- a/romdb.c Fri Jul 17 08:49:23 2015 -0700 +++ b/romdb.c Fri Jul 17 22:16:33 2015 -0700 @@ -80,7 +80,7 @@ case I2C_ADDRESS_HI: case I2C_ADDRESS: case I2C_WRITE: - state->latch = state->host_sda << 7 | state->latch >> 1; + state->latch = state->host_sda | state->latch << 1; state->counter--; if (!state->counter) { switch (state->state & 0x7F) @@ -129,9 +129,11 @@ break; case I2C_ADDRESS_HI_ACK: state->state = I2C_ADDRESS; + state->counter = 8; break; case I2C_ADDRESS_ACK: state->state = I2C_WRITE; + state->counter = 8; break; case I2C_READ: state->counter--; @@ -141,9 +143,11 @@ break; case I2C_READ_ACK: state->state = I2C_READ; + state->counter = 8; break; case I2C_WRITE_ACK: state->state = I2C_WRITE; + state->counter = 8; break; } } else if (~val & state->scl) { @@ -314,14 +318,14 @@ exit(1); } printf("EEPROM word write: %X - %X\n", address, value); + if (map->scl_mask) { + set_scl(&gen->eeprom, (value & map->scl_mask) != 0); + printf("scl: %d, state: %s, counter: %d, latch: %X\n", (value & map->scl_mask) != 0, i2c_states[gen->eeprom.state], gen->eeprom.counter, gen->eeprom.latch); + } if (map->sda_write_mask) { printf("sda: %d\n", (value & map->sda_write_mask) != 0); set_host_sda(&gen->eeprom, (value & map->sda_write_mask) != 0); } - if (map->scl_mask) { - set_scl(&gen->eeprom, (value & map->scl_mask) != 0); - printf("scl: %d, state: %s, counter: %d\n", (value & map->scl_mask) != 0, i2c_states[gen->eeprom.state], gen->eeprom.counter); - } return context; } @@ -343,14 +347,14 @@ mask = 0xFF00; } printf("EEPROM byte write: %X - %X (using mask %X and expanded val %X)\n", address, value, mask, expanded); + if (map->scl_mask & mask) { + printf("scl: %d, state: %s\n", (expanded & map->scl_mask) != 0, i2c_states[gen->eeprom.state]); + set_scl(&gen->eeprom, (expanded & map->scl_mask) != 0); + } if (map->sda_write_mask & mask) { printf("sda: %d\n", (expanded & map->sda_write_mask) != 0); set_host_sda(&gen->eeprom, (expanded & map->sda_write_mask) != 0); } - if (map->scl_mask & mask) { - printf("scl: %d, state: %s\n", (expanded & map->scl_mask) != 0, i2c_states[gen->eeprom.state]); - set_scl(&gen->eeprom, (expanded & map->scl_mask) != 0); - } return context; }