diff --git a/drivers/serial/Kconfig.mcux_lpuart b/drivers/serial/Kconfig.mcux_lpuart index 920642cfd81..d9f1440a762 100644 --- a/drivers/serial/Kconfig.mcux_lpuart +++ b/drivers/serial/Kconfig.mcux_lpuart @@ -25,4 +25,14 @@ menuconfig UART_MCUX_LPUART_1 help Enable UART 1. +menuconfig UART_MCUX_LPUART_2 + bool "UART 2" + help + Enable UART 2. + +menuconfig UART_MCUX_LPUART_3 + bool "UART 3" + help + Enable UART 3. + endif # UART_MCUX_LPUART diff --git a/drivers/serial/uart_mcux_lpuart.c b/drivers/serial/uart_mcux_lpuart.c index a2f109d6f1c..2d280bd0fd2 100644 --- a/drivers/serial/uart_mcux_lpuart.c +++ b/drivers/serial/uart_mcux_lpuart.c @@ -359,3 +359,79 @@ static void mcux_lpuart_config_func_1(struct device *dev) #endif #endif /* CONFIG_UART_MCUX_LPUART_1 */ + +#ifdef CONFIG_UART_MCUX_LPUART_2 + +#ifdef CONFIG_UART_INTERRUPT_DRIVEN +static void mcux_lpuart_config_func_2(struct device *dev); +#endif + +static const struct mcux_lpuart_config mcux_lpuart_2_config = { + .base = (LPUART_Type *) CONFIG_UART_MCUX_LPUART_2_BASE_ADDRESS, + .clock_name = CONFIG_UART_MCUX_LPUART_2_CLOCK_NAME, + .clock_subsys = + (clock_control_subsys_t)CONFIG_UART_MCUX_LPUART_2_CLOCK_SUBSYS, + .baud_rate = CONFIG_UART_MCUX_LPUART_2_BAUD_RATE, +#ifdef CONFIG_UART_INTERRUPT_DRIVEN + .irq_config_func = mcux_lpuart_config_func_2, +#endif +}; + +static struct mcux_lpuart_data mcux_lpuart_2_data; + +DEVICE_AND_API_INIT(uart_2, CONFIG_UART_MCUX_LPUART_2_NAME, + &mcux_lpuart_init, + &mcux_lpuart_2_data, &mcux_lpuart_2_config, + PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, + &mcux_lpuart_driver_api); + +#ifdef CONFIG_UART_INTERRUPT_DRIVEN +static void mcux_lpuart_config_func_2(struct device *dev) +{ + IRQ_CONNECT(CONFIG_UART_MCUX_LPUART_2_IRQ, + CONFIG_UART_MCUX_LPUART_2_IRQ_PRI, + mcux_lpuart_isr, DEVICE_GET(uart_2), 0); + + irq_enable(CONFIG_UART_MCUX_LPUART_2_IRQ); +} +#endif + +#endif /* CONFIG_UART_MCUX_LPUART_2 */ + +#ifdef CONFIG_UART_MCUX_LPUART_3 + +#ifdef CONFIG_UART_INTERRUPT_DRIVEN +static void mcux_lpuart_config_func_3(struct device *dev); +#endif + +static const struct mcux_lpuart_config mcux_lpuart_3_config = { + .base = (LPUART_Type *) CONFIG_UART_MCUX_LPUART_3_BASE_ADDRESS, + .clock_name = CONFIG_UART_MCUX_LPUART_3_CLOCK_NAME, + .clock_subsys = + (clock_control_subsys_t)CONFIG_UART_MCUX_LPUART_3_CLOCK_SUBSYS, + .baud_rate = CONFIG_UART_MCUX_LPUART_3_BAUD_RATE, +#ifdef CONFIG_UART_INTERRUPT_DRIVEN + .irq_config_func = mcux_lpuart_config_func_3, +#endif +}; + +static struct mcux_lpuart_data mcux_lpuart_3_data; + +DEVICE_AND_API_INIT(uart_3, CONFIG_UART_MCUX_LPUART_3_NAME, + &mcux_lpuart_init, + &mcux_lpuart_3_data, &mcux_lpuart_3_config, + PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, + &mcux_lpuart_driver_api); + +#ifdef CONFIG_UART_INTERRUPT_DRIVEN +static void mcux_lpuart_config_func_3(struct device *dev) +{ + IRQ_CONNECT(CONFIG_UART_MCUX_LPUART_3_IRQ, + CONFIG_UART_MCUX_LPUART_3_IRQ_PRI, + mcux_lpuart_isr, DEVICE_GET(uart_3), 0); + + irq_enable(CONFIG_UART_MCUX_LPUART_3_IRQ); +} +#endif + +#endif /* CONFIG_UART_MCUX_LPUART_3 */