Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Peng Fan | aa3b907 | 2018-01-10 13:20:23 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2017 NXP |
Peng Fan | aa3b907 | 2018-01-10 13:20:23 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <asm/arch/sys_proto.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 8 | #include <asm/cache.h> |
Simon Glass | 6b9f010 | 2020-05-10 11:40:06 -0600 | [diff] [blame] | 9 | #include <asm/ptrace.h> |
Peng Fan | aa3b907 | 2018-01-10 13:20:23 +0800 | [diff] [blame] | 10 | |
| 11 | unsigned long call_imx_sip(unsigned long id, unsigned long reg0, |
Ye Li | e5e9109 | 2019-10-26 16:24:03 +0200 | [diff] [blame] | 12 | unsigned long reg1, unsigned long reg2, |
| 13 | unsigned long reg3) |
Peng Fan | aa3b907 | 2018-01-10 13:20:23 +0800 | [diff] [blame] | 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; |
Ye Li | e5e9109 | 2019-10-26 16:24:03 +0200 | [diff] [blame] | 21 | regs.regs[4] = reg3; |
Peng Fan | aa3b907 | 2018-01-10 13:20:23 +0800 | [diff] [blame] | 22 | |
| 23 | smc_call(®s); |
| 24 | |
| 25 | return regs.regs[0]; |
| 26 | } |
Peng Fan | a506009 | 2019-04-12 07:54:50 +0000 | [diff] [blame] | 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(®s); |
| 44 | |
| 45 | *reg1 = regs.regs[1]; |
| 46 | |
| 47 | return regs.regs[0]; |
| 48 | } |