blob: 6cb8179ee8cb6684f85baf33ddaba06cf41753da [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peng Fanaa3b9072018-01-10 13:20:23 +08002/*
3 * Copyright 2017 NXP
Peng Fanaa3b9072018-01-10 13:20:23 +08004 */
5
6#include <common.h>
7#include <asm/arch/sys_proto.h>
Simon Glass274e0b02020-05-10 11:39:56 -06008#include <asm/cache.h>
Simon Glass6b9f0102020-05-10 11:40:06 -06009#include <asm/ptrace.h>
Peng Fanaa3b9072018-01-10 13:20:23 +080010
11unsigned long call_imx_sip(unsigned long id, unsigned long reg0,
Ye Lie5e91092019-10-26 16:24:03 +020012 unsigned long reg1, unsigned long reg2,
13 unsigned long reg3)
Peng Fanaa3b9072018-01-10 13:20:23 +080014{
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;
Ye Lie5e91092019-10-26 16:24:03 +020021 regs.regs[4] = reg3;
Peng Fanaa3b9072018-01-10 13:20:23 +080022
23 smc_call(&regs);
24
25 return regs.regs[0];
26}
Peng Fana5060092019-04-12 07:54:50 +000027
28/*
29 * Do an SMC call to return 2 registers by having reg1 passed in by reference
30 */
31unsigned 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}