sip.c 908 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2017 NXP
  4. */
  5. #include <common.h>
  6. #include <asm/arch/sys_proto.h>
  7. #include <asm/cache.h>
  8. #include <asm/ptrace.h>
  9. unsigned long call_imx_sip(unsigned long id, unsigned long reg0,
  10. unsigned long reg1, unsigned long reg2,
  11. unsigned long reg3)
  12. {
  13. struct pt_regs regs;
  14. regs.regs[0] = id;
  15. regs.regs[1] = reg0;
  16. regs.regs[2] = reg1;
  17. regs.regs[3] = reg2;
  18. regs.regs[4] = reg3;
  19. smc_call(&regs);
  20. return regs.regs[0];
  21. }
  22. /*
  23. * Do an SMC call to return 2 registers by having reg1 passed in by reference
  24. */
  25. unsigned long call_imx_sip_ret2(unsigned long id, unsigned long reg0,
  26. unsigned long *reg1, unsigned long reg2,
  27. unsigned long reg3)
  28. {
  29. struct pt_regs regs;
  30. regs.regs[0] = id;
  31. regs.regs[1] = reg0;
  32. regs.regs[2] = *reg1;
  33. regs.regs[3] = reg2;
  34. regs.regs[4] = reg3;
  35. smc_call(&regs);
  36. *reg1 = regs.regs[1];
  37. return regs.regs[0];
  38. }