smccc.c 783 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2021 ARM Ltd.
  4. */
  5. #include <linux/printk.h>
  6. #include "common.h"
  7. static void __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
  8. {
  9. arm_smccc_1_2_smc(&args, res);
  10. }
  11. static void __arm_ffa_fn_hvc(ffa_value_t args, ffa_value_t *res)
  12. {
  13. arm_smccc_1_2_hvc(&args, res);
  14. }
  15. int __init ffa_transport_init(ffa_fn **invoke_ffa_fn)
  16. {
  17. enum arm_smccc_conduit conduit;
  18. if (arm_smccc_get_version() < ARM_SMCCC_VERSION_1_2)
  19. return -EOPNOTSUPP;
  20. conduit = arm_smccc_1_1_get_conduit();
  21. if (conduit == SMCCC_CONDUIT_NONE) {
  22. pr_err("%s: invalid SMCCC conduit\n", __func__);
  23. return -EOPNOTSUPP;
  24. }
  25. if (conduit == SMCCC_CONDUIT_SMC)
  26. *invoke_ffa_fn = __arm_ffa_fn_smc;
  27. else
  28. *invoke_ffa_fn = __arm_ffa_fn_hvc;
  29. return 0;
  30. }