blob: 9cdb28e1a7e25219609b21cd9d6109673ea750dd [file] [log] [blame]
Madhav Bhattceec9a52025-08-28 22:08:46 -07001/*
2 * Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include "eemi_api.h"
8#include "xpm_defs.h"
9#include "xpm_nodeid.h"
10
11#define PM_SUBSYS_RPU0_0 0x1C000005
12#define TARGET_SUBSYSTEM PM_SUBSYS_RPU0_0
13#define TARGET_DEVICEID PM_DEV_RPU0_0
14#define WAKEUP_ADDR 0xFFE00000U
15
16/*
17 * This function is used to force power down the subsystem if the
18 * subsystem is unresponsive and by calling this API all the resources of
19 * that subsystem will be automatically released.
20 *
21 * This function is used to force power down the subsystem if the
22 * subsystem is unresponsive. By calling this API, all the resources of
23 * that subsystem will be automatically released.
24 *
25 * Force power down support for individual processors and power domains has been
26 * deprecated. As a result, the only available option now is to force power down
27 * the entire subsystem.
28 *
29 * To support this, another subsystem (RPU) needs to be present. For example,
30 * the RPU subsystem can be added with only a NOP CDO (which contains only a
31 * single "nop" instruction). This allows the force power down feature to be
32 * tested without requiring an actual executable partition for the RPU.
33 */
34test_result_t test_force_powerdown(void)
35{
36 int32_t status;
37
38 status = xpm_force_powerdown(TARGET_SUBSYSTEM, 1);
39 if (status != PM_RET_SUCCESS) {
40 tftf_testcase_printf("%s ERROR force powering down system: 0x%x, "
41 "Status: 0x%x\n", __func__, TARGET_SUBSYSTEM, status);
42 return TEST_RESULT_FAIL;
43 }
44
45 tftf_testcase_printf("Waiting for 10 seconds before waking up the target\n\r");
46 waitms(10000);
47
48 return TEST_RESULT_SUCCESS;
49}
50
51/*
52 * This function can be used to request power up of a CPU node
53 * within the same PU, or to power up another PU.
54 */
55test_result_t test_request_wake_up(void)
56{
57 int32_t status;
58
59 status = xpm_request_wakeup(TARGET_SUBSYSTEM, 1, WAKEUP_ADDR, 0);
60 if (status != PM_RET_SUCCESS) {
61 tftf_testcase_printf("%s ERROR requesting wake-up for %x, "
62 "Status: 0x%x\n", __func__, TARGET_SUBSYSTEM, status);
63 return TEST_RESULT_FAIL;
64 }
65
66 return TEST_RESULT_SUCCESS;
67}