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