From da6e654bc8b03ee784d0e96a71c4e591e63930f2 Mon Sep 17 00:00:00 2001 From: Ronak Jain Date: Fri, 4 Feb 2022 00:42:55 -0800 Subject: [PATCH] feat(versal): get version for ATF related EEMI APIs The patch does below things. 1. As per current implementation, when Linux send a request to ATF to get the version of APIs which are implemented in ATF then ATF wasn't returning any version because there is a check for LIBPM module id. The ATF is used to return version for the APIs which are implemented in the firmware only. Hence moved this switch-case before checking module id to get ATF version. Also, no need to pass Linux request to the firmware for the APIs which are implemented in ATF instead return success after updating version. 2. As per current implementation, higher 16-bit is used for ATF version and lower 16-bit is used for firmware version. Now, removed 16-bit shift operation and send complete word i.e. 32-bit to Linux user as there is no user who checks ATF version. 3. Add bit mask support in the feature check PM EEMI API for QUERY and IOCTL ids. Change-Id: Icdca3de6659f3b673b81a423ed79a3c20b678768 Signed-off-by: Ronak Jain Signed-off-by: Tanmay Shah --- plat/xilinx/versal/pm_service/pm_api_sys.c | 52 +++++++++------------ plat/xilinx/versal/pm_service/pm_api_sys.h | 2 +- plat/xilinx/versal/pm_service/pm_defs.h | 1 + plat/xilinx/versal/pm_service/pm_svc_main.c | 7 +-- 4 files changed, 27 insertions(+), 35 deletions(-) diff --git a/plat/xilinx/versal/pm_service/pm_api_sys.c b/plat/xilinx/versal/pm_service/pm_api_sys.c index ead255fe9..c7b60476f 100644 --- a/plat/xilinx/versal/pm_service/pm_api_sys.c +++ b/plat/xilinx/versal/pm_service/pm_api_sys.c @@ -533,56 +533,46 @@ enum pm_ret_status pm_set_wakeup_source(uint32_t target, uint32_t wkup_device, /** * pm_feature_check() - Returns the supported API version if supported * @api_id API ID to check - * @value Returned supported API version * @flag 0 - Call from secure source * 1 - Call from non-secure source + * @ret_payload pointer to array of PAYLOAD_ARG_CNT number of + * words Returned supported API version and bitmasks + * for IOCTL and QUERY ID * * @return Returns status, either success or error+reason */ -enum pm_ret_status pm_feature_check(uint32_t api_id, unsigned int *version, +enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *ret_payload, uint32_t flag) { - uint32_t payload[PAYLOAD_ARG_CNT], fw_api_version; - enum pm_ret_status status; + uint32_t payload[PAYLOAD_ARG_CNT]; uint32_t module_id; + /* Return version of API which are implemented in ATF only */ + switch (api_id) { + case PM_GET_CALLBACK_DATA: + case PM_GET_TRUSTZONE_VERSION: + ret_payload[0] = PM_API_VERSION_2; + return PM_RET_SUCCESS; + case PM_LOAD_PDI: + ret_payload[0] = PM_API_BASE_VERSION; + return PM_RET_SUCCESS; + default: + break; + } + module_id = (api_id & MODULE_ID_MASK) >> 8; - /* feature check should be done only for LIBPM module + /* + * feature check should be done only for LIBPM module * If module_id is 0, then we consider it LIBPM module as default id */ if ((module_id > 0) && (module_id != LIBPM_MODULE_ID)) { return PM_RET_SUCCESS; } - switch (api_id) { - case PM_GET_CALLBACK_DATA: - case PM_GET_TRUSTZONE_VERSION: - case PM_LOAD_PDI: - *version = (PM_API_BASE_VERSION << 16); - return PM_RET_SUCCESS; - case PM_QUERY_DATA: - *version = (PM_API_QUERY_DATA_VERSION << 16); - break; - default: - *version = (PM_API_BASE_VERSION << 16); - break; - } - PM_PACK_PAYLOAD2(payload, LIBPM_MODULE_ID, flag, PM_FEATURE_CHECK, api_id); - - status = pm_ipi_send_sync(primary_proc, payload, &fw_api_version, 1); - if (status != PM_RET_SUCCESS) { - goto done; - } - - *version |= fw_api_version; - - status = PM_RET_SUCCESS; - -done: - return status; + return pm_ipi_send_sync(primary_proc, payload, ret_payload, PAYLOAD_ARG_CNT); } /** diff --git a/plat/xilinx/versal/pm_service/pm_api_sys.h b/plat/xilinx/versal/pm_service/pm_api_sys.h index d3f5060e7..86a46d01e 100644 --- a/plat/xilinx/versal/pm_service/pm_api_sys.h +++ b/plat/xilinx/versal/pm_service/pm_api_sys.h @@ -49,7 +49,7 @@ enum pm_ret_status pm_api_ioctl(uint32_t device_id, uint32_t ioctl_id, enum pm_ret_status pm_query_data(uint32_t qid, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t *data, uint32_t flag); unsigned int pm_get_shutdown_scope(void); -enum pm_ret_status pm_feature_check(uint32_t api_id, unsigned int *version, +enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *ret_payload, uint32_t flag); enum pm_ret_status pm_load_pdi(uint32_t src, uint32_t address_low, uint32_t address_high, uint32_t flag); diff --git a/plat/xilinx/versal/pm_service/pm_defs.h b/plat/xilinx/versal/pm_service/pm_defs.h index 8b6286995..378565049 100644 --- a/plat/xilinx/versal/pm_service/pm_defs.h +++ b/plat/xilinx/versal/pm_service/pm_defs.h @@ -38,6 +38,7 @@ /* PM API Versions */ #define PM_API_BASE_VERSION 1U +#define PM_API_VERSION_2 2U #define PM_API_QUERY_DATA_VERSION 2U diff --git a/plat/xilinx/versal/pm_service/pm_svc_main.c b/plat/xilinx/versal/pm_service/pm_svc_main.c index c698aa724..75c12684a 100644 --- a/plat/xilinx/versal/pm_service/pm_svc_main.c +++ b/plat/xilinx/versal/pm_service/pm_svc_main.c @@ -156,10 +156,11 @@ static uintptr_t eemi_for_compatibility(uint32_t api_id, uint32_t *pm_arg, case PM_FEATURE_CHECK: { - uint32_t version; + uint32_t result[PAYLOAD_ARG_CNT] = {0U}; - ret = pm_feature_check(pm_arg[0], &version, security_flag); - SMC_RET1(handle, (uint64_t)ret | ((uint64_t)version << 32)); + ret = pm_feature_check(pm_arg[0], result, security_flag); + SMC_RET2(handle, (uint64_t)ret | ((uint64_t)result[0] << 32), + (uint64_t)result[1] | ((uint64_t)result[2] << 32)); } case PM_LOAD_PDI: