1 /*
2  * Copyright 2021-2024 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 #ifndef _FSL_PM_CORE_H_
8 #define _FSL_PM_CORE_H_
9 
10 #include "fsl_common.h"
11 #include "fsl_component_generic_list.h"
12 
13 #include "fsl_pm_config.h"
14 
15 /*!
16  * @defgroup PM Framework: Power Manager Framework
17  * @details This document consists of sections titled with <b>Framework Overview</b>, <b>Data Structures</b>,
18  *          <b>Enumerations</b>, <b>Functions</b>, etc., each with an overview list and detailed documentation.
19  *          It is recommended to read the <b>Framework Overview</b> first for it includes a comprehensive description
20  *          of the framework. Other sections give detailed information for APIs, enums, macros, etc., for your further
21  *          reference.
22  * @{
23  */
24 
25 /*******************************************************************************
26  * Introducation of power manager framework
27  ******************************************************************************/
28 /*!
29  * Framework Overview
30  * ==================
31  * The power manager framework manages the transition of both active-to-sleep and sleep-to-active states of the MCU. It
32  * provides the upper layer software the ability to set and release constraints of the hardware basic
33  * resources(such as clock, power, ram, etc.) and the ability to register callback
34  * functions to be invoked before entering/after exiting the sleep mode. In addition, the upper layer software
35  * can register the wakeup source service function to be executed if related wakeup source occurs.
36  *
37  *              +-----------------------------------------------------------------+
38  *              |                       Application Software                      |
39  *              +-----------------------------------------------------------------+
40  *              +-----------------------------------------------------------------+
41  *              |                       Stacks and Components                     |
42  *              +-----------------------------------------------------------------+
43  *              +-----------------------------------------------------------------+
44  *              |                       Power Manager Framework                   |
45  *              +-----------------------------------------------------------------+
46  *              +---------------+    +---------------+    +-----------------------+
47  *              | Power Drivers |    | Clock Drivers |    | Wakeup Source Drivers |
48  *              +---------------+    +---------------+    +-----------------------+
49  *
50  * As shown above, the power manager framework safely manages the transitions to and from power saving states by using
51  * MCUXpresso SDK drivers, and the upper layer software only need to use the APIs of power manager framework. Different
52  * MCUs have the same top-level APIs, concepts and conventions.
53  *
54  * Definitions and Terms:
55  * ======================
56  *  - \b Constraint\n
57  *      A system-level declaration that asks the power manager to prevent a specific action. For
58  *      example, if the application sets the constraint as that the ARM PLL should not be turned off, then the power
59  * manager framework will compute the deepest power state with the ARM PLL being turned on. Otherwise, a decision might
60  * be made to transit to a sleep state with ARM PLL being turned off.
61  *
62  *  - \b Notification\n
63  *      A callback mechanism that allows the upper layer software to be notified of specific power
64  *      transitions. Some hardware peripherals may need several steps to enter into or exit the low power mode, so
65  * multiple callbacks are necessary to avoid undesired waiting loop. To address this problem, there are 3 groups of
66  * notification set in the power manager framework. The power manager will execute registered notification callback
67  * functions from group0 to group2 before entering into low power mode while from group2 to group0 after exiting from
68  * low power mode.
69  *
70  *  - \b Wakeup \b Source\n
71  *      Structure that contains the wakeup source Id and its service functions. The upper layer software
72  *      can create the wakeup source object by invoking PM_RegisterWakeupSource() function. The parameter \b wsId is
73  *      the MCU wakeup source definition available. If the MCU exits from the low power mode based on the registered
74  *      wakeup source, the function PM_TriggerWakeSourceService() should be invoked to execute wakeup source service
75  *      function.
76  *
77  * Power Manager Framework Architecture:
78  * =====================================
79  *  The power manager framework consists of four modules: policy module, sequencer module, wakeup source
80  *  manager module, and notification module.
81  *  - The policy module can gather all the constraints from the whole system and then compute the deepest allowed power
82  *  state.
83  *  - The sequencer module is in charge of the power mode entry and exit sequences.
84  *  - The wakeup source manager module is in charge of configuring wakeup sources in low power entry and processing
85  *  registered wakeup source handler callback.
86  *  - The notification module is in charge of notifying the upper layer software of speciic power transitions and
87  * events.
88  *
89  *  To make the power manager framework adapts to different MCU families, the power manager framework adopts a
90  * layer-designed idea, extracting common parts as the pm_core level, and separating device-related parts as the
91  * pm_device level. In details, the pm_core level contains policy module, wakeup source manager module, and notification
92  * module. The pm_device level contains sequencer module.
93  */
94 
95 /*******************************************************************************
96  * Definitions
97  ******************************************************************************/
98 
99 #if (defined(FSL_PM_SUPPORT_ALWAYS_ON_SECTION) && FSL_PM_SUPPORT_ALWAYS_ON_SECTION)
100 /*! @name Always On Region */
101 #if (defined(__ICCARM__))
102 #define AT_ALWAYS_ON_DATA(var)      var @"AlwaysOnData"
103 #define AT_ALWAYS_ON_DATA_INIT(var) var @"AlwaysOnData.init"
104 #elif (defined(__CC_ARM) || defined(__ARMCC_VERSION))
105 #define AT_ALWAYS_ON_DATA(var)      __attribute__((section(".bss.AlwaysOnData"))) var
106 #define AT_ALWAYS_ON_DATA_INIT(var) __attribute__((section("AlwaysOnData.init"))) var
107 #elif (defined(__GNUC__))
108 #define AT_ALWAYS_ON_DATA(var)      __attribute__((section(".AlwaysOnData"))) var
109 #define AT_ALWAYS_ON_DATA_INIT(var) __attribute__((section(".AlwaysOnData.init"))) var
110 #else
111 #error Toolchain not supported.
112 #endif /* defined(__ICCARM__) */
113 #else
114 #define AT_ALWAYS_ON_DATA(var)      var
115 #define AT_ALWAYS_ON_DATA_INIT(var) var
116 /*! @} */
117 #endif /* FSL_PM_SUPPORT_ALWAYS_ON_SECTION */
118 
119 /*!
120  * @brief Power manager status.
121  * @anchor _pm_status
122  */
123 enum
124 {
125     kStatus_PMSuccess                  = kStatus_Success,
126     kStatus_PMFail                     = kStatus_Fail,
127     kStatus_PMWakeupSourceEnableError  = MAKE_STATUS(kStatusGroup_POWER_MANAGER, 1U),
128     kStatus_PMWakeupSourceDisableError = MAKE_STATUS(kStatusGroup_POWER_MANAGER, 2U),
129     kStatus_PMWakeupSourceServiceBusy  = MAKE_STATUS(kStatusGroup_POWER_MANAGER, 3U),
130     kStatus_PMPowerStateNotAllowed     = MAKE_STATUS(kStatusGroup_POWER_MANAGER, 4U),
131     kStatus_PMNotifyEventError         = MAKE_STATUS(kStatusGroup_POWER_MANAGER, 5U),
132 };
133 
134 #if (defined(FSL_PM_SUPPORT_NOTIFICATION) && FSL_PM_SUPPORT_NOTIFICATION)
135 /*!
136  * @brief Power manager event type, used in notification module to inform the upper layer software
137  * of the power transition event.
138  */
139 typedef enum _pm_event_type
140 {
141     kPM_EventEnteringSleep = 0U, /*!< Entering a sleep state. */
142     kPM_EventExitingSleep,       /*!< Exiting a sleep state. */
143 } pm_event_type_t;
144 
145 /*!
146  * @brief The enumeration of notification group.
147  */
148 typedef enum _pm_notify_group
149 {
150     kPM_NotifyGroup0 =
151         0U,           /*!< Notify group0, before entering power state the notifiers in group0 are executed firstly. */
152     kPM_NotifyGroup1, /*!< Notify group1. */
153     kPM_NotifyGroup2, /*!< Notify group2, after exiting power state the notifiers in group2 are executed firstly. */
154 } pm_notify_group_t;
155 
156 /*!
157  * @brief Power manager notify callback function used with the PM_RegisterNotify() API.
158  *
159  * @param eventType Identify the type of power event.
160  * @param powerState The power state which will enter into, actually it is the index of states array
161  * in @ref pm_device_option_t structure.
162  * @param data      Pointer to a custom argument.
163  */
164 typedef status_t (*pm_notify_callback_func_t)(pm_event_type_t eventType, uint8_t powerState, void *data);
165 
166 /*!
167  * @brief Power manager notify object structure.
168  */
169 typedef struct _pm_notify_element
170 {
171     list_element_t link;                      /*!< For placing on the notify list. */
172     pm_notify_callback_func_t notifyCallback; /*!< Registered notification callback function.  */
173     void *data;                               /*!< Pointer to a custom argument. */
174 } pm_notify_element_t;
175 
176 #endif /* FSL_PM_SUPPORT_NOTIFICATION */
177 
178 #if (defined(FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER) && FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER)
179 /*!
180  * @brief Wakeup source service function used with PM_RegisterWakeupSource() function.
181  */
182 typedef void (*pm_wake_up_source_service_func_t)(void);
183 
184 /*!
185  * @brief Wakeup source object structure.
186  *
187  * In PM_RegisterWakeupSource(), the wakeup source object in this structure type is allocated from the heap.
188  * In PM_UnregisterWakeupSource(), the wakeup source object in this structure type is destoried from the heap.
189  */
190 typedef struct _pm_wakeup_source
191 {
192     list_element_t link; /*!< For placing on the wake up source list. */
193     uint32_t wsId; /*!< The wakeup source id that the MCU supports, this value is used to config wakeup source manager
194                       hardware peripheral. NXP will provided wakeup source id for each specific MCU. */
195     pm_wake_up_source_service_func_t service; /*! Wakeup source service function that should be executed if the
196                                     corresponding wakeup event occurred. */
197     bool enabled : 1U;                        /*!< Enable/disable wakeup source. */
198     bool active : 1U;                         /*!< Indicate whether the corresponding wakeup event occurs. */
199 } pm_wakeup_source_t;
200 #endif                                        /* FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER */
201 
202 /*!
203  * @brief The definition of Power manager resource constraint group, the group contains the operation mode of each
204  * constraint.
205  */
206 typedef struct _pm_resc_group
207 {
208     uint32_t groupSlice[PM_RESC_GROUP_ARRAY_SIZE]; /*!< The resource constraint group. */
209 } pm_resc_group_t;
210 
211 /*!
212  * @brief The definition of power manager resource constraint mask.
213  */
214 typedef struct _pm_resc_mask
215 {
216     uint32_t rescMask[PM_RESC_MASK_ARRAY_SIZE]; /*!< The resource constraint mask. */
217 } pm_resc_mask_t;
218 
219 /*!
220  * @brief The counter of resource's power mode.
221  * @note The counter is consist of 3 sub-counter.
222  */
223 typedef union _pm_resc_opMode_counter
224 {
225     uint8_t u8Count;
226     struct _subCounter
227     {
228         uint8_t partOn1Counter : PM_PARTABLE_ON1_COUNTER_SIZE;
229         uint8_t partOn2Counter : PM_PARTABLE_ON2_COUNTER_SIZE;
230         uint8_t fullOnCounter : PM_FULL_ON_COUNTER_SIZE;
231     } subConter;
232 } pm_resc_opMode_counter_t;
233 
234 /*!
235  * @brief The abstraction of MCU power state.
236  */
237 typedef struct _pm_state
238 {
239     uint32_t exitLatency;              /*!< The latency that the power state need to exit, in us */
240     pm_resc_mask_t fixConstraintsMask; /*!< Some constraints that must be satisfied in the power state. */
241     pm_resc_mask_t varConstraintsMask; /*!< Some optional and configurable constraints. */
242 } pm_state_t;
243 
244 /*!
245  * @brief Device power related options., including power states array, power state counts.
246  *
247  */
248 typedef struct _pm_device_option
249 {
250     pm_state_t states[PM_LP_STATE_COUNT]; /*!< The array of device's power state, states array must be ordered in
251                                             decreasing power consumption. */
252     uint8_t stateCount;                   /*!< The counts of device's power state. */
253     void (*prepare)(void);                /*!< prepare for power state transition */
254     void (*enter)(uint8_t powerState,
255                   pm_resc_mask_t *pSoftRescMask,
256                   pm_resc_group_t *pSysRescGroup); /*!< enter power state */
257     void (*clean)(void);                           /*!< clean after power state transition */
258 
259 #if (defined(FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER) && FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER)
260     status_t (*manageWakeupSource)(pm_wakeup_source_t *ws, bool enable); /*!< The function used to enable/disable
261                                                                              wakeup source, this function is
262                                                                              implemented in pm_device level. */
263     bool (*isWakeupSource)(
264         pm_wakeup_source_t *ws); /*!< Used to know if the wake up source triggered the last wake up. */
265 #endif                           /* FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER */
266 } pm_device_option_t;
267 
268 #if (defined(FSL_PM_SUPPORT_LP_TIMER_CONTROLLER) && FSL_PM_SUPPORT_LP_TIMER_CONTROLLER)
269 typedef void (*pm_low_power_timer_start_func_t)(uint64_t timeout);
270 typedef void (*pm_low_power_timer_stop_func_t)(void);
271 typedef uint64_t (*pm_low_power_timer_get_timestamp_func_t)(void);
272 typedef uint64_t (*pm_low_power_timer_get_duration_func_t)(uint64_t entryTimestamp, uint64_t exitTimestamp);
273 #endif /* FSL_PM_SUPPORT_LP_TIMER_CONTROLLER */
274 
275 typedef void (*pm_enter_critical)(void);
276 typedef void (*pm_exit_critical)(void);
277 
278 /*!
279  * @brief Handle structure for power manager.
280  *
281  */
282 typedef struct _pm_handle
283 {
284     bool enable;                      /*!< Enable/disable power manager. */
285     int8_t disableCount;              /*!< Used to support nested call to PM_EnablePowerManager. */
286     pm_device_option_t *deviceOption; /*!< Pointer to device specific power option. */
287     uint8_t targetState;              /*!< The target power state computed by the policy, actually it is the
288                                            index in device states array. */
289 
290     pm_resc_mask_t resConstraintMask; /*!< Current system's resource constraint mask. */
291     pm_resc_mask_t softConstraints;   /*!< Current system's optional resource constraint mask. */
292     pm_resc_opMode_counter_t resConstraintCount[PM_CONSTRAINT_COUNT]; /*!< The count of each resource constraint,
293                                                     if the constraint's count is 0, it means the system has
294                                                     removed that contraint. */
295 
296     pm_resc_group_t sysRescGroup;                        /*!< Current system's resource constraint group. */
297 
298     uint8_t powerModeConstraint;                         /*!< Used to store system allowed lowest power mode. */
299     uint8_t powerModeConstraintCount[PM_LP_STATE_COUNT]; /*!< The count of each power mode constraint. */
300 
301 #if (defined(FSL_PM_SUPPORT_NOTIFICATION) && FSL_PM_SUPPORT_NOTIFICATION)
302     list_label_t notifyList[3U];           /*!< The header of 3 group notification. */
303     pm_notify_group_t curNotifyGroup;      /*!< Store current notification group. */
304     pm_notify_element_t *curNotifyElement; /*!< Store current notification element. */
305 #endif                                     /* FSL_PM_SUPPORT_NOTIFICATION */
306 
307 #if (defined(FSL_PM_SUPPORT_LP_TIMER_CONTROLLER) && FSL_PM_SUPPORT_LP_TIMER_CONTROLLER)
308     pm_low_power_timer_start_func_t timerStart; /*!< If RTOS supports tickless, start low power timer before entering
309                                                      low power mode. */
310     pm_low_power_timer_stop_func_t timerStop; /*!< If RTOS supports tickless, stop low power timer after waking up from
311                                                    low power mode. */
312     pm_low_power_timer_get_timestamp_func_t getTimestamp; /*!< This function is used to get a timestamp before and after
313                                                                low power mode to be able to compute the duration */
314     pm_low_power_timer_get_duration_func_t
315         getTimerDuration;                                 /*!< This function can be used to retrun the actual
316                                                                low power duration based on the entry/exit timestamps */
317     uint64_t entryTimestamp;
318     uint64_t exitTimestamp;
319 #endif /* FSL_PM_SUPPORT_LP_TIMER_CONTROLLER */
320 
321 #if (defined(FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER) && FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER)
322     list_label_t wakeupSourceList;
323 #endif                               /* FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER */
324 
325     pm_enter_critical enterCritical; /* Power manager critical entry function, default set as NULL. */
326     pm_exit_critical exitCritical;   /* Power manager critical exit function, default set as NULL. */
327 } pm_handle_t;
328 
329 #if defined(__cplusplus)
330 extern "C" {
331 #endif
332 
333 /*******************************************************************************
334  * API
335  ******************************************************************************/
336 
337 /*!
338  * @name Power Manager Policy
339  * @{
340  */
341 
342 /*!
343  * @brief Initialize the power manager handle, this function should be invoked before using other power manager
344  * APIs.
345  *
346  * @note In default, the power manager is disabled.
347  *
348  * @param handle Pointer to the @ref pm_handle_t structure, upper layer software should pre-allocate the handle global
349  * variable.
350  */
351 void PM_CreateHandle(pm_handle_t *handle);
352 
353 /*!
354  * @brief Enable/disable power manager functions.
355  *
356  * @param enable Used to enable/disable power manager functions.
357  */
358 void PM_EnablePowerManager(bool enable);
359 
360 /*!
361  * @brief Power manager core API, this API should be used on RTOS's IDLE task.
362  *
363  * This function contains several steps:
364  * 1. Compute target power state based on the policy module.
365  * 2. Notify upper layer software of the power mode entering.
366  * 3. Enter into target power state.
367  * 4. Exit from low power state, if wakeup event occurred.
368  * 5. Notify upper layer software of the power mode exiting.
369  *
370  * The target power state is determined based on two factors:
371  *   a. The input parameter should be larger than state's exitLatency attribution.
372  *   b. resConstraintsMask logical AND state's lossFeature should equal to 0, because constraint can be understand as
373  * some features can not loss.
374  *
375  * @param duration The time in low power mode, this value is calculate from RTOS API.
376  */
377 void PM_EnterLowPower(uint64_t duration);
378 
379 #if (defined(FSL_PM_SUPPORT_LP_TIMER_CONTROLLER) && FSL_PM_SUPPORT_LP_TIMER_CONTROLLER)
380 /*!
381  * @brief Register timer controller related functions to power manager.
382  *
383  * If low power timer is the wakeup source, please remember to register it into power manager by using
384  * PM_RegisterWakeupSource() function.
385  *
386  * @param handle Pointer to the @ref pm_handle_t structure
387  * @param timerStart Low power timer start function, this parameter can be NULL, and it means low power timer is not set
388  *  as the wakeup source.
389  * @param timerStop Low power timer stop function, this parameter can also be set as NULL.
390  * @param timerSync Low power timer sync function, this parameter can also be set as NULL.
391  * @param getTimestamp Low power timestamp function, this parameter can also be set as NULL.
392  * @param getTimerDuration Get timer duration function. this parameter can also be set as NULL.
393  */
394 void PM_RegisterTimerController(pm_handle_t *handle,
395                                 pm_low_power_timer_start_func_t timerStart,
396                                 pm_low_power_timer_stop_func_t timerStop,
397                                 pm_low_power_timer_get_timestamp_func_t getTimestamp,
398                                 pm_low_power_timer_get_duration_func_t getTimerDuration);
399 
400 /*!
401  * @brief Get the actual low power state duration.
402  */
403 uint64_t PM_GetLastLowPowerDuration(void);
404 #endif /* FSL_PM_SUPPORT_LP_TIMER_CONTROLLER */
405 
406 /*!
407  * @brief Register critical region related functions to power manager.
408  *
409  * @note There are multiple-methods to implement critical region(E.g. interrupt controller, locker, semaphore).
410  *
411  * @param handle Pointer to the @ref pm_handle_t structure
412  * @param criticalEntry Enter critical function to register.
413  * @param criticalExit  Exit critical function to register.
414  */
415 void PM_RegisterCriticalRegionController(pm_handle_t *handle,
416                                          pm_enter_critical criticalEntry,
417                                          pm_exit_critical criticalExit);
418 
419 /*! @} */
420 
421 #if (defined(FSL_PM_SUPPORT_NOTIFICATION) && FSL_PM_SUPPORT_NOTIFICATION)
422 /*!
423  * @name Notification Module Interfaces
424  * @{
425  */
426 
427 /*!
428  * @brief Register notify element into the selected group.
429  *
430  * @param groupId The group of the notify list, this will affect the execution sequence.
431  * @param notifyElement The pointer to @ref pm_notify_element_t.
432  * @return status_t The status of register notify object behavior.
433  */
434 status_t PM_RegisterNotify(pm_notify_group_t groupId, pm_notify_element_t *notifyElement);
435 
436 /*!
437  * @brief Update notify element's callback function and application data.
438  *
439  * @param notifyElement The pointer to the notify element to update.
440  * @param callback The callback function to be updated.
441  * @param data Pointer to the callback function private data.
442  */
443 void PM_UpdateNotify(void *notifyElement, pm_notify_callback_func_t callback, void *data);
444 
445 /*!
446  * @brief Remove notify element from its notify group.
447  *
448  * @param notifyElement The pointer to the notify element to remove.
449  */
450 status_t PM_UnregisterNotify(void *notifyElement);
451 
452 /*! @} */
453 #endif /* FSL_PM_SUPPORT_NOTIFICATION */
454 
455 #if (defined(FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER) && FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER)
456 /*!
457  * @name Wakeup Source Manager Interfaces
458  * @{
459  */
460 
461 /*!
462  * @brief Initialize the wakeup source object.
463  *
464  * @param ws    Pointer to the @ref pm_wakeup_source_t variable.
465  * @param wsId  Used to select the wakeup source, the wsId of each wakeup source can be found in fsl_pm_device.h
466  * @param service The function to be invoked when wake up source asserted.
467  * @param enable Used to enable/disable the selected wakeup source.
468  */
469 void PM_InitWakeupSource(pm_wakeup_source_t *ws, uint32_t wsId, pm_wake_up_source_service_func_t service, bool enable);
470 
471 /*!
472  * @brief Enable wakeup source.
473  *
474  * @param ws Pointer to the wakeup source object to be enabled.
475  * @return status_t The status of enable wakeup source behavior.
476  */
477 status_t PM_EnableWakeupSource(pm_wakeup_source_t *ws);
478 
479 /*!
480  * @brief Disable wakeup source
481  *
482  * @param ws Pointer to the wakeup source object to be disabled.
483  * @return status_t The status of disable wakeup source behavior.
484  */
485 status_t PM_DisableWakeupSource(pm_wakeup_source_t *ws);
486 
487 /*!
488  * @brief Checks if any enabled wake up source is responsible for last wake up
489  *       event. In such case, it will call the wake up source callback if it
490  *       has been registered. Likely to be called from Wake Up Unit IRQ Handler.
491  *
492  * @return status_t The status of handling the wake up event.
493  */
494 status_t PM_HandleWakeUpEvent(void);
495 
496 /*!
497  * @brief If the specfic wakeup event occurs, invoke this API to execute its service function.
498  *
499  * @param ws Pointer to the wakeup source object.
500  * @return status_t The status of trigger wakeup source behavior.
501  */
502 status_t PM_TriggerWakeSourceService(pm_wakeup_source_t *ws);
503 /*! @} */
504 #endif /* FSL_PM_SUPPORT_WAKEUP_SOURCE_MANAGER */
505 
506 /*!
507  * @name Constraints Interfaces
508  * @{
509  */
510 
511 /*!
512  * @brief Used to set constraints(including power mode constraint and resource constraints)
513  *
514  * For example, if the device support 3 resource constraints: PM_RESC_1, PM_RESC_2, PM_RESC3
515  *  @code
516  *      PM_SetConstraints(Sleep_Mode, 3, PM_RESC_1, PM_RESC_2, PM_RESC_3);
517  *  @endcode
518  *
519  * @param powerModeConstraint The lowest power mode allowed, the power mode constraint macros
520  *                            can be found in fsl_pm_device.h
521  * @param rescNum The number of resource constraints to be set.
522  * @return status_t The status of set constraints behavior.
523  */
524 status_t PM_SetConstraints(uint8_t powerModeConstraint, int32_t rescNum, ...);
525 
526 /*!
527  * @brief Used to release constraints(including power mode constraint and resource constraints)
528  *
529  * For example, if the device support 3 resource constraints: PM_RESC_1, PM_RESC_2, PM_RESC3
530  *  @code
531  *      PM_ReleaseConstraints(Sleep_Mode, 1, PM_RESC_1);
532  *  @endcode
533  *
534  * @param powerModeConstraint The lowest power mode allowed, the power mode constraint macros
535  *                            can be found in fsl_pm_device.h
536  * @param rescNum The number of resource constraints to be released.
537  * @return status_t The status of set constraints behavior.
538  */
539 status_t PM_ReleaseConstraints(uint8_t powerModeConstraint, int32_t rescNum, ...);
540 
541 /*!
542  * @brief Get current system resource constraints.
543  *
544  * @return Current system constraints.
545  */
546 pm_resc_mask_t PM_GetResourceConstraintsMask(void);
547 
548 /*!
549  * @brief Get current system allowed power mode.
550  *
551  * @return Allowed lowest power mode.
552  */
553 uint8_t PM_GetAllowedLowestPowerMode(void);
554 
555 /*! @} */
556 
557 #if defined(__cplusplus)
558 }
559 #endif
560 /*!
561  * @}
562  */
563 
564 #endif /* _FSL_PM_CORE_H_ */
565