Merge "fix(versal-net): enable PSCI reset2 interface" into integration
diff --git a/plat/xilinx/versal_net/plat_psci_pm.c b/plat/xilinx/versal_net/plat_psci_pm.c
index eb926ee..6ec8649 100644
--- a/plat/xilinx/versal_net/plat_psci_pm.c
+++ b/plat/xilinx/versal_net/plat_psci_pm.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2022, Xilinx, Inc. All rights reserved.
- * Copyright (c) 2022-2024, Advanced Micro Devices, Inc. All rights reserved.
+ * Copyright (c) 2022-2025, Advanced Micro Devices, Inc. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -116,12 +116,14 @@
 }
 
 /**
- * versal_net_system_reset() - This function sends the reset request to firmware
- *                             for the system to reset. This function does not
- *                             return.
+ * versal_net_system_reset_scope() - Sends the reset request to firmware for
+ * the system to reset.
+ * @scope : scope of reset which could be SYSTEM/SUBSYSTEM/PS-ONLY
  *
+ * Return:
+ *     Does not return if system resets, none if there is a failure.
  */
-static void __dead2 versal_net_system_reset(void)
+static void __dead2 versal_net_system_reset_scope(uint32_t scope)
 {
 	uint32_t ret, timeout = 10000U;
 
@@ -133,7 +135,7 @@
 	 */
 	if (!pwrdwn_req_received) {
 		(void)pm_system_shutdown(XPM_SHUTDOWN_TYPE_RESET,
-					 pm_get_shutdown_scope(), SECURE_FLAG);
+					 scope, SECURE_FLAG);
 
 		/*
 		 * Wait for system shutdown request completed and idle callback
@@ -155,6 +157,54 @@
 }
 
 /**
+ * versal_net_system_reset() - This function sends the reset request to firmware
+ * for the system to reset in response to SYSTEM_RESET call
+ *
+ * Return:
+ *     Does not return if system resets, none if there is a failure.
+ */
+static void __dead2 versal_net_system_reset(void)
+{
+	/*
+	 * Any platform-specific actions for handling a cold reset
+	 * should be performed here before invoking
+	 * versal_net_system_reset_scope.
+	 */
+	versal_net_system_reset_scope(XPM_SHUTDOWN_SUBTYPE_RST_SUBSYSTEM);
+}
+
+/**
+ * versal_net_system_reset2() - Handles warm / vendor-specific system reset
+ * in response to SYSTEM_RESET2 call.
+ * @is_vendor: Flag indicating if this is a vendor-specific reset
+ * @reset_type: Type of reset requested
+ * @cookie: Additional reset data
+ *
+ * This function initiates a controlled system reset by requesting it
+ * through the PM firmware.
+ *
+ * Return:
+ *	Does not return if system resets, PSCI_E_INTERN_FAIL
+ *	if there is a failure.
+ */
+static int versal_net_system_reset2(int is_vendor, int reset_type, u_register_t cookie)
+{
+	if (is_vendor == 0 && reset_type == PSCI_RESET2_SYSTEM_WARM_RESET) {
+		/*
+		 * Any platform-specific actions for handling a warm reset
+		 * should be performed here before invoking
+		 * versal_net_system_reset_scope.
+		 */
+		versal_net_system_reset_scope(XPM_SHUTDOWN_SUBTYPE_RST_SUBSYSTEM);
+	} else {
+		/* Vendor specific reset */
+		versal_net_system_reset_scope(pm_get_shutdown_scope());
+	}
+
+	return PSCI_E_INTERN_FAIL;
+}
+
+/**
  * versal_net_pwr_domain_suspend() - This function sends request to PMC to suspend
  *                                   core.
  * @target_state: Targeted state.
@@ -315,6 +365,7 @@
 	.pwr_domain_suspend_finish      = versal_net_pwr_domain_suspend_finish,
 	.system_off                     = versal_net_system_off,
 	.system_reset                   = versal_net_system_reset,
+	.system_reset2                  = versal_net_system_reset2,
 	.validate_ns_entrypoint		= versal_net_validate_ns_entrypoint,
 	.validate_power_state           = versal_net_validate_power_state,
 	.get_sys_suspend_power_state    = versal_net_get_sys_suspend_power_state,