Lines Matching refs:chip

77 	struct tpm_chip *chip;  member
103 static void st33zp24_cancel(struct tpm_chip *chip) in st33zp24_cancel() argument
108 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in st33zp24_cancel()
119 static u8 st33zp24_status(struct tpm_chip *chip) in st33zp24_status() argument
124 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in st33zp24_status()
135 static int check_locality(struct tpm_chip *chip) in check_locality() argument
141 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in check_locality()
147 return chip->vendor.locality; in check_locality()
157 static int request_locality(struct tpm_chip *chip) in request_locality() argument
164 if (check_locality(chip) == chip->vendor.locality) in request_locality()
165 return chip->vendor.locality; in request_locality()
167 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in request_locality()
174 stop = jiffies + chip->vendor.timeout_a; in request_locality()
178 if (check_locality(chip) >= 0) in request_locality()
179 return chip->vendor.locality; in request_locality()
191 static void release_locality(struct tpm_chip *chip) in release_locality() argument
196 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in release_locality()
207 static int get_burstcount(struct tpm_chip *chip) in get_burstcount() argument
214 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in get_burstcount()
216 stop = jiffies + chip->vendor.timeout_d; in get_burstcount()
247 static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask, in wait_for_tpm_stat_cond() argument
250 u8 status = chip->ops->status(chip); in wait_for_tpm_stat_cond()
255 if (check_cancel && chip->ops->req_canceled(chip, status)) { in wait_for_tpm_stat_cond()
271 static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, in wait_for_stat() argument
282 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in wait_for_stat()
285 status = st33zp24_status(chip); in wait_for_stat()
291 if (chip->vendor.irq) { in wait_for_stat()
294 enable_irq(chip->vendor.irq); in wait_for_stat()
308 condition = wait_for_tpm_stat_cond(chip, mask, in wait_for_stat()
317 disable_irq_nosync(chip->vendor.irq); in wait_for_stat()
322 status = chip->ops->status(chip); in wait_for_stat()
338 static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) in recv_data() argument
343 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in recv_data()
346 wait_for_stat(chip, in recv_data()
348 chip->vendor.timeout_c, in recv_data()
349 &chip->vendor.read_queue, true) == 0) { in recv_data()
350 burstcnt = get_burstcount(chip); in recv_data()
372 struct tpm_chip *chip = dev_id; in tpm_ioserirq_handler() local
375 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in tpm_ioserirq_handler()
378 wake_up_interruptible(&chip->vendor.read_queue); in tpm_ioserirq_handler()
379 disable_irq_nosync(chip->vendor.irq); in tpm_ioserirq_handler()
393 static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf, in st33zp24_send() argument
402 if (!chip) in st33zp24_send()
407 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in st33zp24_send()
409 ret = request_locality(chip); in st33zp24_send()
413 status = st33zp24_status(chip); in st33zp24_send()
415 st33zp24_cancel(chip); in st33zp24_send()
417 (chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b, in st33zp24_send()
418 &chip->vendor.read_queue, false) < 0) { in st33zp24_send()
425 burstcnt = get_burstcount(chip); in st33zp24_send()
437 status = st33zp24_status(chip); in st33zp24_send()
448 status = st33zp24_status(chip); in st33zp24_send()
459 if (chip->vendor.irq) { in st33zp24_send()
462 ret = wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, in st33zp24_send()
463 tpm_calc_ordinal_duration(chip, ordinal), in st33zp24_send()
464 &chip->vendor.read_queue, false); in st33zp24_send()
471 st33zp24_cancel(chip); in st33zp24_send()
472 release_locality(chip); in st33zp24_send()
484 static int st33zp24_recv(struct tpm_chip *chip, unsigned char *buf, in st33zp24_recv() argument
490 if (!chip) in st33zp24_recv()
498 size = recv_data(chip, buf, TPM_HEADER_SIZE); in st33zp24_recv()
500 dev_err(&chip->dev, "Unable to read header\n"); in st33zp24_recv()
510 size += recv_data(chip, &buf[TPM_HEADER_SIZE], in st33zp24_recv()
513 dev_err(&chip->dev, "Unable to read remainder of result\n"); in st33zp24_recv()
518 st33zp24_cancel(chip); in st33zp24_recv()
519 release_locality(chip); in st33zp24_recv()
529 static bool st33zp24_req_canceled(struct tpm_chip *chip, u8 status) in st33zp24_req_canceled() argument
556 struct tpm_chip *chip; in st33zp24_probe() local
559 chip = tpmm_chip_alloc(dev, &st33zp24_tpm); in st33zp24_probe()
560 if (IS_ERR(chip)) in st33zp24_probe()
561 return PTR_ERR(chip); in st33zp24_probe()
568 TPM_VPRIV(chip) = tpm_dev; in st33zp24_probe()
572 chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT); in st33zp24_probe()
573 chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT); in st33zp24_probe()
574 chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT); in st33zp24_probe()
575 chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT); in st33zp24_probe()
577 chip->vendor.locality = LOCALITY0; in st33zp24_probe()
581 init_waitqueue_head(&chip->vendor.read_queue); in st33zp24_probe()
584 if (request_locality(chip) != LOCALITY0) { in st33zp24_probe()
592 chip); in st33zp24_probe()
594 dev_err(&chip->dev, "TPM SERIRQ signals %d not available\n", in st33zp24_probe()
614 chip->vendor.irq = irq; in st33zp24_probe()
616 disable_irq_nosync(chip->vendor.irq); in st33zp24_probe()
618 tpm_gen_interrupt(chip); in st33zp24_probe()
621 tpm_get_timeouts(chip); in st33zp24_probe()
622 tpm_do_selftest(chip); in st33zp24_probe()
624 return tpm_chip_register(chip); in st33zp24_probe()
626 dev_info(&chip->dev, "TPM initialization fail\n"); in st33zp24_probe()
636 int st33zp24_remove(struct tpm_chip *chip) in st33zp24_remove() argument
638 tpm_chip_unregister(chip); in st33zp24_remove()
652 struct tpm_chip *chip = dev_get_drvdata(dev); in st33zp24_pm_suspend() local
656 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in st33zp24_pm_suspend()
674 struct tpm_chip *chip = dev_get_drvdata(dev); in st33zp24_pm_resume() local
678 tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); in st33zp24_pm_resume()
682 ret = wait_for_stat(chip, in st33zp24_pm_resume()
683 TPM_STS_VALID, chip->vendor.timeout_b, in st33zp24_pm_resume()
684 &chip->vendor.read_queue, false); in st33zp24_pm_resume()
688 tpm_do_selftest(chip); in st33zp24_pm_resume()