Skip to content

Commit 619d996

Browse files
committed
Merge tag 'tpmdd-next-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd
Pull TPM updates from Jarkko Sakkinen: "Only some minor tweaks" * tag 'tpmdd-next-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd: tpm: atmel: Drop PPC64 specific MMIO setup char: tpm: cr50: Add new device/vendor ID 0x50666666 char: tpm: cr50: Move i2c locking to request/relinquish locality ops char: tpm: cr50: Use generic request/relinquish locality ops tpm: ibmvtpm: Set TPM_OPS_AUTO_STARTUP flag on driver
2 parents d0c9a21 + 5578b43 commit 619d996

File tree

6 files changed

+156
-211
lines changed

6 files changed

+156
-211
lines changed

drivers/char/tpm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ config TCG_NSC
162162

163163
config TCG_ATMEL
164164
tristate "Atmel TPM Interface"
165-
depends on PPC64 || HAS_IOPORT_MAP
165+
depends on HAS_IOPORT_MAP
166166
depends on HAS_IOPORT
167167
help
168168
If you have a TPM security chip from Atmel say Yes and it

drivers/char/tpm/tpm2-sessions.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,5 +1390,4 @@ int tpm2_sessions_init(struct tpm_chip *chip)
13901390

13911391
return rc;
13921392
}
1393-
EXPORT_SYMBOL(tpm2_sessions_init);
13941393
#endif /* CONFIG_TCG_TPM2_HMAC */

drivers/char/tpm/tpm_atmel.c

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,66 @@
1515
*/
1616

1717
#include "tpm.h"
18-
#include "tpm_atmel.h"
18+
19+
struct tpm_atmel_priv {
20+
int region_size;
21+
int have_region;
22+
unsigned long base;
23+
void __iomem *iobase;
24+
};
25+
26+
#define atmel_getb(chip, offset) inb(atmel_get_priv(chip)->base + (offset))
27+
#define atmel_putb(val, chip, offset) \
28+
outb(val, atmel_get_priv(chip)->base + (offset))
29+
#define atmel_request_region request_region
30+
#define atmel_release_region release_region
31+
/* Atmel definitions */
32+
enum tpm_atmel_addr {
33+
TPM_ATMEL_BASE_ADDR_LO = 0x08,
34+
TPM_ATMEL_BASE_ADDR_HI = 0x09
35+
};
36+
37+
static inline int tpm_read_index(int base, int index)
38+
{
39+
outb(index, base);
40+
return inb(base + 1) & 0xFF;
41+
}
42+
43+
/* Verify this is a 1.1 Atmel TPM */
44+
static int atmel_verify_tpm11(void)
45+
{
46+
/* verify that it is an Atmel part */
47+
if (tpm_read_index(TPM_ADDR, 4) != 'A' ||
48+
tpm_read_index(TPM_ADDR, 5) != 'T' ||
49+
tpm_read_index(TPM_ADDR, 6) != 'M' ||
50+
tpm_read_index(TPM_ADDR, 7) != 'L')
51+
return 1;
52+
53+
/* query chip for its version number */
54+
if (tpm_read_index(TPM_ADDR, 0x00) != 1 ||
55+
tpm_read_index(TPM_ADDR, 0x01) != 1)
56+
return 1;
57+
58+
/* This is an atmel supported part */
59+
return 0;
60+
}
61+
62+
/* Determine where to talk to device */
63+
static void __iomem *atmel_get_base_addr(unsigned long *base, int *region_size)
64+
{
65+
int lo, hi;
66+
67+
if (atmel_verify_tpm11() != 0)
68+
return NULL;
69+
70+
lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO);
71+
hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI);
72+
73+
*base = (hi << 8) | lo;
74+
*region_size = 2;
75+
76+
return ioport_map(*base, *region_size);
77+
}
1978

2079
/* write status bits */
2180
enum tpm_atmel_write_status {
@@ -142,7 +201,6 @@ static void atml_plat_remove(void)
142201
tpm_chip_unregister(chip);
143202
if (priv->have_region)
144203
atmel_release_region(priv->base, priv->region_size);
145-
atmel_put_base_addr(priv->iobase);
146204
platform_device_unregister(pdev);
147205
}
148206

@@ -211,7 +269,6 @@ static int __init init_atmel(void)
211269
err_unreg_dev:
212270
platform_device_unregister(pdev);
213271
err_rel_reg:
214-
atmel_put_base_addr(iobase);
215272
if (have_region)
216273
atmel_release_region(base,
217274
region_size);

drivers/char/tpm/tpm_atmel.h

Lines changed: 0 additions & 140 deletions
This file was deleted.

drivers/char/tpm/tpm_ibmvtpm.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ static bool tpm_ibmvtpm_req_canceled(struct tpm_chip *chip, u8 status)
450450
}
451451

452452
static const struct tpm_class_ops tpm_ibmvtpm = {
453+
.flags = TPM_OPS_AUTO_STARTUP,
453454
.recv = tpm_ibmvtpm_recv,
454455
.send = tpm_ibmvtpm_send,
455456
.cancel = tpm_ibmvtpm_cancel,
@@ -690,20 +691,6 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev,
690691
if (!strcmp(id->compat, "IBM,vtpm20"))
691692
chip->flags |= TPM_CHIP_FLAG_TPM2;
692693

693-
rc = tpm_get_timeouts(chip);
694-
if (rc)
695-
goto init_irq_cleanup;
696-
697-
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
698-
rc = tpm2_get_cc_attrs_tbl(chip);
699-
if (rc)
700-
goto init_irq_cleanup;
701-
702-
rc = tpm2_sessions_init(chip);
703-
if (rc)
704-
goto init_irq_cleanup;
705-
}
706-
707694
return tpm_chip_register(chip);
708695
init_irq_cleanup:
709696
do {

0 commit comments

Comments
 (0)