Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: pwm: nrfx: Add runtime PM and fix stopping PWM #2081

Merged
merged 4 commits into from
Oct 22, 2024

Conversation

nordic-krch
Copy link
Contributor

gmarull and others added 4 commits October 21, 2024 15:44
Some devices, e.g. SoC level devices like I2C peripheral, can never be
powerd off as they are always energized. Such devices can only go from an
active state or to a low power state (suspended). Allow them to simply
return -ENOTSUP when called with TURN_ON (or TURN_OFF).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
(cherry picked from commit 740eba1)
Use NRFX_FOREACH_PRESENT macro to iterate over all PWM instances
and create device only for those enabled in the devicetree.
This approach removes need of changing driver code when new
instance id is added.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
(cherry picked from commit 0ab86c4)
Shim was not correctly disabling PWM when it was not used. Task
STOP was triggered but PWM->ENABLE remained set which caused
increased current. Added interrupt and enabled event handler in
the nrfx driver to allow disabling PWM on STOPPED event.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
(cherry picked from commit c3a33cf)
Rework PM handling to use pm_device_driver_init(). Shim is not using
put and get internally as there is no api that disables or stops
pwm so it is hard to determine when to put the device. There are cases
when PWM peripheral is stopped but PWM is still active because
duty cycle is 100% or 0% and pin is driven by GPIO and not PWM.

If user want to use runtime PM with PWM it is possible and getting
the device will initialize internal data and putting will suspend
by forcing PWM stop if used and setting pins to sleep state. However,
from power consumption perspective it is enough to set 0% or 100%
duty cycle on all channels.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
(cherry picked from commit e11d050)
@nordic-krch nordic-krch added this to the ncs-2.8.0 milestone Oct 22, 2024
@nordicjm nordicjm merged commit b063a96 into nrfconnect:main Oct 22, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants