feat(amd): add test for query data EEMI API
Add a test for the query_data EEMI API within the TF-A test framework.
The test validates the functionality of the API for querying platform
resource information.
Note: This initial test focuses on validating the API interface and
does not cover all query IDs
Change-Id: I8488d08c3682613fcfc796acee6e76e384bbc39e
Signed-off-by: Madhav Bhatt <madhav.bhatt@amd.com>
diff --git a/tftf/tests/plat/amd/common/common_files/eemi_api.c b/tftf/tests/plat/amd/common/common_files/eemi_api.c
index 87a63f5..838b560 100644
--- a/tftf/tests/plat/amd/common/common_files/eemi_api.c
+++ b/tftf/tests/plat/amd/common/common_files/eemi_api.c
@@ -513,3 +513,15 @@
return eemi_call(PM_SET_WAKEUP_SOURCE, ((uint64_t)source_node_id << 32 | target_node_id),
enable, 0, 0, 0, 0, 0, ret_payload);
}
+
+int xpm_query_data(const uint32_t qid, const uint32_t arg1, const uint32_t arg2,
+ const uint32_t arg3, uint32_t *output)
+{
+ uint32_t ret_payload[PAYLOAD_ARG_CNT];
+ int32_t ret;
+
+ ret = eemi_call(PM_QUERY_DATA, qid, arg1, arg2, arg3, 0, 0, 0, ret_payload);
+ *output = ret_payload[1];
+
+ return ret;
+}
diff --git a/tftf/tests/plat/amd/common/common_files/eemi_api.h b/tftf/tests/plat/amd/common/common_files/eemi_api.h
index 61c31f2..650d326 100644
--- a/tftf/tests/plat/amd/common/common_files/eemi_api.h
+++ b/tftf/tests/plat/amd/common/common_files/eemi_api.h
@@ -47,6 +47,13 @@
uint32_t clock_id; /**< Clock ID */
};
+struct test_query {
+ uint32_t query_id; /**< Query ID */
+ uint32_t query_arg1; /**< Arg1 for Query-ID if required */
+ uint32_t query_arg2; /**< Arg2 for Query-ID if required */
+ uint32_t query_arg3; /**< Arg3 for Query-ID if required */
+};
+
int xpm_get_api_version(uint32_t *version);
int xpm_get_chip_id(uint32_t *id_code, uint32_t *version);
int xpm_feature_check(const uint32_t api_id, uint32_t *const version);
@@ -93,5 +100,7 @@
const uint8_t state, uint32_t address);
int xpm_set_wakeup_source(const uint32_t target_node_id, const uint32_t source_node_id,
const uint32_t enable);
+int xpm_query_data(const uint32_t qid, const uint32_t arg1, const uint32_t arg2,
+ const uint32_t arg3, uint32_t *output);
#endif /* __EEMI_API_H__ */
diff --git a/tftf/tests/plat/amd/common/common_files/xpm_defs.h b/tftf/tests/plat/amd/common/common_files/xpm_defs.h
index 2e12d58..ee9d725 100644
--- a/tftf/tests/plat/amd/common/common_files/xpm_defs.h
+++ b/tftf/tests/plat/amd/common/common_files/xpm_defs.h
@@ -298,4 +298,26 @@
PM_PLL_MODE_RESET = (2U), /**< PLL mode reset */
};
+/**
+ * Query IDs
+ */
+enum pm_query_id {
+ XPM_QID_INVALID, /**< Invalid Query ID */
+ XPM_QID_CLOCK_GET_NAME, /**< Get clock name */
+ XPM_QID_CLOCK_GET_TOPOLOGY, /**< Get clock topology */
+ XPM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS, /**< Get clock fixedfactor parameter */
+ XPM_QID_CLOCK_GET_MUXSOURCES, /**< Get clock mux sources */
+ XPM_QID_CLOCK_GET_ATTRIBUTES, /**< Get clock attributes */
+ XPM_QID_PINCTRL_GET_NUM_PINS, /**< Get total pins */
+ XPM_QID_PINCTRL_GET_NUM_FUNCTIONS, /**< Get total pin functions */
+ XPM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS, /**< Get total pin function groups */
+ XPM_QID_PINCTRL_GET_FUNCTION_NAME, /**< Get pin function name */
+ XPM_QID_PINCTRL_GET_FUNCTION_GROUPS, /**< Get pin function groups */
+ XPM_QID_PINCTRL_GET_PIN_GROUPS, /**< Get pin groups */
+ XPM_QID_CLOCK_GET_NUM_CLOCKS, /**< Get number of clocks */
+ XPM_QID_CLOCK_GET_MAX_DIVISOR, /**< Get max clock divisor */
+ XPM_QID_PLD_GET_PARENT, /**< Get PLD parent */
+ XPM_QID_PINCTRL_GET_ATTRIBUTES, /**< Get pin attributes */
+};
+
#endif /* XPM_DEFS_H_ */
diff --git a/tftf/tests/plat/amd/common/common_files/xpm_nodeid.h b/tftf/tests/plat/amd/common/common_files/xpm_nodeid.h
index 80259f9..3a1d619 100644
--- a/tftf/tests/plat/amd/common/common_files/xpm_nodeid.h
+++ b/tftf/tests/plat/amd/common/common_files/xpm_nodeid.h
@@ -12,16 +12,23 @@
*/
#define PM_DEV_ACPU_0 0x1810C003U
#define PM_DEV_RPU0_0 0x18110005U
+#define PM_DEV_RPU0_0 0x18110005U
#define PM_DEV_USB_0 0x18224018U
#define PM_DEV_TTC_0 0x18224024U
#define PM_DEV_GEM_0 0x18224019U
#define PM_DEV_QSPI 0x1822402BU
#define PM_DEV_RTC 0x18224034U
#define PM_DEV_SOC 0x18428044U
+#define PM_DEV_PLD_0 0x18700000U
+
/*
* Clock Nodes
*/
+#define PM_CLK_PMC_PLL 0x8104001U
+#define PM_CLK_APU_PLL 0x8104002U
#define PM_CLK_RPU_PLL 0x8104003U
+#define PM_CLK_PMC_PRESRC 0x8208007U
+#define PM_CLK_PMC_PLL_OUT 0x8208009U
#define PM_CLK_QSPI_REF 0x8208039U
#define PM_CLK_GEM0_REF 0x8208058U
@@ -29,6 +36,7 @@
* MIO Nodes
*/
#define PM_STMIC_LMIO_0 0x14104001U
+#define PM_STMIC_LMIO_3 0x14104003U
/*
* Reset Nodes
diff --git a/tftf/tests/plat/amd/common/query_data/query_data.c b/tftf/tests/plat/amd/common/query_data/query_data.c
new file mode 100644
index 0000000..b785d2a
--- /dev/null
+++ b/tftf/tests/plat/amd/common/query_data/query_data.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "eemi_api.h"
+#include "xpm_defs.h"
+#include "xpm_nodeid.h"
+
+struct test_query test_query_list[] = {
+ {
+ .query_id = XPM_QID_CLOCK_GET_NUM_CLOCKS,
+ },
+ {
+ .query_id = XPM_QID_PINCTRL_GET_NUM_PINS,
+ },
+ {
+ .query_id = XPM_QID_PINCTRL_GET_NUM_FUNCTIONS,
+ },
+ {
+ .query_id = XPM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS,
+ .query_arg1 = PIN_FUNC_I2C0,
+ },
+};
+
+/**
+ * This function queries information about the platform resources.
+ */
+int test_query_data(void)
+{
+ int32_t status;
+ uint32_t i;
+
+ for (i = 0; i < ARRAY_SIZE(test_query_list); i++) {
+ uint32_t query_data[4] = {0};
+
+ status = xpm_query_data(test_query_list[i].query_id,
+ test_query_list[i].query_arg1,
+ test_query_list[i].query_arg2,
+ test_query_list[i].query_arg3,
+ query_data);
+
+ if (status != PM_RET_SUCCESS) {
+ tftf_testcase_printf("ERROR: Failed XPm_Query for qid 0x%x, Status: 0x%x\n",
+ test_query_list[i].query_id, status);
+ return TEST_RESULT_FAIL;
+ }
+
+ tftf_testcase_printf("Query Id = %x Output = %x\n\r",
+ test_query_list[i].query_id, query_data[0]);
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
diff --git a/tftf/tests/tests-versal.xml b/tftf/tests/tests-versal.xml
index 4fd12e7..e8e4712 100644
--- a/tftf/tests/tests-versal.xml
+++ b/tftf/tests/tests-versal.xml
@@ -41,6 +41,7 @@
<testcase name="Get PLL parameter " function="test_pll_get_parameter" />
<testcase name="Set Wake Up Source" function="test_set_wakeup_source" />
<testcase name="Self Suspend" function="test_self_suspend" />
+ <testcase name="Query Data" function="test_query_data" />
</testsuite>
</testsuites>