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

Unified Diff: drivers/tpm/slb9635_i2c.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: Fix nits 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
« no previous file with comments | « drivers/tpm/Makefile ('k') | drivers/tpm/slb9635_i2c/compatibility.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: drivers/tpm/slb9635_i2c.c
diff --git a/drivers/tpm/slb9635_i2c.c b/drivers/tpm/slb9635_i2c.c
new file mode 100644
index 0000000000000000000000000000000000000000..41382a117405761f9274451d8bfacfe8544ece17
--- /dev/null
+++ b/drivers/tpm/slb9635_i2c.c
@@ -0,0 +1,71 @@
+/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <common.h>
+#include <config.h>
+#include <i2c.h>
+#include "slb9635_i2c/ifx_auto.h"
+
+/* api function pointer for different version chip */
+static struct {
+ int (*open)(void);
+ int (*close)(void);
+ int (*sendrecv)(const uint8_t *sendbuf, size_t sbuf_size,
+ uint8_t *recvbuf, size_t *rbuf_len);
+} _tpm_instance = {0};
+
+
+int tis_init(void)
+{
+#ifdef CONFIG_TPM_SLB9635_I2C_V03
+ /* prototype version chip detection */
+ if (tpm_init_v03() == 0) {
+ printf("I2C addr(x1A) : v03 prototype\n");
+ _tpm_instance.open = tpm_open_v03;
+ _tpm_instance.close = tpm_close_v03;
+ _tpm_instance.sendrecv = tpm_sendrecv_v03;
+ return 0;
+ }
+#endif
+
+#ifdef CONFIG_TPM_SLB9635_I2C
+ /* firmware virsion > v05 : production */
+ if (tpm_init_v05() == 0) {
+ printf("I2C addr(x20) : v05 engineering/production\n");
+ _tpm_instance.open = tpm_open_v05;
+ _tpm_instance.close = tpm_close_v05;
+ _tpm_instance.sendrecv = tpm_sendrecv_v05;
+ return 0;
+ }
+#endif
+ _tpm_instance.open = NULL;
+ _tpm_instance.close = NULL;
+ _tpm_instance.sendrecv = NULL;
+ return -1;
+}
+
+int tis_open(void)
+{
+ if (_tpm_instance.open)
+ return (*_tpm_instance.open)();
+ return -1;
+}
+
+int tis_close(void)
+{
+ if (_tpm_instance.close)
+ return (*_tpm_instance.close)();
+ return -1;
+}
+
+int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size,
+ uint8_t *recvbuf, size_t *rbuf_len)
+{
+ if (_tpm_instance.sendrecv)
+ return (*_tpm_instance.sendrecv)(sendbuf, sbuf_size, recvbuf,
+ rbuf_len);
+ return -1;
+}
+
« no previous file with comments | « drivers/tpm/Makefile ('k') | drivers/tpm/slb9635_i2c/compatibility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698