EVE 1.0
Power management
Collaboration diagram for Power management:

Data Structures

struct  pm_lock_t
 

Macros

#define PM_LOCK_INIT(l, pm, cb, d)
 
#define DECLARE_PM_LOCK(l, pm, cb, d)   static struct pm_lock_t pm = PM_LOCK_INIT(l, pm, cb, d)
 
#define PM_LOCK(pm)   pm_lock(&pm)
 
#define PM_UNLOCK(pm)   pm_unlock(&pm)
 
#define PM_AUTO_LOCK(l)
 

Enumerations

Functions

void pm_relax (void)
 
void pm_wakeup (void)
 
void pm_lock (struct pm_lock_t *pm)
 
void pm_unlock (struct pm_lock_t *pm)
 
enum pm_level_t pm_waterlevel (void)
 

Detailed Description

EVE power management framework

Macro Definition Documentation

#define PM_LOCK_INIT (   l,
  pm,
  cb,
 
)
Value:
{ \
.next = NULL, \
.level = l, \
.ready_cb = cb, \
.data = d, \
.locked = 0, \
}

Initializes a power lock structure.

The macro is used to initialize a power lock structure instance.

Parameters
lpower level
pmpower lock structure
cbuser callback to be called before the system goes suspend
ddata for the user callback

Usage:

1 struct pm_lock_t MyConstLatPowerLock = PM_LOCK_INIT(PM_LEVEL_CONSTLAT, MyConstLatPowerLock, NULL, 0);

Definition at line 195 of file pm.h.

#define DECLARE_PM_LOCK (   l,
  pm,
  cb,
 
)    static struct pm_lock_t pm = PM_LOCK_INIT(l, pm, cb, d)

Declares a power lock structure instance

Parameters
lpower level
pmpower lock structure
cbuser callback to be called before the system goes suspend
ddata for the user callback

Usage:

1 DECLARE_PM_LOCK(PM_LEVEL_CONSTLAT, MyConstLatPowerLock, NULL, 0);
2 // The above line is an equivalint of
3 struct pm_lock_t MyConstLatPowerLock = PM_LOCK_INIT(PM_LEVEL_CONSTLAT, MyConstLatPowerLock, NULL, 0);

Definition at line 210 of file pm.h.

#define PM_LOCK (   pm)    pm_lock(&pm)

Request the power level

The macro is used to request power at the given power level.

Parameters
pmpower lock structure

Usage:

1 PM_LOCK(MyConstLatPowerLock);

Definition at line 203 of file pm.h.

Referenced by clock_delay_usec(), and clock_wait().

#define PM_UNLOCK (   pm)    pm_unlock(&pm)

Release the power

The macro is used to release previously taken power request at the given power level.

If the power lock structure provides a user-defined callback, the PM_UNLOCK() puts the structure into a linked list of unlocked requests, waiting for suspend. During the following suspend (pm_relax()), the list is traversed and the callbacks are called by the framework. The callbacks can prevent system from suspend by returning false.

Parameters
pmpower lock structure

Usage:

1 PM_UNLOCK(MyConstLatPowerLock);

Definition at line 204 of file pm.h.

Referenced by clock_delay_usec(), and clock_wait().

#define PM_AUTO_LOCK (   l)
Value:
struct pm_lock_t EvePmAutoLock __attribute__((cleanup(pm_unlock))); \
do { EvePmAutoLock = (struct pm_lock_t) PM_LOCK_INIT(l, EvePmAutoLock, NULL, 0); } while (0)
__attribute__((always_inline)) static inline void swint_enable_indirect_adapter(swint_state_t *state)
Definition: work.h:245
Definition: pm.h:78
void pm_unlock(struct pm_lock_t *pm)
#define PM_LOCK_INIT(l, pm, cb, d)
Definition: pm.h:195

Declares an anonymous auto lock, which holds power request in the auto variable visibility block

Parameters
lpower level

Usage:

1 {
2  PM_AUTO_LOCK(PM_LEVEL_CONSTLAT);
3  clock_delay(MS_TO_TICKS(10)); // The delay will be executed at at least CONSTLAT level.
4 }
5 // The lock is released here

Definition at line 205 of file pm.h.

Enumeration Type Documentation

enum pm_level_t

System power level.

Enumerator
PM_LEVEL_RUNNING 

System is kept spinning when idle. Høyest power consumption.

PM_LEVEL_CONSTLAT 

System ON, Constant latency mode.

PM_LEVEL_LOWPWR 

System ON, Low power mode.

PM_LEVEL_CLOCKLESS 

System ON, Low power mode, 32 kHz clock off.

PM_LEVEL_OFF 

System OFF.

PM_LEVEL__COUNT 

Number of elements in the pm_level_t enum.

Definition at line 57 of file pm.h.

Function Documentation

void pm_relax ( void  )

Enters the lowest power level.

Before entring low-power mode, pm_relax() traverses via the list of lock structures, registered by PM_UNLOCK(), and calls user-defined callbacks. If a callback returns false, then the ongoing suspend is cancelled.

While interrupt handling is performed, pm_relax() does not return to the operating system until a wakeup is requested by pm_wakeup() call.

Referenced by clock_delay_usec(), and clock_wait().

void pm_wakeup ( void  )

Wakeups the system from suspend state.

Interrupt handlers must call this function if they want to wake up operating system from suspend state.

Referenced by clock_wait(), process_poll(), and process_post().

void pm_lock ( struct pm_lock_t pm)

Restrict deepness of suspend to the given power level

Parameters
pmpointer to the power lock structure
void pm_unlock ( struct pm_lock_t pm)

Release a previously taken power lock

Parameters
pmpointer to the power lock structure
enum pm_level_t pm_waterlevel ( void  )

Query the level the system can be put down to sleep taking in mind currently taken locks.