7
7
8
8
#define DT_DRV_COMPAT nxp_lpuart
9
9
10
+ #define LPUART_ASYNC_ENABLE \
11
+ IS_ENABLED(CONFIG_UART_ASYNC_API) && IS_ENABLED(CONFIG_UART_NXP_LPUART_ASYNC_API_SUPPORT)
12
+
10
13
#include <errno.h>
11
14
#include <zephyr/device.h>
12
15
#include <zephyr/drivers/uart.h>
15
18
#include <zephyr/kernel.h>
16
19
#include <zephyr/pm/policy.h>
17
20
#include <zephyr/drivers/pinctrl.h>
18
- #ifdef CONFIG_UART_ASYNC_API
21
+ #if LPUART_ASYNC_ENABLE
19
22
#include <zephyr/drivers/dma.h>
20
23
#endif
21
24
#include <zephyr/logging/log.h>
@@ -40,21 +43,21 @@ LOG_MODULE_REGISTER(uart_mcux_lpuart, LOG_LEVEL_ERR);
40
43
#define LPUART_HAS_MCR 1
41
44
#endif
42
45
43
- #if defined( CONFIG_UART_ASYNC_API ) && defined(CONFIG_UART_INTERRUPT_DRIVEN )
46
+ #if LPUART_ASYNC_ENABLE && defined(CONFIG_UART_INTERRUPT_DRIVEN )
44
47
/* there are already going to be build errors, but at least this message will
45
48
* be the first error from this driver making the reason clear
46
49
*/
47
50
BUILD_ASSERT (IS_ENABLED (CONFIG_UART_EXCLUSIVE_API_CALLBACKS ), ""
48
51
"LPUART must use exclusive api callbacks" );
49
52
#endif
50
53
51
- #ifdef CONFIG_UART_ASYNC_API
54
+ #if LPUART_ASYNC_ENABLE
52
55
struct lpuart_dma_config {
53
56
const struct device * dma_dev ;
54
57
const uint32_t dma_channel ;
55
58
struct dma_config dma_cfg ;
56
59
};
57
- #endif /* CONFIG_UART_ASYNC_API */
60
+ #endif /* LPUART_ASYNC_ENABLE */
58
61
59
62
struct mcux_lpuart_config {
60
63
LPUART_Type * base ;
@@ -72,13 +75,13 @@ struct mcux_lpuart_config {
72
75
#ifdef CONFIG_UART_MCUX_LPUART_ISR_SUPPORT
73
76
void (* irq_config_func )(const struct device * dev );
74
77
#endif
75
- #ifdef CONFIG_UART_ASYNC_API
78
+ #if LPUART_ASYNC_ENABLE
76
79
const struct lpuart_dma_config rx_dma_config ;
77
80
const struct lpuart_dma_config tx_dma_config ;
78
- #endif /* CONFIG_UART_ASYNC_API */
81
+ #endif /* LPUART_ASYNC_ENABLE */
79
82
};
80
83
81
- #ifdef CONFIG_UART_ASYNC_API
84
+ #if LPUART_ASYNC_ENABLE
82
85
struct mcux_lpuart_rx_dma_params {
83
86
struct dma_block_config active_dma_block ;
84
87
uint8_t * buf ;
@@ -126,7 +129,7 @@ struct mcux_lpuart_data {
126
129
bool tx_poll_stream_on ;
127
130
bool tx_int_stream_on ;
128
131
#endif /* CONFIG_PM */
129
- #ifdef CONFIG_UART_ASYNC_API
132
+ #if LPUART_ASYNC_ENABLE
130
133
struct mcux_lpuart_async_data async ;
131
134
#endif
132
135
struct uart_config uart_config ;
@@ -423,7 +426,7 @@ static void mcux_lpuart_irq_callback_set(const struct device *dev,
423
426
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
424
427
425
428
426
- #ifdef CONFIG_UART_ASYNC_API
429
+ #if LPUART_ASYNC_ENABLE
427
430
static inline void async_timer_start (struct k_work_delayable * work , size_t timeout_us )
428
431
{
429
432
if ((timeout_us != SYS_FOREVER_US ) && (timeout_us != 0 )) {
@@ -906,7 +909,7 @@ static void mcux_lpuart_async_tx_timeout(struct k_work *work)
906
909
(void )mcux_lpuart_tx_abort (dev );
907
910
}
908
911
909
- #endif /* CONFIG_UART_ASYNC_API */
912
+ #endif /* LPUART_ASYNC_ENABLE */
910
913
911
914
#if CONFIG_UART_MCUX_LPUART_ISR_SUPPORT
912
915
@@ -925,7 +928,7 @@ static inline void mcux_lpuart_irq_driven_isr(const struct device *dev,
925
928
}
926
929
#endif
927
930
928
- #ifdef CONFIG_UART_ASYNC_API
931
+ #if LPUART_ASYNC_ENABLE
929
932
static inline void mcux_lpuart_async_isr (struct mcux_lpuart_data * data ,
930
933
const struct mcux_lpuart_config * config ,
931
934
const uint32_t status ) {
@@ -960,15 +963,15 @@ static void mcux_lpuart_isr(const struct device *dev)
960
963
}
961
964
#endif /* CONFIG_PM */
962
965
963
- #if defined( CONFIG_UART_ASYNC_API ) && defined(CONFIG_UART_INTERRUPT_DRIVEN )
966
+ #if LPUART_ASYNC_ENABLE && defined(CONFIG_UART_INTERRUPT_DRIVEN )
964
967
if (data -> api_type == LPUART_IRQ_DRIVEN ) {
965
968
mcux_lpuart_irq_driven_isr (dev , data , config , status );
966
969
} else if (data -> api_type == LPUART_ASYNC ) {
967
970
mcux_lpuart_async_isr (data , config , status );
968
971
}
969
972
#elif defined(CONFIG_UART_INTERRUPT_DRIVEN )
970
973
mcux_lpuart_irq_driven_isr (dev , data , config , status );
971
- #elif defined( CONFIG_UART_ASYNC_API )
974
+ #elif LPUART_ASYNC_ENABLE
972
975
mcux_lpuart_async_isr (data , config , status );
973
976
#endif /* API */
974
977
}
@@ -1101,7 +1104,7 @@ static int mcux_lpuart_configure_basic(const struct device *dev, const struct ua
1101
1104
return 0 ;
1102
1105
}
1103
1106
1104
- #ifdef CONFIG_UART_ASYNC_API
1107
+ #if LPUART_ASYNC_ENABLE
1105
1108
static int mcux_lpuart_configure_async (const struct device * dev )
1106
1109
{
1107
1110
const struct mcux_lpuart_config * config = dev -> config ;
@@ -1401,14 +1404,14 @@ static DEVICE_API(uart, mcux_lpuart_driver_api) = {
1401
1404
.irq_update = mcux_lpuart_irq_update ,
1402
1405
.irq_callback_set = mcux_lpuart_irq_callback_set ,
1403
1406
#endif
1404
- #ifdef CONFIG_UART_ASYNC_API
1407
+ #if LPUART_ASYNC_ENABLE
1405
1408
.callback_set = mcux_lpuart_callback_set ,
1406
1409
.tx = mcux_lpuart_tx ,
1407
1410
.tx_abort = mcux_lpuart_tx_abort ,
1408
1411
.rx_enable = mcux_lpuart_rx_enable ,
1409
1412
.rx_buf_rsp = mcux_lpuart_rx_buf_rsp ,
1410
1413
.rx_disable = mcux_lpuart_rx_disable ,
1411
- #endif /* CONFIG_UART_ASYNC_API */
1414
+ #endif /* LPUART_ASYNC_ENABLE */
1412
1415
#ifdef CONFIG_UART_LINE_CTRL
1413
1416
.line_ctrl_set = mcux_lpuart_line_ctrl_set ,
1414
1417
.line_ctrl_get = mcux_lpuart_line_ctrl_get ,
@@ -1451,7 +1454,7 @@ static DEVICE_API(uart, mcux_lpuart_driver_api) = {
1451
1454
#define MCUX_LPUART_IRQ_DEFINE (n )
1452
1455
#endif /* CONFIG_UART_MCUX_LPUART_ISR_SUPPORT */
1453
1456
1454
- #ifdef CONFIG_UART_ASYNC_API
1457
+ #if LPUART_ASYNC_ENABLE
1455
1458
#define TX_DMA_CONFIG (id ) \
1456
1459
.tx_dma_config = { \
1457
1460
.dma_dev = \
@@ -1502,7 +1505,7 @@ static DEVICE_API(uart, mcux_lpuart_driver_api) = {
1502
1505
#else
1503
1506
#define RX_DMA_CONFIG (n )
1504
1507
#define TX_DMA_CONFIG (n )
1505
- #endif /* CONFIG_UART_ASYNC_API */
1508
+ #endif /* LPUART_ASYNC_ENABLE */
1506
1509
1507
1510
#define FLOW_CONTROL (n ) \
1508
1511
DT_INST_PROP(n, hw_flow_control) \
0 commit comments