Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1308)

Unified Diff: drivers/tpm/slb9635_i2c/tddl.c

Issue 6683023: Add Infineon v05 TPM driver (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/u-boot-next.git@chromeos-v2010.09
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: drivers/tpm/slb9635_i2c/tddl.c
diff --git a/drivers/tpm/slb9635_i2c/tddl.c b/drivers/tpm/slb9635_i2c/tddl.c
new file mode 100644
index 0000000000000000000000000000000000000000..a678a25bca6cb7a8b2ccc28fbd3da91c2ccdad46
--- /dev/null
+++ b/drivers/tpm/slb9635_i2c/tddl.c
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ **
+ ** FILENAME: $Id: i2c_tddl.c 59 2010-10-20 10:04:48Z hkr $
+ ** COPYRIGHT: Infineon Technologies
+ ** DESCRIPTION: Infineon_TPM-I2C - TDD supporting FW 2010.
+ ** CREATION DATE: 2010/11/10
+ ** LAST CHANGE: $Date: 2010-10-20 12:04:48 +0200 (Wed, 20 Oct 2010) $
+ ** $Author$
+ ** VERSION: $Revision: 59 $
+ **
+ ******************************************************************************/
+#include <exports.h>
+
+#include "tddl.h"
+#include "compatibility.h"
+#include "tpm.h"
+
+/* buffer supporting tpm_transmit */
+#define TDDL_BUFSIZE 4096
+uint8_t tmpbuf[TDDL_BUFSIZE];
+
+/* Open connection to TPM */
+TDDL_RESULT TDDL_Open(void)
+{
+ dbg_printf("INFO: initialising I2C bus TDDL\n");
+ if (tpm_open() < 0)
+ return TDDL_E_FAIL;
+ else
+ return TDDL_SUCCESS;
+}
+
+/* Disconnect from the TPM */
+TDDL_RESULT TDDL_Close(void)
+{
+ tpm_close();
+ return TDDL_SUCCESS;
+}
+
+/* Send the TPM Application Protocol Data Unit (APDU) to the TPM and
+ * return the response APDU */
+TDDL_RESULT TDDL_TransmitData(uint8_t *pbTransmitBuf, uint32_t dwTransmitBufLen,
+ uint8_t *pbReceiveBuf, uint32_t *pdwReceiveBufLen)
+{
+ int len;
+ uint32_t i;
+ TDDL_RESULT rc = TDDL_E_FAIL;
+
+ dbg_printf("--> xTDDL_TransmitData()\n");
+
+ dbg_printf("pbTransmitBuf = ");
+ for (i = 0; i < dwTransmitBufLen; i++)
+ dbg_printf("%02x ", pbTransmitBuf[i]);
+ dbg_printf("\n");
+
+ /* copy buffer to make sure transmit data may be overwritten */
+ memcpy(tmpbuf, pbTransmitBuf, dwTransmitBufLen);
+
+ /* do transmission */
+ len = tpm_transmit(tmpbuf, TDDL_BUFSIZE);
+
+ if (len >= 10) {
+ memcpy(pbReceiveBuf, tmpbuf, len);
+ dbg_printf("INFO: copied %d bytes into pbReceiveBuf\n", len);
+ rc = switch_endian32(&tmpbuf[TPM_RSP_RC_BYTE]);
+ *pdwReceiveBufLen = len;
+ } else {
+ dbg_printf("ERROR: tpm_transmit() returned %d\n", len);
+ *pdwReceiveBufLen = 0;
+ }
+
+ dbg_printf("pbReceiveBuf = ");
+ for (i = 0; i < (*pdwReceiveBufLen); i++)
+ dbg_printf("%02x ", pbReceiveBuf[i]);
+ dbg_printf("\n");
+
+ dbg_printf("<-- xTDDL_TransmitData()\n");
+
+ return rc;
+}
+
+/* Return the requested capability of the TPM or the driver */
+TDDL_RESULT TDDL_GetCapability(uint32_t dwCapArea, uint32_t dwSubCap,
+ uint8_t *pbReceiveBuf, uint32_t *pdwReceiveBufLen)
+{
+ return TDDL_E_FAIL;
+}

Powered by Google App Engine
This is Rietveld 408576698