mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 13:11:31 +00:00
arm: socfpga: soc64: Add SMC helper function for Intel SOCFPGA (64bits)
invoke_smc() allow U-Boot proper running in non-secure mode (EL2) to invoke SMC call to ATF's PSCI runtime services such as System Manager's registers access, 2nd phase bitstream FPGA reconfiguration, Remote System Update (RSU) and etc. smc_send_mailbox() is a send mailbox command helper function which invokes the ATF's PSCI runtime service (function ID: INTEL_SIP_SMC_MBOX_SEND_CMD) to send mailbox messages to Secure Device Manager (SDM). Signed-off-by: Chee Hong Ang <chee.hong.ang@intel.com>
This commit is contained in:
parent
dbdc1df877
commit
0eebfab3fe
3 changed files with 71 additions and 0 deletions
|
@ -72,6 +72,8 @@ ifdef CONFIG_TARGET_SOCFPGA_AGILEX
|
|||
obj-y += firewall.o
|
||||
obj-y += spl_agilex.o
|
||||
endif
|
||||
else
|
||||
obj-$(CONFIG_SPL_ATF) += smc_api.o
|
||||
endif
|
||||
|
||||
ifdef CONFIG_TARGET_SOCFPGA_GEN5
|
||||
|
|
13
arch/arm/mach-socfpga/include/mach/smc_api.h
Normal file
13
arch/arm/mach-socfpga/include/mach/smc_api.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*/
|
||||
|
||||
#ifndef _SMC_API_H_
|
||||
#define _SMC_API_H_
|
||||
|
||||
int invoke_smc(u32 func_id, u64 *args, int arg_len, u64 *ret_arg, int ret_len);
|
||||
int smc_send_mailbox(u32 cmd, u32 len, u32 *arg, u8 urgent, u32 *resp_buf_len,
|
||||
u32 *resp_buf);
|
||||
|
||||
#endif /* _SMC_API_H_ */
|
56
arch/arm/mach-socfpga/smc_api.c
Normal file
56
arch/arm/mach-socfpga/smc_api.c
Normal file
|
@ -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];
|
||||
}
|
Loading…
Add table
Reference in a new issue