Commit c2b0f600a1707450ef985e28363893987f36fd8a

Authored by Christophe Ricard
Committed by Simon Glass
1 parent 302c5dba0a

dm: tpm: Remove every compilation switch for TPM driver model

As every TPM drivers support UCLASS_TPM, we can only rely on DM_TPM
functions.

This simplify a bit the code.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

Showing 6 changed files with 4 additions and 97 deletions Side-by-side Diff

... ... @@ -443,7 +443,6 @@
443 443 TPM_COMMAND_NO_ARG(tpm_physical_enable)
444 444 TPM_COMMAND_NO_ARG(tpm_physical_disable)
445 445  
446   -#ifdef CONFIG_DM_TPM
447 446 static int get_tpm(struct udevice **devp)
448 447 {
449 448 int rc;
450 449  
... ... @@ -476,11 +475,11 @@
476 475  
477 476 return 0;
478 477 }
479   -#endif
480 478  
481 479 static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag,
482 480 int argc, char * const argv[])
483 481 {
  482 + struct udevice *dev;
484 483 void *command;
485 484 uint8_t response[1024];
486 485 size_t count, response_length = sizeof(response);
487 486  
... ... @@ -492,17 +491,11 @@
492 491 return CMD_RET_FAILURE;
493 492 }
494 493  
495   -#ifdef CONFIG_DM_TPM
496   - struct udevice *dev;
497   -
498 494 rc = get_tpm(&dev);
499 495 if (rc)
500 496 return rc;
501 497  
502 498 rc = tpm_xfer(dev, command, count, response, &response_length);
503   -#else
504   - rc = tis_sendrecv(command, count, response, &response_length);
505   -#endif
506 499 free(command);
507 500 if (!rc) {
508 501 puts("tpm response:\n");
509 502  
... ... @@ -657,9 +650,7 @@
657 650 U_BOOT_CMD_MKENT(cmd, 0, 1, do_tpm_ ## cmd, "", "")
658 651  
659 652 static cmd_tbl_t tpm_commands[] = {
660   -#ifdef CONFIG_DM_TPM
661 653 U_BOOT_CMD_MKENT(info, 0, 1, do_tpm_info, "", ""),
662   -#endif
663 654 U_BOOT_CMD_MKENT(init, 0, 1,
664 655 do_tpm_init, "", ""),
665 656 U_BOOT_CMD_MKENT(startup, 0, 1,
666 657  
... ... @@ -730,9 +721,7 @@
730 721 "cmd args...\n"
731 722 " - Issue TPM command <cmd> with arguments <args...>.\n"
732 723 "Admin Startup and State Commands:\n"
733   -#ifdef CONFIG_DM_TPM
734 724 " info - Show information about the TPM\n"
735   -#endif
736 725 " init\n"
737 726 " - Put TPM into a state where it waits for 'startup' command.\n"
738 727 " startup mode\n"
drivers/tpm/tpm_tis_infineon.c
... ... @@ -24,7 +24,6 @@
24 24 #include <dm.h>
25 25 #include <fdtdec.h>
26 26 #include <i2c.h>
27   -#include <tis.h>
28 27 #include <tpm.h>
29 28 #include <asm-generic/errno.h>
30 29 #include <linux/compiler.h>
drivers/tpm/tpm_tis_lpc.c
... ... @@ -16,7 +16,6 @@
16 16 #include <common.h>
17 17 #include <dm.h>
18 18 #include <mapmem.h>
19   -#include <tis.h>
20 19 #include <tpm.h>
21 20 #include <asm/io.h>
22 21  
include/tis.h
1   -/*
2   - * Copyright (c) 2011 The Chromium OS Authors.
3   - *
4   - * SPDX-License-Identifier: GPL-2.0+
5   - */
6   -
7   -#ifndef __TIS_H
8   -#define __TIS_H
9   -
10   -#ifndef CONFIG_DM_TPM
11   -
12   -#include <common.h>
13   -
14   -/* Low-level interface to access TPM */
15   -
16   -/*
17   - * tis_init()
18   - *
19   - * Initialize the TPM device. Returns 0 on success or -1 on
20   - * failure (in case device probing did not succeed).
21   - */
22   -int tis_init(void);
23   -
24   -/*
25   - * tis_open()
26   - *
27   - * Requests access to locality 0 for the caller. After all commands have been
28   - * completed the caller is supposed to call tis_close().
29   - *
30   - * Returns 0 on success, -1 on failure.
31   - */
32   -int tis_open(void);
33   -
34   -/*
35   - * tis_close()
36   - *
37   - * terminate the currect session with the TPM by releasing the locked
38   - * locality. Returns 0 on success of -1 on failure (in case lock
39   - * removal did not succeed).
40   - */
41   -int tis_close(void);
42   -
43   -/*
44   - * tis_sendrecv()
45   - *
46   - * Send the requested data to the TPM and then try to get its response
47   - *
48   - * @sendbuf - buffer of the data to send
49   - * @send_size size of the data to send
50   - * @recvbuf - memory to save the response to
51   - * @recv_len - pointer to the size of the response buffer
52   - *
53   - * Returns 0 on success (and places the number of response bytes at recv_len)
54   - * or -1 on failure.
55   - */
56   -int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf,
57   - size_t *recv_len);
58   -#endif
59   -
60   -#endif /* __TIS_H */
... ... @@ -8,8 +8,6 @@
8 8 #ifndef __TPM_H
9 9 #define __TPM_H
10 10  
11   -#include <tis.h>
12   -
13 11 /*
14 12 * Here is a partial implementation of TPM commands. Please consult TCG Main
15 13 * Specification for definitions of TPM commands.
... ... @@ -196,8 +194,6 @@
196 194 u8 disable_full_da_logic_info;
197 195 } __packed;
198 196  
199   -#ifdef CONFIG_DM_TPM
200   -
201 197 /* Max buffer size supported by our tpm */
202 198 #define TPM_DEV_BUFSIZE 1260
203 199  
... ... @@ -374,8 +370,6 @@
374 370 */
375 371 int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size,
376 372 uint8_t *recvbuf, size_t *recv_size);
377   -
378   -#endif /* CONFIG_DM_TPM */
379 373  
380 374 /**
381 375 * Initialize TPM device. It must be called before any TPM commands.
... ... @@ -7,7 +7,6 @@
7 7  
8 8 #include <common.h>
9 9 #include <dm.h>
10   -#include <tis.h>
11 10 #include <tpm.h>
12 11 #include <asm/unaligned.h>
13 12 #include <u-boot/sha1.h>
... ... @@ -230,6 +229,8 @@
230 229 static uint32_t tpm_sendrecv_command(const void *command,
231 230 void *response, size_t *size_ptr)
232 231 {
  232 + struct udevice *dev;
  233 + int ret;
233 234 uint8_t response_buffer[COMMAND_BUFFER_SIZE];
234 235 size_t response_length;
235 236 uint32_t err;
236 237  
... ... @@ -240,19 +241,13 @@
240 241 response = response_buffer;
241 242 response_length = sizeof(response_buffer);
242 243 }
243   -#ifdef CONFIG_DM_TPM
244   - struct udevice *dev;
245   - int ret;
246 244  
247 245 ret = uclass_first_device(UCLASS_TPM, &dev);
248 246 if (ret)
249 247 return ret;
250 248 err = tpm_xfer(dev, command, tpm_command_size(command),
251 249 response, &response_length);
252   -#else
253   - err = tis_sendrecv(command, tpm_command_size(command),
254   - response, &response_length);
255   -#endif
  250 +
256 251 if (err < 0)
257 252 return TPM_LIB_ERROR;
258 253 if (size_ptr)
259 254  
... ... @@ -264,21 +259,12 @@
264 259 int tpm_init(void)
265 260 {
266 261 int err;
267   -
268   -#ifdef CONFIG_DM_TPM
269 262 struct udevice *dev;
270 263  
271 264 err = uclass_first_device(UCLASS_TPM, &dev);
272 265 if (err)
273 266 return err;
274 267 return tpm_open(dev);
275   -#else
276   - err = tis_init();
277   - if (err)
278   - return err;
279   -
280   - return tis_open();
281   -#endif
282 268 }
283 269  
284 270 uint32_t tpm_startup(enum tpm_startup_type mode)