From: Pengguang Zhu Date: Tue, 3 Dec 2019 07:15:10 +0000 (+0800) Subject: tee: add api tee_protect_tvp_mem [1/1] X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=63aff7a40d6bfb43be886959a3f609d15271f264;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git tee: add api tee_protect_tvp_mem [1/1] 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 --- diff --git a/drivers/amlogic/tee/tee.c b/drivers/amlogic/tee/tee.c index 1c2e3ebd1693..296cacef0afd 100644 --- a/drivers/amlogic/tee/tee.c +++ b/drivers/amlogic/tee/tee.c @@ -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; diff --git a/include/linux/amlogic/tee.h b/include/linux/amlogic/tee.h index 224dde5cb3ee..e63d886e110b 100644 --- a/include/linux/amlogic/tee.h +++ b/include/linux/amlogic/tee.h @@ -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__ */