ARM: OMAP2+: Introduce check for OP-TEE in omap_secure_init()
authorAndrew F. Davis <afd@ti.com>
Thu, 2 Jan 2020 21:19:41 +0000 (16:19 -0500)
committerTony Lindgren <tony@atomide.com>
Mon, 13 Jan 2020 18:06:25 +0000 (10:06 -0800)
This check and associated flag can be used to signal the presence
of OP-TEE on the platform. This can be used to determine which
SMC calls to make to perform secure operations.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/omap-secure.c
arch/arm/mach-omap2/omap-secure.h

index e936732cdc4f4d48169976ba77758efef9706b39..5686466600810b7526e98462355cf09f825f6209 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/memblock.h>
+#include <linux/of.h>
 
 #include <asm/cacheflush.h>
 #include <asm/memblock.h>
 
 static phys_addr_t omap_secure_memblock_base;
 
+bool optee_available;
+
+static void __init omap_optee_init_check(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);
+}
+
 /**
  * omap_sec_dispatcher: Routine to dispatch low power secure
  * service routines
@@ -166,4 +184,5 @@ u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag)
 
 void __init omap_secure_init(void)
 {
+       omap_optee_init_check();
 }
index 9aeeb236a2244b6c5fda75dd7f2510bd32e80888..78a1c4f04bbe0110ff80bd8c94d487112dcf009b 100644 (file)
@@ -10,6 +10,8 @@
 #ifndef OMAP_ARCH_OMAP_SECURE_H
 #define OMAP_ARCH_OMAP_SECURE_H
 
+#include <linux/types.h>
+
 /* Monitor error code */
 #define  API_HAL_RET_VALUE_NS2S_CONVERSION_ERROR       0xFFFFFFFE
 #define  API_HAL_RET_VALUE_SERVICE_UNKNWON             0xFFFFFFFF
@@ -72,6 +74,7 @@ extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
 extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits);
 extern u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag);
 
+extern bool optee_available;
 void omap_secure_init(void);
 
 #ifdef CONFIG_SOC_HAS_REALTIME_COUNTER