@@ -75,13 +75,12 @@ struct i2s_cavs_config {
7575 struct i2s_cavs_mn_div * mn_regs ;
7676 uint32_t irq_id ;
7777 void (* irq_connect )(void );
78- const char * dma_name ;
78+ const struct device * dev_dma ;
7979};
8080
8181/* Device run time data */
8282struct i2s_cavs_dev_data {
8383 struct i2s_config cfg ;
84- const struct device * dev_dma ;
8584 struct stream tx ;
8685 struct stream rx ;
8786};
@@ -140,10 +139,10 @@ static void i2s_dma_tx_callback(const struct device *dma_dev, void *arg,
140139 ret = k_msgq_get (& strm -> in_queue , & buffer , K_NO_WAIT );
141140 if (ret == 0 ) {
142141 /* reload the DMA */
143- dma_reload (dev_data -> dev_dma , strm -> dma_channel ,
142+ dma_reload (dev_cfg -> dev_dma , strm -> dma_channel ,
144143 (uint32_t )buffer , (uint32_t )& ssp -> ssd ,
145144 dev_data -> cfg .block_size );
146- dma_start (dev_data -> dev_dma , strm -> dma_channel );
145+ dma_start (dev_cfg -> dev_dma , strm -> dma_channel );
147146 ssp -> ssc1 |= SSCR1_TSRE ;
148147 k_msgq_put (& strm -> out_queue , & buffer , K_NO_WAIT );
149148 }
@@ -157,13 +156,13 @@ static void i2s_dma_tx_callback(const struct device *dma_dev, void *arg,
157156 LOG_ERR ("DMA status %08x channel %u k_msgq_get ret %d" ,
158157 status , channel , ret );
159158 strm -> state = I2S_STATE_STOPPING ;
160- i2s_tx_stream_disable (dev_data , ssp , dev_data -> dev_dma );
159+ i2s_tx_stream_disable (dev_data , ssp , dev_cfg -> dev_dma );
161160 }
162161
163162 break ;
164163
165164 case I2S_STATE_STOPPING :
166- i2s_tx_stream_disable (dev_data , ssp , dev_data -> dev_dma );
165+ i2s_tx_stream_disable (dev_data , ssp , dev_cfg -> dev_dma );
167166 break ;
168167 }
169168}
@@ -200,7 +199,7 @@ static void i2s_dma_rx_callback(const struct device *dma_dev, void *arg,
200199 if (ret != 0 ) {
201200 LOG_ERR ("buffer alloc from slab %p err %d" ,
202201 dev_data -> cfg .mem_slab , ret );
203- i2s_rx_stream_disable (dev_data , ssp , dev_data -> dev_dma );
202+ i2s_rx_stream_disable (dev_data , ssp , dev_cfg -> dev_dma );
204203 strm -> state = I2S_STATE_READY ;
205204 } else {
206205 /* put buffer in input queue */
@@ -213,15 +212,15 @@ static void i2s_dma_rx_callback(const struct device *dma_dev, void *arg,
213212 SOC_DCACHE_INVALIDATE (buffer , dev_data -> cfg .block_size );
214213
215214 /* reload the DMA */
216- dma_reload (dev_data -> dev_dma , strm -> dma_channel ,
215+ dma_reload (dev_cfg -> dev_dma , strm -> dma_channel ,
217216 (uint32_t )& ssp -> ssd , (uint32_t )buffer ,
218217 dev_data -> cfg .block_size );
219- dma_start (dev_data -> dev_dma , strm -> dma_channel );
218+ dma_start (dev_cfg -> dev_dma , strm -> dma_channel );
220219 ssp -> ssc1 |= SSCR1_RSRE ;
221220 }
222221 break ;
223222 case I2S_STATE_STOPPING :
224- i2s_rx_stream_disable (dev_data , ssp , dev_data -> dev_dma );
223+ i2s_rx_stream_disable (dev_data , ssp , dev_cfg -> dev_dma );
225224 strm -> state = I2S_STATE_READY ;
226225 break ;
227226 }
@@ -459,7 +458,7 @@ static int i2s_cavs_configure(const struct device *dev, enum i2s_dir dir,
459458 dma_block -> source_address = (uint32_t )NULL ;
460459 dma_block -> dest_address = (uint32_t )& ssp -> ssd ;
461460
462- ret = dma_config (dev_data -> dev_dma , dev_data -> tx .dma_channel ,
461+ ret = dma_config (dev_cfg -> dev_dma , dev_data -> tx .dma_channel ,
463462 & dev_data -> tx .dma_cfg );
464463 if (ret < 0 ) {
465464 LOG_ERR ("dma_config failed: %d" , ret );
@@ -471,7 +470,7 @@ static int i2s_cavs_configure(const struct device *dev, enum i2s_dir dir,
471470 dma_block -> source_address = (uint32_t )& ssp -> ssd ;
472471 dma_block -> dest_address = (uint32_t )NULL ;
473472
474- ret = dma_config (dev_data -> dev_dma , dev_data -> rx .dma_channel ,
473+ ret = dma_config (dev_cfg -> dev_dma , dev_data -> rx .dma_channel ,
475474 & dev_data -> rx .dma_cfg );
476475 if (ret < 0 ) {
477476 LOG_ERR ("dma_config failed: %d" , ret );
@@ -656,10 +655,10 @@ static int i2s_cavs_trigger(const struct device *dev, enum i2s_dir dir,
656655
657656 if (dir == I2S_DIR_TX ) {
658657 ret = i2s_tx_stream_start (dev_data , ssp ,
659- dev_data -> dev_dma );
658+ dev_cfg -> dev_dma );
660659 } else {
661660 ret = i2s_rx_stream_start (dev_data , ssp ,
662- dev_data -> dev_dma );
661+ dev_cfg -> dev_dma );
663662 }
664663
665664 if (ret < 0 ) {
@@ -771,9 +770,8 @@ static int i2s_cavs_initialize(const struct device *dev)
771770 const struct i2s_cavs_config * const dev_cfg = DEV_CFG (dev );
772771 struct i2s_cavs_dev_data * const dev_data = DEV_DATA (dev );
773772
774- dev_data -> dev_dma = device_get_binding (dev_cfg -> dma_name );
775- if (!dev_data -> dev_dma ) {
776- LOG_ERR ("%s device not found" , dev_cfg -> dma_name );
773+ if (!device_is_ready (dev_cfg -> dev_dma )) {
774+ LOG_ERR ("%s device not ready" , dev_cfg -> dev_dma -> name );
777775 return - ENODEV ;
778776 }
779777
@@ -823,7 +821,7 @@ static const struct i2s_driver_api i2s_cavs_driver_api = {
823821 DT_INST_REG_ADDR_BY_IDX(n, 1), \
824822 .irq_id = DT_INST_IRQN(n), \
825823 .irq_connect = i2s_cavs_irq_connect_##n, \
826- .dma_name = DT_INST_DMAS_LABEL_BY_NAME( n, tx), \
824+ .dev_dma = DEVICE_DT_GET(DT_INST_DMAS_CTLR_BY_NAME( n, tx)), \
827825 }; \
828826 \
829827 static struct i2s_cavs_dev_data i2s_cavs_data_##n = { \
0 commit comments