-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Update uart_mcux.c #50726
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
Merged
Merged
Update uart_mcux.c #50726
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| #include <zephyr/drivers/clock_control.h> | ||
| #include <fsl_uart.h> | ||
| #include <soc.h> | ||
| #include <zephyr/pm/device.h> | ||
| #ifdef CONFIG_PINCTRL | ||
| #include <zephyr/drivers/pinctrl.h> | ||
| #endif | ||
|
|
@@ -209,15 +210,17 @@ static void uart_mcux_irq_tx_enable(const struct device *dev) | |
| { | ||
| const struct uart_mcux_config *config = dev->config; | ||
| uint32_t mask = kUART_TxDataRegEmptyInterruptEnable; | ||
|
|
||
| config->base->C2 |= UART_C2_TE_MASK; | ||
| pm_device_busy_set(dev); | ||
| UART_EnableInterrupts(config->base, mask); | ||
| } | ||
|
|
||
| static void uart_mcux_irq_tx_disable(const struct device *dev) | ||
| { | ||
| const struct uart_mcux_config *config = dev->config; | ||
| uint32_t mask = kUART_TxDataRegEmptyInterruptEnable; | ||
|
|
||
| config->base->C2 &= ~UART_C2_TE_MASK; | ||
| pm_device_busy_clear(dev); | ||
| UART_DisableInterrupts(config->base, mask); | ||
| } | ||
|
|
||
|
|
@@ -315,7 +318,6 @@ static void uart_mcux_irq_callback_set(const struct device *dev, | |
| static void uart_mcux_isr(const struct device *dev) | ||
| { | ||
| struct uart_mcux_data *data = dev->data; | ||
|
|
||
| if (data->callback) { | ||
| data->callback(dev, data->cb_data); | ||
| } | ||
|
|
@@ -349,6 +351,29 @@ static int uart_mcux_init(const struct device *dev) | |
| return 0; | ||
| } | ||
|
|
||
| #ifdef CONFIG_PM_DEVICE | ||
| static int uart_mcux_pm_action(const struct device *dev, enum pm_device_action action) | ||
| { | ||
| const struct uart_mcux_config *config = dev->config; | ||
|
|
||
| switch (action) { | ||
| case PM_DEVICE_ACTION_RESUME: | ||
| clock_control_on(config->clock_dev, config->clock_subsys); | ||
| break; | ||
| case PM_DEVICE_ACTION_SUSPEND: | ||
| clock_control_off(config->clock_dev, config->clock_subsys); | ||
| break; | ||
| case PM_DEVICE_ACTION_TURN_OFF: | ||
| return 0; | ||
| case PM_DEVICE_ACTION_TURN_ON: | ||
| return 0; | ||
| default: | ||
| return -ENOTSUP; | ||
| } | ||
| return 0; | ||
| } | ||
| #endif /*CONFIG_PM_DEVICE*/ | ||
|
|
||
| static const struct uart_driver_api uart_mcux_driver_api = { | ||
| .poll_in = uart_mcux_poll_in, | ||
| .poll_out = uart_mcux_poll_out, | ||
|
|
@@ -434,10 +459,11 @@ static const struct uart_mcux_config uart_mcux_##n##_config = { \ | |
| }; \ | ||
| \ | ||
| static const struct uart_mcux_config uart_mcux_##n##_config; \ | ||
| PM_DEVICE_DT_INST_DEFINE(n, uart_mcux_pm_action);\ | ||
|
||
| \ | ||
| DEVICE_DT_INST_DEFINE(n, \ | ||
| &uart_mcux_init, \ | ||
| NULL, \ | ||
| PM_DEVICE_DT_INST_GET(n), \ | ||
| &uart_mcux_##n##_data, \ | ||
| &uart_mcux_##n##_config, \ | ||
| PRE_KERNEL_1, \ | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@mmahadevan108 can you check it please ?
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.
Minor issue, please fix the indentation of the break commands
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.
Looks like this bit keeps the UART clock running during low power modes. Should this be something the user gets to decide through a device tree property?
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.
Another point is that we don't need to clear and enable this bit in suspend and resume. This is a one time operation where the user decides if the UART clock should be active in low power modes.