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)
765765#endif
766766 return pm_device_driver_init (dev , spim_nrfx_pm_action );
767767}
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+
768790/*
769791 * We use NODELABEL here because the nrfx API requires us to call
770792 * functions which are named according to SoC peripheral instance
@@ -870,8 +892,9 @@ static int spi_nrfx_init(const struct device *dev)
870892 !(DT_GPIO_FLAGS(SPIM(idx), wake_gpios) & GPIO_ACTIVE_LOW),\
871893 "WAKE line must be configured as active high"); \
872894 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), \
874896 spi_nrfx_init, \
897+ spi_nrfx_deinit, \
875898 PM_DEVICE_DT_GET(SPIM(idx)), \
876899 &spi_##idx##_data, \
877900 &spi_##idx##z_config, \
You can’t perform that action at this time.
0 commit comments