Commit d6a885f0878043d572bfd85a423e4a6bb6073178

Authored by Simon Glass
Committed by Tom Rini
1 parent bfe8fa262c
Exists in emb_lf_v2022.04

tpm: Switch TPMv1 over to use the new API

Take over the plain 'tpm_...' functions for use by the new TPM API. Rename
all the TPMv1 functions so they are called from the API.

Update the TPMv1 functions so that they are called from the API. Change
existing users to use the tpm1_ prefix so they don't need to go through
the API, which might introduce uncertainty.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Showing 10 changed files with 168 additions and 169 deletions Side-by-side Diff

board/gdsys/a38x/controlcenterdc.c
... ... @@ -288,8 +288,8 @@
288 288 ccdc_eth_init();
289 289 #endif
290 290 ret = get_tpm(&tpm);
291   - if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR) ||
292   - tpm_continue_self_test(tpm)) {
  291 + if (ret || tpm_init(tpm) || tpm1_startup(tpm, TPM_ST_CLEAR) ||
  292 + tpm1_continue_self_test(tpm)) {
293 293 return 1;
294 294 }
295 295  
board/gdsys/a38x/hre.c
... ... @@ -107,8 +107,8 @@
107 107 uint8_t *ptr;
108 108 uint16_t v16;
109 109  
110   - err = tpm_get_capability(tpm, TPM_CAP_NV_INDEX, index,
111   - info, sizeof(info));
  110 + err = tpm1_get_capability(tpm, TPM_CAP_NV_INDEX, index, info,
  111 + sizeof(info));
112 112 if (err) {
113 113 printf("tpm_get_capability(CAP_NV_INDEX, %08x) failed: %u\n",
114 114 index, err);
... ... @@ -150,8 +150,8 @@
150 150 unsigned int i;
151 151  
152 152 /* fetch list of already loaded keys in the TPM */
153   - err = tpm_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
154   - sizeof(buf));
  153 + err = tpm1_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
  154 + sizeof(buf));
