File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -765,6 +765,28 @@ static int spi_nrfx_init(const struct device *dev)
765
765
#endif
766
766
return pm_device_driver_init (dev , spim_nrfx_pm_action );
767
767
}
768
+
769
+ static int spi_nrfx_deinit (const struct device * dev )
770
+ {
771
+ #if defined(CONFIG_PM_DEVICE )
772
+ enum pm_device_state state ;
773
+
774
+ /*
775
+ * PM must have suspended the device before driver can
776
+ * be deinitialized
777
+ */
778
+ (void )pm_device_state_get (dev , & state );
779
+ return state == PM_DEVICE_STATE_SUSPENDED ||
780
+ state == PM_DEVICE_STATE_OFF ?
781
+ 0 : - EBUSY ;
782
+ #else
783
+ /* PM suspend implementation does everything we need */
784
+ spim_suspend (dev );
785
+ #endif
786
+
787
+ return 0 ;
788
+ }
789
+
768
790
/*
769
791
* We use NODELABEL here because the nrfx API requires us to call
770
792
* functions which are named according to SoC peripheral instance
@@ -870,8 +892,9 @@ static int spi_nrfx_init(const struct device *dev)
870
892
!(DT_GPIO_FLAGS(SPIM(idx), wake_gpios) & GPIO_ACTIVE_LOW),\
871
893
"WAKE line must be configured as active high"); \
872
894
PM_DEVICE_DT_DEFINE(SPIM(idx), spim_nrfx_pm_action); \
873
- SPI_DEVICE_DT_DEFINE (SPIM(idx), \
895
+ SPI_DEVICE_DT_DEINIT_DEFINE (SPIM(idx), \
874
896
spi_nrfx_init, \
897
+ spi_nrfx_deinit, \
875
898
PM_DEVICE_DT_GET(SPIM(idx)), \
876
899
&spi_##idx##_data, \
877
900
&spi_##idx##z_config, \
You can’t perform that action at this time.
0 commit comments