hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
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>
....@@ -52,6 +48,31 @@
5248 static inline struct tpm_tis_tcg_phy *to_tpm_tis_tcg_phy(struct tpm_tis_data *data)
5349 {
5450 return container_of(data, struct tpm_tis_tcg_phy, priv);
51
+}
52
+
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);
5576 }
5677
5778 static int interrupts = -1;
....@@ -173,7 +194,7 @@
173194 struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data);
174195
175196 while (len--)
176
- iowrite8(*value++, phy->iobase + addr);
197
+ tpm_tis_iowrite8(*value++, phy->iobase, addr);
177198
178199 return 0;
179200 }
....@@ -200,7 +221,7 @@
200221 {
201222 struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data);
202223
203
- iowrite32(value, phy->iobase + addr);
224
+ tpm_tis_iowrite32(value, phy->iobase, addr);
204225
205226 return 0;
206227 }
....@@ -264,6 +285,13 @@
264285 return tpm_tis_init(&pnp_dev->dev, &tpm_info);
265286 }
266287
288
+/*
289
+ * There is a known bug caused by 93e1b7d42e1e ("[PATCH] tpm: add HID module
290
+ * parameter"). This commit added IFX0102 device ID, which is also used by
291
+ * tpm_infineon but ignored to add quirks to probe which driver ought to be
292
+ * used.
293
+ */
294
+
267295 static struct pnp_device_id tpm_pnp_tbl[] = {
268296 {"PNP0C31", 0}, /* TPM */
269297 {"ATM1200", 0}, /* Atmel */
....@@ -315,7 +343,7 @@
315343 }
316344 tpm_info.res = *res;
317345
318
- tpm_info.irq = platform_get_irq(pdev, 0);
346
+ tpm_info.irq = platform_get_irq_optional(pdev, 0);
319347 if (tpm_info.irq <= 0) {
320348 if (pdev != force_pdev)
321349 tpm_info.irq = -1;