^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2004 IBM Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2015 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Leendert van Doorn <leendert@watson.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Dave Safford <safford@watson.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Reiner Sailer <sailer@watson.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Kylene Hall <kjhall@us.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Maintained by: <tpmdd-devel@lists.sourceforge.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Device driver for TCG/TCPA TPM (trusted platform module).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Specifications at www.trustedcomputinggroup.org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #ifndef __TPM_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define __TPM_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/tpm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/tpm_eventlog.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #ifdef CONFIG_X86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <asm/intel-family.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define TPM_MINOR 224 /* officially assigned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define TPM_BUFSIZE 4096
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define TPM_NUM_DEVICES 65536
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define TPM_RETRY 50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) enum tpm_timeout {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) TPM_TIMEOUT = 5, /* msecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) TPM_TIMEOUT_RETRY = 100, /* msecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) TPM_TIMEOUT_RANGE_US = 300, /* usecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) TPM_TIMEOUT_POLL = 1, /* msecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) TPM_TIMEOUT_USECS_MIN = 100, /* usecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) TPM_TIMEOUT_USECS_MAX = 500 /* usecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* TPM addresses */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) enum tpm_addr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) TPM_SUPERIO_ADDR = 0x2E,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) TPM_ADDR = 0x4E,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define TPM_WARN_RETRY 0x800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define TPM_WARN_DOING_SELFTEST 0x802
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define TPM_ERR_DEACTIVATED 0x6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define TPM_ERR_DISABLED 0x7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define TPM_ERR_INVALID_POSTINIT 38
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define TPM_TAG_RQU_COMMAND 193
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /* TPM2 specific constants. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define TPM2_SPACE_BUFFER_SIZE 16384 /* 16 kB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct stclear_flags_t {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) __be16 tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u8 deactivated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) u8 disableForceClear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) u8 physicalPresence;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) u8 physicalPresenceLock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) u8 bGlobalLock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct tpm1_version {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) u8 major;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) u8 minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) u8 rev_major;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) u8 rev_minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct tpm1_version2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) __be16 tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct tpm1_version version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct timeout_t {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) __be32 a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) __be32 b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) __be32 c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) __be32 d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct duration_t {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) __be32 tpm_short;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) __be32 tpm_medium;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) __be32 tpm_long;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct permanent_flags_t {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) __be16 tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) u8 disable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) u8 ownership;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) u8 deactivated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) u8 readPubek;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) u8 disableOwnerClear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) u8 allowMaintenance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) u8 physicalPresenceLifetimeLock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) u8 physicalPresenceHWEnable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) u8 physicalPresenceCMDEnable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) u8 CEKPUsed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) u8 TPMpost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) u8 TPMpostLock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) u8 FIPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) u8 operator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) u8 enableRevokeEK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) u8 nvLocked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) u8 readSRKPub;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) u8 tpmEstablished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) u8 maintenanceDone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) u8 disableFullDALogicInfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) typedef union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct permanent_flags_t perm_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct stclear_flags_t stclear_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) __u8 owned;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) __be32 num_pcrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) struct tpm1_version version1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct tpm1_version2 version2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) __be32 manufacturer_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct timeout_t timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct duration_t duration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) } cap_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) enum tpm_capabilities {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) TPM_CAP_FLAG = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) TPM_CAP_PROP = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) TPM_CAP_VERSION_1_1 = 0x06,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) TPM_CAP_VERSION_1_2 = 0x1A,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) enum tpm_sub_capabilities {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) TPM_CAP_PROP_PCR = 0x101,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) TPM_CAP_PROP_MANUFACTURER = 0x103,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) TPM_CAP_FLAG_PERM = 0x108,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) TPM_CAP_FLAG_VOL = 0x109,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) TPM_CAP_PROP_OWNER = 0x111,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) TPM_CAP_PROP_TIS_TIMEOUT = 0x115,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) TPM_CAP_PROP_TIS_DURATION = 0x120,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* 128 bytes is an arbitrary cap. This could be as large as TPM_BUFSIZE - 18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * bytes, but 128 is still a relatively large number of random bytes and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * anything much bigger causes users of struct tpm_cmd_t to start getting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * compiler warnings about stack frame size. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #define TPM_MAX_RNG_DATA 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) extern struct class *tpm_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) extern struct class *tpmrm_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) extern dev_t tpm_devt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) extern const struct file_operations tpm_fops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) extern const struct file_operations tpmrm_fops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) extern struct idr dev_nums_idr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) int tpm_get_timeouts(struct tpm_chip *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) int tpm_auto_startup(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) int tpm1_pm_suspend(struct tpm_chip *chip, u32 tpm_suspend_pcr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) int tpm1_auto_startup(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) int tpm1_do_selftest(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) int tpm1_get_timeouts(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) unsigned long tpm1_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) int tpm1_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, const u8 *hash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) const char *log_msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) int tpm1_pcr_read(struct tpm_chip *chip, u32 pcr_idx, u8 *res_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ssize_t tpm1_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) const char *desc, size_t min_cap_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) int tpm1_get_random(struct tpm_chip *chip, u8 *out, size_t max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) int tpm1_get_pcr_allocation(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) int tpm_pm_suspend(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int tpm_pm_resume(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static inline void tpm_msleep(unsigned int delay_msec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) usleep_range((delay_msec * 1000) - TPM_TIMEOUT_RANGE_US,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) delay_msec * 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) int tpm_chip_start(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) void tpm_chip_stop(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct tpm_chip *tpm_chip_alloc(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) const struct tpm_class_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct tpm_chip *tpmm_chip_alloc(struct device *pdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) const struct tpm_class_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) int tpm_chip_register(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) void tpm_chip_unregister(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) void tpm_sysfs_add_device(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) #ifdef CONFIG_ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) extern void tpm_add_ppi(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static inline void tpm_add_ppi(struct tpm_chip *chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) int tpm2_get_timeouts(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int tpm2_pcr_read(struct tpm_chip *chip, u32 pcr_idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct tpm_digest *digest, u16 *digest_size_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) int tpm2_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct tpm_digest *digests);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) u32 *value, const char *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) int tpm2_auto_startup(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) int tpm2_probe(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) int tpm2_get_cc_attrs_tbl(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) int tpm2_find_cc(struct tpm_chip *chip, u32 cc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) int tpm2_init_space(struct tpm_space *space, unsigned int buf_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) void tpm2_flush_space(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u8 *cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) size_t cmdsiz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space, void *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) size_t *bufsiz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) int tpm_devs_add(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) void tpm_devs_remove(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) void tpm_bios_log_setup(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) void tpm_bios_log_teardown(struct tpm_chip *chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) int tpm_dev_common_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) void tpm_dev_common_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) #endif