diff options
author | Tom Rini <trini@konsulko.com> | 2021-01-15 07:23:50 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-01-15 07:55:11 -0500 |
commit | 83e13c3469c710af03bf43f53aede0f9b7ba2dd0 (patch) | |
tree | 411d6bc9f7f2dbe605fcc979f680b286fabba695 /arch/arm/mach-socfpga/smc_api.c | |
parent | 35772ff4f63a302e0b873096372c70292fb0af79 (diff) | |
parent | 40551cf99c237f93d9e0e07b6dd8f31b3868a0f0 (diff) |
Merge branch '2021.04-rc' of https://github.com/lftan/u-boot
- Add ATF flow for SoC64 devices
- Update socfpgaimage to support print header and update padding flow
Diffstat (limited to 'arch/arm/mach-socfpga/smc_api.c')
-rw-r--r-- | arch/arm/mach-socfpga/smc_api.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/arch/arm/mach-socfpga/smc_api.c b/arch/arm/mach-socfpga/smc_api.c new file mode 100644 index 0000000000..085daba162 --- /dev/null +++ b/arch/arm/mach-socfpga/smc_api.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 Intel Corporation <www.intel.com> + * + */ + +#include <common.h> +#include <asm/ptrace.h> +#include <asm/system.h> +#include <linux/intel-smc.h> + +int invoke_smc(u32 func_id, u64 *args, int arg_len, u64 *ret_arg, int ret_len) +{ + struct pt_regs regs; + + memset(®s, 0, sizeof(regs)); + regs.regs[0] = func_id; + + if (args) + memcpy(®s.regs[1], args, arg_len * sizeof(*args)); + + smc_call(®s); + + if (ret_arg) + memcpy(ret_arg, ®s.regs[1], ret_len * sizeof(*ret_arg)); + + return regs.regs[0]; +} + +int smc_send_mailbox(u32 cmd, u32 len, u32 *arg, u8 urgent, u32 *resp_buf_len, + u32 *resp_buf) +{ + int ret; + u64 args[6]; + u64 resp[3]; + + args[0] = cmd; + args[1] = (u64)arg; + args[2] = len; + args[3] = urgent; + args[4] = (u64)resp_buf; + if (resp_buf_len) + args[5] = *resp_buf_len; + else + args[5] = 0; + + ret = invoke_smc(INTEL_SIP_SMC_MBOX_SEND_CMD, args, ARRAY_SIZE(args), + resp, ARRAY_SIZE(resp)); + + if (ret == INTEL_SIP_SMC_STATUS_OK && resp_buf && resp_buf_len) { + if (!resp[0]) + *resp_buf_len = resp[1]; + } + + return (int)resp[0]; +} |