feat(versal): add platform specific testcase
Add common platform test to read the PM-API version and Chip ID.
Specify TESTS=versal in make command. This will append the versal specific
tests to standard tests
--
Running test suite 'AMD-Xilinx tests'
Description: AMD-Xilinx common platform tests
> Executing 'Read PM API Version'
TEST COMPLETE Passed
test_pmapi_version PM-API Version : 1.0
> Executing 'Get Platform Chip ID'
TEST COMPLETE Passed
test_get_chipid Idcode = 0x14ca8093 Version = 0x302020
--
Signed-off-by: Akshay Belsare <Akshay.Belsare@amd.com>
Change-Id: I33fbdd42427fd0913001b83990e98b8ecbcc2282
diff --git a/tftf/tests/plat/xilinx/common/plat_pm.c b/tftf/tests/plat/xilinx/common/plat_pm.c
new file mode 100644
index 0000000..7f43824
--- /dev/null
+++ b/tftf/tests/plat/xilinx/common/plat_pm.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2023, Advanced Micro Devices, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <arch_helpers.h>
+#include <debug.h>
+#include <smccc.h>
+#include <tftf_lib.h>
+
+#include <platform_def.h>
+
+/* Number of 32bits values in payload */
+#define PAYLOAD_ARG_CNT 4U
+
+#define upper_32_bits(n) ((uint32_t)(((n) >> 32)))
+#define lower_32_bits(n) ((uint32_t)((n) & 0xffffffff))
+
+
+#define PM_GET_API_VERSION 0xC2000001
+#define PM_GET_CHIPID 0xC2000018
+
+
+/*
+ * @Test_Aim@ Test to read the PM-API version from AMD-Xilinx platform
+ * This test run on lead CPU and issues PM_GET_API_VERSION SMC call to read the
+ * supported PM-API version on the platform.
+ * Return vslues are packed as
+ * ret.ret0(31:0) : actual return value
+ * ret.ret0(63:32) : Return arg1
+ * ret.ret1(31:0) : Return arg2
+ * ret.ret1(63:32) : Return arg3 and so on.
+ */
+test_result_t test_pmapi_version(void)
+{
+ smc_args args = { PM_GET_API_VERSION };
+ smc_ret_values ret;
+ uint32_t major, minor, status;
+
+ ret = tftf_smc(&args);
+ status = lower_32_bits(ret.ret0);
+ if (status) {
+ tftf_testcase_printf("%s ERROR Reading PM-API Version\n",
+ __func__);
+ return TEST_RESULT_FAIL;
+ }
+
+ major = upper_32_bits(ret.ret0) >> 16;
+ minor = upper_32_bits(ret.ret0) & 0xFFFF;
+
+ tftf_testcase_printf("%s PM-API Version : %d.%d\n", __func__,
+ major, minor);
+ return TEST_RESULT_SUCCESS;
+}
+
+/*
+ * @Test_Aim@ Test to read the Chip ID of AMD-Xilinx platforms.
+ * This test runs on Lead CPU and issues PM_GET_CHIPID SMC call to read ChipID
+ * The IDcode and version is printed
+ * Return vslues are packed as
+ * ret.ret0(31:0) : actual return value
+ * ret.ret0(63:32) : Return arg1
+ * ret.ret1(31:0) : Return arg2
+ * ret.ret1(63:32) : Return arg3 and so on.
+ */
+test_result_t test_get_chipid(void)
+{
+ smc_args args = { PM_GET_CHIPID };
+ smc_ret_values ret;
+ uint32_t idcode, version, status;
+
+ ret = tftf_smc(&args);
+ status = lower_32_bits(ret.ret0);
+ if (status) {
+ tftf_testcase_printf("%s ERROR Reading Chip ID\n", __func__);
+ return TEST_RESULT_FAIL;
+ }
+
+ idcode = upper_32_bits(ret.ret0);
+ version = lower_32_bits(ret.ret1);
+
+ tftf_testcase_printf("%s Idcode = 0x%x Version = 0x%x\n", __func__,
+ idcode, version);
+
+ return TEST_RESULT_SUCCESS;
+}
diff --git a/tftf/tests/tests-versal.mk b/tftf/tests/tests-versal.mk
new file mode 100644
index 0000000..6717ee5
--- /dev/null
+++ b/tftf/tests/tests-versal.mk
@@ -0,0 +1,12 @@
+#
+# Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+TESTS_SOURCES += $(addprefix tftf/tests/plat/xilinx/common/, \
+ plat_pm.c \
+)
+
+
+include tftf/tests/tests-standard.mk
+TESTS_SOURCES += $(sort ${TESTS_SOURCES})
diff --git a/tftf/tests/tests-versal.xml b/tftf/tests/tests-versal.xml
new file mode 100644
index 0000000..6c8f519
--- /dev/null
+++ b/tftf/tests/tests-versal.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-3-Clause
+-->
+
+<document>
+ <!-- External reference to standard tests files. -->
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tests-standard.xml" />
+ <testsuites>
+
+ <testsuite name="AMD-Xilinx tests" description="AMD-Xilinx common platform tests" >
+ <testcase name="Read PM API Version" function="test_pmapi_version" />
+ <testcase name="Get Platform Chip ID" function="test_get_chipid" />
+ </testsuite>
+
+ </testsuites>
+</document>