MA-13758 Enable Trusty OS on imx8mm

Use SPD_trusty macro for Trusty OS specific
configuration for imx8mm.

Trusty OS will be loaded on 0xbe000000 and have 32M size
memory space.

Signed-off-by: Haoran.Wang <elven.wang@nxp.com>
(cherry picked from commit c929b657f541a233d0bddf162096d0ba36d69599)
diff --git a/plat/imx/imx8mm/imx8mm_bl31_setup.c b/plat/imx/imx8mm/imx8mm_bl31_setup.c
index 867985d..aa1c336 100644
--- a/plat/imx/imx8mm/imx8mm_bl31_setup.c
+++ b/plat/imx/imx8mm/imx8mm_bl31_setup.c
@@ -53,6 +53,8 @@
 #define SMC_CMD_ALLOC_PAGE	0x01	/* allocate page to this partition */
 #define SMC_CMD_DEALLOC_PART	0x03	/* deallocate partition */
 
+#define TRUSTY_PARAMS_LEN_BYTES      (4096*2)
+
 static entry_point_info_t bl32_image_ep_info;
 static entry_point_info_t bl33_image_ep_info;
 
@@ -289,8 +291,13 @@
 	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;
+#else
 	/* Pass TEE base and size to uboot */
 	bl33_image_ep_info.args.arg1 = 0xBE000000;
+#endif
 	/* TEE size + RDC reserved memory = 0x2000000 + 0x2000000 + 0x30000000 */
 #ifdef DECRYPTED_BUFFER_START
 	bl33_image_ep_info.args.arg2 = 0xC0000000 - DECRYPTED_BUFFER_START;
@@ -346,6 +353,10 @@
 
 	mmap_add_region(0x38330000, 0x38330000, 0x100000, MT_DEVICE | MT_RW);
 
+#ifdef SPD_trusty
+	mmap_add_region(BL32_BASE, BL32_BASE, BL32_SIZE, MT_MEMORY | MT_RW);
+#endif
+
 #if USE_COHERENT_MEM
 	mmap_add_region(BL31_COHERENT_RAM_BASE, BL31_COHERENT_RAM_BASE,
 		BL31_COHERENT_RAM_LIMIT - BL31_COHERENT_RAM_BASE,
@@ -396,3 +407,12 @@
 {
 	return;
 }
+
+#ifdef SPD_trusty
+void plat_trusty_set_boot_args(aapcs64_params_t *args)
+{
+	args->arg0 = BL32_SIZE;
+	args->arg1 = BL32_BASE;
+	args->arg2 = TRUSTY_PARAMS_LEN_BYTES;
+}
+#endif
diff --git a/plat/imx/imx8mm/include/platform_def.h b/plat/imx/imx8mm/include/platform_def.h
index a8b21ce..dea9b61 100644
--- a/plat/imx/imx8mm/include/platform_def.h
+++ b/plat/imx/imx8mm/include/platform_def.h
@@ -25,6 +25,11 @@
 
 #define BL31_BASE			0x920000
 #define BL31_LIMIT			0x940000
+
+#ifdef SPD_trusty
+#define BL32_SIZE			0x02000000
+#define BL32_LIMIT			0xC0000000
+#endif
 #define BL32_BASE			0xbe000000
 
 /* non-secure uboot base */
@@ -39,8 +44,13 @@
 #define PLAT_VIRT_ADDR_SPACE_SIZE	(1ull << 32)
 #define PLAT_PHY_ADDR_SPACE_SIZE	(1ull << 32)
 
+#ifdef SPD_trusty
+#define MAX_XLAT_TABLES			5
+#define MAX_MMAP_REGIONS		13
+#else
 #define MAX_XLAT_TABLES			4
 #define MAX_MMAP_REGIONS		12
+#endif
 
 #define HAB_RVT_BASE			0x00000900 /* HAB_RVT for i.MX8MM */