drivers: uart_imx: add pin control support
Add pin control support to uart_imx serial driver. Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
694637a83c
commit
c4a7985064
2 changed files with 18 additions and 1 deletions
|
@ -20,6 +20,7 @@
|
|||
#include <zephyr/init.h>
|
||||
#include <zephyr/drivers/uart.h>
|
||||
#include <uart_imx.h>
|
||||
#include <drivers/pinctrl.h>
|
||||
|
||||
#define UART_STRUCT(dev) \
|
||||
((UART_Type *)((const struct imx_uart_config *const)(dev)->config)->base)
|
||||
|
@ -28,6 +29,7 @@ struct imx_uart_config {
|
|||
UART_Type *base;
|
||||
uint32_t baud_rate;
|
||||
uint8_t modem_mode;
|
||||
const struct pinctrl_dev_config *pincfg;
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
void (*irq_config_func)(const struct device *dev);
|
||||
#endif
|
||||
|
@ -55,6 +57,7 @@ static int uart_imx_init(const struct device *dev)
|
|||
UART_Type *uart = UART_STRUCT(dev);
|
||||
const struct imx_uart_config *config = dev->config;
|
||||
unsigned int old_level;
|
||||
int err;
|
||||
|
||||
/* disable interrupts */
|
||||
old_level = irq_lock();
|
||||
|
@ -68,6 +71,11 @@ static int uart_imx_init(const struct device *dev)
|
|||
.direction = uartDirectionTxRx
|
||||
};
|
||||
|
||||
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Get current module clock frequency */
|
||||
initConfig.clockRate = get_uart_clock_freq(uart);
|
||||
|
||||
|
@ -283,6 +291,7 @@ static const struct uart_driver_api uart_imx_driver_api = {
|
|||
.base = (UART_Type *) DT_INST_REG_ADDR(n), \
|
||||
.baud_rate = DT_INST_PROP(n, current_speed), \
|
||||
.modem_mode = DT_INST_PROP(n, modem_mode), \
|
||||
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
|
||||
IRQ_FUNC_INIT \
|
||||
}
|
||||
|
||||
|
@ -312,6 +321,8 @@ static const struct uart_driver_api uart_imx_driver_api = {
|
|||
\
|
||||
static const struct imx_uart_config imx_uart_##n##_config; \
|
||||
\
|
||||
PINCTRL_DT_INST_DEFINE(n); \
|
||||
\
|
||||
DEVICE_DT_INST_DEFINE(n, &uart_imx_init, NULL, \
|
||||
&imx_uart_##n##_data, &imx_uart_##n##_config, \
|
||||
PRE_KERNEL_1, \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue