refactor(versal2): add tfa_no_pm flag for scmi

Added the TFA_NO_PM flag in the SCMI file and guarded SCMI
functionality with if conditions. When TFA_NO_PM is set to 0
(default), Platform Management is enabled. When set to 1, Platform
Management is disabled. This allows the generic SCMI driver to be
used in non-PM scenarios while maintaining compatibility with
conforming power management interfaces.

Change-Id: I4f6483e2c8a322ecb41e523bc03a351af4a2cb6b
Signed-off-by: Prasad Kummari <prasad.kummari@amd.com>
diff --git a/plat/amd/versal2/bl31_setup.c b/plat/amd/versal2/bl31_setup.c
index 0901df3..da91f02 100644
--- a/plat/amd/versal2/bl31_setup.c
+++ b/plat/amd/versal2/bl31_setup.c
@@ -252,9 +252,11 @@
 	plat_gic_driver_init();
 	plat_gic_init();
 
+#if (TFA_NO_PM == 1)
 	if (platform_id != EMU) {
 		init_scmi_server();
 	}
+#endif
 }
 
 void bl31_plat_runtime_setup(void)
@@ -292,8 +294,10 @@
 				MT_CODE | MT_SECURE),
 		MAP_REGION_FLAT(BL_RO_DATA_BASE, BL_RO_DATA_END - BL_RO_DATA_BASE,
 				MT_RO_DATA | MT_SECURE),
+#if (TFA_NO_PM == 1)
 		MAP_REGION_FLAT(SMT_BUFFER_BASE, 0x1000,
 			MT_DEVICE | MT_RW | MT_NON_CACHEABLE | MT_EXECUTE_NEVER | MT_NS),
+#endif
 		{0}
 	};
 
diff --git a/plat/amd/versal2/include/scmi.h b/plat/amd/versal2/include/scmi.h
index 761535b..13cca59 100644
--- a/plat/amd/versal2/include/scmi.h
+++ b/plat/amd/versal2/include/scmi.h
@@ -7,6 +7,8 @@
 #ifndef SCMI_H
 #define SCMI_H
 
+#if (TFA_NO_PM == 1)
+
 #include "versal2-scmi.h"
 
 #define SIP_SCMI	(0xC200ffffU)
@@ -25,4 +27,6 @@
 #define SCMI_VENDOR	"AMD"
 #define SCMI_PRODUCT	"Versal Gen 2"
 
+#endif
+
 #endif /* DEF_H */
diff --git a/plat/amd/versal2/platform.mk b/plat/amd/versal2/platform.mk
index 475e8ff..447f473 100644
--- a/plat/amd/versal2/platform.mk
+++ b/plat/amd/versal2/platform.mk
@@ -128,14 +128,7 @@
 BL31_SOURCES		+=	drivers/arm/cci/cci.c				\
 				lib/cpus/aarch64/cortex_a78_ae.S		\
 				lib/cpus/aarch64/cortex_a78.S			\
-				plat/common/plat_psci_common.c			\
-				drivers/scmi-msg/base.c				\
-				drivers/scmi-msg/entry.c			\
-				drivers/scmi-msg/smt.c				\
-				drivers/scmi-msg/clock.c			\
-				drivers/scmi-msg/power_domain.c			\
-				drivers/scmi-msg/reset_domain.c			\
-				${PLAT_PATH}/scmi.c
+				plat/common/plat_psci_common.c
 
 ifeq ($(TFA_NO_PM), 0)
 BL31_SOURCES		+=	plat/xilinx/common/pm_service/pm_api_sys.c	\
@@ -144,7 +137,14 @@
 				${PLAT_PATH}/pm_service/pm_svc_main.c	\
 				${PLAT_PATH}/pm_service/pm_client.c
 else
-BL31_SOURCES		+=	${PLAT_PATH}/plat_psci.c
+BL31_SOURCES		+=	${PLAT_PATH}/plat_psci.c			\
+				drivers/scmi-msg/base.c				\
+				drivers/scmi-msg/entry.c			\
+				drivers/scmi-msg/smt.c				\
+				drivers/scmi-msg/clock.c			\
+				drivers/scmi-msg/power_domain.c			\
+				drivers/scmi-msg/reset_domain.c			\
+				${PLAT_PATH}/scmi.c
 endif
 
 BL31_SOURCES		+=	common/fdt_wrappers.c                           \
diff --git a/plat/amd/versal2/sip_svc_setup.c b/plat/amd/versal2/sip_svc_setup.c
index 9e81af0..6d3c49b 100644
--- a/plat/amd/versal2/sip_svc_setup.c
+++ b/plat/amd/versal2/sip_svc_setup.c
@@ -94,6 +94,7 @@
 	case SIP_SVC_VERSION:
 		SMC_RET2(handle, SIP_SVC_VERSION_MAJOR, SIP_SVC_VERSION_MINOR);
 
+#if (TFA_NO_PM == 1)
 	case SIP_SCMI:
 		if (platform_id != EMU) {
 			scmi_smt_fastcall_smc_entry(0);
@@ -101,6 +102,7 @@
 		}
 		WARN("SCMI is not working on EMU\n");
 		SMC_RET1(handle, SMC_UNK);
+#endif
 	default:
 		WARN("Unimplemented SiP Service Call: 0x%x\n", smc_fid);
 		SMC_RET1(handle, SMC_UNK);