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/init.h>
|
||||||
#include <zephyr/drivers/uart.h>
|
#include <zephyr/drivers/uart.h>
|
||||||
#include <uart_imx.h>
|
#include <uart_imx.h>
|
||||||
|
#include <drivers/pinctrl.h>
|
||||||
|
|
||||||
#define UART_STRUCT(dev) \
|
#define UART_STRUCT(dev) \
|
||||||
((UART_Type *)((const struct imx_uart_config *const)(dev)->config)->base)
|
((UART_Type *)((const struct imx_uart_config *const)(dev)->config)->base)
|
||||||
|
@ -28,6 +29,7 @@ struct imx_uart_config {
|
||||||
UART_Type *base;
|
UART_Type *base;
|
||||||
uint32_t baud_rate;
|
uint32_t baud_rate;
|
||||||
uint8_t modem_mode;
|
uint8_t modem_mode;
|
||||||
|
const struct pinctrl_dev_config *pincfg;
|
||||||
#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
|
||||||
|
@ -55,6 +57,7 @@ static int uart_imx_init(const struct device *dev)
|
||||||
UART_Type *uart = UART_STRUCT(dev);
|
UART_Type *uart = UART_STRUCT(dev);
|
||||||
const struct imx_uart_config *config = dev->config;
|
const struct imx_uart_config *config = dev->config;
|
||||||
unsigned int old_level;
|
unsigned int old_level;
|
||||||
|
int err;
|
||||||
|
|
||||||
/* disable interrupts */
|
/* disable interrupts */
|
||||||
old_level = irq_lock();
|
old_level = irq_lock();
|
||||||
|
@ -68,6 +71,11 @@ static int uart_imx_init(const struct device *dev)
|
||||||
.direction = uartDirectionTxRx
|
.direction = uartDirectionTxRx
|
||||||
};
|
};
|
||||||
|
|
||||||
|
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get current module clock frequency */
|
/* Get current module clock frequency */
|
||||||
initConfig.clockRate = get_uart_clock_freq(uart);
|
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), \
|
.base = (UART_Type *) DT_INST_REG_ADDR(n), \
|
||||||
.baud_rate = DT_INST_PROP(n, current_speed), \
|
.baud_rate = DT_INST_PROP(n, current_speed), \
|
||||||
.modem_mode = DT_INST_PROP(n, modem_mode), \
|
.modem_mode = DT_INST_PROP(n, modem_mode), \
|
||||||
|
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
|
||||||
IRQ_FUNC_INIT \
|
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; \
|
static const struct imx_uart_config imx_uart_##n##_config; \
|
||||||
\
|
\
|
||||||
|
PINCTRL_DT_INST_DEFINE(n); \
|
||||||
|
\
|
||||||
DEVICE_DT_INST_DEFINE(n, &uart_imx_init, NULL, \
|
DEVICE_DT_INST_DEFINE(n, &uart_imx_init, NULL, \
|
||||||
&imx_uart_##n##_data, &imx_uart_##n##_config, \
|
&imx_uart_##n##_data, &imx_uart_##n##_config, \
|
||||||
PRE_KERNEL_1, \
|
PRE_KERNEL_1, \
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: iMX UART
|
||||||
|
|
||||||
compatible: "nxp,imx-uart"
|
compatible: "nxp,imx-uart"
|
||||||
|
|
||||||
include: uart-controller.yaml
|
include: [uart-controller.yaml, pinctrl-device.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
reg:
|
reg:
|
||||||
|
@ -23,3 +23,9 @@ properties:
|
||||||
type: int
|
type: int
|
||||||
required: true
|
required: true
|
||||||
description: Set the RDC permission for this peripheral
|
description: Set the RDC permission for this peripheral
|
||||||
|
|
||||||
|
pinctrl-0:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
pinctrl-names:
|
||||||
|
required: true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue