X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Ftpm-common.h;h=5f8bc6bc5287189d48ee1829d60fd5a9be4c4bc4;hb=0223462b373b975d970fa86e5e1a7eadd1d41820;hp=734c2c9d5398acf75939dfefc5f9ec5e7c42b87d;hpb=add7aa9f97f73ed20e2883f7fc6156b72276cdbc;p=platform%2Fkernel%2Fu-boot.git diff --git a/include/tpm-common.h b/include/tpm-common.h index 734c2c9..5f8bc6b 100644 --- a/include/tpm-common.h +++ b/include/tpm-common.h @@ -27,26 +27,39 @@ enum tpm_duration { #define TPM_DEV_BUFSIZE 1260 /** + * enum tpm_version - The version of the TPM stack to be used + * @TPM_V1: Use TPM v1.x stack + * @TPM_V2: Use TPM v2.x stack + */ +enum tpm_version { + TPM_V1 = 0, + TPM_V2, +}; + +/** * struct tpm_chip_priv - Information about a TPM, stored by the uclass * * These values must be set up by the device's probe() method before * communcation is attempted. If the device has an xfer() method, this is * not needed. There is no need to set up @buf. * + * @version: TPM stack to be used * @duration_ms: Length of each duration type in milliseconds * @retry_time_ms: Time to wait before retrying receive + * @buf: Buffer used during the exchanges with the chip * @pcr_count: Number of PCR per bank * @pcr_select_min: Minimum size in bytes of the pcrSelect array - * @buf: Buffer used during the exchanges with the chip */ struct tpm_chip_priv { + enum tpm_version version; + uint duration_ms[TPM_DURATION_COUNT]; uint retry_time_ms; -#if defined(CONFIG_TPM_V2) + u8 buf[TPM_DEV_BUFSIZE + sizeof(u8)]; /* Max buffer size + addr */ + + /* TPM v2 specific data */ uint pcr_count; uint pcr_select_min; -#endif - u8 buf[TPM_DEV_BUFSIZE + sizeof(u8)]; /* Max buffer size + addr */ }; /** @@ -71,7 +84,7 @@ struct tpm_ops { * After all commands have been completed the caller should call * close(). * - * @dev: Device to close + * @dev: Device to open * @return 0 ok OK, -ve on error */ int (*open)(struct udevice *dev); @@ -208,10 +221,25 @@ int tpm_xfer(struct udevice *dev, const u8 *sendbuf, size_t send_size, int tpm_init(void); /** - * Retrieve the array containing all the commands. + * Retrieve the array containing all the v1 (resp. v2) commands. * * @return a cmd_tbl_t array. */ -cmd_tbl_t *get_tpm_commands(unsigned int *size); +#if defined(CONFIG_TPM_V1) +cmd_tbl_t *get_tpm1_commands(unsigned int *size); +#else +static inline cmd_tbl_t *get_tpm1_commands(unsigned int *size) +{ + return NULL; +} +#endif +#if defined(CONFIG_TPM_V2) +cmd_tbl_t *get_tpm2_commands(unsigned int *size); +#else +static inline cmd_tbl_t *get_tpm2_commands(unsigned int *size) +{ + return NULL; +} +#endif #endif /* __TPM_COMMON_H */