This is an automated email from the ASF dual-hosted git repository. jerzy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 54f08cafd0e6ae475c6535371db830d7e13c6405 Author: Jerzy Kasenberg <jerzy.kasenb...@codecoup.pl> AuthorDate: Fri Feb 26 14:16:24 2021 +0100 hw/bus: Allow automatic power mode from syscfg Bus driver with BUS_PM enabled was defaulting to manual mode. User code still was required to call bus_dev_set_pm function to switch to automatic mode. Now BUS_PM_MODE configuration value is provided that allows starting in automatic mode from the beginning. Automatic mode is also chosen as default mode when BUS_PM is enabled. Inactivity timeout (time after which bus goes to power save mode) now can be specified in syscfg with BUS_PM_INACTIVITY_TMO value. --- hw/bus/src/bus.c | 4 ++++ hw/bus/syscfg.yml | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/hw/bus/src/bus.c b/hw/bus/src/bus.c index 265cf02..ce5188a 100644 --- a/hw/bus/src/bus.c +++ b/hw/bus/src/bus.c @@ -238,6 +238,10 @@ bus_dev_init_func(struct os_dev *odev, void *arg) /* XXX allow custom eventq */ os_callout_init(&bdev->inactivity_tmo, os_eventq_dflt_get(), bus_dev_inactivity_tmo_func, odev); + bdev->pm_mode = MYNEWT_VAL_CHOICE(BUS_PM_MODE, AUTO) ? BUS_PM_MODE_AUTO : BUS_PM_MODE_MANUAL; + if (MYNEWT_VAL_CHOICE(BUS_PM_MODE, AUTO)) { + bdev->pm_opts.pm_mode_auto.disable_tmo = MYNEWT_VAL(BUS_PM_INACTIVITY_TMO); + } #endif #if MYNEWT_VAL(BUS_STATS) diff --git a/hw/bus/syscfg.yml b/hw/bus/syscfg.yml index 0303470..f9ac0e6 100644 --- a/hw/bus/syscfg.yml +++ b/hw/bus/syscfg.yml @@ -37,6 +37,22 @@ syscfg.defs: allows for some automatic management of bus device state instead of implementing this manually. value: 0 + BUS_PM_MODE: + description: > + Default power management mode for bus drivers. When set to AUTO + bus drivers will take care of turning off controllers when they + are not needed for some time. + When set to MANUAL bus driver will not enable/disable controllers + leaving it to the application code. + This setting is only valid when BUS_PM == 1. + choices: + - AUTO + - MANUAL + value: AUTO + BUS_PM_INACTIVITY_TMO: + description: > + Default inactivity time after which bus controller will be disabled (in ticks). + value: 1 BUS_STATS: description: >