|
31 | 31 | #define TPM_CR50_MAX_BUFSIZE 64
|
32 | 32 | #define TPM_CR50_TIMEOUT_SHORT_MS 2 /* Short timeout during transactions */
|
33 | 33 | #define TPM_CR50_TIMEOUT_NOIRQ_MS 20 /* Timeout for TPM ready without IRQ */
|
34 |
| -#define TPM_CR50_I2C_DID_VID 0x00281ae0L /* Device and vendor ID reg value */ |
35 |
| -#define TPM_TI50_I2C_DID_VID 0x504a6666L /* Device and vendor ID reg value */ |
| 34 | +#define TPM_CR50_I2C_DID_VID 0x00281ae0L /* Device and vendor ID for Cr50 H1 */ |
| 35 | +#define TPM_TI50_DT_I2C_DID_VID 0x504a6666L /* Device and vendor ID for Ti50 DT */ |
| 36 | +#define TPM_TI50_OT_I2C_DID_VID 0x50666666L /* Device and vendor ID for TI50 OT */ |
36 | 37 | #define TPM_CR50_I2C_MAX_RETRIES 3 /* Max retries due to I2C errors */
|
37 | 38 | #define TPM_CR50_I2C_RETRY_DELAY_LO 55 /* Min usecs between retries on I2C */
|
38 | 39 | #define TPM_CR50_I2C_RETRY_DELAY_HI 65 /* Max usecs between retries on I2C */
|
@@ -680,6 +681,27 @@ static const struct of_device_id of_cr50_i2c_match[] = {
|
680 | 681 | MODULE_DEVICE_TABLE(of, of_cr50_i2c_match);
|
681 | 682 | #endif
|
682 | 683 |
|
| 684 | +/** |
| 685 | + * tpm_cr50_vid_to_name() - Maps VID to name. |
| 686 | + * @vendor: Vendor identifier to map to name |
| 687 | + * |
| 688 | + * Return: |
| 689 | + * A valid string for the vendor or empty string |
| 690 | + */ |
| 691 | +static const char *tpm_cr50_vid_to_name(u32 vendor) |
| 692 | +{ |
| 693 | + switch (vendor) { |
| 694 | + case TPM_CR50_I2C_DID_VID: |
| 695 | + return "cr50"; |
| 696 | + case TPM_TI50_DT_I2C_DID_VID: |
| 697 | + return "ti50 DT"; |
| 698 | + case TPM_TI50_OT_I2C_DID_VID: |
| 699 | + return "ti50 OT"; |
| 700 | + default: |
| 701 | + return "unknown"; |
| 702 | + } |
| 703 | +} |
| 704 | + |
683 | 705 | /**
|
684 | 706 | * tpm_cr50_i2c_probe() - Driver probe function.
|
685 | 707 | * @client: I2C client information.
|
@@ -761,13 +783,15 @@ static int tpm_cr50_i2c_probe(struct i2c_client *client)
|
761 | 783 | }
|
762 | 784 |
|
763 | 785 | vendor = le32_to_cpup((__le32 *)buf);
|
764 |
| - if (vendor != TPM_CR50_I2C_DID_VID && vendor != TPM_TI50_I2C_DID_VID) { |
| 786 | + if (vendor != TPM_CR50_I2C_DID_VID && |
| 787 | + vendor != TPM_TI50_DT_I2C_DID_VID && |
| 788 | + vendor != TPM_TI50_OT_I2C_DID_VID) { |
765 | 789 | dev_err(dev, "Vendor ID did not match! ID was %08x\n", vendor);
|
766 | 790 | return -ENODEV;
|
767 | 791 | }
|
768 | 792 |
|
769 | 793 | dev_info(dev, "%s TPM 2.0 (i2c 0x%02x irq %d id 0x%x)\n",
|
770 |
| - vendor == TPM_TI50_I2C_DID_VID ? "ti50" : "cr50", |
| 794 | + tpm_cr50_vid_to_name(vendor), |
771 | 795 | client->addr, client->irq, vendor >> 16);
|
772 | 796 | return tpm_chip_register(chip);
|
773 | 797 | }
|
|
0 commit comments