155 155 if (err)
156 156 return -1;
157 157 key_count = get_unaligned_be16(buf);
... ... @@ -162,8 +162,8 @@
162 162 /* now search a(/ the) key which we can access with the given auth */
163 163 for (i = 0; i < key_count; ++i) {
164 164 buf_len = sizeof(buf);
165   - err = tpm_get_pub_key_oiap(tpm, key_handles[i], auth, buf,
166   - &buf_len);
  165 + err = tpm1_get_pub_key_oiap(tpm, key_handles[i], auth, buf,
  166 + &buf_len);
167 167 if (err && err != TPM_AUTHFAIL)
168 168 return -1;
169 169 if (err)
... ... @@ -192,8 +192,8 @@
192 192 if (get_tpm_nv_size(tpm, NV_COMMON_DATA_INDEX, &size) ||
193 193 size < NV_COMMON_DATA_MIN_SIZE)
194 194 return 1;
195   - err = tpm_nv_read_value(tpm, NV_COMMON_DATA_INDEX,
196   - buf, min(sizeof(buf), size));
  195 + err = tpm1_nv_read_value(tpm, NV_COMMON_DATA_INDEX, buf,
  196 + min(sizeof(buf), size));
197 197 if (err) {
198 198 printf("tpm_nv_read_value() failed: %u\n", err);
199 199 return 1;
... ... @@ -270,8 +270,8 @@
270 270 if (mode & HREG_RD) {
271 271 if (!result->valid) {
272 272 if (IS_PCR_HREG(spec)) {
273   - hre_tpm_err = tpm_pcr_read(tpm, HREG_IDX(spec),
274   - result->digest, 20);
  273 + hre_tpm_err = tpm1_pcr_read(tpm, HREG_IDX(spec),
  274 + result->digest, 20);
275 275 result->valid = (hre_tpm_err == TPM_SUCCESS);
276 276 } else if (IS_FIX_HREG(spec)) {
277 277 switch (HREG_IDX(spec)) {
... ... @@ -357,8 +357,8 @@
357 357 return -1;
358 358 if (find_key(tpm, src_reg->digest, dst_reg->digest, &parent_handle))
359 359 return -1;
360   - hre_tpm_err = tpm_load_key2_oiap(tpm, parent_handle, key, key_size,
361   - src_reg->digest, &key_handle);
  360 + hre_tpm_err = tpm1_load_key2_oiap(tpm, parent_handle, key, key_size,
  361 + src_reg->digest, &key_handle);
362 362 if (hre_tpm_err) {
363 363 hre_err = HRE_E_TPM_FAILURE;
364 364 return -1;
... ... @@ -474,8 +474,8 @@
474 474 }
475 475  
476 476 if (dst_reg && dst_modified && IS_PCR_HREG(dst_spec)) {
477   - hre_tpm_err = tpm_extend(tpm, HREG_IDX(dst_spec),
478   - dst_reg->digest, dst_reg->digest);
  477 + hre_tpm_err = tpm1_extend(tpm, HREG_IDX(dst_spec),
  478 + dst_reg->digest, dst_reg->digest);
479 479 if (hre_tpm_err) {
480 480 hre_err = HRE_E_TPM_FAILURE;
481 481 return NULL;
board/gdsys/a38x/keyprogram.c
... ... @@ -23,15 +23,15 @@
23 23 uint i;
24 24  
25 25 /* fetch list of already loaded keys in the TPM */
26   - err = tpm_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
27   - sizeof(buf));
  26 + err = tpm1_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
  27 + sizeof(buf));
28 28 if (err)
29 29 return -1;
30 30 key_count = get_unaligned_be16(buf);
31 31 ptr = buf + 2;
32 32 for (i = 0; i < key_count; ++i, ptr += 4) {
33   - err = tpm_flush_specific(tpm, get_unaligned_be32(ptr),
34   - TPM_RT_KEY);
  33 + err = tpm1_flush_specific(tpm, get_unaligned_be32(ptr),
  34 + TPM_RT_KEY);
35 35 if (err && err != TPM_KEY_OWNER_CONTROL)
36 36 return err;
37 37 }
board/gdsys/mpc8308/gazerbeam.c
... ... @@ -145,8 +145,8 @@
145 145 env_set_ulong("fpga_hw_rev", fpga_hw_rev);
146 146  
147 147 ret = get_tpm(&tpm);
148   - if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR) ||
149   - tpm_continue_self_test(tpm)) {
  148 + if (ret || tpm_init(tpm) || tpm1_startup(tpm, TPM_ST_CLEAR) ||
  149 + tpm1_continue_self_test(tpm)) {
150 150 printf("TPM init failed\n");
151 151 }
152 152  
board/gdsys/p1022/controlcenterd-id.c
... ... @@ -273,8 +273,8 @@
273 273 uint8_t *ptr;
274 274 uint16_t v16;
275 275  
276   - err = tpm_get_capability(tpm, TPM_CAP_NV_INDEX, index,
277   - info, sizeof(info));
  276 + err = tpm1_get_capability(tpm, TPM_CAP_NV_INDEX, index, info,
  277 + sizeof(info));
278 278 if (err) {
279 279 printf("tpm_get_capability(CAP_NV_INDEX, %08x) failed: %u\n",
280 280 index, err);
... ... @@ -315,8 +315,8 @@
315 315 unsigned int i;
316 316  
317 317 /* fetch list of already loaded keys in the TPM */
318   - err = tpm_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
319   - sizeof(buf));
  318 + err = tpm1_get_capability(tpm, TPM_CAP_HANDLE, TPM_RT_KEY, buf,
  319 + sizeof(buf));
320 320 if (err)
321 321 return -1;
322 322 key_count = get_unaligned_be16(buf);
... ... @@ -327,8 +327,8 @@
327 327 /* now search a(/ the) key which we can access with the given auth */
328 328 for (i = 0; i < key_count; ++i) {
329 329 buf_len = sizeof(buf);
330   - err = tpm_get_pub_key_oiap(tpm, key_handles[i], auth, buf,
331   - &buf_len);
  330 + err = tpm1_get_pub_key_oiap(tpm, key_handles[i], auth, buf,
  331 + &buf_len);
332 332 if (err && err != TPM_AUTHFAIL)
333 333 return -1;
334 334 if (err)
... ... @@ -356,8 +356,8 @@
356 356 if (get_tpm_nv_size(tpm, NV_COMMON_DATA_INDEX, &size) ||
357 357 size < NV_COMMON_DATA_MIN_SIZE)
358 358 return 1;
359   - err = tpm_nv_read_value(tpm, NV_COMMON_DATA_INDEX,
360   - buf, min(sizeof(buf), size));
  359 + err = tpm1_nv_read_value(tpm, NV_COMMON_DATA_INDEX, buf,
  360 + min(sizeof(buf), size));
361 361 if (err) {
362 362 printf("tpm_nv_read_value() failed: %u\n", err);
363 363 return 1;
... ... @@ -508,8 +508,8 @@
508 508 if (mode & HREG_RD) {
509 509 if (!result->valid) {
510 510 if (IS_PCR_HREG(spec)) {
511   - hre_tpm_err = tpm_pcr_read(tpm, HREG_IDX(spec),
512   - result->digest, 20);
  511 + hre_tpm_err = tpm1_pcr_read(tpm, HREG_IDX(spec),
  512 + result->digest, 20);
513 513 result->valid = (hre_tpm_err == TPM_SUCCESS);
514 514 } else if (IS_FIX_HREG(spec)) {
515 515 switch (HREG_IDX(spec)) {
... ... @@ -601,8 +601,8 @@
601 601 return -1;
602 602 if (find_key(tpm, src_reg->digest, dst_reg->digest, &parent_handle))
603 603 return -1;
604   - hre_tpm_err = tpm_load_key2_oiap(tpm, parent_handle, key, key_size,
605   - src_reg->digest, &key_handle);
  604 + hre_tpm_err = tpm1_load_key2_oiap(tpm, parent_handle, key, key_size,
  605 + src_reg->digest, &key_handle);
606 606 if (hre_tpm_err) {
607 607 hre_err = HRE_E_TPM_FAILURE;
608 608 return -1;
... ... @@ -718,8 +718,8 @@
718 718 }
719 719  
720 720 if (dst_reg && dst_modified && IS_PCR_HREG(dst_spec)) {
721   - hre_tpm_err = tpm_extend(tpm, HREG_IDX(dst_spec),
722   - dst_reg->digest, dst_reg->digest);
  721 + hre_tpm_err = tpm1_extend(tpm, HREG_IDX(dst_spec),
  722 + dst_reg->digest, dst_reg->digest);
723 723 if (hre_tpm_err) {
724 724 hre_err = HRE_E_TPM_FAILURE;
725 725 return NULL;
726 726  
... ... @@ -964,10 +964,10 @@
964 964  
965 965 puts("CCDM S1: start actions\n");
966 966 #ifndef CCDM_SECOND_STAGE
967   - if (tpm_continue_self_test(tpm))
  967 + if (tpm1_continue_self_test(tpm))
968 968 goto failure;
969 969 #else
970   - tpm_continue_self_test(tpm);
  970 + tpm1_continue_self_test(tpm);
971 971 #endif
972 972 mdelay(37);
973 973  
... ... @@ -1003,7 +1003,7 @@
1003 1003  
1004 1004 puts("CCDM S1\n");
1005 1005 ret = get_tpm(&tpm);
1006   - if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR))
  1006 + if (ret || tpm_init(tpm) || tpm1_startup(tpm, TPM_ST_CLEAR))
1007 1007 return 1;
1008 1008 ret = first_stage_actions(tpm);
1009 1009 #ifndef CCDM_SECOND_STAGE
... ... @@ -1061,7 +1061,7 @@
1061 1061 ret = get_tpm(&tpm);
1062 1062 if (ret || tpm_init(tpm))
1063 1063 return 1;
1064   - err = tpm_startup(tpm, TPM_ST_CLEAR);
  1064 + err = tpm1_startup(tpm, TPM_ST_CLEAR);
1065 1065 if (err != TPM_INVALID_POSTINIT)
1066 1066 did_first_stage_run = false;
1067 1067  
... ... @@ -11,6 +11,7 @@
11 11 #include <tpm-common.h>
12 12 #include <tpm-v1.h>
13 13 #include "tpm-user-utils.h"
  14 +#include <tpm_api.h>
14 15  
15 16 static int do_tpm_startup(struct cmd_tbl *cmdtp, int flag, int argc,
16 17 char *const argv[])
... ... @@ -55,7 +56,7 @@
55 56 perm = simple_strtoul(argv[2], NULL, 0);
56 57 size = simple_strtoul(argv[3], NULL, 0);
57 58  
58   - return report_return_code(tpm_nv_define_space(dev, index, perm, size));
  59 + return report_return_code(tpm1_nv_define_space(dev, index, perm, size));
59 60 }
60 61  
61 62 static int do_tpm_nv_read_value(struct cmd_tbl *cmdtp, int flag, int argc,
... ... @@ -130,7 +131,7 @@
130 131 return CMD_RET_FAILURE;
131 132 }
132 133  
133   - rc = tpm_extend(dev, index, in_digest, out_digest);
  134 + rc = tpm_pcr_extend(dev, index, in_digest, out_digest);
134 135 if (!rc) {
135 136 puts("PCR value after execution of the command:\n");
136 137 print_byte_string(out_digest, sizeof(out_digest));
... ... @@ -304,7 +305,7 @@
304 305 index = simple_strtoul(argv[2], NULL, 0);
305 306 perm = simple_strtoul(argv[3], NULL, 0);
306 307  
307   - return report_return_code(tpm_nv_define_space(dev, index, perm, size));
  308 + return report_return_code(tpm1_nv_define_space(dev, index, perm, size));
308 309 }
309 310  
310 311 static int do_tpm_nv_read(struct cmd_tbl *cmdtp, int flag, int argc,
... ... @@ -389,7 +390,7 @@
389 390 if (rc)
390 391 return rc;
391 392  
392   - err = tpm_oiap(dev, &auth_handle);
  393 + err = tpm1_oiap(dev, &auth_handle);
393 394  
394 395 return report_return_code(err);
395 396 }
... ... @@ -461,8 +462,8 @@
461 462 return CMD_RET_FAILURE;
462 463 parse_byte_string(argv[4], usage_auth, NULL);
463 464  
464   - err = tpm_load_key2_oiap(dev, parent_handle, key, key_len, usage_auth,
465   - &key_handle);
  465 + err = tpm1_load_key2_oiap(dev, parent_handle, key, key_len, usage_auth,
  466 + &key_handle);
466 467 if (!err)
467 468 printf("Key handle is 0x%x\n", key_handle);
468 469  
... ... @@ -491,8 +492,8 @@
491 492 return CMD_RET_FAILURE;
492 493 parse_byte_string(argv[2], usage_auth, NULL);
493 494  
494   - err = tpm_get_pub_key_oiap(dev, key_handle, usage_auth, pub_key_buffer,
495   - &pub_key_len);
  495 + err = tpm1_get_pub_key_oiap(dev, key_handle, usage_auth, pub_key_buffer,
  496 + &pub_key_len);
496 497 if (!err) {
497 498 printf("dump of received pub key structure:\n");
498 499 print_byte_string(pub_key_buffer, pub_key_len);
... ... @@ -500,7 +501,7 @@
500 501 return report_return_code(err);
501 502 }
502 503  
503   -TPM_COMMAND_NO_ARG(tpm_end_oiap)
  504 +TPM_COMMAND_NO_ARG(tpm1_end_oiap)
504 505  
505 506 #endif /* CONFIG_TPM_AUTH_SESSIONS */
506 507  
... ... @@ -562,7 +563,7 @@
562 563 res_count = get_unaligned_be16(buf);
563 564 ptr = buf + 2;
564 565 for (i = 0; i < res_count; ++i, ptr += 4)
565   - tpm_flush_specific(dev, get_unaligned_be32(ptr), type);
  566 + tpm1_flush_specific(dev, get_unaligned_be32(ptr), type);
566 567 } else {
567 568 u32 handle = simple_strtoul(argv[2], NULL, 0);
568 569  
... ... @@ -570,7 +571,7 @@
570 571 printf("Illegal resource handle %s\n", argv[2]);
571 572 return -1;
572 573 }
573   - tpm_flush_specific(dev, cpu_to_be32(handle), type);
  574 + tpm1_flush_specific(dev, cpu_to_be32(handle), type);
574 575 }
575 576  
576 577 return 0;
... ... @@ -691,7 +692,7 @@
691 692 U_BOOT_CMD_MKENT(oiap, 0, 1,
692 693 do_tpm_oiap, "", ""),
693 694 U_BOOT_CMD_MKENT(end_oiap, 0, 1,
694   - do_tpm_end_oiap, "", ""),
  695 + do_tpm1_end_oiap, "", ""),
695 696 U_BOOT_CMD_MKENT(load_key2_oiap, 0, 1,
696 697 do_tpm_load_key2_oiap, "", ""),
697 698 #ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
... ... @@ -9,6 +9,7 @@
9 9 #include <log.h>
10 10 #include <tpm-v1.h>
11 11 #include "tpm-user-utils.h"
  12 +#include <tpm_api.h>
12 13  
13 14 /* Prints error and returns on failure */
14 15 #define TPM_CHECK(tpm_command) do { \
... ... @@ -49,7 +50,7 @@
49 50 struct tpm_permanent_flags pflags;
50 51 uint32_t result;
51 52  
52   - result = tpm_get_permanent_flags(dev, &pflags);
  53 + result = tpm1_get_permanent_flags(dev, &pflags);
53 54 if (result)
54 55 return result;
55 56 if (disable)
... ... @@ -90,7 +91,7 @@
90 91 tpm_init(dev);
91 92 TPM_CHECK(tpm_startup(dev, TPM_ST_CLEAR));
92 93 TPM_CHECK(tpm_continue_self_test(dev));
93   - TPM_CHECK(tpm_extend(dev, 1, value_in, value_out));
  94 + TPM_CHECK(tpm_pcr_extend(dev, 1, value_in, value_out));
94 95 printf("done\n");
95 96 return 0;
96 97 }
97 98  
98 99  
99 100  
100 101  
... ... @@ -238,18 +239,18 @@
238 239 uint32_t perm = TPM_NV_PER_WRITE_STCLEAR | TPM_NV_PER_PPWRITE;
239 240  
240 241 printf("\tInitialising spaces\n");
241   - tpm_nv_set_locked(dev); /* useful only the first time */
242   - tpm_nv_define_space(dev, INDEX0, perm, 4);
  242 + tpm1_nv_set_locked(dev); /* useful only the first time */
  243 + tpm1_nv_define_space(dev, INDEX0, perm, 4);
243 244 tpm_nv_write_value(dev, INDEX0, (uint8_t *)&zero, 4);
244   - tpm_nv_define_space(dev, INDEX1, perm, 4);
  245 + tpm1_nv_define_space(dev, INDEX1, perm, 4);
245 246 tpm_nv_write_value(dev, INDEX1, (uint8_t *)&zero, 4);
246   - tpm_nv_define_space(dev, INDEX2, perm, 4);
  247 + tpm1_nv_define_space(dev, INDEX2, perm, 4);
247 248 tpm_nv_write_value(dev, INDEX2, (uint8_t *)&zero, 4);
248   - tpm_nv_define_space(dev, INDEX3, perm, 4);
  249 + tpm1_nv_define_space(dev, INDEX3, perm, 4);
249 250 tpm_nv_write_value(dev, INDEX3, (uint8_t *)&zero, 4);
250 251 perm = TPM_NV_PER_READ_STCLEAR | TPM_NV_PER_WRITE_STCLEAR |
251 252 TPM_NV_PER_PPWRITE;
252   - tpm_nv_define_space(dev, INDEX_INITIALISED, perm, 1);
  253 + tpm1_nv_define_space(dev, INDEX_INITIALISED, perm, 1);
253 254 }
254 255  
255 256 static int test_readonly(struct udevice *dev)
256 257  
257 258  
258 259  
259 260  
260 261  
... ... @@ -325,30 +326,33 @@
325 326  
326 327 /* Redefines spaces a couple of times. */
327 328 perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK;
328   - TPM_CHECK(tpm_nv_define_space(dev, INDEX0, perm, 2 * sizeof(uint32_t)));
329   - TPM_CHECK(tpm_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t)));
  329 + TPM_CHECK(tpm1_nv_define_space(dev, INDEX0, perm,
  330 + 2 * sizeof(uint32_t)));
  331 + TPM_CHECK(tpm1_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t)));
330 332 perm = TPM_NV_PER_PPWRITE;
331   - TPM_CHECK(tpm_nv_define_space(dev, INDEX1, perm, 2 * sizeof(uint32_t)));
332   - TPM_CHECK(tpm_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t)));
  333 + TPM_CHECK(tpm1_nv_define_space(dev, INDEX1, perm,
  334 + 2 * sizeof(uint32_t)));
  335 + TPM_CHECK(tpm1_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t)));
