drivers: serial: Add pinctrl support to mcux uart driver
Add pinctrl support to mcux uart driver Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
5e300f2027
commit
1fd4205eee
1 changed files with 24 additions and 1 deletions
|
@ -13,6 +13,9 @@
|
||||||
#include <drivers/clock_control.h>
|
#include <drivers/clock_control.h>
|
||||||
#include <fsl_uart.h>
|
#include <fsl_uart.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
#include <drivers/pinctrl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct uart_mcux_config {
|
struct uart_mcux_config {
|
||||||
UART_Type *base;
|
UART_Type *base;
|
||||||
|
@ -21,6 +24,9 @@ struct uart_mcux_config {
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
void (*irq_config_func)(const struct device *dev);
|
void (*irq_config_func)(const struct device *dev);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
const struct pinctrl_dev_config *pincfg;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct uart_mcux_data {
|
struct uart_mcux_data {
|
||||||
|
@ -314,7 +320,7 @@ static void uart_mcux_isr(const struct device *dev)
|
||||||
|
|
||||||
static int uart_mcux_init(const struct device *dev)
|
static int uart_mcux_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#if defined(CONFIG_PINCTRL) || defined(CONFIG_UART_INTERRUPT_DRIVEN)
|
||||||
const struct uart_mcux_config *config = dev->config;
|
const struct uart_mcux_config *config = dev->config;
|
||||||
#endif
|
#endif
|
||||||
struct uart_mcux_data *data = dev->data;
|
struct uart_mcux_data *data = dev->data;
|
||||||
|
@ -325,6 +331,13 @@ static int uart_mcux_init(const struct device *dev)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
if (err != 0) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
config->irq_config_func(dev);
|
config->irq_config_func(dev);
|
||||||
#endif
|
#endif
|
||||||
|
@ -358,11 +371,20 @@ static const struct uart_driver_api uart_mcux_driver_api = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
#define PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n),
|
||||||
|
#define PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n);
|
||||||
|
#else
|
||||||
|
#define PINCTRL_DEFINE(n)
|
||||||
|
#define PINCTRL_INIT(n)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define UART_MCUX_DECLARE_CFG(n, IRQ_FUNC_INIT) \
|
#define UART_MCUX_DECLARE_CFG(n, IRQ_FUNC_INIT) \
|
||||||
static const struct uart_mcux_config uart_mcux_##n##_config = { \
|
static const struct uart_mcux_config uart_mcux_##n##_config = { \
|
||||||
.base = (UART_Type *)DT_INST_REG_ADDR(n), \
|
.base = (UART_Type *)DT_INST_REG_ADDR(n), \
|
||||||
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
|
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
|
||||||
.clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
.clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
||||||
|
PINCTRL_INIT(n) \
|
||||||
IRQ_FUNC_INIT \
|
IRQ_FUNC_INIT \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,6 +416,7 @@ static const struct uart_mcux_config uart_mcux_##n##_config = { \
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define UART_MCUX_INIT(n) \
|
#define UART_MCUX_INIT(n) \
|
||||||
|
PINCTRL_DEFINE(n) \
|
||||||
\
|
\
|
||||||
static struct uart_mcux_data uart_mcux_##n##_data = { \
|
static struct uart_mcux_data uart_mcux_##n##_data = { \
|
||||||
.uart_cfg = { \
|
.uart_cfg = { \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue