pm: device: Dynamically add a device to a power domain

Add API to add devices to a power domain in runtime. The number of
devices that can be added is defined in build time.

The script gen_handles.py will check the number defined in
`CONFIG_PM_DEVICE_POWER_DOMAIN_DYNAMIC` to resize the handles vector,
adding empty slots in the supported sector to be used later.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2022-01-05 17:19:53 -08:00 committed by Marti Bolivar
commit 0b13b44a66
9 changed files with 183 additions and 3 deletions

View file

@ -840,6 +840,12 @@ zephyr_get_include_directories_for_lang(C
STRIP_PREFIX # Don't use a -I prefix
)
if(CONFIG_PM_DEVICE_POWER_DOMAIN_DYNAMIC)
set(number_of_dynamic_devices ${CONFIG_PM_DEVICE_POWER_DOMAIN_DYNAMIC_NUM})
else()
set(number_of_dynamic_devices 0)
endif()
if(CONFIG_HAS_DTS)
# dev_handles.c is generated from ${ZEPHYR_LINK_STAGE_EXECUTABLE} by
# gen_handles.py
@ -849,6 +855,7 @@ if(CONFIG_HAS_DTS)
${PYTHON_EXECUTABLE}
${ZEPHYR_BASE}/scripts/gen_handles.py
--output-source dev_handles.c
--num-dynamic-devices ${number_of_dynamic_devices}
--kernel $<TARGET_FILE:${ZEPHYR_LINK_STAGE_EXECUTABLE}>
--zephyr-base ${ZEPHYR_BASE}
--start-symbol "$<TARGET_PROPERTY:linker,devices_start_symbol>"