@@ -33,21 +33,20 @@ struct i2s_nrfx_drv_data {
3333 struct k_msgq tx_queue ;
3434 struct stream_cfg rx ;
3535 struct k_msgq rx_queue ;
36- const nrfx_i2s_t * p_i2s ;
36+ nrfx_i2s_t i2s ;
3737 const uint32_t * last_tx_buffer ;
3838 enum i2s_state state ;
3939 enum i2s_dir active_dir ;
4040 bool stop ; /* stop after the current (TX or RX) block */
4141 bool discard_rx ; /* discard further RX blocks */
4242 volatile bool next_tx_buffer_needed ;
43- bool tx_configured : 1 ;
44- bool rx_configured : 1 ;
45- bool request_clock : 1 ;
43+ bool tx_configured : 1 ;
44+ bool rx_configured : 1 ;
45+ bool request_clock : 1 ;
4646};
4747
4848struct i2s_nrfx_drv_cfg {
4949 nrfx_i2s_data_handler_t data_handler ;
50- nrfx_i2s_t i2s ;
5150 nrfx_i2s_config_t nrfx_def_cfg ;
5251 const struct pinctrl_dev_config * pcfg ;
5352 enum clock_source {
@@ -81,7 +80,7 @@ static void find_suitable_clock(const struct i2s_nrfx_drv_cfg *drv_cfg,
8180 .allow_bypass = IS_ENABLED (CONFIG_I2S_NRFX_ALLOW_MCK_BYPASS ),
8281 };
8382
84- if (nrfx_i2s_prescalers_calc (& clk_params , & config -> prescalers ) != NRFX_SUCCESS ) {
83+ if (nrfx_i2s_prescalers_calc (& clk_params , & config -> prescalers )) {
8584 LOG_ERR ("Failed to find suitable I2S clock configuration." );
8685 }
8786}
@@ -134,7 +133,7 @@ static bool supply_next_buffers(struct i2s_nrfx_drv_data *drv_data,
134133 if (drv_data -> active_dir != I2S_DIR_TX ) { /* -> RX active */
135134 if (!get_next_rx_buffer (drv_data , next )) {
136135 drv_data -> state = I2S_STATE_ERROR ;
137- nrfx_i2s_stop (drv_data -> p_i2s );
136+ nrfx_i2s_stop (& drv_data -> i2s );
138137 return false;
139138 }
140139 /* Set buffer size if there is no TX buffer (which effectively
@@ -149,7 +148,7 @@ static bool supply_next_buffers(struct i2s_nrfx_drv_data *drv_data,
149148 drv_data -> last_tx_buffer = next -> p_tx_buffer ;
150149
151150 LOG_DBG ("Next buffers: %p/%p" , next -> p_tx_buffer , next -> p_rx_buffer );
152- nrfx_i2s_next_buffers_set (drv_data -> p_i2s , next );
151+ nrfx_i2s_next_buffers_set (& drv_data -> i2s , next );
153152 return true;
154153}
155154
@@ -181,7 +180,7 @@ static void data_handler(const struct device *dev,
181180 }
182181 drv_data -> last_tx_buffer = NULL ;
183182 }
184- nrfx_i2s_uninit (drv_data -> p_i2s );
183+ nrfx_i2s_uninit (& drv_data -> i2s );
185184 if (drv_data -> request_clock ) {
186185 (void )onoff_release (drv_data -> clk_mgr );
187186 }
@@ -198,7 +197,7 @@ static void data_handler(const struct device *dev,
198197 LOG_ERR ("Next buffers not supplied on time" );
199198 drv_data -> state = I2S_STATE_ERROR ;
200199 }
201- nrfx_i2s_stop (drv_data -> p_i2s );
200+ nrfx_i2s_stop (& drv_data -> i2s );
202201 return ;
203202 }
204203
@@ -248,7 +247,7 @@ static void data_handler(const struct device *dev,
248247 }
249248
250249 if (stop_transfer ) {
251- nrfx_i2s_stop (drv_data -> p_i2s );
250+ nrfx_i2s_stop (& drv_data -> i2s );
252251 } else if (status & NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED ) {
253252 nrfx_i2s_buffers_t next = { 0 };
254253
@@ -419,7 +418,7 @@ static int i2s_nrfx_configure(const struct device *dev, enum i2s_dir dir,
419418 * the MCK output is used), find a suitable clock configuration for it.
420419 */
421420 if (nrfx_cfg .mode == NRF_I2S_MODE_MASTER ||
422- (nrf_i2s_mck_pin_get (drv_cfg -> i2s .p_reg ) & I2S_PSEL_MCK_CONNECT_Msk )
421+ (nrf_i2s_mck_pin_get (drv_data -> i2s .p_reg ) & I2S_PSEL_MCK_CONNECT_Msk )
423422 == I2S_PSEL_MCK_CONNECT_Connected << I2S_PSEL_MCK_CONNECT_Pos ) {
424423 find_suitable_clock (drv_cfg , & nrfx_cfg , i2s_cfg );
425424 /* Unless the PCLK32M source is used with the HFINT oscillator
@@ -578,7 +577,7 @@ static int start_transfer(struct i2s_nrfx_drv_data *drv_data)
578577 /* Failed to allocate next RX buffer */
579578 ret = - ENOMEM ;
580579 } else {
581- nrfx_err_t err ;
580+ int err ;
582581
583582 /* It is necessary to set buffer size here only for I2S_DIR_RX,
584583 * because only then the get_next_tx_buffer() call in the if
@@ -591,16 +590,16 @@ static int start_transfer(struct i2s_nrfx_drv_data *drv_data)
591590
592591 drv_data -> last_tx_buffer = initial_buffers .p_tx_buffer ;
593592
594- err = nrfx_i2s_start (drv_data -> p_i2s , & initial_buffers , 0 );
595- if (err == NRFX_SUCCESS ) {
593+ err = nrfx_i2s_start (& drv_data -> i2s , & initial_buffers , 0 );
594+ if (err == 0 ) {
596595 return 0 ;
597596 }
598597
599- LOG_ERR ("Failed to start I2S transfer: 0x%08x " , err );
598+ LOG_ERR ("Failed to start I2S transfer: %d " , err );
600599 ret = - EIO ;
601600 }
602601
603- nrfx_i2s_uninit (drv_data -> p_i2s );
602+ nrfx_i2s_uninit (& drv_data -> i2s );
604603 if (drv_data -> request_clock ) {
605604 (void )onoff_release (drv_data -> clk_mgr );
606605 }
@@ -629,7 +628,7 @@ static void clock_started_callback(struct onoff_manager *mgr,
629628 * the actual transfer in such case.
630629 */
631630 if (drv_data -> state == I2S_STATE_READY ) {
632- nrfx_i2s_uninit (drv_data -> p_i2s );
631+ nrfx_i2s_uninit (& drv_data -> i2s );
633632 (void )onoff_release (drv_data -> clk_mgr );
634633 } else {
635634 (void )start_transfer (drv_data );
@@ -640,22 +639,22 @@ static int trigger_start(const struct device *dev)
640639{
641640 struct i2s_nrfx_drv_data * drv_data = dev -> data ;
642641 const struct i2s_nrfx_drv_cfg * drv_cfg = dev -> config ;
643- nrfx_err_t err ;
642+ int err ;
644643 int ret ;
645644 const nrfx_i2s_config_t * nrfx_cfg = (drv_data -> active_dir == I2S_DIR_TX )
646645 ? & drv_data -> tx .nrfx_cfg
647646 : & drv_data -> rx .nrfx_cfg ;
648647
649- err = nrfx_i2s_init (drv_data -> p_i2s , nrfx_cfg , drv_cfg -> data_handler );
650- if (err != NRFX_SUCCESS ) {
651- LOG_ERR ("Failed to initialize I2S: 0x%08x " , err );
648+ err = nrfx_i2s_init (& drv_data -> i2s , nrfx_cfg , drv_cfg -> data_handler );
649+ if (err != 0 ) {
650+ LOG_ERR ("Failed to initialize I2S: %d " , err );
652651 return - EIO ;
653652 }
654653
655654 drv_data -> state = I2S_STATE_RUNNING ;
656655
657656#if NRF_I2S_HAS_CLKCONFIG
658- nrf_i2s_clk_configure (drv_cfg -> i2s . p_reg ,
657+ nrf_i2s_clk_configure (& drv_data -> i2s ,
659658 drv_cfg -> clk_src == ACLK ? NRF_I2S_CLKSRC_ACLK
660659 : NRF_I2S_CLKSRC_PCLK32M ,
661660 nrfx_cfg -> prescalers .enable_bypass );
@@ -669,7 +668,7 @@ static int trigger_start(const struct device *dev)
669668 clock_started_callback );
670669 ret = onoff_request (drv_data -> clk_mgr , & drv_data -> clk_cli );
671670 if (ret < 0 ) {
672- nrfx_i2s_uninit (drv_data -> p_i2s );
671+ nrfx_i2s_uninit (& drv_data -> i2s );
673672 drv_data -> state = I2S_STATE_READY ;
674673
675674 LOG_ERR ("Failed to request clock: %d" , ret );
@@ -776,7 +775,7 @@ static int i2s_nrfx_trigger(const struct device *dev,
776775 case I2S_TRIGGER_DROP :
777776 if (drv_data -> state != I2S_STATE_READY ) {
778777 drv_data -> discard_rx = true;
779- nrfx_i2s_stop (drv_data -> p_i2s );
778+ nrfx_i2s_stop (& drv_data -> i2s );
780779 }
781780 purge_queue (dev , dir );
782781 drv_data -> state = I2S_STATE_READY ;
@@ -835,7 +834,6 @@ static DEVICE_API(i2s, i2s_nrf_drv_api) = {
835834 PINCTRL_DT_DEFINE(I2S(idx)); \
836835 static const struct i2s_nrfx_drv_cfg i2s_nrfx_cfg##idx = { \
837836 .data_handler = data_handler##idx, \
838- .i2s = NRFX_I2S_INSTANCE(idx), \
839837 .nrfx_def_cfg = NRFX_I2S_DEFAULT_CONFIG( \
840838 NRF_I2S_PIN_NOT_CONNECTED, \
841839 NRF_I2S_PIN_NOT_CONNECTED, \
@@ -849,8 +847,9 @@ static DEVICE_API(i2s, i2s_nrf_drv_api) = {
849847 }; \
850848 static struct i2s_nrfx_drv_data i2s_nrfx_data##idx = { \
851849 .state = I2S_STATE_READY, \
852- .p_i2s = &i2s_nrfx_cfg ##idx.i2s \
850+ .i2s = NRFX_I2S_INSTANCE(NRF_I2S ##idx), \
853851 }; \
852+ NRFX_INSTANCE_IRQ_HANDLER_DEFINE(i2s, idx, &i2s_nrfx_data##idx.i2s); \
854853 static int i2s_nrfx_init##idx(const struct device *dev) \
855854 { \
856855 IRQ_CONNECT(DT_IRQN(I2S(idx)), DT_IRQ(I2S(idx), priority), \
0 commit comments