forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/char/tpm/tpm_tis.c
....@@ -50,31 +50,6 @@
5050 return container_of(data, struct tpm_tis_tcg_phy, priv);
5151 }
5252
53
-#ifdef CONFIG_PREEMPT_RT
54
-/*
55
- * Flushes previous write operations to chip so that a subsequent
56
- * ioread*()s won't stall a cpu.
57
- */
58
-static inline void tpm_tis_flush(void __iomem *iobase)
59
-{
60
- ioread8(iobase + TPM_ACCESS(0));
61
-}
62
-#else
63
-#define tpm_tis_flush(iobase) do { } while (0)
64
-#endif
65
-
66
-static inline void tpm_tis_iowrite8(u8 b, void __iomem *iobase, u32 addr)
67
-{
68
- iowrite8(b, iobase + addr);
69
- tpm_tis_flush(iobase);
70
-}
71
-
72
-static inline void tpm_tis_iowrite32(u32 b, void __iomem *iobase, u32 addr)
73
-{
74
- iowrite32(b, iobase + addr);
75
- tpm_tis_flush(iobase);
76
-}
77
-
7853 static int interrupts = -1;
7954 module_param(interrupts, int, 0444);
8055 MODULE_PARM_DESC(interrupts, "Enable interrupts");
....@@ -106,6 +81,22 @@
10681 .matches = {
10782 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
10883 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T490s"),
84
+ },
85
+ },
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"),
109100 },
110101 },
111102 {}
....@@ -150,6 +141,7 @@
150141 const struct acpi_device_id *aid = acpi_match_device(tpm_acpi_tbl, dev);
151142 struct acpi_table_tpm2 *tbl;
152143 acpi_status st;
144
+ int ret = 0;
153145
154146 if (!aid || aid->driver_data != DEVICE_IS_TPM2)
155147 return 0;
....@@ -157,8 +149,7 @@
157149 /* If the ACPI TPM2 signature is matched then a global ACPI_SIG_TPM2
158150 * table is mandatory
159151 */
160
- st =
161
- 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);
162153 if (ACPI_FAILURE(st) || tbl->header.length < sizeof(*tbl)) {
163154 dev_err(dev, FW_BUG "failed to get TPM2 ACPI table\n");
164155 return -EINVAL;
....@@ -166,9 +157,10 @@
166157
167158 /* The tpm2_crb driver handles this device */
168159 if (tbl->start_method != ACPI_TPM2_MEMORY_MAPPED)
169
- return -ENODEV;
160
+ ret = -ENODEV;
170161
171
- return 0;
162
+ acpi_put_table((struct acpi_table_header *)tbl);
163
+ return ret;
172164 }
173165 #else
174166 static int check_acpi_tpm2(struct device *dev)
....@@ -194,7 +186,7 @@
194186 struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data);
195187
196188 while (len--)
197
- tpm_tis_iowrite8(*value++, phy->iobase, addr);
189
+ iowrite8(*value++, phy->iobase + addr);
198190
199191 return 0;
200192 }
....@@ -221,7 +213,7 @@
221213 {
222214 struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data);
223215
224
- tpm_tis_iowrite32(value, phy->iobase, addr);
216
+ iowrite32(value, phy->iobase + addr);
225217
226218 return 0;
227219 }