ci: test with pabandon

Gelas and Travis support powerdown abandon which is not modelled by the
FVP. TC includes these cores and on a real system should be able to deal
with pabandon. So add a fake pabandon to the main TC4 config so we can
test it.

Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
Change-Id: I4b9b306f49b3b1c90593b424057816e9ea9cc0d0
diff --git a/group/tf-l2-boot-tests-misc/fvp-tc4-tbb-dpe:fvp-linux.tc-fip.tc-tc4-debug b/group/tf-l2-boot-tests-misc/fvp-tc4-tbb-dpe:fvp-linux.tc-fip.tc-tc4-pabandon-debug
similarity index 100%
rename from group/tf-l2-boot-tests-misc/fvp-tc4-tbb-dpe:fvp-linux.tc-fip.tc-tc4-debug
rename to group/tf-l2-boot-tests-misc/fvp-tc4-tbb-dpe:fvp-linux.tc-fip.tc-tc4-pabandon-debug
diff --git a/patch/pabandon/pabandon_on_half_powerdowns.patch b/patch/pabandon/pabandon_on_half_powerdowns.patch
new file mode 100644
index 0000000..e0ced79
--- /dev/null
+++ b/patch/pabandon/pabandon_on_half_powerdowns.patch
@@ -0,0 +1,40 @@
+diff --git a/lib/psci/psci_common.c b/lib/psci/psci_common.c
+index 25e30d489..8ff7fee51 100644
+--- a/lib/psci/psci_common.c
++++ b/lib/psci/psci_common.c
+@@ -1284,6 +1284,10 @@ void __dead2 psci_pwrdown_cpu_end_terminal(void)
+ 	panic();
+ }
+ 
++#include <travis.h>
++#include <cortex_gelas.h>
++static bool should_abandon[PLATFORM_CORE_COUNT];
++
+ /*******************************************************************************
+  * Finish a non-terminal power down sequence, ending with a wfi. In case of
+  * wakeup will unwind any CPU specific actions and return.
+@@ -1294,11 +1298,23 @@ void psci_pwrdown_cpu_end_wakeup(unsigned int power_level)
+ 	/* ensure write buffer empty */
+ 	dsbsy();
+ 
++	long pos = plat_my_core_pos();
++	bool abandon = should_abandon[pos];
++	/* abandon every other time */
++	should_abandon[pos] = !should_abandon[pos];
++	long midr = EXTRACT_PARTNUM(read_midr());
++
+ 	/*
+ 	 * Turn the core off. Usually, will be terminal. In some circumstances
+ 	 * the powerdown will be denied and we'll need to unwind.
+ 	 */
+-	wfi();
++	/* only abandon for cores that support it */
++	if (!(abandon &&
++	     (midr == EXTRACT_PARTNUM(CORTEX_GELAS_MIDR)
++	      || midr == EXTRACT_PARTNUM(TRAVIS_MIDR))))
++	{
++		wfi();
++	}
+ 
+ 	/*
+ 	 * Waking up does not require hardware-assisted coherency, but that is
diff --git a/run_config/fvp-pabandon b/run_config/fvp-pabandon
new file mode 100644
index 0000000..34d6ca5
--- /dev/null
+++ b/run_config/fvp-pabandon
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2025, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+pre_tf_build() {
+	# skips the `wfi` in the powerdown sequence half the time. This has the
+	# same effect as an aborted powerdown (by an eg. GIC wake request) half
+	# the time.
+	apply_tf_patch "pabandon/pabandon_on_half_powerdowns.patch"
+}