Commit graph

23 commits

Author SHA1 Message Date
Kumar Gala
a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Carles Cufi
04d1104ee5 timeouts: Fix power _sys_suspend invocation
Use K_TICKS_FOREVER instead of K_FOREVER after the timeout API rework.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-07 11:01:55 +02:00
Wentong Wu
7cb74655da power: add system power management direct force mode.
Add system power management direct force trigger mode. In this
mode application thread can directly put system in sleep or deep
sleep mode instead of waiting for idle thread to do it, so that
it can reduce latency to enter low power mode.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-01-24 21:37:40 -05:00
Wentong Wu
a9bd208b5b Power: change sys_pm_force_power_state only works for one shot
Change sys_pm_force_power_state only works for the current ongoing
suspend operation, before the end of syspend state forced_pm_state
will be cleared.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-01-24 21:37:40 -05:00
Wentong Wu
7d2586533d power: add DEVICE_PM_LOW_POWER_STATE for device power management
When system going to sleep state, make peripherals go to state
DEVICE_PM_LOW_POWER_STATE which needs less time than state
DEVICE_PM_SUSPEND_STATE to save more power.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-01-04 09:23:15 -05:00
Wentong Wu
e71485e8ff power: active all devices if not all devices enter suspend state
Active all devices if not all devices enter suspend state when system
decide going to suspend state.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-01-04 09:23:15 -05:00
Wentong Wu
9989e5ee06 power: correct log level for power management
Current PM policy allow devices make the decision if going to
sleep/deep sleep state, so it's not error message if some
devices don't enter suspend state, change it to debug level.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2020-01-04 09:23:15 -05:00
Anas Nashif
190e368275 cleanup: include/: move power.h to power/power.h
move power.h to power/power.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Piotr Mienkowski
17b08ceca5 power: clean up system power managment function names
This commit cleans up names of system power management functions by
assuring that:
- all functions start with 'sys_pm_' prefix
- API functions which should not be exposed to the user start with '_'
- name of the function hints at its purpose

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-03-26 13:27:55 -04:00
Piotr Zięcik
99c35602fe power: Do not suspend devices if device PM is not compiled in
This commit fixes compilation of System Power Management module
when Device Power Management is disabled.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-19 13:25:36 -05:00
Piotr Zięcik
c45961daae power: Rework OS <-> Application interface
This commit simplifies OS <-> Application interface controlling power
management. In the previous approach application-based PM required
overriding sys_suspend() and sys_resume() functions. As these functions
actually implemented power state change, in such case application
basically had to provide own implementation of all PM-related stuff,
which was not portable and hard to maintain.

This commit changes this scheme: The sys_suspend() and sys_resume()
are now system functions while the application could either use
built-in power management policies or provide its own. All details
of power mode switching are now handled by the OS.

Also, this commit cleans up the Kconfig options related to system-level
power management grouping them under common CONFIG_SYS_PM_ prefix.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-19 13:25:36 -05:00
Piotr Zięcik
04cb93a250 power: Add sys_pm_force_power_state() API
At the moment application which chosen policy based power
management does not have an option to override decision
taken by the policy (it could only disable some power
states).

This commit adds the sys_pm_force_power_state() method,
which allow the application to choose power state used
when OS decide to suspend the SoC.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-11 07:52:12 -05:00
Piotr Zięcik
d02e3ebd4c power: Eliminate SYS_PM_* power states.
The power management framework used two different abstractions
to describe power states. The SYS_PM_* given coarse information
what kind of power state (low power or deep sleep) was used,
while the SYS_POWER_STATE_* abstraction provided information
about particular power mode.

This commit removes the SYS_PM_* abstraction as the same
information is already carried in SYS_POWER_STATE_*.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-08 09:07:00 -05:00
Piotr Zięcik
b6bf56c3fc power: pm_ctrl: Allow fine-grained power state locking
This commit enables fine-grained power state locking.
Now, each power state could be independently enabled or disabled.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-06 14:24:01 +01:00
Piotr Zięcik
c39bb49e84 power: Implement weak notification functions.
The power subsystems call the sys_pm_notify_lps_entry()
and sys_pm_notify_lps_exit() to notify application that
given power mode has been entered and exited. This commit
adds weak implementation of these functions in order to
not force applications to implement its own empty stubs.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-02-01 15:08:33 +01:00
Anas Nashif
74a74bb6b8 power: rename api sys_soc -> sys_
sys_soc is just redundant, just call APIs with sys_*.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-12-28 16:16:28 -05:00
Anas Nashif
9151fbebf2 power: rename APIs and removing leading _
Remove leading underscore from PM APIs. _ was used for internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-12-28 16:16:28 -05:00
Ramakrishna Pallala
212b2180c9 power: Add API's to enable/disable System PM states
Add API's to enable/disable System PM states so that an
an application can enable/disable system from entering
certain Low Power states.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-11-26 06:55:57 -08:00
Krzysztof Chruscinski
5e346812ac logging: Refactor LOG_MODULE_REGISTER and LOG_MODULE_DECLARE macros
Changed LOG_MODULE_REGISTER and LOG_MODULE_DECLARE macros to take log
level as optional parameter. LOG_MODULE_DECLARE can now also be used
in static inline functions in headers. Added LOG_LEVEL_SET macro
which is used when instance logging API is used to indicate maximal
log level compiled into the file.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-11-10 12:38:29 -05:00
Ramakrishna Pallala
359341203f power: Add OS Power Management debug hooks
Add the necessary PM hooks like Low Power state entry
count and residencies for logging and debugging purposes.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-10-28 11:44:22 -04:00
Ramakrishna Pallala
c511857f57 subsys: power: Add support for pluggable PM policies
Add support for adding and selecting pluggable PM policies
which can be enabled based on the application needs.

Also added a dummy policy for demonstration purpose which
simply loops over the supported PM states.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-09-20 10:20:23 -04:00
Kumar Gala
4fede8dd0b log: make name param explicit
Rather than having some implied name for the logging name, explicitly
pass it in the macros LOG_MODULE_REGISTER & LOG_MODULE_DECLARE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-09-11 13:25:55 -05:00
Ramakrishna Pallala
2ad647857c subsys: power: Add OS managed Power Management framework
Add support for OS managed Power Management framework for Zephyr
under 'subsys/power'. This framework takes care of implementing
the _sys_soc_suspend/_sys_soc_resume API's, a PM policy based on
SoC Low Power residencies and also provides necessary API's to
do devices suspend and resume.

Also add necessary changes to support the existing Application
managed Power Management framework.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-08-22 08:07:14 -07:00