333 336  
334 337 /* Sets the global lock */
335 338 tpm_set_global_lock(dev);
336 339  
337 340 /* Verifies that index0 cannot be redefined */
338   - result = tpm_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t));
  341 + result = tpm1_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t));
339 342 assert(result == TPM_AREA_LOCKED);
340 343  
341 344 /* Checks that index1 can */
342   - TPM_CHECK(tpm_nv_define_space(dev, INDEX1, perm, 2 * sizeof(uint32_t)));
343   - TPM_CHECK(tpm_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t)));
  345 + TPM_CHECK(tpm1_nv_define_space(dev, INDEX1, perm,
  346 + 2 * sizeof(uint32_t)));
  347 + TPM_CHECK(tpm1_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t)));
344 348  
345 349 /* Turns off PP */
346 350 tpm_tsc_physical_presence(dev, PHYS_PRESENCE);
347 351  
348 352 /* Verifies that neither index0 nor index1 can be redefined */
349   - result = tpm_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t));
  353 + result = tpm1_nv_define_space(dev, INDEX0, perm, sizeof(uint32_t));
350 354 assert(result == TPM_BAD_PRESENCE);
351   - result = tpm_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t));
  355 + result = tpm1_nv_define_space(dev, INDEX1, perm, sizeof(uint32_t));
