tpmvar.h revision 1.7 1 /* $NetBSD: tpmvar.h,v 1.7 2019/10/09 14:03:58 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 #define TPM_API_VERSION 1
33
34 enum tpm_version {
35 TPM_1_2,
36 TPM_2_0
37 };
38
39 enum itf_version {
40 TIS_1_2,
41 CRB
42 };
43
44 struct tpm_ioc_getinfo {
45 uint32_t api_version;
46 uint32_t tpm_version;
47 uint32_t itf_version;
48 uint32_t device_id;
49 uint32_t device_rev;
50 uint32_t device_caps;
51 };
52
53 #define TPM_IOC_GETINFO _IOR ('N', 0, struct tpm_ioc_getinfo)
54
55 #ifdef _KERNEL
56
57 struct tpm_softc;
58
59 struct tpm_intf {
60 enum itf_version version;
61 int (*probe)(bus_space_tag_t, bus_space_handle_t);
62 int (*init)(struct tpm_softc *);
63 int (*start)(struct tpm_softc *, int);
64 int (*read)(struct tpm_softc *, void *, size_t, size_t *, int);
65 int (*write)(struct tpm_softc *, const void *, size_t);
66 int (*end)(struct tpm_softc *, int, int);
67 };
68
69 extern const struct tpm_intf tpm_intf_tis12;
70
71 struct tpm_softc {
72 device_t sc_dev;
73 enum tpm_version sc_ver;
74 kmutex_t sc_lock;
75 bool sc_busy;
76
77 const struct tpm_intf *sc_intf;
78 bus_space_tag_t sc_bt;
79 bus_space_handle_t sc_bh;
80
81 uint32_t sc_devid;
82 uint32_t sc_rev;
83 uint32_t sc_status;
84 uint32_t sc_caps;
85 };
86
87 bool tpm_suspend(device_t, const pmf_qual_t *);
88 bool tpm_resume(device_t, const pmf_qual_t *);
89
90 #endif
91