Home | History | Annotate | Line # | Download | only in ic
tpmvar.h revision 1.5
      1  1.5      maxv /*	$NetBSD: tpmvar.h,v 1.5 2019/10/08 18:43:02 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.4      maxv struct tpm_ioc_getinfo {
     40  1.4      maxv 	uint32_t api_version;
     41  1.4      maxv 	uint32_t tpm_version;
     42  1.4      maxv 	uint32_t device_id;
     43  1.4      maxv 	uint32_t device_rev;
     44  1.4      maxv 	uint32_t device_caps;
     45  1.4      maxv };
     46  1.4      maxv 
     47  1.4      maxv #define TPM_IOC_GETINFO		_IOR ('N',  0, struct tpm_ioc_getinfo)
     48  1.4      maxv 
     49  1.4      maxv #ifdef _KERNEL
     50  1.4      maxv 
     51  1.1  christos struct tpm_softc {
     52  1.3       chs 	device_t sc_dev;
     53  1.4      maxv 	enum tpm_version sc_ver;
     54  1.5      maxv 	kmutex_t sc_lock;
     55  1.5      maxv 	bool sc_busy;
     56  1.1  christos 
     57  1.5      maxv 	int (*sc_init)(struct tpm_softc *);
     58  1.4      maxv 	int (*sc_start)(struct tpm_softc *, int);
     59  1.4      maxv 	int (*sc_read)(struct tpm_softc *, void *, size_t, size_t *, int);
     60  1.4      maxv 	int (*sc_write)(struct tpm_softc *, const void *, size_t);
     61  1.4      maxv 	int (*sc_end)(struct tpm_softc *, int, int);
     62  1.1  christos 
     63  1.5      maxv 	bus_space_tag_t sc_bt;
     64  1.5      maxv 	bus_space_handle_t sc_bh;
     65  1.1  christos 
     66  1.4      maxv 	uint32_t sc_devid;
     67  1.4      maxv 	uint32_t sc_rev;
     68  1.4      maxv 	uint32_t sc_status;
     69  1.5      maxv 	uint32_t sc_caps;
     70  1.1  christos };
     71  1.1  christos 
     72  1.4      maxv bool tpm12_suspend(device_t, const pmf_qual_t *);
     73  1.4      maxv bool tpm12_resume(device_t, const pmf_qual_t *);
     74  1.1  christos 
     75  1.1  christos int tpm_tis12_probe(bus_space_tag_t, bus_space_handle_t);
     76  1.5      maxv int tpm_tis12_init(struct tpm_softc *);
     77  1.1  christos int tpm_tis12_start(struct tpm_softc *, int);
     78  1.2  christos int tpm_tis12_read(struct tpm_softc *, void *, size_t, size_t *, int);
     79  1.2  christos int tpm_tis12_write(struct tpm_softc *, const void *, size_t);
     80  1.1  christos int tpm_tis12_end(struct tpm_softc *, int, int);
     81  1.1  christos 
     82  1.4      maxv #endif
     83