diff options
Diffstat (limited to 'src/drivers/i2c')
-rw-r--r-- | src/drivers/i2c/tpm/tis.c | 5 | ||||
-rw-r--r-- | src/drivers/i2c/tpm/tpm.c | 19 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/drivers/i2c/tpm/tis.c b/src/drivers/i2c/tpm/tis.c index e8d69acfbf..49bcdd7049 100644 --- a/src/drivers/i2c/tpm/tis.c +++ b/src/drivers/i2c/tpm/tis.c @@ -79,10 +79,7 @@ int tis_init(void) * Probe TPM twice; the first probing might fail because TPM is asleep, * and the probing can wake up TPM. */ - uint8_t tmp = 0; - - if (i2c_write(bus, chip, 0, 1, &tmp, sizeof(tmp)) && - i2c_write(bus, chip, 0, 1, &tmp, sizeof(tmp))) + if (i2c_writeb(bus, chip, 0, 0) && i2c_writeb(bus, chip, 0, 0)) return -1; return 0; diff --git a/src/drivers/i2c/tpm/tpm.c b/src/drivers/i2c/tpm/tpm.c index 837bd234ac..6f6878969c 100644 --- a/src/drivers/i2c/tpm/tpm.c +++ b/src/drivers/i2c/tpm/tpm.c @@ -120,8 +120,7 @@ static int iic_tpm_read(uint8_t addr, uint8_t *buffer, size_t len) if ((tpm_dev.chip_type == SLB9635) || (tpm_dev.chip_type == UNKNOWN)) { /* slb9635 protocol should work in both cases */ for (count = 0; count < MAX_COUNT; count++) { - rc = i2c_write(tpm_dev.bus, tpm_dev.addr, - 0, 0, &addr, 1); + rc = i2c_write_raw(tpm_dev.bus, tpm_dev.addr, &addr, 1); if (rc == 0) break; /* success, break to skip sleep */ @@ -137,8 +136,8 @@ static int iic_tpm_read(uint8_t addr, uint8_t *buffer, size_t len) */ for (count = 0; count < MAX_COUNT; count++) { udelay(SLEEP_DURATION); - rc = i2c_read(tpm_dev.bus, tpm_dev.addr, - 0, 0, buffer, len); + rc = i2c_read_raw(tpm_dev.bus, tpm_dev.addr, + buffer, len); if (rc == 0) break; /* success, break to skip sleep */ @@ -150,9 +149,13 @@ static int iic_tpm_read(uint8_t addr, uint8_t *buffer, size_t len) * retries should usually not be needed, but are kept just to * be safe on the safe side. */ + struct i2c_seg aseg = { .read = 0, .chip = tpm_dev.addr, + .buf = &addr, .len = 1 }; + struct i2c_seg dseg = { .read = 1, .chip = tpm_dev.addr, + .buf = buffer, .len = len }; for (count = 0; count < MAX_COUNT; count++) { - rc = i2c_read(tpm_dev.bus, tpm_dev.addr, - addr, 1, buffer, len); + rc = i2c_transfer(tpm_dev.bus, &aseg, 1) || + i2c_transfer(tpm_dev.bus, &dseg, 1); if (rc == 0) break; /* break here to skip sleep */ udelay(SLEEP_DURATION); @@ -186,8 +189,8 @@ static int iic_tpm_write_generic(uint8_t addr, uint8_t *buffer, size_t len, if (!tpm_dev.bus) return -1; for (count = 0; count < max_count; count++) { - rc = i2c_write(tpm_dev.bus, tpm_dev.addr, 0, 0, - tpm_dev.buf, len + 1); + rc = i2c_write_raw(tpm_dev.bus, tpm_dev.addr, + tpm_dev.buf, len + 1); if (rc == 0) break; /* success, break to skip sleep */ |