Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Peng Fan | de27466 | 2018-01-10 13:20:23 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2017 NXP |
Peng Fan | de27466 | 2018-01-10 13:20:23 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <asm/arch/sys_proto.h> |
| 8 | |
| 9 | unsigned long call_imx_sip(unsigned long id, unsigned long reg0, |
Ye Li | 264977d | 2019-10-26 16:24:03 +0200 | [diff] [blame] | 10 | unsigned long reg1, unsigned long reg2, |
| 11 | unsigned long reg3) |
Peng Fan | de27466 | 2018-01-10 13:20:23 +0800 | [diff] [blame] | 12 | { |
| 13 | struct pt_regs regs; |
| 14 | |
| 15 | regs.regs[0] = id; |
| 16 | regs.regs[1] = reg0; |
| 17 | regs.regs[2] = reg1; |
| 18 | regs.regs[3] = reg2; |
Ye Li | 264977d | 2019-10-26 16:24:03 +0200 | [diff] [blame] | 19 | regs.regs[4] = reg3; |
Peng Fan | de27466 | 2018-01-10 13:20:23 +0800 | [diff] [blame] | 20 | |
| 21 | smc_call(®s); |
| 22 | |
| 23 | return regs.regs[0]; |
| 24 | } |
Peng Fan | a87eb04 | 2019-04-12 07:54:50 +0000 | [diff] [blame] | 25 | |
| 26 | /* |
| 27 | * Do an SMC call to return 2 registers by having reg1 passed in by reference |
| 28 | */ |
| 29 | unsigned long call_imx_sip_ret2(unsigned long id, unsigned long reg0, |
| 30 | unsigned long *reg1, unsigned long reg2, |
| 31 | unsigned long reg3) |
| 32 | { |
| 33 | struct pt_regs regs; |
| 34 | |
| 35 | regs.regs[0] = id; |
| 36 | regs.regs[1] = reg0; |
| 37 | regs.regs[2] = *reg1; |
| 38 | regs.regs[3] = reg2; |
| 39 | regs.regs[4] = reg3; |
| 40 | |
| 41 | smc_call(®s); |
| 42 | |
| 43 | *reg1 = regs.regs[1]; |
| 44 | |
| 45 | return regs.regs[0]; |
| 46 | } |