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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6 #include <common.h>
7 #include <config.h>
8 #include <i2c.h>
9 #include "slb9635_i2c/ifx_auto.h"
10
11 /* api function pointer for different version chip */
12 static struct {
13 int (*open)(void);
14 int (*close)(void);
15 int (*sendrecv)(const uint8_t *sendbuf, size_t sbuf_size,
16 uint8_t *recvbuf, size_t *rbuf_len);
17 } _tpm_instance = {0};
18
19
20 int tis_init(void)
21 {
22 #ifdef CONFIG_TPM_SLB9635_I2C_V03
23 /* prototype version chip detection */
24 if (tpm_init_v03() == 0) {
25 printf("I2C addr(x1A) : v03 prototype\n");
26 _tpm_instance.open = tpm_open_v03;
27 _tpm_instance.close = tpm_close_v03;
28 _tpm_instance.sendrecv = tpm_sendrecv_v03;
29 return 0;
30 }
31 #endif
32
33 #ifdef CONFIG_TPM_SLB9635_I2C
34 /* firmware virsion > v05 : production */
35 if (tpm_init_v05() == 0) {
36 printf("I2C addr(x20) : v05 engineering/production\n");
37 _tpm_instance.open = tpm_open_v05;
38 _tpm_instance.close = tpm_close_v05;
39 _tpm_instance.sendrecv = tpm_sendrecv_v05;
40 return 0;
41 }
42 #endif
43 _tpm_instance.open = NULL;
44 _tpm_instance.close = NULL;
45 _tpm_instance.sendrecv = NULL;
46 return -1;
47 }
48
49 int tis_open(void)
50 {
51 if (_tpm_instance.open)
52 return (*_tpm_instance.open)();
53 return -1;
54 }
55
56 int tis_close(void)
57 {
58 if (_tpm_instance.close)
59 return (*_tpm_instance.close)();
60 return -1;
61 }
62
63 int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size,
64 uint8_t *recvbuf, size_t *rbuf_len)
65 {
66 if (_tpm_instance.sendrecv)
67 return (*_tpm_instance.sendrecv)(sendbuf, sbuf_size, recvbuf,
68 rbuf_len);
69 return -1;
70 }
71
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698