Home | History | Annotate | Line # | Download | only in ic
      1  1.10  riastrad /*	$NetBSD: tpmvar.h,v 1.10 2021/12/20 23:05:55 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.9  riastrad #include <sys/rndsource.h>
     66   1.9  riastrad #include <sys/workqueue.h>
     67   1.8  riastrad 
     68   1.7      maxv struct tpm_softc;
     69   1.7      maxv 
     70   1.7      maxv struct tpm_intf {
     71   1.7      maxv 	enum itf_version version;
     72   1.7      maxv 	int (*probe)(bus_space_tag_t, bus_space_handle_t);
     73   1.7      maxv 	int (*init)(struct tpm_softc *);
     74   1.7      maxv 	int (*start)(struct tpm_softc *, int);
     75   1.7      maxv 	int (*read)(struct tpm_softc *, void *, size_t, size_t *, int);
     76   1.7      maxv 	int (*write)(struct tpm_softc *, const void *, size_t);
     77   1.7      maxv 	int (*end)(struct tpm_softc *, int, int);
     78   1.7      maxv };
     79   1.7      maxv 
     80   1.7      maxv extern const struct tpm_intf tpm_intf_tis12;
     81   1.7      maxv 
     82   1.1  christos struct tpm_softc {
     83   1.3       chs 	device_t sc_dev;
     84   1.4      maxv 	enum tpm_version sc_ver;
     85   1.5      maxv 	kmutex_t sc_lock;
     86   1.5      maxv 	bool sc_busy;
     87   1.1  christos 
     88   1.7      maxv 	const struct tpm_intf *sc_intf;
     89   1.5      maxv 	bus_space_tag_t sc_bt;
     90   1.5      maxv 	bus_space_handle_t sc_bh;
     91   1.1  christos 
     92   1.4      maxv 	uint32_t sc_devid;
     93   1.4      maxv 	uint32_t sc_rev;
     94   1.4      maxv 	uint32_t sc_status;
     95   1.5      maxv 	uint32_t sc_caps;
     96   1.9  riastrad 
     97   1.9  riastrad 	struct krndsource sc_rnd;
     98   1.9  riastrad 	struct workqueue *sc_rndwq;
     99   1.9  riastrad 	struct work sc_rndwk;
    100   1.9  riastrad 	volatile unsigned sc_rndpending;
    101  1.10  riastrad 	bool sc_rnddisabled;
    102   1.1  christos };
    103   1.1  christos 
    104   1.6      maxv bool tpm_suspend(device_t, const pmf_qual_t *);
    105   1.6      maxv bool tpm_resume(device_t, const pmf_qual_t *);
    106   1.1  christos 
    107   1.4      maxv #endif
    108   1.8  riastrad 
    109   1.8  riastrad #endif	/* DEV_IC_TPMVAR_H */
    110