Skip to content

Commit 5578b43

Browse files
robherringjarkkojs
authored andcommitted
tpm: atmel: Drop PPC64 specific MMIO setup
The PPC64 specific MMIO setup open codes DT address functions rather than using standard address parsing functions. The open-coded version fails to handle any address translation and is not endian safe. I haven't found any evidence of what platform used this. The only thing that turned up was a PPC405 platform, but that is 32-bit and PPC405 support is being removed as well. CONFIG_TCG_ATMEL is not enabled for any powerpc config and never was. The support was added in 2005 and hasn't been touched since. Rather than try to modernize and fix this code, just remove it. [jarkko: fixed couple of style issues reported by checkpatch.pl --strict and put offset into parentheses in the macro declarations.] Signed-off-by: Rob Herring (Arm) <[email protected]> Acked-by: Michael Ellerman <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 2e1827d commit 5578b43

File tree

3 files changed

+61
-144
lines changed

3 files changed

+61
-144
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/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.

0 commit comments

Comments
 (0)