Build: Add memory protection configuration

Add a config macro "CONFIG_TFM_ENABLE_MEMORY_PROTECT" to control if the
memory protection function is enabled or not. The default value is "OFF"
and it is set to "ON" when the isolation level greater than 1.

Change-Id: I3e5495c97183e07a0f9b82ea4923ea20ee10071a
Signed-off-by: Edison Ai <edison.ai@arm.com>
Co-authored-by: Shawn Shan <shawn.shan@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index c34ee5a..e1f1f7e 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -156,6 +156,10 @@
 option(TFM_PARTITION_CRYPTO "Enable the TF-M crypto partition" ON)
 option(TFM_PARTITION_INITIAL_ATTESTATION "Enable the TF-M initial attestation partition" ON)
 
+if (NOT TFM_LVL EQUAL 1 AND NOT DEFINED CONFIG_TFM_ENABLE_MEMORY_PROTECT)
+	set (CONFIG_TFM_ENABLE_MEMORY_PROTECT ON)
+endif()
+
 if (TFM_PARTITION_INITIAL_ATTESTATION OR TFM_PARTITION_SECURE_STORAGE)
 	#PSA Initial Attestation and Protected storage rely on Cryptography API
 	set(TFM_PARTITION_CRYPTO ON)
@@ -309,6 +313,10 @@
 	add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
 endif()
 
+if (CONFIG_TFM_ENABLE_MEMORY_PROTECT)
+	add_definitions(-DCONFIG_TFM_ENABLE_MEMORY_PROTECT)
+endif()
+
 if (PSA_API_TEST)
 	add_definitions(-DPSA_API_TEST_NS)
 	set(PSA_API_TEST_NS ON)