Lines Matching refs:chip
17 * Note, the TPM chip is not interrupt driven (only polling)
44 * @chip: TPM chip to use.
47 * The function returns the maximum amount of time the chip could take
52 unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal)
54 if (chip->flags & TPM_CHIP_FLAG_TPM2)
55 return tpm2_calc_ordinal_duration(chip, ordinal);
57 return tpm1_calc_ordinal_duration(chip, ordinal);
61 static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
80 dev_err(&chip->dev,
85 rc = chip->ops->send(chip, buf, count);
88 dev_err(&chip->dev,
97 dev_warn(&chip->dev,
102 if (chip->flags & TPM_CHIP_FLAG_IRQ)
105 stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
107 u8 status = chip->ops->status(chip);
108 if ((status & chip->ops->req_complete_mask) ==
109 chip->ops->req_complete_val)
112 if (chip->ops->req_canceled(chip, status)) {
113 dev_err(&chip->dev, "Operation Canceled\n");
121 chip->ops->cancel(chip);
122 dev_err(&chip->dev, "Operation Timed out\n");
126 len = chip->ops->recv(chip, buf, bufsiz);
129 dev_err(&chip->dev, "tpm_transmit: tpm_recv: error %d\n", rc);
138 * @chip: a TPM chip to use
153 ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz)
173 ret = tpm_try_transmit(chip, buf, bufsiz);
188 dev_err(&chip->dev, "in retry loop\n");
190 dev_err(&chip->dev,
203 * @chip: a TPM chip to use
213 ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf,
220 len = tpm_transmit(chip, buf->data, PAGE_SIZE);
227 dev_err(&chip->dev, "A TPM error (%d) occurred %s\n", err,
239 int tpm_get_timeouts(struct tpm_chip *chip)
241 if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS)
244 if (chip->flags & TPM_CHIP_FLAG_TPM2)
245 return tpm2_get_timeouts(chip);
247 return tpm1_get_timeouts(chip);
252 * tpm_is_tpm2 - do we a have a TPM2 chip?
253 * @chip: a &struct tpm_chip instance, %NULL for the default chip
256 * 1 if we have a TPM2 chip.
257 * 0 if we don't have a TPM2 chip.
260 int tpm_is_tpm2(struct tpm_chip *chip)
264 chip = tpm_find_get_ops(chip);
265 if (!chip)
268 rc = (chip->flags & TPM_CHIP_FLAG_TPM2) != 0;
270 tpm_put_ops(chip);
278 * @chip: a &struct tpm_chip instance, %NULL for the default chip
284 int tpm_pcr_read(struct tpm_chip *chip, u32 pcr_idx,
289 chip = tpm_find_get_ops(chip);
290 if (!chip)
293 if (chip->flags & TPM_CHIP_FLAG_TPM2)
294 rc = tpm2_pcr_read(chip, pcr_idx, digest, NULL);
296 rc = tpm1_pcr_read(chip, pcr_idx, digest->digest);
298 tpm_put_ops(chip);
305 * @chip: a &struct tpm_chip instance, %NULL for the default chip
310 * order of the banks in chip->allocated_banks.
314 int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
320 chip = tpm_find_get_ops(chip);
321 if (!chip)
324 for (i = 0; i < chip->nr_allocated_banks; i++) {
325 if (digests[i].alg_id != chip->allocated_banks[i].alg_id) {
331 if (chip->flags & TPM_CHIP_FLAG_TPM2) {
332 rc = tpm2_pcr_extend(chip, pcr_idx, digests);
336 rc = tpm1_pcr_extend(chip, pcr_idx, digests[0].digest,
340 tpm_put_ops(chip);
347 * @chip: a &struct tpm_chip instance, %NULL for the default chip
353 int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen)
358 chip = tpm_find_get_ops(chip);
359 if (!chip)
363 rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to a send a command");
365 tpm_put_ops(chip);
370 int tpm_auto_startup(struct tpm_chip *chip)
374 if (!(chip->ops->flags & TPM_OPS_AUTO_STARTUP))
377 if (chip->flags & TPM_CHIP_FLAG_TPM2)
378 rc = tpm2_auto_startup(chip);
380 rc = tpm1_auto_startup(chip);
391 struct tpm_chip *chip = dev_get_drvdata(dev);
394 if (!chip)
397 if (chip->flags & TPM_CHIP_FLAG_ALWAYS_POWERED)
400 if ((chip->flags & TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED) &&
404 rc = tpm_try_get_ops(chip);
406 if (chip->flags & TPM_CHIP_FLAG_TPM2)
407 tpm2_shutdown(chip, TPM2_SU_STATE);
409 rc = tpm1_pm_suspend(chip, tpm_suspend_pcr);
411 tpm_put_ops(chip);
415 chip->flags |= TPM_CHIP_FLAG_SUSPENDED;
429 struct tpm_chip *chip = dev_get_drvdata(dev);
431 if (chip == NULL)
434 chip->flags &= ~TPM_CHIP_FLAG_SUSPENDED;
438 * activate before the chip has been fully resumed.
448 * @chip: a &struct tpm_chip instance, %NULL for the default chip
454 int tpm_get_random(struct tpm_chip *chip, u8 *out, size_t max)
461 chip = tpm_find_get_ops(chip);
462 if (!chip)
465 if (chip->flags & TPM_CHIP_FLAG_TPM2)
466 rc = tpm2_get_random(chip, out, max);
468 rc = tpm1_get_random(chip, out, max);
470 tpm_put_ops(chip);