Lines Matching refs:chip

308 unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip,  in tpm_calc_ordinal_duration()  argument
320 duration = chip->vendor.duration[duration_idx]; in tpm_calc_ordinal_duration()
331 ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, in tpm_transmit() argument
346 dev_err(chip->pdev, in tpm_transmit()
351 mutex_lock(&chip->tpm_mutex); in tpm_transmit()
353 rc = chip->ops->send(chip, (u8 *) buf, count); in tpm_transmit()
355 dev_err(chip->pdev, in tpm_transmit()
360 if (chip->vendor.irq) in tpm_transmit()
363 if (chip->flags & TPM_CHIP_FLAG_TPM2) in tpm_transmit()
364 stop = jiffies + tpm2_calc_ordinal_duration(chip, ordinal); in tpm_transmit()
366 stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal); in tpm_transmit()
368 u8 status = chip->ops->status(chip); in tpm_transmit()
369 if ((status & chip->ops->req_complete_mask) == in tpm_transmit()
370 chip->ops->req_complete_val) in tpm_transmit()
373 if (chip->ops->req_canceled(chip, status)) { in tpm_transmit()
374 dev_err(chip->pdev, "Operation Canceled\n"); in tpm_transmit()
383 chip->ops->cancel(chip); in tpm_transmit()
384 dev_err(chip->pdev, "Operation Timed out\n"); in tpm_transmit()
389 rc = chip->ops->recv(chip, (u8 *) buf, bufsiz); in tpm_transmit()
391 dev_err(chip->pdev, in tpm_transmit()
394 mutex_unlock(&chip->tpm_mutex); in tpm_transmit()
401 ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd, in tpm_transmit_cmd() argument
407 len = tpm_transmit(chip, (u8 *) cmd, len); in tpm_transmit_cmd()
417 dev_err(chip->pdev, "A TPM error (%d) occurred %s\n", err, in tpm_transmit_cmd()
438 struct tpm_chip *chip = dev_get_drvdata(dev); in tpm_getcap() local
455 rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, desc); in tpm_getcap()
461 void tpm_gen_interrupt(struct tpm_chip *chip) in tpm_gen_interrupt() argument
471 rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, in tpm_gen_interrupt()
486 static int tpm_startup(struct tpm_chip *chip, __be16 startup_type) in tpm_startup() argument
492 return tpm_transmit_cmd(chip, &start_cmd, TPM_INTERNAL_RESULT_SIZE, in tpm_startup()
496 int tpm_get_timeouts(struct tpm_chip *chip) in tpm_get_timeouts() argument
508 rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, NULL); in tpm_get_timeouts()
513 dev_info(chip->pdev, "Issuing TPM_STARTUP"); in tpm_get_timeouts()
514 if (tpm_startup(chip, TPM_ST_CLEAR)) in tpm_get_timeouts()
521 rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, in tpm_get_timeouts()
525 dev_err(chip->pdev, in tpm_get_timeouts()
546 if (chip->ops->update_timeouts != NULL) in tpm_get_timeouts()
547 chip->vendor.timeout_adjusted = in tpm_get_timeouts()
548 chip->ops->update_timeouts(chip, new_timeout); in tpm_get_timeouts()
550 if (!chip->vendor.timeout_adjusted) { in tpm_get_timeouts()
558 chip->vendor.timeout_adjusted = true; in tpm_get_timeouts()
563 if (chip->vendor.timeout_adjusted) { in tpm_get_timeouts()
564 dev_info(chip->pdev, in tpm_get_timeouts()
572 chip->vendor.timeout_a = usecs_to_jiffies(new_timeout[0]); in tpm_get_timeouts()
573 chip->vendor.timeout_b = usecs_to_jiffies(new_timeout[1]); in tpm_get_timeouts()
574 chip->vendor.timeout_c = usecs_to_jiffies(new_timeout[2]); in tpm_get_timeouts()
575 chip->vendor.timeout_d = usecs_to_jiffies(new_timeout[3]); in tpm_get_timeouts()
583 rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, in tpm_get_timeouts()
594 chip->vendor.duration[TPM_SHORT] = in tpm_get_timeouts()
596 chip->vendor.duration[TPM_MEDIUM] = in tpm_get_timeouts()
598 chip->vendor.duration[TPM_LONG] = in tpm_get_timeouts()
606 if (chip->vendor.duration[TPM_SHORT] < (HZ / 100)) { in tpm_get_timeouts()
607 chip->vendor.duration[TPM_SHORT] = HZ; in tpm_get_timeouts()
608 chip->vendor.duration[TPM_MEDIUM] *= 1000; in tpm_get_timeouts()
609 chip->vendor.duration[TPM_LONG] *= 1000; in tpm_get_timeouts()
610 chip->vendor.duration_adjusted = true; in tpm_get_timeouts()
611 dev_info(chip->pdev, "Adjusting TPM timeout parameters."); in tpm_get_timeouts()
633 static int tpm_continue_selftest(struct tpm_chip *chip) in tpm_continue_selftest() argument
639 rc = tpm_transmit_cmd(chip, &cmd, CONTINUE_SELFTEST_RESULT_SIZE, in tpm_continue_selftest()
652 int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf) in tpm_pcr_read_dev() argument
659 rc = tpm_transmit_cmd(chip, &cmd, READ_PCR_RESULT_SIZE, in tpm_pcr_read_dev()
677 struct tpm_chip *chip; in tpm_is_tpm2() local
680 chip = tpm_chip_find_get(chip_num); in tpm_is_tpm2()
681 if (chip == NULL) in tpm_is_tpm2()
684 rc = (chip->flags & TPM_CHIP_FLAG_TPM2) != 0; in tpm_is_tpm2()
686 tpm_chip_put(chip); in tpm_is_tpm2()
705 struct tpm_chip *chip; in tpm_pcr_read() local
708 chip = tpm_chip_find_get(chip_num); in tpm_pcr_read()
709 if (chip == NULL) in tpm_pcr_read()
711 if (chip->flags & TPM_CHIP_FLAG_TPM2) in tpm_pcr_read()
712 rc = tpm2_pcr_read(chip, pcr_idx, res_buf); in tpm_pcr_read()
714 rc = tpm_pcr_read_dev(chip, pcr_idx, res_buf); in tpm_pcr_read()
715 tpm_chip_put(chip); in tpm_pcr_read()
742 struct tpm_chip *chip; in tpm_pcr_extend() local
744 chip = tpm_chip_find_get(chip_num); in tpm_pcr_extend()
745 if (chip == NULL) in tpm_pcr_extend()
748 if (chip->flags & TPM_CHIP_FLAG_TPM2) { in tpm_pcr_extend()
749 rc = tpm2_pcr_extend(chip, pcr_idx, hash); in tpm_pcr_extend()
750 tpm_chip_put(chip); in tpm_pcr_extend()
757 rc = tpm_transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, in tpm_pcr_extend()
760 tpm_chip_put(chip); in tpm_pcr_extend()
773 int tpm_do_selftest(struct tpm_chip *chip) in tpm_do_selftest() argument
781 duration = tpm_calc_ordinal_duration(chip, TPM_ORD_CONTINUE_SELFTEST); in tpm_do_selftest()
785 rc = tpm_continue_selftest(chip); in tpm_do_selftest()
796 rc = tpm_transmit(chip, (u8 *) &cmd, READ_PCR_RESULT_SIZE); in tpm_do_selftest()
801 dev_info(chip->pdev, HW_ERR "TPM command timed out during continue self test"); in tpm_do_selftest()
811 dev_info(chip->pdev, in tpm_do_selftest()
830 struct tpm_chip *chip; in tpm_send() local
833 chip = tpm_chip_find_get(chip_num); in tpm_send()
834 if (chip == NULL) in tpm_send()
837 rc = tpm_transmit_cmd(chip, cmd, buflen, "attempting tpm_cmd"); in tpm_send()
839 tpm_chip_put(chip); in tpm_send()
844 static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask, in wait_for_tpm_stat_cond() argument
847 u8 status = chip->ops->status(chip); in wait_for_tpm_stat_cond()
852 if (check_cancel && chip->ops->req_canceled(chip, status)) { in wait_for_tpm_stat_cond()
859 int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, in wait_for_tpm_stat() argument
868 status = chip->ops->status(chip); in wait_for_tpm_stat()
874 if (chip->vendor.irq) { in wait_for_tpm_stat()
880 wait_for_tpm_stat_cond(chip, mask, check_cancel, in wait_for_tpm_stat()
895 status = chip->ops->status(chip); in wait_for_tpm_stat()
919 struct tpm_chip *chip = dev_get_drvdata(dev); in tpm_pm_suspend() local
925 if (chip == NULL) in tpm_pm_suspend()
928 if (chip->flags & TPM_CHIP_FLAG_TPM2) { in tpm_pm_suspend()
929 tpm2_shutdown(chip, TPM2_SU_STATE); in tpm_pm_suspend()
939 rc = tpm_transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE, in tpm_pm_suspend()
946 rc = tpm_transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE, NULL); in tpm_pm_suspend()
964 dev_err(chip->pdev, in tpm_pm_suspend()
967 dev_warn(chip->pdev, "TPM savestate took %dms\n", in tpm_pm_suspend()
980 struct tpm_chip *chip = dev_get_drvdata(dev); in tpm_pm_resume() local
982 if (chip == NULL) in tpm_pm_resume()
1006 struct tpm_chip *chip; in tpm_get_random() local
1015 chip = tpm_chip_find_get(chip_num); in tpm_get_random()
1016 if (chip == NULL) in tpm_get_random()
1019 if (chip->flags & TPM_CHIP_FLAG_TPM2) { in tpm_get_random()
1020 err = tpm2_get_random(chip, out, max); in tpm_get_random()
1021 tpm_chip_put(chip); in tpm_get_random()
1029 err = tpm_transmit_cmd(chip, &tpm_cmd, in tpm_get_random()
1043 tpm_chip_put(chip); in tpm_get_random()
1060 struct tpm_chip *chip; in tpm_seal_trusted() local
1063 chip = tpm_chip_find_get(chip_num); in tpm_seal_trusted()
1064 if (chip == NULL || !(chip->flags & TPM_CHIP_FLAG_TPM2)) in tpm_seal_trusted()
1067 rc = tpm2_seal_trusted(chip, payload, options); in tpm_seal_trusted()
1069 tpm_chip_put(chip); in tpm_seal_trusted()
1086 struct tpm_chip *chip; in tpm_unseal_trusted() local
1089 chip = tpm_chip_find_get(chip_num); in tpm_unseal_trusted()
1090 if (chip == NULL || !(chip->flags & TPM_CHIP_FLAG_TPM2)) in tpm_unseal_trusted()
1093 rc = tpm2_unseal_trusted(chip, payload, options); in tpm_unseal_trusted()
1095 tpm_chip_put(chip); in tpm_unseal_trusted()