Skip to content

Commit 2e1827d

Browse files
Jett Rinkjarkkojs
authored andcommitted
char: tpm: cr50: Add new device/vendor ID 0x50666666
Accept another DID:VID for the next generation Google TPM. This TPM has the same Ti50 firmware and fulfills the same interface. Suggested-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jett Rink <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 44637b0 commit 2e1827d

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

drivers/char/tpm/tpm_tis_i2c_cr50.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
#define TPM_CR50_MAX_BUFSIZE 64
3232
#define TPM_CR50_TIMEOUT_SHORT_MS 2 /* Short timeout during transactions */
3333
#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 */
3637
#define TPM_CR50_I2C_MAX_RETRIES 3 /* Max retries due to I2C errors */
3738
#define TPM_CR50_I2C_RETRY_DELAY_LO 55 /* Min usecs between retries on I2C */
3839
#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[] = {
680681
MODULE_DEVICE_TABLE(of, of_cr50_i2c_match);
681682
#endif
682683

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+
683705
/**
684706
* tpm_cr50_i2c_probe() - Driver probe function.
685707
* @client: I2C client information.
@@ -761,13 +783,15 @@ static int tpm_cr50_i2c_probe(struct i2c_client *client)
761783
}
762784

763785
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) {
765789
dev_err(dev, "Vendor ID did not match! ID was %08x\n", vendor);
766790
return -ENODEV;
767791
}
768792

769793
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),
771795
client->addr, client->irq, vendor >> 16);
772796
return tpm_chip_register(chip);
773797
}

0 commit comments

Comments
 (0)