9
9
* @brief I2S bus (SAI) driver for NXP i.MX RT series.
10
10
*/
11
11
12
+ #define DT_DRV_COMPAT nxp_mcux_i2s
13
+
12
14
#include <errno.h>
13
15
#include <string.h>
14
16
#include <zephyr/sys/__assert.h>
21
23
#include <zephyr/drivers/clock_control.h>
22
24
#include <zephyr/dt-bindings/clock/imx_ccm.h>
23
25
#include <zephyr/sys/barrier.h>
26
+ #include <zephyr/device.h>
24
27
#include <soc.h>
25
28
26
- #include "i2s_mcux_sai.h"
29
+ #include <fsl_sai.h>
30
+ #include <fsl_edma.h>
27
31
28
- #define LOG_DOMAIN dev_i2s_mcux
29
- #define LOG_LEVEL CONFIG_I2S_LOG_LEVEL
30
32
#include <zephyr/logging/log.h>
31
- #include <zephyr/irq.h>
32
-
33
- LOG_MODULE_REGISTER (LOG_DOMAIN );
33
+ LOG_MODULE_REGISTER (dev_i2s_mcux , CONFIG_I2S_LOG_LEVEL );
34
34
35
- #define DT_DRV_COMPAT nxp_mcux_i2s
36
35
#define NUM_DMA_BLOCKS_RX_PREP 3
37
- #define MAX_TX_DMA_BLOCKS CONFIG_DMA_TCD_QUEUE_SIZE
38
- #if (NUM_DMA_BLOCKS_RX_PREP >= CONFIG_DMA_TCD_QUEUE_SIZE )
39
- #error NUM_DMA_BLOCKS_RX_PREP must be < CONFIG_DMA_TCD_QUEUE_SIZE
40
- #endif
41
- #if defined(CONFIG_DMA_MCUX_EDMA ) && (NUM_DMA_BLOCKS_RX_PREP < 3 )
42
- #error eDMA avoids TCD coherency issue if NUM_DMA_BLOCKS_RX_PREP >= 3
43
- #endif
36
+ #if defined(CONFIG_DMA_MCUX_EDMA )
37
+ BUILD_ASSERT (NUM_DMA_BLOCKS_RX_PREP >= 3 ,
38
+ "eDMA avoids TCD coherency issue if NUM_DMA_BLOCKS_RX_PREP >= 3" );
39
+ #endif /* CONFIG_DMA_MCUX_EDMA */
40
+
41
+ #define MAX_TX_DMA_BLOCKS CONFIG_DMA_TCD_QUEUE_SIZE
42
+ BUILD_ASSERT (MAX_TX_DMA_BLOCKS > NUM_DMA_BLOCKS_RX_PREP ,
43
+ "NUM_DMA_BLOCKS_RX_PREP must be < CONFIG_DMA_TCD_QUEUE_SIZE" );
44
+
45
+ #define SAI_WORD_SIZE_BITS_MIN 8
46
+ #define SAI_WORD_SIZE_BITS_MAX 32
47
+
48
+ #define SAI_WORD_PER_FRAME_MIN 0
49
+ #define SAI_WORD_PER_FRAME_MAX 32
44
50
45
51
/*
46
52
* SAI driver uses source_gather_en/dest_scatter_en feature of DMA, and relies
@@ -65,7 +71,7 @@ LOG_MODULE_REGISTER(LOG_DOMAIN);
65
71
* (may optionally block) from out_queue and presented to application.
66
72
*/
67
73
struct stream {
68
- int32_t state ;
74
+ enum i2s_state state ;
69
75
uint32_t dma_channel ;
70
76
uint32_t start_channel ;
71
77
void (* irq_call_back )(void );
@@ -111,10 +117,6 @@ struct i2s_dev_data {
111
117
void * rx_out_msgs [CONFIG_I2S_RX_BLOCK_COUNT ];
112
118
};
113
119
114
- static void i2s_dma_tx_callback (const struct device * , void * , uint32_t , int );
115
- static void i2s_tx_stream_disable (const struct device * , bool drop );
116
- static void i2s_rx_stream_disable (const struct device * , bool in_drop , bool out_drop );
117
-
118
120
static inline void i2s_purge_stream_buffers (struct stream * strm , struct k_mem_slab * mem_slab ,
119
121
bool in_drop , bool out_drop )
120
122
{
@@ -388,7 +390,6 @@ static void i2s_dma_rx_callback(const struct device *dma_dev, void *arg, uint32_
388
390
LOG_ERR ("%p -> in_queue %p err %d" , buffer , & strm -> in_queue ,
389
391
ret );
390
392
}
391
-
392
393
}
393
394
} else {
394
395
i2s_rx_stream_disable (dev , true, false);
@@ -399,6 +400,8 @@ static void i2s_dma_rx_callback(const struct device *dma_dev, void *arg, uint32_
399
400
case I2S_STATE_ERROR :
400
401
i2s_rx_stream_disable (dev , true, true);
401
402
break ;
403
+ default :
404
+ break ;
402
405
}
403
406
}
404
407
0 commit comments