[U-Boot,1/8] imx: sip: add call_imx_sip_ret2
diff mbox series

Message ID 20190412080741.32412-1-peng.fan@nxp.com
State Accepted
Commit a87eb0405f460978e9e344dfa89e10bc447aa7a6
Delegated to: Stefano Babic
Headers show
Series
  • [U-Boot,1/8] imx: sip: add call_imx_sip_ret2
Related show

Commit Message

Peng Fan April 12, 2019, 7:54 a.m. UTC
This function will be used by i.MX8 fuse driver.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 arch/arm/include/asm/mach-imx/sys_proto.h |  3 +++
 arch/arm/mach-imx/sip.c                   | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+)

Patch
diff mbox series

diff --git a/arch/arm/include/asm/mach-imx/sys_proto.h b/arch/arm/include/asm/mach-imx/sys_proto.h
index d0f866b630..4925dd7894 100644
--- a/arch/arm/include/asm/mach-imx/sys_proto.h
+++ b/arch/arm/include/asm/mach-imx/sys_proto.h
@@ -134,4 +134,7 @@  int mxs_wait_mask_clr(struct mxs_register_32 *reg, u32 mask, u32 timeout);
 
 unsigned long call_imx_sip(unsigned long id, unsigned long reg0,
 			   unsigned long reg1, unsigned long reg2);
+unsigned long call_imx_sip_ret2(unsigned long id, unsigned long reg0,
+				unsigned long *reg1, unsigned long reg2,
+				unsigned long reg3);
 #endif
diff --git a/arch/arm/mach-imx/sip.c b/arch/arm/mach-imx/sip.c
index 813c2ae5e1..968e7cf309 100644
--- a/arch/arm/mach-imx/sip.c
+++ b/arch/arm/mach-imx/sip.c
@@ -20,3 +20,25 @@  unsigned long call_imx_sip(unsigned long id, unsigned long reg0,
 
 	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];
+}