tee: add api tee_protect_tvp_mem [1/1]
authorPengguang Zhu <pengguang.zhu@amlogic.com>
Tue, 3 Dec 2019 07:15:10 +0000 (15:15 +0800)
committerShipeng Sun <shipeng.sun@amlogic.com>
Wed, 25 Dec 2019 07:36:54 +0000 (00:36 -0700)
PD#SWPL-17811

Problem:
need API to protect mem for tvp

Solution:
add api tee_protect_tvp_mem

Verify:
Android Q + franklin

Test: manual

Change-Id: I46daec70a843524789aa63b32ef5e43111b65c66
Signed-off-by: Pengguang Zhu <pengguang.zhu@amlogic.com>
drivers/amlogic/tee/tee.c
include/linux/amlogic/tee.h

index 1c2e3ebd16934b2eca1b92eb9d1601a272684334..296cacef0afd270f86f189c14f5426d66d401d20 100644 (file)
@@ -56,6 +56,13 @@ static int disable_flag;
 #define TEE_SMC_LOAD_VIDEO_FW \
        TEE_SMC_FAST_CALL_VAL(TEE_SMC_FUNCID_LOAD_VIDEO_FW)
 
+#define TEE_SMC_FUNCID_PROTECT_TVP_MEM             0xE020
+#define TEE_SMC_PROTECT_TVP_MEM \
+       TEE_SMC_FAST_CALL_VAL(TEE_SMC_FUNCID_PROTECT_TVP_MEM)
+
+#define TEE_SMC_FUNCID_UNPROTECT_TVP_MEM           0xE021
+#define TEE_SMC_UNPROTECT_TVP_MEM \
+       TEE_SMC_FAST_CALL_VAL(TEE_SMC_FUNCID_UNPROTECT_TVP_MEM)
 static struct class *tee_sys_class;
 
 struct tee_smc_calls_revision_result {
@@ -172,6 +179,31 @@ bool tee_enabled(void)
 }
 EXPORT_SYMBOL(tee_enabled);
 
+uint32_t tee_protect_tvp_mem(uint32_t start, uint32_t size, uint32_t *handle)
+{
+       struct arm_smccc_res res;
+
+       if (handle == NULL)
+               return 0xFFFF0006;
+
+       arm_smccc_smc(TEE_SMC_PROTECT_TVP_MEM,
+                       start, size, 0, 0, 0, 0, 0, &res);
+
+       *handle = res.a1;
+
+       return res.a0;
+}
+EXPORT_SYMBOL(tee_protect_tvp_mem);
+
+void tee_unprotect_tvp_mem(uint32_t handle)
+{
+       struct arm_smccc_res res;
+
+       arm_smccc_smc(TEE_SMC_UNPROTECT_TVP_MEM,
+                       handle, 0, 0, 0, 0, 0, 0, &res);
+}
+EXPORT_SYMBOL(tee_unprotect_tvp_mem);
+
 int tee_create_sysfs(void)
 {
        int ret;
index 224dde5cb3eedf55e1d18f0bcb9848a6dd4c70c8..e63d886e110b67881790a7da0600410efa8efafd 100644 (file)
@@ -22,5 +22,8 @@ extern bool tee_enabled(void);
 extern int is_secload_get(void);
 extern int tee_load_video_fw(uint32_t index, uint32_t vdec);
 extern int tee_load_video_fw_swap(uint32_t index, uint32_t vdec, bool is_swap);
+extern uint32_t tee_protect_tvp_mem(uint32_t start, uint32_t size,
+                       uint32_t *handle);
+extern void tee_unprotect_tvp_mem(uint32_t handle);
 #endif /* __TEE_H__ */