diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c index c74058b18dfa..0729bfaf8562 100644 --- a/drivers/tee/optee/call.c +++ b/drivers/tee/optee/call.c @@ -14,8 +14,7 @@ #include "optee_private.h" #include "optee_smc.h" -#if defined(CONFIG_SOC_IMX6) || defined(CONFIG_SOC_IMX7) \ - || (CONFIG_HAVE_IMX8_SOC) +#if defined(CONFIG_HAVE_IMX_BUSFREQ) #include #endif @@ -141,13 +140,13 @@ u32 optee_do_call_with_arg(struct tee_context *ctx, phys_addr_t parg) /* Initialize waiter */ optee_cq_wait_init(&optee->call_queue, &w); -#if defined(CONFIG_SOC_IMX6) || defined(CONFIG_SOC_IMX7) \ - || (CONFIG_HAVE_IMX8_SOC) +#if defined(CONFIG_HAVE_IMX_BUSFREQ) /* * Request Busfreq to HIGH to prevent DDR self-refresh while * executing Secure stuff */ - request_bus_freq(BUS_FREQ_HIGH); + if (optee->sec_caps & OPTEE_SMC_SEC_CAP_IMX_BUSFREQ) + request_bus_freq(BUS_FREQ_HIGH); #endif while (true) { @@ -178,12 +177,12 @@ u32 optee_do_call_with_arg(struct tee_context *ctx, phys_addr_t parg) optee_rpc_finalize_call(&call_ctx); -#if defined(CONFIG_SOC_IMX6) || defined(CONFIG_SOC_IMX7) \ - || (CONFIG_HAVE_IMX8_SOC) +#if defined(CONFIG_HAVE_IMX_BUSFREQ) /* * Release Busfreq from HIGH */ - release_bus_freq(BUS_FREQ_HIGH); + if (optee->sec_caps & OPTEE_SMC_SEC_CAP_IMX_BUSFREQ) + release_bus_freq(BUS_FREQ_HIGH); #endif /* diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index b23862c9e5ce..ad79061e903e 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -613,6 +613,10 @@ static struct optee *optee_probe(struct device_node *np) goto err; } +#if defined(CONFIG_HAVE_IMX_BUSFREQ) + if (of_find_compatible_node(NULL, NULL, "fsl,imx_busfreq")) + sec_caps |= OPTEE_SMC_SEC_CAP_IMX_BUSFREQ; +#endif optee->invoke_fn = invoke_fn; optee->sec_caps = sec_caps; diff --git a/drivers/tee/optee/optee_smc.h b/drivers/tee/optee/optee_smc.h index 777ad54d4c2c..4018c39792cf 100644 --- a/drivers/tee/optee/optee_smc.h +++ b/drivers/tee/optee/optee_smc.h @@ -218,6 +218,8 @@ struct optee_smc_get_shm_config_result { /* Secure world supports Shared Memory with a NULL buffer reference */ #define OPTEE_SMC_SEC_CAP_MEMREF_NULL BIT(4) +#define OPTEE_SMC_SEC_CAP_IMX_BUSFREQ BIT(31) + #define OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES 9 #define OPTEE_SMC_EXCHANGE_CAPABILITIES \ OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES)