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