aboutsummaryrefslogtreecommitdiff
path: root/libstb/tpm_chip.h
blob: 70f5c9736304213727c9d46a84d2a6b9956f8ff6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* Copyright 2013-2016 IBM Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __TPM_H
#define __TPM_H

#include <device.h>

struct tpm_dev {

	/* TPM bus id */
	int bus_id;

	/* TPM address in the bus */
	int xscom_base;
};

struct tpm_driver {

	/* Driver name */
	const char* name;

	/* Transmit the TPM command stored in buf to the tpm device */
	int (*transmit)(struct tpm_dev *dev, uint8_t* buf, size_t cmdlen,
			size_t *buflen);
};

struct tpm_chip {

	/* TPM chip id */
	int id;

	/* Indicates whether or not the device and log are functional */
	bool enabled;

	/* TPM device tree node */
	struct dt_node *node;

	/* TPM device handler */
	struct tpm_dev    *dev;

	/* TPM driver handler */
	struct tpm_driver *driver;

	struct list_node link;
};

/*
 * Register a tpm chip by binding the driver to dev.
 */
extern int tpm_register_chip(struct dt_node *node, struct tpm_dev *dev,
			     struct tpm_driver *driver);

/* Add status property to the TPM devices */
extern void tpm_add_status_property(void);

extern void tpm_init(void);
extern void tpm_cleanup(void);

#endif /* __TPM_H */