-
Notifications
You must be signed in to change notification settings - Fork 7.9k
drivers: serial: nrfx_uarte: Add support for device deinit #93273
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
Conversation
|
@bjarki-andreasen i've added option to keep sleep configuration for pinctrl (so far it was available only when PM was enabled). I think that this option would need to be enabled in SPIM as well as currently deinit will not set pins to the default state. |
drivers/serial/Kconfig.nrfx
Outdated
config UART_NRFX_UARTE_DEINIT | ||
bool "Support deinit" | ||
depends on UART_NRFX_UARTE | ||
imply PINCTRL_KEEP_SLEEP_STATE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of doing this on a driver level (all drivers will need sleep states set if deinit is used) extend the base nordic soc Kconfig with:
config PINCTRL_KEEP_SLEEP_STATE
default y if DEVICE_DEINIT_SUPPORT
this will apply the config soc wide instead of forcing every driver to manually select or imply it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done,
drivers/serial/uart_nrfx_uarte.c
Outdated
if (IS_ENABLED(CONFIG_PM_DEVICE)) { | ||
enum pm_device_state state; | ||
|
||
/* PM must have suspended the device before driver can be deinitialized. */ | ||
(void)pm_device_state_get(dev, &state); | ||
return (state == PM_DEVICE_STATE_SUSPENDED) || (state == PM_DEVICE_STATE_OFF) ? | ||
0 : -EBUSY; | ||
} | ||
|
||
uarte_pm_suspend(dev); | ||
|
||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can now be done with
return pm_device_driver_deinit(dev, uarte_nrfx_pm_action);
which calls uarte_pm_suspend()
if needed using the pm_action_hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
e49a55c
2b26816
to
e49a55c
Compare
When PM or PM_DEVICE is enabled pinctrl sleep state is using for device suspension. However, there are cases where power management is not used but we still want to be able to put pins to sleep state, e.g. device deinit. Signed-off-by: Krzysztof Chruściński <[email protected]>
Add device deinit function. Support is optional as it is not widely used and it enables pinctrl sleep state so it impacts memory footprint. Signed-off-by: Krzysztof Chruściński <[email protected]>
e49a55c
to
7276384
Compare
|
Add device deinit function. Support is optional as it is not widely used and it enables pinctrl sleep state so it impacts memory footprint.
Additionally, added option to create pinctrl sleep state. So far it was only created when power management was used but in case of deinit it is possible that it is used without PM and we still want to put pins into the default state.