tpmvar.h revision 1.8 1 1.8 riastrad /* $NetBSD: tpmvar.h,v 1.8 2021/01/04 18:22:19 riastradh Exp $ */
2 1.4 maxv
3 1.4 maxv /*
4 1.4 maxv * Copyright (c) 2019 The NetBSD Foundation, Inc.
5 1.4 maxv * All rights reserved.
6 1.4 maxv *
7 1.4 maxv * This code is derived from software contributed to The NetBSD Foundation
8 1.4 maxv * by Maxime Villard.
9 1.4 maxv *
10 1.4 maxv * Redistribution and use in source and binary forms, with or without
11 1.4 maxv * modification, are permitted provided that the following conditions
12 1.4 maxv * are met:
13 1.4 maxv * 1. Redistributions of source code must retain the above copyright
14 1.4 maxv * notice, this list of conditions and the following disclaimer.
15 1.4 maxv * 2. Redistributions in binary form must reproduce the above copyright
16 1.4 maxv * notice, this list of conditions and the following disclaimer in the
17 1.4 maxv * documentation and/or other materials provided with the distribution.
18 1.4 maxv *
19 1.4 maxv * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.4 maxv * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.4 maxv * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.4 maxv * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.4 maxv * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.4 maxv * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.4 maxv * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.4 maxv * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.4 maxv * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.4 maxv * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.4 maxv * POSSIBILITY OF SUCH DAMAGE.
30 1.4 maxv */
31 1.4 maxv
32 1.8 riastrad #ifndef DEV_IC_TPMVAR_H
33 1.8 riastrad #define DEV_IC_TPMVAR_H
34 1.8 riastrad
35 1.8 riastrad #include <sys/types.h>
36 1.8 riastrad
37 1.4 maxv #define TPM_API_VERSION 1
38 1.4 maxv
39 1.4 maxv enum tpm_version {
40 1.4 maxv TPM_1_2,
41 1.4 maxv TPM_2_0
42 1.4 maxv };
43 1.4 maxv
44 1.7 maxv enum itf_version {
45 1.7 maxv TIS_1_2,
46 1.7 maxv CRB
47 1.7 maxv };
48 1.7 maxv
49 1.4 maxv struct tpm_ioc_getinfo {
50 1.4 maxv uint32_t api_version;
51 1.4 maxv uint32_t tpm_version;
52 1.7 maxv uint32_t itf_version;
53 1.4 maxv uint32_t device_id;
54 1.4 maxv uint32_t device_rev;
55 1.4 maxv uint32_t device_caps;
56 1.4 maxv };
57 1.4 maxv
58 1.4 maxv #define TPM_IOC_GETINFO _IOR ('N', 0, struct tpm_ioc_getinfo)
59 1.4 maxv
60 1.4 maxv #ifdef _KERNEL
61 1.4 maxv
62 1.8 riastrad #include <sys/bus.h>
63 1.8 riastrad #include <sys/device_if.h>
64 1.8 riastrad #include <sys/mutex.h>
65 1.8 riastrad
66 1.7 maxv struct tpm_softc;
67 1.7 maxv
68 1.7 maxv struct tpm_intf {
69 1.7 maxv enum itf_version version;
70 1.7 maxv int (*probe)(bus_space_tag_t, bus_space_handle_t);
71 1.7 maxv int (*init)(struct tpm_softc *);
72 1.7 maxv int (*start)(struct tpm_softc *, int);
73 1.7 maxv int (*read)(struct tpm_softc *, void *, size_t, size_t *, int);
74 1.7 maxv int (*write)(struct tpm_softc *, const void *, size_t);
75 1.7 maxv int (*end)(struct tpm_softc *, int, int);
76 1.7 maxv };
77 1.7 maxv
78 1.7 maxv extern const struct tpm_intf tpm_intf_tis12;
79 1.7 maxv
80 1.1 christos struct tpm_softc {
81 1.3 chs device_t sc_dev;
82 1.4 maxv enum tpm_version sc_ver;
83 1.5 maxv kmutex_t sc_lock;
84 1.5 maxv bool sc_busy;
85 1.1 christos
86 1.7 maxv const struct tpm_intf *sc_intf;
87 1.5 maxv bus_space_tag_t sc_bt;
88 1.5 maxv bus_space_handle_t sc_bh;
89 1.1 christos
90 1.4 maxv uint32_t sc_devid;
91 1.4 maxv uint32_t sc_rev;
92 1.4 maxv uint32_t sc_status;
93 1.5 maxv uint32_t sc_caps;
94 1.1 christos };
95 1.1 christos
96 1.6 maxv bool tpm_suspend(device_t, const pmf_qual_t *);
97 1.6 maxv bool tpm_resume(device_t, const pmf_qual_t *);
98 1.1 christos
99 1.4 maxv #endif
100 1.8 riastrad
101 1.8 riastrad #endif /* DEV_IC_TPMVAR_H */
102