Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / arm / mach-imx / sip.c
index b724330d35810effc003f862b18c4d462be9f35a..6cb8179ee8cb6684f85baf33ddaba06cf41753da 100644 (file)
@@ -1,14 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2017 NXP
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <asm/arch/sys_proto.h>
+#include <asm/cache.h>
+#include <asm/ptrace.h>
 
 unsigned long call_imx_sip(unsigned long id, unsigned long reg0,
-                          unsigned long reg1, unsigned long reg2)
+                          unsigned long reg1, unsigned long reg2,
+                          unsigned long reg3)
 {
        struct pt_regs regs;
 
@@ -16,8 +18,31 @@ unsigned long call_imx_sip(unsigned long id, unsigned long reg0,
        regs.regs[1] = reg0;
        regs.regs[2] = reg1;
        regs.regs[3] = reg2;
+       regs.regs[4] = reg3;
 
        smc_call(&regs);
 
        return regs.regs[0];
 }
+
+/*
+ * Do an SMC call to return 2 registers by having reg1 passed in by reference
+ */
+unsigned long call_imx_sip_ret2(unsigned long id, unsigned long reg0,
+                               unsigned long *reg1, unsigned long reg2,
+                               unsigned long reg3)
+{
+       struct pt_regs regs;
+
+       regs.regs[0] = id;
+       regs.regs[1] = reg0;
+       regs.regs[2] = *reg1;
+       regs.regs[3] = reg2;
+       regs.regs[4] = reg3;
+
+       smc_call(&regs);
+
+       *reg1 = regs.regs[1];
+
+       return regs.regs[0];
+}