352 356 assert(result == TPM_BAD_PRESENCE);
353 357  
354 358 printf("done\n");
... ... @@ -434,7 +438,7 @@
434 438 100);
435 439 TTPM_CHECK(tpm_nv_read_value(dev, INDEX0, (uint8_t *)&x, sizeof(x)),
436 440 100);
437   - TTPM_CHECK(tpm_extend(dev, 0, in, out), 200);
  441 + TTPM_CHECK(tpm_pcr_extend(dev, 0, in, out), 200);
438 442 TTPM_CHECK(tpm_set_global_lock(dev), 50);
439 443 TTPM_CHECK(tpm_tsc_physical_presence(dev, PHYS_PRESENCE), 100);
440 444 printf("done\n");
... ... @@ -289,7 +289,7 @@
289 289 * @param mode TPM startup mode
290 290 * @return return code of the operation
291 291 */
292   -u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode);
  292 +u32 tpm1_startup(struct udevice *dev, enum tpm_startup_type mode);
293 293  
294 294 /**
295 295 * Issue a TPM_SelfTestFull command.
... ... @@ -297,7 +297,7 @@
297 297 * @param dev TPM device
298 298 * @return return code of the operation
299 299 */
300   -u32 tpm_self_test_full(struct udevice *dev);
  300 +u32 tpm1_self_test_full(struct udevice *dev);
301 301  
302 302 /**
303 303 * Issue a TPM_ContinueSelfTest command.
... ... @@ -305,7 +305,7 @@
305 305 * @param dev TPM device
306 306 * @return return code of the operation
307 307 */
308   -u32 tpm_continue_self_test(struct udevice *dev);
  308 +u32 tpm1_continue_self_test(struct udevice *dev);
309 309  
310 310 /**
311 311 * Issue a TPM_NV_DefineSpace command. The implementation is limited
... ... @@ -318,7 +318,7 @@
318 318 * @param size size of the area
319 319 * @return return code of the operation
320 320 */
321   -u32 tpm_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size);
  321 +u32 tpm1_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size);
