Commit graph

17 commits

Author SHA1 Message Date
Krzysztof Chruściński 25173f71cd pm: device_runtime: Extend with synchronous runtime PM
In many cases suspending or resuming of a device is limited to
just a few register writes. Current solution assumes that those
operations may be blocking, asynchronous and take a lot of time.
Due to this assumption runtime PM API cannot be effectively used
from the interrupt context. Zephyr has few driver APIs which
can be used from an interrupt context and now use of runtime PM
is limited in those cases.

Patch introduces a new type of PM device - synchronous PM. If
device is specified as capable of synchronous PM operations then
device runtime getting and putting is executed in the critical
section. In that case, runtime API can be used from an interrupt
context. Additionally, this approach reduces RAM needed for
PM device (104 -> 20 bytes of RAM on ARM Cortex-M).

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-02-01 15:03:42 +01:00
Flavio Ceolin e80ea1e129 drivers: power_domain/gpio: Init priority option
Add a Kconfig option to customize initialization priority of
gpio power domain.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-01-24 18:20:17 -05:00
Albert Jakieła 06cfbd4159 drivers: power_domain: Introduce a gpio monitor driver
Power rails of some peripherals are controlled externally.
This is a case in embedded controllers, where the power of
some I2C devices are managed by the main application
processor.

To ensure that zephyr drivers access the devices where is
powered on, introduce a "monitoring" power domain. It works
by registering interrupt handler with gpio a pin, so that
when power state changes, it will notify relevant drivers.

Additionaly add CONFIG_POWER_DOMAIN_INIT_PRIORITY to replace
harcoded init priority.

Fixes: #51349

Signed-off-by: Albert Jakieła <jakiela@google.com>
2023-11-01 10:57:17 +00:00
Nick Ward 2d65acca3a drivers: gpio: use gpio_is_ready_dt helper function
Update `struct gpio_dt_spec` use with gpio_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-08-28 08:48:35 -05:00
Jordan Yates 014760234b power_domain: gpio: init with pm_device_driver_init
Startup power domains according to the expected final state given the
power supply and PM device runtime support.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-26 08:16:44 +00:00
Jordan Yates 1ddadaf255 power_domain: gpio: compile without PM_DEVICE_POWER_DOMAIN
Let the driver compile without `PM_DEVICE_POWER_DOMAIN`, in which case
the driver only controls the GPIO, without notifying dependant devices.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-26 08:16:44 +00:00
Jordan Yates f613074283 Revert "power_domain: gpio: compile without PM_DEVICE_POWER_DOMAIN"
This reverts commit 1f1217e832.
2023-07-25 14:17:11 +02:00
Jordan Yates 226f1c5e4b Revert "power_domain: gpio: init with pm_device_driver_init"
This reverts commit 39b2ec57a0.
2023-07-25 14:17:11 +02:00
Jordan Yates 39b2ec57a0 power_domain: gpio: init with pm_device_driver_init
Startup power domains according to the expected final state given the
power supply and PM device runtime support.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-25 09:13:16 +02:00
Jordan Yates 1f1217e832 power_domain: gpio: compile without PM_DEVICE_POWER_DOMAIN
Let the driver compile without `PM_DEVICE_POWER_DOMAIN`, in which case
the driver only controls the GPIO, without notifying dependant devices.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-07-25 09:13:16 +02:00
Jordan Yates addf405fe6 power_domain: gpio: only run actions for children on domain
Only run the `PM_DEVICE_ACTION_TURN_ON` and `PM_DEVICE_ACTION_TURN_OFF`
actions for child devices that have refered to the domain via the
`power-domain` property.

This prevents multiple actions being run for devices that refer to
several power domains, e.g.

```
	test_dev: test_dev {
		compatible = "test-device-pm";
		status = "okay";
		power-domain = <&test_reg_1>;
		alternate-domain = <&test_reg_chained>;
	};
```

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-01-24 09:42:11 +01:00
Jordan Yates e5c391fad6 power_domain: gpio: improve logging
Improve the power domain logging by making the log level configurable
and boosting the log level of the messages printed when the domain turns
on and off.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-10 17:59:56 -04:00
Jordan Yates 9b59721ab3 power_domain: gpio: update include paths
Update the Zephyr include paths to be compatible with removing
`CONFIG_LEGACY_INCLUDE_PATH` in the future.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-06 11:33:10 +02:00
Jordan Yates d1ab0f6b6e power_domain: gpio: use on-off and startup time
Respect the configured values for how long the domain takes to turn on,
and how long the domain needs to be off for before it can be repowered.

As these actions can block, guard the transition function with
pm_device_action_can_block. To avoid system PM being able to turn the
domain off but not back on again, guard the entire implementation.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-06 11:33:10 +02:00
Jordan Yates 31ad7e2bd4 power_domain: gpio: remove unused strings
Remove unused power domain transition strings.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-06 11:33:10 +02:00
Jordan Yates 6d1a08b3a8 pm: device: move pm_device_runtime_init_* funcs
Move the `pm_device_runtime_init_*` functions from <pm/device_runtime.h>
to <pm/device.h>. The initial device state should be settable
independently of whether `CONFIG_PM_DEVICE_RUNTIME` is enabled.

This also resolves a compilation error when attempting to use these
functions without also including <pm/device.h>.

Function documentation is also updated to be more general than only
referencing runtime PM, as this also applies to system PM and manually
run actions.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-03-25 10:39:55 +01:00
Jordan Yates ccdc009077 drivers: power_domain: gpio controlled domain
Initial implementation of a simple GPIO controlled power domain.
It exposes no API of its own, all functionality is contained inside
the runtime power management callbacks.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-01-19 13:35:32 -05:00