tpmvar.h revision 1.4 1 /* $NetBSD: tpmvar.h,v 1.4 2019/06/22 12:57:41 maxv Exp $ */
2
3 /*
4 * Copyright (c) 2019 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Maxime Villard.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 * Copyright (c) 2008, 2009 Michael Shalayeff
34 * Copyright (c) 2009, 2010 Hans-Joerg Hoexer
35 * All rights reserved.
36 *
37 * Permission to use, copy, modify, and distribute this software for any
38 * purpose with or without fee is hereby granted, provided that the above
39 * copyright notice and this permission notice appear in all copies.
40 *
41 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
42 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
43 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
44 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
45 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
46 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
47 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
48 */
49
50 #define TPM_API_VERSION 1
51
52 enum tpm_version {
53 TPM_1_2,
54 TPM_2_0
55 };
56
57 struct tpm_ioc_getinfo {
58 uint32_t api_version;
59
60 uint32_t tpm_version;
61 uint32_t device_id;
62 uint32_t device_rev;
63 uint32_t device_caps;
64 };
65
66 #define TPM_IOC_GETINFO _IOR ('N', 0, struct tpm_ioc_getinfo)
67
68 #ifdef _KERNEL
69
70 struct tpm_softc {
71 device_t sc_dev;
72 enum tpm_version sc_ver;
73 void *sc_ih;
74
75 int (*sc_init)(struct tpm_softc *, int);
76 int (*sc_start)(struct tpm_softc *, int);
77 int (*sc_read)(struct tpm_softc *, void *, size_t, size_t *, int);
78 int (*sc_write)(struct tpm_softc *, const void *, size_t);
79 int (*sc_end)(struct tpm_softc *, int, int);
80
81 bus_space_tag_t sc_bt, sc_batm;
82 bus_space_handle_t sc_bh, sc_bahm;
83
84 uint32_t sc_devid;
85 uint32_t sc_rev;
86 uint32_t sc_status;
87 uint32_t sc_capabilities;
88
89 int sc_flags;
90 #define TPM_OPEN 0x0001
91
92 int sc_vector;
93 };
94
95 int tpm_intr(void *);
96
97 bool tpm12_suspend(device_t, const pmf_qual_t *);
98 bool tpm12_resume(device_t, const pmf_qual_t *);
99
100 int tpm_tis12_probe(bus_space_tag_t, bus_space_handle_t);
101 int tpm_tis12_init(struct tpm_softc *, int);
102 int tpm_tis12_start(struct tpm_softc *, int);
103 int tpm_tis12_read(struct tpm_softc *, void *, size_t, size_t *, int);
104 int tpm_tis12_write(struct tpm_softc *, const void *, size_t);
105 int tpm_tis12_end(struct tpm_softc *, int, int);
106
107 #endif
108