forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/char/tpm/tpm_tis.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2005, 2006 IBM Corporation
34 * Copyright (C) 2014, 2015 Intel Corporation
....@@ -13,11 +14,6 @@
1314 *
1415 * This device driver implements the TPM interface as defined in
1516 * the TCG TPM Interface Spec version 1.2, revision 1.0.
16
- *
17
- * This program is free software; you can redistribute it and/or
18
- * modify it under the terms of the GNU General Public License as
19
- * published by the Free Software Foundation, version 2 of the
20
- * License.
2117 */
2218 #include <linux/init.h>
2319 #include <linux/module.h>
....@@ -87,6 +83,22 @@
8783 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T490s"),
8884 },
8985 },
86
+ {
87
+ .callback = tpm_tis_disable_irq,
88
+ .ident = "ThinkStation P360 Tiny",
89
+ .matches = {
90
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
91
+ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkStation P360 Tiny"),
92
+ },
93
+ },
94
+ {
95
+ .callback = tpm_tis_disable_irq,
96
+ .ident = "ThinkPad L490",
97
+ .matches = {
98
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
99
+ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L490"),
100
+ },
101
+ },
90102 {}
91103 };
92104
....@@ -129,6 +141,7 @@
129141 const struct acpi_device_id *aid = acpi_match_device(tpm_acpi_tbl, dev);
130142 struct acpi_table_tpm2 *tbl;
131143 acpi_status st;
144
+ int ret = 0;
132145
133146 if (!aid || aid->driver_data != DEVICE_IS_TPM2)
134147 return 0;
....@@ -136,8 +149,7 @@
136149 /* If the ACPI TPM2 signature is matched then a global ACPI_SIG_TPM2
137150 * table is mandatory
138151 */
139
- st =
140
- acpi_get_table(ACPI_SIG_TPM2, 1, (struct acpi_table_header **)&tbl);
152
+ st = acpi_get_table(ACPI_SIG_TPM2, 1, (struct acpi_table_header **)&tbl);
141153 if (ACPI_FAILURE(st) || tbl->header.length < sizeof(*tbl)) {
142154 dev_err(dev, FW_BUG "failed to get TPM2 ACPI table\n");
143155 return -EINVAL;
....@@ -145,9 +157,10 @@
145157
146158 /* The tpm2_crb driver handles this device */
147159 if (tbl->start_method != ACPI_TPM2_MEMORY_MAPPED)
148
- return -ENODEV;
160
+ ret = -ENODEV;
149161
150
- return 0;
162
+ acpi_put_table((struct acpi_table_header *)tbl);
163
+ return ret;
151164 }
152165 #else
153166 static int check_acpi_tpm2(struct device *dev)
....@@ -264,6 +277,13 @@
264277 return tpm_tis_init(&pnp_dev->dev, &tpm_info);
265278 }
266279
280
+/*
281
+ * There is a known bug caused by 93e1b7d42e1e ("[PATCH] tpm: add HID module
282
+ * parameter"). This commit added IFX0102 device ID, which is also used by
283
+ * tpm_infineon but ignored to add quirks to probe which driver ought to be
284
+ * used.
285
+ */
286
+
267287 static struct pnp_device_id tpm_pnp_tbl[] = {
268288 {"PNP0C31", 0}, /* TPM */
269289 {"ATM1200", 0}, /* Atmel */
....@@ -315,7 +335,7 @@
315335 }
316336 tpm_info.res = *res;
317337
318
- tpm_info.irq = platform_get_irq(pdev, 0);
338
+ tpm_info.irq = platform_get_irq_optional(pdev, 0);
319339 if (tpm_info.irq <= 0) {
320340 if (pdev != force_pdev)
321341 tpm_info.irq = -1;