322 322  
323 323 /**
324 324 * Issue a TPM_NV_ReadValue command. This implementation is limited
... ... @@ -331,7 +331,7 @@
331 331 * @param count size of output buffer
332 332 * @return return code of the operation
333 333 */
334   -u32 tpm_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count);
  334 +u32 tpm1_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count);
335 335  
336 336 /**
337 337 * Issue a TPM_NV_WriteValue command. This implementation is limited
... ... @@ -344,8 +344,8 @@
344 344 * @param length length of data bytes of input buffer
345 345 * @return return code of the operation
346 346 */
347   -u32 tpm_nv_write_value(struct udevice *dev, u32 index, const void *data,
348   - u32 length);
  347 +u32 tpm1_nv_write_value(struct udevice *dev, u32 index, const void *data,
  348 + u32 length);
349 349  
350 350 /**
351 351 * Issue a TPM_Extend command.
... ... @@ -358,8 +358,8 @@
358 358 * command
359 359 * @return return code of the operation
360 360 */
361   -u32 tpm_extend(struct udevice *dev, u32 index, const void *in_digest,
362   - void *out_digest);
  361 +u32 tpm1_extend(struct udevice *dev, u32 index, const void *in_digest,
  362 + void *out_digest);
363 363  
364 364 /**
365 365 * Issue a TPM_PCRRead command.
... ... @@ -370,7 +370,7 @@
370 370 * @param count size of output buffer
371 371 * @return return code of the operation
372 372 */
373   -u32 tpm_pcr_read(struct udevice *dev, u32 index, void *data, size_t count);
  373 +u32 tpm1_pcr_read(struct udevice *dev, u32 index, void *data, size_t count);
374 374  
375 375 /**
376 376 * Issue a TSC_PhysicalPresence command. TPM physical presence flag
... ... @@ -380,7 +380,7 @@
380 380 * @param presence TPM physical presence flag
381 381 * @return return code of the operation
382 382 */
383   -u32 tpm_tsc_physical_presence(struct udevice *dev, u16 presence);
  383 +u32 tpm1_tsc_physical_presence(struct udevice *dev, u16 presence);
384 384  
385 385 /**
386 386 * Issue a TPM_ReadPubek command.
... ... @@ -390,7 +390,7 @@
390 390 * @param count size of output buffer
391 391 * @return return code of the operation
392 392 */
393   -u32 tpm_read_pubek(struct udevice *dev, void *data, size_t count);
  393 +u32 tpm1_read_pubek(struct udevice *dev, void *data, size_t count);
394 394  
395 395 /**
396 396 * Issue a TPM_ForceClear command.
... ... @@ -398,7 +398,7 @@
398 398 * @param dev TPM device
399 399 * @return return code of the operation
400 400 */
401   -u32 tpm_force_clear(struct udevice *dev);
  401 +u32 tpm1_force_clear(struct udevice *dev);
402 402  
403 403 /**
404 404 * Issue a TPM_PhysicalEnable command.
... ... @@ -406,7 +406,7 @@
406 406 * @param dev TPM device
407 407 * @return return code of the operation
408 408 */
409   -u32 tpm_physical_enable(struct udevice *dev);
  409 +u32 tpm1_physical_enable(struct udevice *dev);
410 410  
411 411 /**
412 412 * Issue a TPM_PhysicalDisable command.
... ... @@ -414,7 +414,7 @@
414 414 * @param dev TPM device
415 415 * @return return code of the operation
416 416 */
417   -u32 tpm_physical_disable(struct udevice *dev);
  417 +u32 tpm1_physical_disable(struct udevice *dev);
418 418  
419 419 /**
420 420 * Issue a TPM_PhysicalSetDeactivated command.
... ... @@ -423,7 +423,7 @@
423 423 * @param state boolean state of the deactivated flag
424 424 * @return return code of the operation
425 425 */
426   -u32 tpm_physical_set_deactivated(struct udevice *dev, u8 state);
  426 +u32 tpm1_physical_set_deactivated(struct udevice *dev, u8 state);
427 427  
428 428 /**
429 429 * Issue a TPM_GetCapability command. This implementation is limited
... ... @@ -437,8 +437,8 @@
437 437 * @param count size of output buffer
438 438 * @return return code of the operation
439 439 */
440   -u32 tpm_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
441   - void *cap, size_t count);
  440 +u32 tpm1_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
  441 + void *cap, size_t count);
442 442  
443 443 /**
444 444 * Issue a TPM_FlushSpecific command for a AUTH resource.
... ... @@ -447,7 +447,7 @@
447 447 * @param auth_handle handle of the auth session
448 448 * @return return code of the operation
449 449 */
450   -u32 tpm_terminate_auth_session(struct udevice *dev, u32 auth_handle);
  450 +u32 tpm1_terminate_auth_session(struct udevice *dev, u32 auth_handle);
451 451  
452 452 /**
453 453 * Issue a TPM_OIAP command to setup an object independent authorization
... ... @@ -460,7 +460,7 @@
460 460 * @param auth_handle pointer to the (new) auth handle or NULL.
461 461 * @return return code of the operation
462 462 */
463   -u32 tpm_oiap(struct udevice *dev, u32 *auth_handle);
  463 +u32 tpm1_oiap(struct udevice *dev, u32 *auth_handle);
464 464  
465 465 /**
466 466 * Ends an active OIAP session.
... ... @@ -468,7 +468,7 @@
468 468 * @param dev TPM device
469 469 * @return return code of the operation
470 470 */
471   -u32 tpm_end_oiap(struct udevice *dev);
  471 +u32 tpm1_end_oiap(struct udevice *dev);
472 472  
473 473 /**
474 474 * Issue a TPM_LoadKey2 (Auth1) command using an OIAP session for authenticating
... ... @@ -482,9 +482,9 @@
482 482 * @param key_handle pointer to the key handle
483 483 * @return return code of the operation
484 484 */
485   -u32 tpm_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
486   - size_t key_length, const void *parent_key_usage_auth,
487   - u32 *key_handle);
  485 +u32 tpm1_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
  486 + size_t key_length, const void *parent_key_usage_auth,
  487 + u32 *key_handle);
