Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions drivers/serial/uart_mcux.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <device.h>
#include <drivers/uart.h>
#include <drivers/clock_control.h>
#include <drivers/pinctrl.h>
#include <fsl_uart.h>
#include <soc.h>

Expand All @@ -21,6 +22,7 @@ struct uart_mcux_config {
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
void (*irq_config_func)(const struct device *dev);
#endif
const struct pinctrl_dev_config *pincfg;
};

struct uart_mcux_data {
Expand All @@ -39,6 +41,12 @@ static int uart_mcux_configure(const struct device *dev,
uart_config_t uart_config;
uint32_t clock_freq;
status_t retval;
int ret;

ret = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
if (ret < 0) {
return ret;
}

if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
&clock_freq)) {
Expand Down Expand Up @@ -359,10 +367,13 @@ static const struct uart_driver_api uart_mcux_driver_api = {
};

#define UART_MCUX_DECLARE_CFG(n, IRQ_FUNC_INIT) \
PINCTRL_DT_INST_DEFINE(n) \
\
static const struct uart_mcux_config uart_mcux_##n##_config = { \
.base = (UART_Type *)DT_INST_REG_ADDR(n), \
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
.clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
IRQ_FUNC_INIT \
}

Expand Down
5 changes: 2 additions & 3 deletions dts/bindings/serial/nxp,kinetis-uart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ description: Kinetis UART

compatible: "nxp,kinetis-uart"

include: uart-controller.yaml
include: [uart-controller.yaml, pinctrl-device.yaml]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: update binding description to mention pinctrl requirements, with some example.


properties:
reg:
Expand All @@ -14,6 +14,5 @@ properties:
clocks:
required: true

pinctrl-0:
type: phandles
pinctrl-names:
required: true