From 6c08d5e2bdee2f0ad9f70b60a00e6862274ada5a Mon Sep 17 00:00:00 2001 From: linyx10 Date: Wed, 24 Feb 2021 22:51:32 +0800 Subject: [PATCH] Make Trustonic TEE driver module compatible with kernel 5.4. The paths and interfaces for qcom scm call on kernel 4.x and kernel 5.x are different, considering that different platform use different kernels, so workaround here for compatibility. Change-Id: I1a52e58be740799587a8ec924a5fd76d8f69a018 Signed-off-by: linyx10 Reviewed-on: https://gerrit.mot.com/1885962 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Jefferson Rodrigo Capovilla Reviewed-by: Binsheng Que Reviewed-by: Zhenxin Xi Submit-Approved: Jira Key --- drivers/gud/MobiCoreDriver/platform.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/gud/MobiCoreDriver/platform.h b/drivers/gud/MobiCoreDriver/platform.h index 936db23ba831..e56f37b26294 100644 --- a/drivers/gud/MobiCoreDriver/platform.h +++ b/drivers/gud/MobiCoreDriver/platform.h @@ -27,11 +27,20 @@ #define USE_SHM_BRIDGE #endif +#if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE +#include +#include +#if defined USE_SHM_BRIDGE +#include +#endif +#elif KERNEL_VERSION(4, 14, 0) <= LINUX_VERSION_CODE #include #include #if defined USE_SHM_BRIDGE #include #endif +#endif + /*--------------- Implementation -------------- */ /* MobiCore Interrupt for Qualcomm (DT IRQ has priority if present) */ #define MC_INTR_SSIQ 280 @@ -39,6 +48,7 @@ /* Use SMC for fastcalls */ #define MC_SMC_FASTCALL +#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 4, 0) #define SCM_MOBIOS_FNID(s, c) (((((s) & 0xFF) << 8) | ((c) & 0xFF)) \ | 0x33000000) @@ -48,11 +58,20 @@ TZ_SYSCALL_PARAM_TYPE_VAL, \ TZ_SYSCALL_PARAM_TYPE_BUF_RW, \ TZ_SYSCALL_PARAM_TYPE_VAL) +#endif /* from following file */ #define SCM_SVC_MOBICORE 250 #define SCM_CMD_MOBICORE 1 +#if KERNEL_VERSION(5, 4, 0) <= LINUX_VERSION_CODE +extern int trustonic_smc_fastcall(void *fc_generic, size_t size); +static inline int smc_fastcall(void *fc_generic, size_t size) +{ + return trustonic_smc_fastcall(fc_generic, size); +} + +#elif KERNEL_VERSION(4, 14, 0) <= LINUX_VERSION_CODE static inline int smc_fastcall(void *fc_generic, size_t size) { #if !defined(USE_SHM_BRIDGE) @@ -102,6 +121,7 @@ static inline int smc_fastcall(void *fc_generic, size_t size) fc_generic, size); #endif } +#endif /* * Do not start the TEE at driver init