drivers: uart_mcux_iuart: add pin control support
Add pin control support to mcux_iuart driver. Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
0f7145e037
commit
694637a83c
2 changed files with 18 additions and 1 deletions
|
@ -12,12 +12,14 @@
|
|||
#include <errno.h>
|
||||
#include <fsl_uart.h>
|
||||
#include <soc.h>
|
||||
#include <drivers/pinctrl.h>
|
||||
|
||||
struct mcux_iuart_config {
|
||||
UART_Type *base;
|
||||
const struct device *clock_dev;
|
||||
clock_control_subsys_t clock_subsys;
|
||||
uint32_t baud_rate;
|
||||
const struct pinctrl_dev_config *pincfg;
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
void (*irq_config_func)(const struct device *dev);
|
||||
#endif
|
||||
|
@ -223,6 +225,7 @@ static int mcux_iuart_init(const struct device *dev)
|
|||
const struct mcux_iuart_config *config = dev->config;
|
||||
uart_config_t uart_config;
|
||||
uint32_t clock_freq;
|
||||
int err;
|
||||
|
||||
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
|
||||
&clock_freq)) {
|
||||
|
@ -236,6 +239,11 @@ static int mcux_iuart_init(const struct device *dev)
|
|||
|
||||
UART_Init(config->base, &uart_config, clock_freq);
|
||||
|
||||
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
config->irq_config_func(dev);
|
||||
#endif
|
||||
|
@ -299,6 +307,7 @@ static const struct mcux_iuart_config mcux_iuart_##n##_config = { \
|
|||
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
|
||||
.clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
||||
.baud_rate = DT_INST_PROP(n, current_speed), \
|
||||
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
|
||||
IRQ_FUNC_INIT \
|
||||
}
|
||||
|
||||
|
@ -317,6 +326,8 @@ static const struct mcux_iuart_config mcux_iuart_##n##_config = { \
|
|||
CONFIG_SERIAL_INIT_PRIORITY, \
|
||||
&mcux_iuart_driver_api); \
|
||||
\
|
||||
PINCTRL_DT_INST_DEFINE(n); \
|
||||
\
|
||||
IUART_MCUX_CONFIG_FUNC(n) \
|
||||
\
|
||||
IUART_MCUX_INIT_CFG(n);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue