Lines Matching +full:max +full:- +full:retries

1 // SPDX-License-Identifier: GPL-2.0-only
25 /* max. number of iterations after I2C NAK */
31 /* max. number of iterations after I2C NAK for 'long' commands
62 /* In addition to the data itself, the buffer must fit the 7-bit I2C
74 * iic_tpm_read() - read from TPM register
80 * buffer (little-endian format, i.e. first byte is put into buffer[0]).
82 * NOTE: TPM is big-endian for multi-byte values. Multi-byte
90 * Return -EIO on error, 0 on success.
96 .addr = tpm_dev.client->addr, in iic_tpm_read()
101 .addr = tpm_dev.client->addr, in iic_tpm_read()
113 if (!tpm_dev.client->adapter->algo->master_xfer) in iic_tpm_read()
114 return -EOPNOTSUPP; in iic_tpm_read()
115 i2c_lock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT); in iic_tpm_read()
121 * retries should usually not be needed, but are kept just to in iic_tpm_read()
125 rc = __i2c_transfer(tpm_dev.client->adapter, msgs, 2); in iic_tpm_read()
137 rc = __i2c_transfer(tpm_dev.client->adapter, in iic_tpm_read()
162 rc = __i2c_transfer(tpm_dev.client->adapter, in iic_tpm_read()
171 len -= msglen; in iic_tpm_read()
179 if (rc == -EOPNOTSUPP) in iic_tpm_read()
190 i2c_unlock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT); in iic_tpm_read()
199 return -EIO; in iic_tpm_read()
208 int rc = -EIO; in iic_tpm_write_generic()
212 .addr = tpm_dev.client->addr, in iic_tpm_write_generic()
218 return -EINVAL; in iic_tpm_write_generic()
220 if (!tpm_dev.client->adapter->algo->master_xfer) in iic_tpm_write_generic()
221 return -EOPNOTSUPP; in iic_tpm_write_generic()
222 i2c_lock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT); in iic_tpm_write_generic()
235 rc = __i2c_transfer(tpm_dev.client->adapter, &msg1, 1); in iic_tpm_write_generic()
241 i2c_unlock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT); in iic_tpm_write_generic()
250 return -EIO; in iic_tpm_write_generic()
256 * iic_tpm_write() - write to TPM register
264 * NOTE: TPM is big-endian for multi-byte values. Multi-byte
269 * Return -EIO on error, 0 on success
355 stop = jiffies + chip->timeout_a; in request_locality()
362 return -ETIME; in request_locality()
367 /* NOTE: since I2C read may fail, return 0 in this case --> time-out */ in tpm_tis_i2c_status()
397 stop = jiffies + chip->timeout_d; in get_burstcount()
410 return -EBUSY; in get_burstcount()
433 return -ETIME; in wait_for_stat()
440 u8 retries = 0; in recv_data() local
450 /* limit received data to max. left */ in recv_data()
451 if (burstcnt > (count - size)) in recv_data()
452 burstcnt = count - size; in recv_data()
459 retries++; in recv_data()
462 if (retries > MAX_COUNT_LONG) in recv_data()
463 return -EIO; in recv_data()
475 size = -EIO; in tpm_tis_i2c_recv()
482 dev_err(&chip->dev, "Unable to read header\n"); in tpm_tis_i2c_recv()
488 size = -EIO; in tpm_tis_i2c_recv()
493 expected - TPM_HEADER_SIZE); in tpm_tis_i2c_recv()
495 dev_err(&chip->dev, "Unable to read remainder of result\n"); in tpm_tis_i2c_recv()
496 size = -ETIME; in tpm_tis_i2c_recv()
500 wait_for_stat(chip, TPM_STS_VALID, chip->timeout_c, &status); in tpm_tis_i2c_recv()
502 dev_err(&chip->dev, "Error left over data\n"); in tpm_tis_i2c_recv()
503 size = -EIO; in tpm_tis_i2c_recv()
522 u8 retries = 0; in tpm_tis_i2c_send() local
526 return -E2BIG; in tpm_tis_i2c_send()
529 return -EBUSY; in tpm_tis_i2c_send()
536 chip->timeout_b, &status) < 0) { in tpm_tis_i2c_send()
537 rc = -ETIME; in tpm_tis_i2c_send()
542 while (count < len - 1) { in tpm_tis_i2c_send()
549 if (burstcnt > (len - 1 - count)) in tpm_tis_i2c_send()
550 burstcnt = len - 1 - count; in tpm_tis_i2c_send()
557 retries++; in tpm_tis_i2c_send()
560 if (retries > MAX_COUNT_LONG) { in tpm_tis_i2c_send()
561 rc = -EIO; in tpm_tis_i2c_send()
566 chip->timeout_c, &status); in tpm_tis_i2c_send()
569 rc = -EIO; in tpm_tis_i2c_send()
576 wait_for_stat(chip, TPM_STS_VALID, chip->timeout_c, &status); in tpm_tis_i2c_send()
578 rc = -EIO; in tpm_tis_i2c_send()
623 chip->timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT); in tpm_tis_i2c_init()
624 chip->timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT); in tpm_tis_i2c_init()
625 chip->timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT); in tpm_tis_i2c_init()
626 chip->timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT); in tpm_tis_i2c_init()
630 rc = -ENODEV; in tpm_tis_i2c_init()
637 rc = -EIO; in tpm_tis_i2c_init()
647 rc = -ENODEV; in tpm_tis_i2c_init()
651 dev_info(dev, "1.2 TPM (device-id 0x%X)\n", vendor >> 16); in tpm_tis_i2c_init()
687 struct device *dev = &(client->dev); in tpm_tis_i2c_probe()
691 return -EBUSY; /* We only support one client */ in tpm_tis_i2c_probe()
694 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in tpm_tis_i2c_probe()
696 return -ENODEV; in tpm_tis_i2c_probe()
700 rc = tpm_tis_i2c_init(&client->dev); in tpm_tis_i2c_probe()
703 rc = -ENODEV; in tpm_tis_i2c_probe()