Software APIs
pwrmgr_sleep_all_wake_ups_impl.h
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 #ifndef OPENTITAN_SW_DEVICE_TESTS_PWRMGR_SLEEP_ALL_WAKE_UPS_IMPL_H_
6 #define OPENTITAN_SW_DEVICE_TESTS_PWRMGR_SLEEP_ALL_WAKE_UPS_IMPL_H_
7 
8 // Contains header for code that is common to deep, normal, and random sleep for
9 // pwrmgr all_wake_ups test.
10 
12 #include "sw/device/lib/testing/test_framework/check.h"
14 
15 /**
16  * The retention sram counter used in this test.
17  */
18 enum { kCounterCases };
19 
20 typedef struct test_wakeup_sources {
21  /**
22  * Name of the device.
23  */
24  const char *name;
25  /*
26  * Type of the module.
27  */
28  dt_device_type_t dev_type;
29  /*
30  * Index of the wakeup signal.
31  */
32  size_t wakeup;
33  /**
34  * Check whether this wake up should be skipped in this configuration.
35  * If set to NULL, assume that it should not be skipped.
36  */
37  bool (*skip)(dt_pwrmgr_wakeup_src_t src);
38  /**
39  * Configuration and initialization actions for the device.
40  */
41  void (*config)(dt_pwrmgr_wakeup_src_t src);
42  /**
43  * Check the wakeup reason.
44  */
45  void (*check)(dt_pwrmgr_wakeup_src_t src);
46  /**
47  * Clear the wakeup reason.
48  */
49  void (*clear)(dt_pwrmgr_wakeup_src_t src);
51 
52 extern dif_pwrmgr_t pwrmgr;
53 
54 /**
55  * Initialize the units used in this test.
56  */
57 void init_units(void);
58 
59 /**
60  * Return the number of units to test.
61  */
62 size_t get_wakeup_count(void);
63 
64 /**
65  * Obtain information about a wakeup source.
66  */
67 const test_wakeup_sources_t *get_wakeup_source(size_t wakeup_unit,
68  dt_pwrmgr_wakeup_src_t *src);
69 
70 /**
71  * Check pwrmgr reports this unit as the reason for the wakeup.
72  */
73 void check_wakeup_reason(size_t wakeup_unit);
74 
75 /**
76  * Execute the test for a given unit and sleep mode.
77  *
78  * Configure wakeup_unit to cause a wakeup up and the pwrmgr sleep mode,
79  * and let the CPU wait for interrupt. Returns false if this wakeup unit
80  * must be skipped.
81  */
83 bool execute_test(size_t wakeup_unit, bool deep_sleep);
84 
85 /**
86  * Clear the wakeup for the given unit.
87  */
88 void clear_wakeup(size_t wakeup_unit);
89 
90 #endif // OPENTITAN_SW_DEVICE_TESTS_PWRMGR_SLEEP_ALL_WAKE_UPS_IMPL_H_