2
* Copyright (C) 2005 IBM Corporation
5
* Kylene Hall <kjhall@us.ibm.com>
7
* Maintained by: <tpmdd-devel@lists.sourceforge.net>
9
* Device driver for TCG/TCPA TPM (trusted platform module).
10
* Specifications at www.trustedcomputinggroup.org
12
* This program is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU General Public License as
14
* published by the Free Software Foundation, version 2 of the
17
* These difference are required on power because the device must be
18
* discovered through the device tree and iomap must be used to get
19
* around the need for holes in the io_page_mask. This does not happen
20
* automatically because the tpm is not a normal pci device and lives
21
* under the root node.
29
#define atmel_getb(chip, offset) readb(chip->vendor->iobase + offset);
30
#define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset)
31
#define atmel_request_region request_mem_region
32
#define atmel_release_region release_mem_region
34
static inline void atmel_put_base_addr(void __iomem *iobase)
39
static void __iomem * atmel_get_base_addr(unsigned long *base, int *region_size)
41
struct device_node *dn;
42
unsigned long address, size;
43
const unsigned int *reg;
48
dn = of_find_node_by_name(NULL, "tpm");
53
if (!of_device_is_compatible(dn, "AT97SC3201")) {
58
reg = of_get_property(dn, "reg", ®len);
59
naddrc = of_n_addr_cells(dn);
60
nsizec = of_n_size_cells(dn);
66
address = ((unsigned long) reg[0] << 32) | reg[1];
72
((unsigned long) reg[naddrc] << 32) | reg[naddrc + 1];
78
return ioremap(*base, *region_size);
81
#define atmel_getb(chip, offset) inb(chip->vendor->base + offset)
82
#define atmel_putb(val, chip, offset) outb(val, chip->vendor->base + offset)
83
#define atmel_request_region request_region
84
#define atmel_release_region release_region
85
/* Atmel definitions */
87
TPM_ATMEL_BASE_ADDR_LO = 0x08,
88
TPM_ATMEL_BASE_ADDR_HI = 0x09
91
/* Verify this is a 1.1 Atmel TPM */
92
static int atmel_verify_tpm11(void)
95
/* verify that it is an Atmel part */
96
if (tpm_read_index(TPM_ADDR, 4) != 'A' ||
97
tpm_read_index(TPM_ADDR, 5) != 'T' ||
98
tpm_read_index(TPM_ADDR, 6) != 'M' ||
99
tpm_read_index(TPM_ADDR, 7) != 'L')
102
/* query chip for its version number */
103
if (tpm_read_index(TPM_ADDR, 0x00) != 1 ||
104
tpm_read_index(TPM_ADDR, 0x01) != 1)
107
/* This is an atmel supported part */
111
static inline void atmel_put_base_addr(void __iomem *iobase)
115
/* Determine where to talk to device */
116
static void __iomem * atmel_get_base_addr(unsigned long *base, int *region_size)
120
if (atmel_verify_tpm11() != 0)
123
lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO);
124
hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI);
126
*base = (hi << 8) | lo;
129
return ioport_map(*base, *region_size);