Software APIs
pwrmgr_normal_sleep_all_wake_ups.c
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #include "sw/device/lib/runtime/irq.h"
7 #include "sw/device/lib/testing/pwrmgr_testutils.h"
8 #include "sw/device/lib/testing/test_framework/check.h"
10 #include "sw/device/tests/pwrmgr_sleep_all_wake_ups_impl.h"
11 
12 /*
13  PWRMGR NORMAL SLEEP ALL WAKE UPS test
14 
15  This test runs power manager wake up from deep sleep mode by
16  wake up inputs.
17  */
18 
19 OTTF_DEFINE_TEST_CONFIG();
20 
21 bool test_main(void) {
22  // Enable global and external IRQ at Ibex.
23  irq_global_ctrl(true);
24  irq_external_ctrl(true);
25 
26  init_units();
27 
28  if (UNWRAP(pwrmgr_testutils_is_wakeup_reason(&pwrmgr, 0))) {
29  LOG_INFO("POR reset");
30 
31  for (size_t wakeup_unit = 0; wakeup_unit < get_wakeup_count();
32  ++wakeup_unit) {
33  if (!execute_test(wakeup_unit, /*deep_sleep=*/false)) {
34  continue;
35  }
36  check_wakeup_reason(wakeup_unit);
37  LOG_INFO("Woke up by source %d", wakeup_unit);
38  clear_wakeup(wakeup_unit);
39  LOG_INFO("clean up done source %d", wakeup_unit);
40  }
41  return true;
42  } else {
43  LOG_ERROR("Unexpected wake up reason");
44  return false;
45  }
46 }