488 488  
489 489 /**
490 490 * Issue a TPM_GetPubKey (Auth1) command using an OIAP session for
... ... @@ -500,9 +500,9 @@
500 500 * of the stored TPM_PUBKEY structure (iff pubkey != NULL).
501 501 * @return return code of the operation
502 502 */
503   -u32 tpm_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
504   - const void *usage_auth, void *pubkey,
505   - size_t *pubkey_len);
  503 +u32 tpm1_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
  504 + const void *usage_auth, void *pubkey,
  505 + size_t *pubkey_len);
506 506  
507 507 /**
508 508 * Get the TPM permanent flags value
... ... @@ -511,8 +511,8 @@
511 511 * @param pflags Place to put permanent flags
512 512 * @return return code of the operation
513 513 */
514   -u32 tpm_get_permanent_flags(struct udevice *dev,
515   - struct tpm_permanent_flags *pflags);
  514 +u32 tpm1_get_permanent_flags(struct udevice *dev,
  515 + struct tpm_permanent_flags *pflags);
516 516  
517 517 /**
518 518 * Get the TPM permissions
... ... @@ -521,7 +521,7 @@
521 521 * @param perm Returns permissions value
522 522 * @return return code of the operation
523 523 */
524   -u32 tpm_get_permissions(struct udevice *dev, u32 index, u32 *perm);
  524 +u32 tpm1_get_permissions(struct udevice *dev, u32 index, u32 *perm);
525 525  
526 526 /**
527 527 * Flush a resource with a given handle and type from the TPM
... ... @@ -531,7 +531,7 @@
531 531 * @param resource_type type of the resource
532 532 * @return return code of the operation
533 533 */
534   -u32 tpm_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type);
  534 +u32 tpm1_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type);
535 535  
536 536 #ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
537 537 /**
... ... @@ -543,8 +543,8 @@
543 543 * @param[out] handle The handle of the key (Non-null iff found)
544 544 * @return 0 if key was found in TPM; != 0 if not.
545 545 */
546   -u32 tpm_find_key_sha1(struct udevice *dev, const u8 auth[20],
547   - const u8 pubkey_digest[20], u32 *handle);
  546 +u32 tpm1_find_key_sha1(struct udevice *dev, const u8 auth[20],
  547 + const u8 pubkey_digest[20], u32 *handle);
548 548 #endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
549 549  
550 550 /**
... ... @@ -557,7 +557,7 @@
557 557 * @param count size of output buffer
558 558 * @return return code of the operation
559 559 */
560   -u32 tpm_get_random(struct udevice *dev, void *data, u32 count);
  560 +u32 tpm1_get_random(struct udevice *dev, void *data, u32 count);
561 561  
562 562 /**
563 563 * tpm_finalise_physical_presence() - Finalise physical presence
564 564  
565 565  
... ... @@ -565,15 +565,15 @@
565 565 * @param dev TPM device
566 566 * @return return code of the operation (0 = success)
567 567 */
568   -u32 tpm_finalise_physical_presence(struct udevice *dev);
  568 +u32 tpm1_finalise_physical_presence(struct udevice *dev);
569 569  
570 570 /**
571   - * tpm_nv_set_locked() - lock the non-volatile space
  571 + * tpm_nv_enable_locking() - lock the non-volatile space
572 572 *
573 573 * @param dev TPM device
574 574 * @return return code of the operation (0 = success)
575 575 */
576   -u32 tpm_nv_set_locked(struct udevice *dev);
  576 +u32 tpm1_nv_set_locked(struct udevice *dev);
577 577  
578 578 /**
579 579 * tpm_set_global_lock() - set the global lock
... ... @@ -589,7 +589,7 @@
589 589 * @param dev TPM device
590 590 * @return return code of the operation (0 = success)
591 591 */
592   -u32 tpm_resume(struct udevice *dev);
  592 +u32 tpm1_resume(struct udevice *dev);
593 593  
594 594 #endif /* __TPM_V1_H */
... ... @@ -53,6 +53,7 @@
53 53 obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm-common.o
54 54 ifeq ($(CONFIG_$(SPL_TPL_)TPM),y)
55 55 obj-y += crc8.o
  56 +obj-$(CONFIG_TPM) += tpm_api.o
56 57 obj-$(CONFIG_TPM_V1) += tpm-v1.o
57 58 obj-$(CONFIG_TPM_V2) += tpm-v2.o
58 59 endif
... ... @@ -32,7 +32,7 @@
32 32  
33 33 #endif /* CONFIG_TPM_AUTH_SESSIONS */
34 34  
35   -u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode)
  35 +u32 tpm1_startup(struct udevice *dev, enum tpm_startup_type mode)
