tpm_tis.c (6ea24cf79e055f0a62a64baa8587e2254a493c7b) | tpm_tis.c (8cfffc9d4d3786d3b496a021d7224e06328bac7d) |
---|---|
1/* 2 * Copyright (C) 2005, 2006 IBM Corporation 3 * Copyright (C) 2014, 2015 Intel Corporation 4 * 5 * Authors: 6 * Leendert van Doorn <leendert@watson.ibm.com> 7 * Kylene Hall <kjhall@us.ibm.com> 8 * --- 246 unchanged lines hidden (view full) --- 255 if (count < TPM_HEADER_SIZE) { 256 size = -EIO; 257 goto out; 258 } 259 260 /* read first 10 bytes, including tag, paramsize, and result */ 261 if ((size = 262 recv_data(chip, buf, TPM_HEADER_SIZE)) < TPM_HEADER_SIZE) { | 1/* 2 * Copyright (C) 2005, 2006 IBM Corporation 3 * Copyright (C) 2014, 2015 Intel Corporation 4 * 5 * Authors: 6 * Leendert van Doorn <leendert@watson.ibm.com> 7 * Kylene Hall <kjhall@us.ibm.com> 8 * --- 246 unchanged lines hidden (view full) --- 255 if (count < TPM_HEADER_SIZE) { 256 size = -EIO; 257 goto out; 258 } 259 260 /* read first 10 bytes, including tag, paramsize, and result */ 261 if ((size = 262 recv_data(chip, buf, TPM_HEADER_SIZE)) < TPM_HEADER_SIZE) { |
263 dev_err(chip->pdev, "Unable to read header\n"); | 263 dev_err(&chip->dev, "Unable to read header\n"); |
264 goto out; 265 } 266 267 expected = be32_to_cpu(*(__be32 *) (buf + 2)); 268 if (expected > count) { 269 size = -EIO; 270 goto out; 271 } 272 273 if ((size += 274 recv_data(chip, &buf[TPM_HEADER_SIZE], 275 expected - TPM_HEADER_SIZE)) < expected) { | 264 goto out; 265 } 266 267 expected = be32_to_cpu(*(__be32 *) (buf + 2)); 268 if (expected > count) { 269 size = -EIO; 270 goto out; 271 } 272 273 if ((size += 274 recv_data(chip, &buf[TPM_HEADER_SIZE], 275 expected - TPM_HEADER_SIZE)) < expected) { |
276 dev_err(chip->pdev, "Unable to read remainder of result\n"); | 276 dev_err(&chip->dev, "Unable to read remainder of result\n"); |
277 size = -ETIME; 278 goto out; 279 } 280 281 wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, 282 &chip->vendor.int_queue, false); 283 status = tpm_tis_status(chip); 284 if (status & TPM_STS_DATA_AVAIL) { /* retry? */ | 277 size = -ETIME; 278 goto out; 279 } 280 281 wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, 282 &chip->vendor.int_queue, false); 283 status = tpm_tis_status(chip); 284 if (status & TPM_STS_DATA_AVAIL) { /* retry? */ |
285 dev_err(chip->pdev, "Error left over data\n"); | 285 dev_err(&chip->dev, "Error left over data\n"); |
286 size = -EIO; 287 goto out; 288 } 289 290out: 291 tpm_tis_ready(chip); 292 release_locality(chip, chip->vendor.locality, 0); 293 return size; --- 69 unchanged lines hidden (view full) --- 363 364 intmask = 365 ioread32(chip->vendor.iobase + 366 TPM_INT_ENABLE(chip->vendor.locality)); 367 intmask &= ~TPM_GLOBAL_INT_ENABLE; 368 iowrite32(intmask, 369 chip->vendor.iobase + 370 TPM_INT_ENABLE(chip->vendor.locality)); | 286 size = -EIO; 287 goto out; 288 } 289 290out: 291 tpm_tis_ready(chip); 292 release_locality(chip, chip->vendor.locality, 0); 293 return size; --- 69 unchanged lines hidden (view full) --- 363 364 intmask = 365 ioread32(chip->vendor.iobase + 366 TPM_INT_ENABLE(chip->vendor.locality)); 367 intmask &= ~TPM_GLOBAL_INT_ENABLE; 368 iowrite32(intmask, 369 chip->vendor.iobase + 370 TPM_INT_ENABLE(chip->vendor.locality)); |
371 devm_free_irq(chip->pdev, chip->vendor.irq, chip); | 371 devm_free_irq(&chip->dev, chip->vendor.irq, chip); |
372 chip->vendor.irq = 0; 373} 374 375/* 376 * If interrupts are used (signaled by an irq set in the vendor structure) 377 * tpm.c can skip polling for the data to be available as the interrupt is 378 * waited for here 379 */ --- 112 unchanged lines hidden (view full) --- 492 493 tpm_tis_ready(chip); 494 release_locality(chip, chip->vendor.locality, 0); 495 496 itpm = true; 497 498 rc = tpm_tis_send_data(chip, cmd_getticks, len); 499 if (rc == 0) { | 372 chip->vendor.irq = 0; 373} 374 375/* 376 * If interrupts are used (signaled by an irq set in the vendor structure) 377 * tpm.c can skip polling for the data to be available as the interrupt is 378 * waited for here 379 */ --- 112 unchanged lines hidden (view full) --- 492 493 tpm_tis_ready(chip); 494 release_locality(chip, chip->vendor.locality, 0); 495 496 itpm = true; 497 498 rc = tpm_tis_send_data(chip, cmd_getticks, len); 499 if (rc == 0) { |
500 dev_info(chip->pdev, "Detected an iTPM.\n"); | 500 dev_info(&chip->dev, "Detected an iTPM.\n"); |
501 rc = 1; 502 } else 503 rc = -EFAULT; 504 505out: 506 itpm = rem_itpm; 507 tpm_tis_ready(chip); 508 release_locality(chip, chip->vendor.locality, 0); --- 62 unchanged lines hidden (view full) --- 571 * everything and leave in polling mode. Returns 0 on success. 572 */ 573static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, 574 int flags, int irq) 575{ 576 struct priv_data *priv = chip->vendor.priv; 577 u8 original_int_vec; 578 | 501 rc = 1; 502 } else 503 rc = -EFAULT; 504 505out: 506 itpm = rem_itpm; 507 tpm_tis_ready(chip); 508 release_locality(chip, chip->vendor.locality, 0); --- 62 unchanged lines hidden (view full) --- 571 * everything and leave in polling mode. Returns 0 on success. 572 */ 573static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask, 574 int flags, int irq) 575{ 576 struct priv_data *priv = chip->vendor.priv; 577 u8 original_int_vec; 578 |
579 if (devm_request_irq(chip->pdev, irq, tis_int_handler, flags, | 579 if (devm_request_irq(&chip->dev, irq, tis_int_handler, flags, |
580 chip->devname, chip) != 0) { | 580 chip->devname, chip) != 0) { |
581 dev_info(chip->pdev, "Unable to request irq: %d for probe\n", | 581 dev_info(&chip->dev, "Unable to request irq: %d for probe\n", |
582 irq); 583 return -1; 584 } 585 chip->vendor.irq = irq; 586 587 original_int_vec = ioread8(chip->vendor.iobase + 588 TPM_INT_VECTOR(chip->vendor.locality)); 589 iowrite8(irq, --- 184 unchanged lines hidden (view full) --- 774 /* INTERRUPT Setup */ 775 init_waitqueue_head(&chip->vendor.read_queue); 776 init_waitqueue_head(&chip->vendor.int_queue); 777 if (interrupts && tpm_info->irq != -1) { 778 if (tpm_info->irq) { 779 tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, 780 tpm_info->irq); 781 if (!chip->vendor.irq) | 582 irq); 583 return -1; 584 } 585 chip->vendor.irq = irq; 586 587 original_int_vec = ioread8(chip->vendor.iobase + 588 TPM_INT_VECTOR(chip->vendor.locality)); 589 iowrite8(irq, --- 184 unchanged lines hidden (view full) --- 774 /* INTERRUPT Setup */ 775 init_waitqueue_head(&chip->vendor.read_queue); 776 init_waitqueue_head(&chip->vendor.int_queue); 777 if (interrupts && tpm_info->irq != -1) { 778 if (tpm_info->irq) { 779 tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, 780 tpm_info->irq); 781 if (!chip->vendor.irq) |
782 dev_err(chip->pdev, FW_BUG | 782 dev_err(&chip->dev, FW_BUG |
783 "TPM interrupt not working, polling instead\n"); 784 } else 785 tpm_tis_probe_irq(chip, intmask); 786 } 787 788 if (chip->flags & TPM_CHIP_FLAG_TPM2) { 789 rc = tpm2_do_selftest(chip); 790 if (rc == TPM2_RC_INITIALIZE) { --- 360 unchanged lines hidden --- | 783 "TPM interrupt not working, polling instead\n"); 784 } else 785 tpm_tis_probe_irq(chip, intmask); 786 } 787 788 if (chip->flags & TPM_CHIP_FLAG_TPM2) { 789 rc = tpm2_do_selftest(chip); 790 if (rc == TPM2_RC_INITIALIZE) { --- 360 unchanged lines hidden --- |