TEE-329-1: OP-TEE: Add support for i.MX 8QxP

reuse Trusty support for OP-TEE

Signed-off-by: Silvano di Ninno <silvano.dininno@nxp.com>
(cherry picked from commit 6e2885a262b94bdeb8face851012f58ed32e86a9)
diff --git a/plat/imx/imx8qx/imx8qx_bl31_setup.c b/plat/imx/imx8qx/imx8qx_bl31_setup.c
index 7f15a4a..0028e53 100644
--- a/plat/imx/imx8qx/imx8qx_bl31_setup.c
+++ b/plat/imx/imx8qx/imx8qx_bl31_setup.c
@@ -156,7 +156,7 @@
 	sc_err_t err;
 	bool owned;
 	int i;
-#ifdef SPD_trusty
+#ifdef TEE_IMX8
 	sc_rm_mr_t mr_tee = 64;
 	bool mr_tee_atf_same = false;
 	sc_faddr_t reg_start;
@@ -201,7 +201,7 @@
 				if (BL31_BASE >= start && (BL31_LIMIT - 1) <= end) {
 					mr_record = mr; /* Record the mr for ATF running */
 				}
-#ifdef SPD_trusty
+#ifdef TEE_IMX8
 				else if (BL32_BASE >= start && (BL32_LIMIT -1) <= end) {
 					mr_tee = mr;
 				}
@@ -215,7 +215,7 @@
 		}
 	}
 
-#ifdef SPD_trusty
+#ifdef TEE_IMX8
 	if (mr_tee != 64) {
 		err = sc_rm_get_memreg_info(ipc_handle, mr_tee, &start, &end);
 		if (err) {
@@ -248,7 +248,7 @@
 	if (mr_record != 64) {
 		err = sc_rm_get_memreg_info(ipc_handle, mr_record, &start, &end);
 
-#ifdef SPD_trusty
+#ifdef TEE_IMX8
 		if (BL32_BASE >= start && (BL32_LIMIT - 1) <= end)
 			mr_tee_atf_same = true;
 #endif
@@ -257,7 +257,7 @@
 			ERROR("Memreg get info failed, %u\n", mr_record);
 		} else {
 			if ((BL31_LIMIT - 1) < end) {
-#ifdef SPD_trusty
+#ifdef TEE_IMX8
 				if ((end > BL32_BASE) && mr_tee_atf_same)
 					reg_end = BL32_BASE - 1;
 #endif
@@ -270,7 +270,7 @@
 						ERROR("Memreg assign failed, 0x%llx -- 0x%llx\n", (sc_faddr_t)BL31_LIMIT, reg_end);
 				}
 			}
-#ifdef SPD_trusty
+#ifdef TEE_IMX8
 			if (mr_tee_atf_same) {
 				if ((BL32_LIMIT - 1) < end) {
 					reg_start = BL32_LIMIT;
@@ -279,8 +279,8 @@
 						ERROR("sc_rm_memreg_alloc failed, 0x%llx -- 0x%llx\n", reg_start, reg_end);
 					} else {
 						err = sc_rm_assign_memreg(ipc_handle, os_part, mr);
-					if (err)
-						ERROR("Memreg assign failed, 0x%llx -- 0x%llx\n", reg_start, reg_end);
+						if (err)
+							ERROR("Memreg assign failed, 0x%llx -- 0x%llx\n", reg_start, reg_end);
 					}
 				}
 			}
@@ -387,14 +387,16 @@
 
 	bl33_image_ep_info.pc = PLAT_NS_IMAGE_OFFSET;
 	bl33_image_ep_info.spsr = get_spsr_for_bl33_entry();
-#ifdef SPD_trusty
+#ifdef TEE_IMX8
 	SET_PARAM_HEAD(&bl32_image_ep_info, PARAM_EP, VERSION_1, 0);
 	SET_SECURITY_STATE(bl32_image_ep_info.h.attr, SECURE);
 	bl32_image_ep_info.pc = BL32_BASE;
 	bl32_image_ep_info.spsr = 0;
+#ifdef SPD_trusty
 	bl32_image_ep_info.args.arg0 = BL32_SIZE;
 	bl32_image_ep_info.args.arg1 = BL32_BASE;
 #endif
+#endif
 	SET_SECURITY_STATE(bl33_image_ep_info.h.attr, NON_SECURE);
 }
 
@@ -415,7 +417,7 @@
 		MT_RW | MT_MEMORY | MT_SECURE);
 	mmap_add(imx_mmap);
 
-#ifdef SPD_trusty
+#ifdef TEE_IMX8
 	mmap_add_region(BL32_BASE, BL32_BASE, BL32_SIZE, MT_MEMORY | MT_RW);
 #endif
 
diff --git a/plat/imx/imx8qx/include/platform_def.h b/plat/imx/imx8qx/include/platform_def.h
index c81b12f..34c98f1 100644
--- a/plat/imx/imx8qx/include/platform_def.h
+++ b/plat/imx/imx8qx/include/platform_def.h
@@ -36,7 +36,7 @@
 #define BL31_BASE			0x80000000
 #define BL31_LIMIT			0x80020000
 
-#ifdef SPD_trusty
+#ifdef TEE_IMX8
 #define BL32_BASE			0xfe000000
 #define BL32_SIZE			0x00200000
 #define BL32_LIMIT			0x100000000
@@ -81,7 +81,7 @@
 
 #define DEBUG_CONSOLE			0
 
-#ifdef SPD_trusty
+#ifdef TEE_IMX8
 #define DEBUG_CONSOLE_A35		1
 #else
 #define DEBUG_CONSOLE_A35		0
diff --git a/plat/imx/imx8qx/platform.mk b/plat/imx/imx8qx/platform.mk
index d9f0c51..233cffc 100644
--- a/plat/imx/imx8qx/platform.mk
+++ b/plat/imx/imx8qx/platform.mk
@@ -37,3 +37,7 @@
 USE_COHERENT_MEM	:=	1
 RESET_TO_BL31		:=	1
 MULTI_CONSOLE_API	:=	1
+
+ifneq (${SPD},none)
+$(eval $(call add_define,TEE_IMX8))
+endif