.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2005, 2006 IBM Corporation |
---|
3 | 4 | * Copyright (C) 2014, 2015 Intel Corporation |
---|
.. | .. |
---|
13 | 14 | * |
---|
14 | 15 | * This device driver implements the TPM interface as defined in |
---|
15 | 16 | * 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. |
---|
21 | 17 | */ |
---|
22 | 18 | #include <linux/init.h> |
---|
23 | 19 | #include <linux/module.h> |
---|
.. | .. |
---|
52 | 48 | static inline struct tpm_tis_tcg_phy *to_tpm_tis_tcg_phy(struct tpm_tis_data *data) |
---|
53 | 49 | { |
---|
54 | 50 | 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); |
---|
55 | 76 | } |
---|
56 | 77 | |
---|
57 | 78 | static int interrupts = -1; |
---|
.. | .. |
---|
173 | 194 | struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data); |
---|
174 | 195 | |
---|
175 | 196 | while (len--) |
---|
176 | | - iowrite8(*value++, phy->iobase + addr); |
---|
| 197 | + tpm_tis_iowrite8(*value++, phy->iobase, addr); |
---|
177 | 198 | |
---|
178 | 199 | return 0; |
---|
179 | 200 | } |
---|
.. | .. |
---|
200 | 221 | { |
---|
201 | 222 | struct tpm_tis_tcg_phy *phy = to_tpm_tis_tcg_phy(data); |
---|
202 | 223 | |
---|
203 | | - iowrite32(value, phy->iobase + addr); |
---|
| 224 | + tpm_tis_iowrite32(value, phy->iobase, addr); |
---|
204 | 225 | |
---|
205 | 226 | return 0; |
---|
206 | 227 | } |
---|
.. | .. |
---|
264 | 285 | return tpm_tis_init(&pnp_dev->dev, &tpm_info); |
---|
265 | 286 | } |
---|
266 | 287 | |
---|
| 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 | + |
---|
267 | 295 | static struct pnp_device_id tpm_pnp_tbl[] = { |
---|
268 | 296 | {"PNP0C31", 0}, /* TPM */ |
---|
269 | 297 | {"ATM1200", 0}, /* Atmel */ |
---|
.. | .. |
---|
315 | 343 | } |
---|
316 | 344 | tpm_info.res = *res; |
---|
317 | 345 | |
---|
318 | | - tpm_info.irq = platform_get_irq(pdev, 0); |
---|
| 346 | + tpm_info.irq = platform_get_irq_optional(pdev, 0); |
---|
319 | 347 | if (tpm_info.irq <= 0) { |
---|
320 | 348 | if (pdev != force_pdev) |
---|
321 | 349 | tpm_info.irq = -1; |
---|