Commit 0c9fd821 authored by Clément Léger's avatar Clément Léger Committed by Claudiu Beznea

ARM: at91: add code to handle secure calls

Since OP-TEE now has a more complete support for sama5d2, add necessary
code to perform SMC calls. The detection of OP-TEE is based on a
specific device-tree node path (/firmware/optee) such has done by some
other SoC. A check is added to avoid doing SMC calls without having
OP-TEE.
Signed-off-by: default avatarClément Léger <clement.leger@bootlin.com>
Signed-off-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
parent f611af4c
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
obj-$(CONFIG_SOC_AT91RM9200) += at91rm9200.o obj-$(CONFIG_SOC_AT91RM9200) += at91rm9200.o
obj-$(CONFIG_SOC_AT91SAM9) += at91sam9.o obj-$(CONFIG_SOC_AT91SAM9) += at91sam9.o
obj-$(CONFIG_SOC_SAM9X60) += sam9x60.o obj-$(CONFIG_SOC_SAM9X60) += sam9x60.o
obj-$(CONFIG_SOC_SAMA5) += sama5.o obj-$(CONFIG_SOC_SAMA5) += sama5.o sam_secure.o
obj-$(CONFIG_SOC_SAMA7) += sama7.o obj-$(CONFIG_SOC_SAMA7) += sama7.o
obj-$(CONFIG_SOC_SAMV7) += samv7.o obj-$(CONFIG_SOC_SAMV7) += samv7.o
......
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2022, Microchip
*/
#include <linux/arm-smccc.h>
#include <linux/of.h>
#include "sam_secure.h"
static bool optee_available;
#define SAM_SIP_SMC_STD_CALL_VAL(func_num) \
ARM_SMCCC_CALL_VAL(ARM_SMCCC_STD_CALL, ARM_SMCCC_SMC_32, \
ARM_SMCCC_OWNER_SIP, (func_num))
struct arm_smccc_res sam_smccc_call(u32 fn, u32 arg0, u32 arg1)
{
struct arm_smccc_res res = {.a0 = -1};
if (WARN_ON(!optee_available))
return res;
arm_smccc_smc(SAM_SIP_SMC_STD_CALL_VAL(fn), arg0, arg1, 0, 0, 0, 0, 0,
&res);
return res;
}
void __init sam_secure_init(void)
{
struct device_node *np;
/*
* We only check that the OP-TEE node is present and available. The
* OP-TEE kernel driver is not needed for the type of interaction made
* with OP-TEE here so the driver's status is not checked.
*/
np = of_find_node_by_path("/firmware/optee");
if (np && of_device_is_available(np))
optee_available = true;
of_node_put(np);
if (optee_available)
pr_info("Running under OP-TEE firmware\n");
}
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2022, Microchip
*/
#ifndef SAM_SECURE_H
#define SAM_SECURE_H
#include <linux/arm-smccc.h>
void __init sam_secure_init(void);
struct arm_smccc_res sam_smccc_call(u32 fn, u32 arg0, u32 arg1);
#endif /* SAM_SECURE_H */
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <asm/system_misc.h> #include <asm/system_misc.h>
#include "generic.h" #include "generic.h"
#include "sam_secure.h"
static void __init sama5_dt_device_init(void) static void __init sama5_dt_device_init(void)
{ {
...@@ -47,6 +48,7 @@ MACHINE_END ...@@ -47,6 +48,7 @@ MACHINE_END
static void __init sama5d2_init(void) static void __init sama5d2_init(void)
{ {
of_platform_default_populate(NULL, NULL, NULL); of_platform_default_populate(NULL, NULL, NULL);
sam_secure_init();
sama5d2_pm_init(); sama5d2_pm_init();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment