1 /* 2 * Copyright (C) 2005, 2006 IBM Corporation 3 * Copyright (C) 2014, 2015 Intel Corporation 4 * 5 * Authors: 6 * Leendert van Doorn <leendert@watson.ibm.com> 7 * Kylene Hall <kjhall@us.ibm.com> 8 * 9 * Maintained by: <tpmdd-devel@lists.sourceforge.net> 10 * 11 * Device driver for TCG/TCPA TPM (trusted platform module). 12 * Specifications at www.trustedcomputinggroup.org 13 * 14 * This device driver implements the TPM interface as defined in 15 * the TCG TPM Interface Spec version 1.2, revision 1.0. 16 * 17 * This program is free software; you can redistribute it and/or 18 * modify it under the terms of the GNU General Public License as 19 * published by the Free Software Foundation, version 2 of the 20 * License. 21 */ 22 23 #ifndef __TPM_TIS_CORE_H__ 24 #define __TPM_TIS_CORE_H__ 25 26 #include "tpm.h" 27 28 struct tpm_tis_data { 29 u16 manufacturer_id; 30 int locality; 31 int irq; 32 bool irq_tested; 33 wait_queue_head_t int_queue; 34 wait_queue_head_t read_queue; 35 const struct tpm_tis_phy_ops *phy_ops; 36 }; 37 38 struct tpm_tis_phy_ops { 39 int (*read_bytes)(struct tpm_tis_data *data, u32 addr, u16 len, 40 u8 *result); 41 int (*write_bytes)(struct tpm_tis_data *data, u32 addr, u16 len, 42 u8 *value); 43 int (*read16)(struct tpm_tis_data *data, u32 addr, u16 *result); 44 int (*read32)(struct tpm_tis_data *data, u32 addr, u32 *result); 45 int (*write32)(struct tpm_tis_data *data, u32 addr, u32 src); 46 }; 47 48 static inline int tpm_tis_read_bytes(struct tpm_tis_data *data, u32 addr, 49 u16 len, u8 *result) 50 { 51 return data->phy_ops->read_bytes(data, addr, len, result); 52 } 53 54 static inline int tpm_tis_read8(struct tpm_tis_data *data, u32 addr, u8 *result) 55 { 56 return data->phy_ops->read_bytes(data, addr, 1, result); 57 } 58 59 static inline int tpm_tis_read16(struct tpm_tis_data *data, u32 addr, 60 u16 *result) 61 { 62 return data->phy_ops->read16(data, addr, result); 63 } 64 65 static inline int tpm_tis_read32(struct tpm_tis_data *data, u32 addr, 66 u32 *result) 67 { 68 return data->phy_ops->read32(data, addr, result); 69 } 70 71 static inline int tpm_tis_write_bytes(struct tpm_tis_data *data, u32 addr, 72 u16 len, u8 *value) 73 { 74 return data->phy_ops->write_bytes(data, addr, len, value); 75 } 76 77 static inline int tpm_tis_write8(struct tpm_tis_data *data, u32 addr, u8 value) 78 { 79 return data->phy_ops->write_bytes(data, addr, 1, &value); 80 } 81 82 static inline int tpm_tis_write32(struct tpm_tis_data *data, u32 addr, 83 u32 value) 84 { 85 return data->phy_ops->write32(data, addr, value); 86 } 87 88 #endif 89