36 36 {
37 37 const u8 command[12] = {
38 38 0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x0,
39 39  
40 40  
... ... @@ -48,12 +48,12 @@
48 48 return tpm_sendrecv_command(dev, buf, NULL, NULL);
49 49 }
50 50  
51   -u32 tpm_resume(struct udevice *dev)
  51 +u32 tpm1_resume(struct udevice *dev)
52 52 {
53   - return tpm_startup(dev, TPM_ST_STATE);
  53 + return tpm1_startup(dev, TPM_ST_STATE);
54 54 }
55 55  
56   -u32 tpm_self_test_full(struct udevice *dev)
  56 +u32 tpm1_self_test_full(struct udevice *dev)
57 57 {
58 58 const u8 command[10] = {
59 59 0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x50,
... ... @@ -61,7 +61,7 @@
61 61 return tpm_sendrecv_command(dev, command, NULL, NULL);
62 62 }
63 63  
64   -u32 tpm_continue_self_test(struct udevice *dev)
  64 +u32 tpm1_continue_self_test(struct udevice *dev)
65 65 {
66 66 const u8 command[10] = {
67 67 0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x53,
68 68  
69 69  
70 70  
71 71  
... ... @@ -69,35 +69,33 @@
69 69 return tpm_sendrecv_command(dev, command, NULL, NULL);
70 70 }
71 71  
72   -u32 tpm_clear_and_reenable(struct udevice *dev)
  72 +u32 tpm1_clear_and_reenable(struct udevice *dev)
73 73 {
74 74 u32 ret;
75 75  
76 76 log_info("TPM: Clear and re-enable\n");
77   - ret = tpm_force_clear(dev);
  77 + ret = tpm1_force_clear(dev);
78 78 if (ret != TPM_SUCCESS) {
79 79 log_err("Can't initiate a force clear\n");
80 80 return ret;
81 81 }
82 82  
83   - if (tpm_get_version(dev) == TPM_V1) {
84   - ret = tpm_physical_enable(dev);
85   - if (ret != TPM_SUCCESS) {
86   - log_err("TPM: Can't set enabled state\n");
87   - return ret;
88   - }
  83 + ret = tpm1_physical_enable(dev);
  84 + if (ret != TPM_SUCCESS) {
  85 + log_err("TPM: Can't set enabled state\n");
  86 + return ret;
  87 + }
89 88  
90   - ret = tpm_physical_set_deactivated(dev, 0);
91   - if (ret != TPM_SUCCESS) {
92   - log_err("TPM: Can't set deactivated state\n");
93   - return ret;
94   - }
  89 + ret = tpm1_physical_set_deactivated(dev, 0);
  90 + if (ret != TPM_SUCCESS) {
  91 + log_err("TPM: Can't set deactivated state\n");
  92 + return ret;
95 93 }
96 94  
97 95 return TPM_SUCCESS;
98 96 }
99 97  
100   -u32 tpm_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size)
  98 +u32 tpm1_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size)
101 99 {
102 100 const u8 command[101] = {
103 101 0x0, 0xc1, /* TPM_TAG */
104 102  
105 103  
... ... @@ -140,12 +138,12 @@
140 138 return tpm_sendrecv_command(dev, buf, NULL, NULL);
141 139 }
142 140  
143   -u32 tpm_nv_set_locked(struct udevice *dev)
  141 +u32 tpm1_nv_set_locked(struct udevice *dev)
144 142 {
145   - return tpm_nv_define_space(dev, TPM_NV_INDEX_LOCK, 0, 0);
  143 + return tpm1_nv_define_space(dev, TPM_NV_INDEX_LOCK, 0, 0);
146 144 }
147 145  
148   -u32 tpm_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count)
  146 +u32 tpm1_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count)
149 147 {
150 148 const u8 command[22] = {
151 149 0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0xcf,
... ... @@ -179,8 +177,8 @@
179 177 return 0;
180 178 }
181 179  
182   -u32 tpm_nv_write_value(struct udevice *dev, u32 index, const void *data,
183   - u32 length)
  180 +u32 tpm1_nv_write_value(struct udevice *dev, u32 index, const void *data,
  181 + u32 length)
184 182 {
185 183 const u8 command[256] = {
186 184 0x0, 0xc1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcd,
187 185  
... ... @@ -210,14 +208,9 @@
210 208 return 0;
211 209 }
212 210  
213   -uint32_t tpm_set_global_lock(struct udevice *dev)
  211 +u32 tpm1_extend(struct udevice *dev, u32 index, const void *in_digest,
  212 + void *out_digest)
214 213 {
215   - return tpm_nv_write_value(dev, TPM_NV_INDEX_0, NULL, 0);
216   -}
217   -
218   -u32 tpm_extend(struct udevice *dev, u32 index, const void *in_digest,
219   - void *out_digest)
220   -{
221 214 const u8 command[34] = {
222 215 0x0, 0xc1, 0x0, 0x0, 0x0, 0x22, 0x0, 0x0, 0x0, 0x14,
223 216 };
... ... @@ -247,7 +240,7 @@
247 240 return 0;
248 241 }
249 242  
250   -u32 tpm_pcr_read(struct udevice *dev, u32 index, void *data, size_t count)
  243 +u32 tpm1_pcr_read(struct udevice *dev, u32 index, void *data, size_t count)
251 244 {
252 245 const u8 command[14] = {
253 246 0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x15,
... ... @@ -275,7 +268,7 @@
275 268 return 0;
276 269 }
277 270  
278   -u32 tpm_tsc_physical_presence(struct udevice *dev, u16 presence)
  271 +u32 tpm1_tsc_physical_presence(struct udevice *dev, u16 presence)
279 272 {
280 273 const u8 command[12] = {
281 274 0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x0,
... ... @@ -291,7 +284,7 @@
291 284 return tpm_sendrecv_command(dev, buf, NULL, NULL);
292 285 }
293 286  
294   -u32 tpm_finalise_physical_presence(struct udevice *dev)
  287 +u32 tpm1_finalise_physical_presence(struct udevice *dev)
295 288 {
296 289 const u8 command[12] = {
297 290 0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x2, 0xa0,
... ... @@ -300,7 +293,7 @@
300 293 return tpm_sendrecv_command(dev, command, NULL, NULL);
301 294 }
302 295  
303   -u32 tpm_read_pubek(struct udevice *dev, void *data, size_t count)
  296 +u32 tpm1_read_pubek(struct udevice *dev, void *data, size_t count)
304 297 {
305 298 const u8 command[30] = {
306 299 0x0, 0xc1, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x7c,
... ... @@ -331,7 +324,7 @@
331 324 return 0;
332 325 }
333 326  
334   -u32 tpm_force_clear(struct udevice *dev)
  327 +u32 tpm1_force_clear(struct udevice *dev)
335 328 {
336 329 const u8 command[10] = {
337 330 0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x5d,
... ... @@ -340,7 +333,7 @@
340 333 return tpm_sendrecv_command(dev, command, NULL, NULL);
341 334 }
342 335  
343   -u32 tpm_physical_enable(struct udevice *dev)
  336 +u32 tpm1_physical_enable(struct udevice *dev)
344 337 {
345 338 const u8 command[10] = {
346 339 0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x6f,
... ... @@ -349,7 +342,7 @@
349 342 return tpm_sendrecv_command(dev, command, NULL, NULL);
350 343 }
351 344  
352   -u32 tpm_physical_disable(struct udevice *dev)
  345 +u32 tpm1_physical_disable(struct udevice *dev)
353 346 {
354 347 const u8 command[10] = {
355 348 0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x70,
... ... @@ -358,7 +351,7 @@
358 351 return tpm_sendrecv_command(dev, command, NULL, NULL);
359 352 }
360 353  
361   -u32 tpm_physical_set_deactivated(struct udevice *dev, u8 state)
  354 +u32 tpm1_physical_set_deactivated(struct udevice *dev, u8 state)
362 355 {
363 356 const u8 command[11] = {
364 357 0x0, 0xc1, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x72,
... ... @@ -374,8 +367,8 @@
374 367 return tpm_sendrecv_command(dev, buf, NULL, NULL);
375 368 }
376 369  
377   -u32 tpm_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
378   - void *cap, size_t count)
  370 +u32 tpm1_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
  371 + void *cap, size_t count)
379 372 {
380 373 const u8 command[22] = {
381 374 0x0, 0xc1, /* TPM_TAG */
... ... @@ -414,8 +407,8 @@
414 407 return 0;
415 408 }
416 409  
417   -u32 tpm_get_permanent_flags(struct udevice *dev,
418   - struct tpm_permanent_flags *pflags)
  410 +u32 tpm1_get_permanent_flags(struct udevice *dev,
  411 + struct tpm_permanent_flags *pflags)
419 412 {
420 413 const u8 command[22] = {
421 414 0x0, 0xc1, /* TPM_TAG */
... ... @@ -453,7 +446,7 @@
453 446 return 0;
454 447 }
455 448  
456   -u32 tpm_get_permissions(struct udevice *dev, u32 index, u32 *perm)
  449 +u32 tpm1_get_permissions(struct udevice *dev, u32 index, u32 *perm)
457 450 {
458 451 const u8 command[22] = {
459 452 0x0, 0xc1, /* TPM_TAG */
... ... @@ -482,7 +475,7 @@
482 475 }
483 476  
484 477 #ifdef CONFIG_TPM_FLUSH_RESOURCES
485   -u32 tpm_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type)
  478 +u32 tpm1_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type)
486 479 {
487 480 const u8 command[18] = {
488 481 0x00, 0xc1, /* TPM_TAG */
... ... @@ -641,7 +634,7 @@
641 634 return TPM_SUCCESS;
642 635 }
643 636  
644   -u32 tpm_terminate_auth_session(struct udevice *dev, u32 auth_handle)
  637 +u32 tpm1_terminate_auth_session(struct udevice *dev, u32 auth_handle)
645 638 {
646 639 const u8 command[18] = {
647 640 0x00, 0xc1, /* TPM_TAG */
648 641  
649 642  
... ... @@ -663,16 +656,16 @@
663 656 return tpm_sendrecv_command(dev, request, NULL, NULL);
664 657 }
665 658  
666   -u32 tpm_end_oiap(struct udevice *dev)
  659 +u32 tpm1_end_oiap(struct udevice *dev)
667 660 {
668 661 u32 err = TPM_SUCCESS;
669 662  
670 663 if (oiap_session.valid)
671   - err = tpm_terminate_auth_session(dev, oiap_session.handle);
  664 + err = tpm1_terminate_auth_session(dev, oiap_session.handle);
672 665 return err;
673 666 }
674 667  
675   -u32 tpm_oiap(struct udevice *dev, u32 *auth_handle)
  668 +u32 tpm1_oiap(struct udevice *dev, u32 *auth_handle)
676 669 {
677 670 const u8 command[10] = {
678 671 0x00, 0xc1, /* TPM_TAG */
... ... @@ -686,7 +679,7 @@
686 679 u32 err;
687 680  
688 681 if (oiap_session.valid)
689   - tpm_terminate_auth_session(dev, oiap_session.handle);
  682 + tpm1_terminate_auth_session(dev, oiap_session.handle);
690 683  
691 684 err = tpm_sendrecv_command(dev, command, response, &response_length);
692 685 if (err)
... ... @@ -702,9 +695,9 @@
702 695 return 0;
703 696 }
704 697  
705   -u32 tpm_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
706   - size_t key_length, const void *parent_key_usage_auth,
707   - u32 *key_handle)
  698 +u32 tpm1_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
  699 + size_t key_length, const void *parent_key_usage_auth,
  700 + u32 *key_handle)
708 701 {
709 702 const u8 command[14] = {
710 703 0x00, 0xc2, /* TPM_TAG */
... ... @@ -723,7 +716,7 @@
723 716 u32 err;
724 717  
725 718 if (!oiap_session.valid) {
726   - err = tpm_oiap(dev, NULL);
  719 + err = tpm1_oiap(dev, NULL);
727 720 if (err)
728 721 return err;
729 722 }
... ... @@ -768,9 +761,9 @@
768 761 return 0;
769 762 }
770 763  
771   -u32 tpm_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
772   - const void *usage_auth, void *pubkey,
773   - size_t *pubkey_len)
  764 +u32 tpm1_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
  765 + const void *usage_auth, void *pubkey,
  766 + size_t *pubkey_len)
774 767 {
775 768 const u8 command[14] = {
776 769 0x00, 0xc2, /* TPM_TAG */
... ... @@ -788,7 +781,7 @@
788 781 u32 err;
789 782  
790 783 if (!oiap_session.valid) {
791   - err = tpm_oiap(dev, NULL);
  784 + err = tpm1_oiap(dev, NULL);
792 785 if (err)
793 786 return err;
794 787 }
... ... @@ -834,8 +827,8 @@
834 827 }
835 828  
836 829 #ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
837   -u32 tpm_find_key_sha1(struct udevice *dev, const u8 auth[20],
838   - const u8 pubkey_digest[20], u32 *handle)
  830 +u32 tpm1_find_key_sha1(struct udevice *dev, const u8 auth[20],
  831 + const u8 pubkey_digest[20], u32 *handle)
839 832 {
840 833 u16 key_count;
841 834 u32 key_handles[10];
... ... @@ -876,7 +869,7 @@
876 869  
877 870 #endif /* CONFIG_TPM_AUTH_SESSIONS */
878 871  
879   -u32 tpm_get_random(struct udevice *dev, void *data, u32 count)
  872 +u32 tpm1_get_random(struct udevice *dev, void *data, u32 count)
880 873 {
881 874 const u8 command[14] = {
882 875 0x0, 0xc1, /* TPM_TAG */