scp03.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2021, Foundries.IO
  4. *
  5. */
  6. #include <common.h>
  7. #include <scp03.h>
  8. #include <tee.h>
  9. #include <tee/optee_ta_scp03.h>
  10. static int scp03_enable(bool provision)
  11. {
  12. const struct tee_optee_ta_uuid uuid = PTA_SCP03_UUID;
  13. struct tee_open_session_arg session;
  14. struct tee_invoke_arg invoke;
  15. struct tee_param param;
  16. struct udevice *tee = NULL;
  17. tee = tee_find_device(tee, NULL, NULL, NULL);
  18. if (!tee)
  19. return -ENODEV;
  20. memset(&session, 0, sizeof(session));
  21. tee_optee_ta_uuid_to_octets(session.uuid, &uuid);
  22. if (tee_open_session(tee, &session, 0, NULL))
  23. return -ENXIO;
  24. memset(&param, 0, sizeof(param));
  25. param.attr = TEE_PARAM_ATTR_TYPE_VALUE_INPUT;
  26. param.u.value.a = provision;
  27. memset(&invoke, 0, sizeof(invoke));
  28. invoke.func = PTA_CMD_ENABLE_SCP03;
  29. invoke.session = session.session;
  30. if (tee_invoke_func(tee, &invoke, 1, &param))
  31. return -EIO;
  32. tee_close_session(tee, session.session);
  33. return 0;
  34. }
  35. int tee_enable_scp03(void)
  36. {
  37. return scp03_enable(false);
  38. }
  39. int tee_provision_scp03(void)
  40. {
  41. return scp03_enable(true);
  42. }