From 603bf24744b623da7f4c3a0be314977633fc8b97 Mon Sep 17 00:00:00 2001 From: Zhang Zhijie Date: Wed, 7 Mar 2018 14:45:39 +0800 Subject: [PATCH] OP-TEE: add configure uart port function When kernel change print log uart port, optee should keep the same with it. Kernel driver will tell optee the uart port id when tee-supplicant starts up. If fiq-debugger node is disabled, then id is set as 0xffffffff, optee uart print is disabled. Change-Id: Id0bc5428d244896fa95eb6a9c2f36bd3ff1248b7 Signed-off-by: Zhang Zhijie --- security/optee_linuxdriver/armtz/tee_tz_drv.c | 35 +++++++++++++++++++ .../include/arm_common/teesmc.h | 8 +++++ 2 files changed, 43 insertions(+) diff --git a/security/optee_linuxdriver/armtz/tee_tz_drv.c b/security/optee_linuxdriver/armtz/tee_tz_drv.c index c806bf30c729..d1d23eb50d6a 100644 --- a/security/optee_linuxdriver/armtz/tee_tz_drv.c +++ b/security/optee_linuxdriver/armtz/tee_tz_drv.c @@ -33,6 +33,7 @@ #include #include +#include #include "tee_mem.h" #include "tee_tz_op.h" @@ -1182,6 +1183,38 @@ static int configure_shm(struct tee_tz *ptee) return ret; } +static int rk_set_uart_port(struct tee_tz *ptee) +{ + struct smc_param param = {0}; + struct device_node *np; + int serial_id; + int ret = 0; + + np = of_find_node_by_name(NULL, "fiq-debugger"); + if (!np) + return -ENODEV; + + if (of_device_is_available(np)) { + if (of_property_read_u32(np, "rockchip,serial-id", &serial_id)) + return -EINVAL; + } else { + serial_id = 0xffffffff; + } + + dev_dbg(DEV, "optee set uart port id: %d\n", serial_id); + param.a0 = TEESMC32_ROCKCHIP_FASTCALL_SET_UART_PORT; + param.a1 = serial_id; + + mutex_lock(&ptee->mutex); +#ifdef SWITCH_CPU0_DEBUG + ret = tee_smc_call_switchcpu0(¶m); +#else + tee_smc_call(¶m); +#endif + mutex_unlock(&ptee->mutex); + + return ret; +} /******************************************************************************/ @@ -1201,6 +1234,8 @@ static int tz_start(struct tee *tee) BUG_ON(ptee->started); ptee->started = true; + rk_set_uart_port(ptee); + ret = configure_shm(ptee); if (ret) goto exit; diff --git a/security/optee_linuxdriver/include/arm_common/teesmc.h b/security/optee_linuxdriver/include/arm_common/teesmc.h index cbc12c02b370..83e85bdc8386 100644 --- a/security/optee_linuxdriver/include/arm_common/teesmc.h +++ b/security/optee_linuxdriver/include/arm_common/teesmc.h @@ -346,6 +346,9 @@ struct teesmc_meta_open_session { #define TEESMC_OWNER_TRUSTED_APP 48 #define TEESMC_OWNER_TRUSTED_OS 50 +/* Rockchip define trusted os call */ +#define TEESMC_OWNER_TRUSTED_OS_ROCKCHIP 55 + #define TEESMC_OWNER_TRUSTED_OS_API 63 /* @@ -699,4 +702,9 @@ struct teesmc_meta_open_session { */ #define TEESMC_RPC_REQUEST_IRQ 0x0 +#define TEESMC_ROCKCHIP_FUNCID_SET_UART_PORT 0x0000 +#define TEESMC32_ROCKCHIP_FASTCALL_SET_UART_PORT \ + TEESMC_CALL_VAL(TEESMC_32, TEESMC_FAST_CALL, TEESMC_OWNER_TRUSTED_OS_ROCKCHIP, \ + TEESMC_ROCKCHIP_FUNCID_SET_UART_PORT) + #endif /* TEESMC_H */