drivers: uart: mcux_flexcomm: Convert to DT_INST

Convert driver to use new DT_INST macros throughout.  Removed per
instance Kconfig symbols and replaced with DT_NODELABEL references
where needed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-04-19 10:28:52 -05:00 committed by Kumar Gala
commit d73ffa3855
4 changed files with 48 additions and 44 deletions

View file

@ -9,10 +9,6 @@ config BOARD
default "lpcxpresso54114_m4" if BOARD_LPCXPRESSO54114_M4
default "lpcxpresso54114_m0" if BOARD_LPCXPRESSO54114_M0
config UART_MCUX_FLEXCOMM_0
default y if UART_CONSOLE
depends on UART_MCUX_FLEXCOMM
if PINMUX_MCUX_LPC
config PINMUX_MCUX_LPC_PORT0

View file

@ -9,10 +9,6 @@ config BOARD
default "lpcxpresso55S69_cpu0" if BOARD_LPCXPRESSO55S69_CPU0
default "lpcxpresso55S69_cpu1" if BOARD_LPCXPRESSO55S69_CPU1
config UART_MCUX_FLEXCOMM_0
default y if UART_CONSOLE
depends on UART_MCUX_FLEXCOMM
if PINMUX_MCUX_LPC
config PINMUX_MCUX_LPC_PORT0

View file

@ -3,16 +3,10 @@
# Copyright 2017, NXP
# SPDX-License-Identifier: Apache-2.0
menuconfig UART_MCUX_FLEXCOMM
config UART_MCUX_FLEXCOMM
bool "MCUX FLEXCOMM UART driver"
depends on HAS_MCUX_FLEXCOMM
select SERIAL_HAS_DRIVER
select SERIAL_SUPPORT_INTERRUPT
help
Enable the MCUX USART driver.
config UART_MCUX_FLEXCOMM_0
bool "USART 0"
depends on UART_MCUX_FLEXCOMM
help
Enable USART 0.

View file

@ -4,6 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT nxp_lpc_usart
/** @file
* @brief USART driver for LPC54XXX and LPC55xxx families.
*
@ -284,37 +286,53 @@ static const struct uart_driver_api mcux_flexcomm_driver_api = {
#endif
};
#ifdef CONFIG_UART_MCUX_FLEXCOMM_0
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void mcux_flexcomm_config_func_0(struct device *dev);
#define UART_MCUX_FLEXCOMM_CONFIG_FUNC(n) \
static void mcux_flexcomm_config_func_##n(struct device *dev) \
{ \
IRQ_CONNECT(DT_INST_IRQN(n), \
DT_INST_IRQ(n, priority), \
mcux_flexcomm_isr, DEVICE_GET(uart_##n), 0);\
\
irq_enable(DT_INST_IRQN(n)); \
}
#define UART_MCUX_FLEXCOMM_IRQ_CFG_FUNC_INIT(n) \
.irq_config_func = mcux_flexcomm_config_func_##n
#define UART_MCUX_FLEXCOMM_INIT_CFG(n) \
UART_MCUX_FLEXCOMM_DECLARE_CFG(n, \
UART_MCUX_FLEXCOMM_IRQ_CFG_FUNC_INIT(n))
#else
#define UART_MCUX_FLEXCOMM_CONFIG_FUNC(n)
#define UART_MCUX_FLEXCOMM_IRQ_CFG_FUNC_INIT
#define UART_MCUX_FLEXCOMM_INIT_CFG(n) \
UART_MCUX_FLEXCOMM_DECLARE_CFG(n, UART_MCUX_FLEXCOMM_IRQ_CFG_FUNC_INIT)
#endif
static const struct mcux_flexcomm_config mcux_flexcomm_0_config = {
.base = (USART_Type *)DT_NXP_LPC_USART_USART_0_BASE_ADDRESS,
.clock_source = 0,
.baud_rate = DT_NXP_LPC_USART_USART_0_CURRENT_SPEED,
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
.irq_config_func = mcux_flexcomm_config_func_0,
#endif
};
static struct mcux_flexcomm_data mcux_flexcomm_0_data;
DEVICE_AND_API_INIT(usart_0, DT_NXP_LPC_USART_USART_0_LABEL,
&mcux_flexcomm_init,
&mcux_flexcomm_0_data, &mcux_flexcomm_0_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&mcux_flexcomm_driver_api);
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void mcux_flexcomm_config_func_0(struct device *dev)
{
IRQ_CONNECT(DT_NXP_LPC_USART_USART_0_IRQ_0,
DT_NXP_LPC_USART_USART_0_IRQ_0_PRIORITY,
mcux_flexcomm_isr, DEVICE_GET(usart_0), 0);
irq_enable(DT_NXP_LPC_USART_USART_0_IRQ_0);
#define UART_MCUX_FLEXCOMM_DECLARE_CFG(n, IRQ_FUNC_INIT) \
static const struct mcux_flexcomm_config mcux_flexcomm_##n##_config = { \
.base = (USART_Type *)DT_INST_REG_ADDR(n), \
.clock_source = 0, \
.baud_rate = DT_INST_PROP(n, current_speed), \
IRQ_FUNC_INIT \
}
#endif
#endif /* CONFIG_UART_MCUX_FLEXCOMM_0 */
#define UART_MCUX_FLEXCOMM_INIT(n) \
\
static struct mcux_flexcomm_data mcux_flexcomm_##n##_data; \
\
static const struct mcux_flexcomm_config mcux_flexcomm_##n##_config;\
\
DEVICE_AND_API_INIT(uart_##n, DT_INST_LABEL(n), \
&mcux_flexcomm_init, \
&mcux_flexcomm_##n##_data, \
&mcux_flexcomm_##n##_config, \
PRE_KERNEL_1, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
&mcux_flexcomm_driver_api); \
\
UART_MCUX_FLEXCOMM_CONFIG_FUNC(n) \
\
UART_MCUX_FLEXCOMM_INIT_CFG(n)
DT_INST_FOREACH(UART_MCUX_FLEXCOMM_INIT)