Software APIs
pwrmgr_testutils.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/testing/pwrmgr_testutils.h"
6 
7 #include <stdbool.h>
8 #include <stdint.h>
9 
12 #include "sw/device/lib/testing/test_framework/check.h"
13 
14 status_t pwrmgr_testutils_enable_low_power(
15  const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_request_sources_t wakeups,
16  dif_pwrmgr_domain_config_t domain_config) {
17  // Enable low power on the next WFI with clocks and power domains configured
18  // per domain_config.
21  TRY(dif_pwrmgr_set_domain_config(pwrmgr, domain_config, kDifToggleDisabled));
24  return OK_STATUS();
25 }
26 
27 status_t pwrmgr_testutils_is_wakeup_reason(
28  const dif_pwrmgr_t *pwrmgr, dif_pwrmgr_request_sources_t reasons) {
29  dif_pwrmgr_wakeup_reason_t wakeup_reason;
30  TRY(dif_pwrmgr_wakeup_reason_get(pwrmgr, &wakeup_reason));
31 
32  return OK_STATUS((wakeup_reason.request_sources == 0 ||
33  wakeup_reason.types == kDifPwrmgrWakeupTypeRequest) &&
34  wakeup_reason.request_sources == reasons);
35 }