@@ -154,6 +154,7 @@ static inline void finalize_spi_transaction(const struct device *dev, bool deact
154154
155155 if (deactivate_cs ) {
156156 spi_context_cs_control (& dev_data -> ctx , false);
157+ pm_device_runtime_put_async (dev , K_NO_WAIT );
157158 }
158159
159160 if (NRF_SPIM_IS_320MHZ_SPIM (reg ) && !(dev_data -> ctx .config -> operation & SPI_HOLD_ON_CS )) {
@@ -163,8 +164,6 @@ static inline void finalize_spi_transaction(const struct device *dev, bool deact
163164 if (!IS_ENABLED (CONFIG_PM_DEVICE_RUNTIME )) {
164165 release_clock (dev );
165166 }
166-
167- pm_device_runtime_put_async (dev , K_NO_WAIT );
168167}
169168
170169static inline uint32_t get_nrf_spim_frequency (uint32_t frequency )
@@ -402,7 +401,7 @@ static void finish_transaction(const struct device *dev, int error)
402401 spi_context_complete (ctx , dev , error );
403402 dev_data -> busy = false;
404403
405- finalize_spi_transaction (dev , true );
404+ finalize_spi_transaction (dev , ( dev_data -> ctx . config -> operation & SPI_HOLD_ON_CS ) > 0 );
406405}
407406
408407static void transfer_next_chunk (const struct device * dev )
@@ -661,12 +660,17 @@ static DEVICE_API(spi, spi_nrfx_driver_api) = {
661660static int spim_resume (const struct device * dev )
662661{
663662 const struct spi_nrfx_config * dev_config = dev -> config ;
663+ struct spi_nrfx_data * dev_data = dev -> data ;
664664
665665 (void )pinctrl_apply_state (dev_config -> pcfg , PINCTRL_STATE_DEFAULT );
666666 /* nrfx_spim_init() will be called at configuration before
667667 * the next transfer.
668668 */
669669
670+ if (spi_context_cs_get_all (& dev_data -> ctx )) {
671+ return - EAGAIN ;
672+ }
673+
670674#ifdef CONFIG_SOC_NRF54H20_GPD
671675 nrf_gpd_retain_pins_set (dev_config -> pcfg , false);
672676#endif
@@ -688,6 +692,8 @@ static void spim_suspend(const struct device *dev)
688692 release_clock (dev );
689693 }
690694
695+ spi_context_cs_put_all (& dev_data -> ctx );
696+
691697#ifdef CONFIG_SOC_NRF54H20_GPD
692698 nrf_gpd_retain_pins_set (dev_config -> pcfg , true);
693699#endif
0 commit comments