xilinx: versal: Add query data API

Add PM_QUERY_DATA API to pass query data
EEMI call from Linux to PLM .

Signed-off-by: Tejas Patel <tejas.patel@xilinx.com>
Signed-off-by: Jolly Shah <jolly.shah@xilinx.com>
Change-Id: I18735b72ab9cb62fb6cbc7582e77de6cb57f99b0
diff --git a/plat/xilinx/versal/pm_service/pm_api_sys.c b/plat/xilinx/versal/pm_service/pm_api_sys.c
index 3e7e8d1..125134d 100644
--- a/plat/xilinx/versal/pm_service/pm_api_sys.c
+++ b/plat/xilinx/versal/pm_service/pm_api_sys.c
@@ -642,6 +642,26 @@
 }
 
 /**
+* pm_query_data() -  PM API for querying firmware data
+* @qid	The type of data to query
+* @arg1	Argument 1 to requested query data call
+* @arg2	Argument 2 to requested query data call
+* @arg3	Argument 3 to requested query data call
+* @data	Returned output data
+*
+* This function returns requested data.
+*/
+enum pm_ret_status pm_query_data(uint32_t qid, uint32_t arg1, uint32_t arg2,
+				 uint32_t arg3, uint32_t *data)
+{
+	uint32_t payload[PAYLOAD_ARG_CNT];
+
+	/* Send request to the PMC */
+	PM_PACK_PAYLOAD5(payload, LIBPM_MODULE_ID, PM_QUERY_DATA, qid, arg1,
+			 arg2, arg3);
+	return pm_ipi_send_sync(primary_proc, payload, data, 4);
+}
+/**
  * pm_api_ioctl() -  PM IOCTL API for device control and configs
  * @device_id	Device ID
  * @ioctl_id	ID of the requested IOCTL
diff --git a/plat/xilinx/versal/pm_service/pm_api_sys.h b/plat/xilinx/versal/pm_service/pm_api_sys.h
index 91d3368..ff35882 100644
--- a/plat/xilinx/versal/pm_service/pm_api_sys.h
+++ b/plat/xilinx/versal/pm_service/pm_api_sys.h
@@ -59,5 +59,6 @@
 enum pm_ret_status pm_system_shutdown(uint32_t type, uint32_t subtype);
 enum pm_ret_status pm_api_ioctl(uint32_t device_id, uint32_t ioctl_id,
 				uint32_t arg1, uint32_t arg2, uint32_t *value);
-
+enum pm_ret_status pm_query_data(uint32_t qid, uint32_t arg1, uint32_t arg2,
+				 uint32_t arg3, uint32_t *data);
 #endif /* PM_API_SYS_H */
diff --git a/plat/xilinx/versal/pm_service/pm_defs.h b/plat/xilinx/versal/pm_service/pm_defs.h
index cfb1ca6..bd74304 100644
--- a/plat/xilinx/versal/pm_service/pm_defs.h
+++ b/plat/xilinx/versal/pm_service/pm_defs.h
@@ -44,6 +44,7 @@
 #define	PM_PINCTRL_CONFIG_PARAM_GET	32U
 #define	PM_PINCTRL_CONFIG_PARAM_SET	33U
 #define PM_IOCTL			34U
+#define PM_QUERY_DATA			35U
 #define PM_CLOCK_ENABLE			36U
 #define PM_CLOCK_DISABLE		37U
 #define PM_CLOCK_GETSTATE		38U
diff --git a/plat/xilinx/versal/pm_service/pm_svc_main.c b/plat/xilinx/versal/pm_service/pm_svc_main.c
index bd3ebf3..7f8e42f 100644
--- a/plat/xilinx/versal/pm_service/pm_svc_main.c
+++ b/plat/xilinx/versal/pm_service/pm_svc_main.c
@@ -200,6 +200,16 @@
 		SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
 	}
 
+	case PM_QUERY_DATA:
+	{
+		uint32_t data[4] = { 0 };
+
+		ret = pm_query_data(pm_arg[0], pm_arg[1], pm_arg[2],
+			      pm_arg[3], data);
+		SMC_RET2(handle, (uint64_t)ret  | ((uint64_t)data[0] << 32),
+			 (uint64_t)data[1] | ((uint64_t)data[2] << 32));
+	}
+
 	case PM_CLOCK_ENABLE:
 		ret = pm_clock_enable(pm_arg[0]);
 		SMC_RET1(handle, (uint64_t)ret);