1313#include  <zephyr/pm/device.h> 
1414#include  <zephyr/pm/device_runtime.h> 
1515
16+ #if  DT_ANY_INST_HAS_PROP_STATUS_OKAY (reset_gpios ) &&  defined(CONFIG_MSPI_NRFE )
17+ #include  <drivers/mspi/nrf_mspi.h> 
18+ #endif 
19+ 
1620#include  "jesd216.h" 
1721#include  "spi_nor.h" 
1822
@@ -22,6 +26,10 @@ LOG_MODULE_REGISTER(flash_mspi_nor, CONFIG_FLASH_LOG_LEVEL);
2226#define  WITH_RESET_GPIO  1
2327#endif 
2428
29+ #if  defined(WITH_RESET_GPIO ) &&  defined(CONFIG_MSPI_NRFE )
30+ #define  SDP_MSPI_WITH_RESET  1
31+ #endif 
32+ 
2533#define  FLASH_MX25R_LH_MASK  BIT(1)
2634
2735static  uint8_t  hp_payload [3 ] =  {SPI_NOR_QE_BIT , 0x0 , FLASH_MX25R_LH_MASK };
@@ -229,6 +237,9 @@ struct flash_mspi_nor_config {
229237	struct  gpio_dt_spec  reset ;
230238	uint32_t  reset_pulse_us ;
231239	uint32_t  reset_recovery_us ;
240+ #if  defined (SDP_MSPI_WITH_RESET )
241+ 	uint8_t  reset_port_num ;
242+ #endif 
232243#endif 
233244#if  defined(CONFIG_FLASH_PAGE_LAYOUT )
234245	struct  flash_pages_layout  layout ;
@@ -799,7 +810,39 @@ static int drv_init(const struct device *dev)
799810		return  - ENODEV ;
800811	}
801812
802- #if  defined(WITH_RESET_GPIO )
813+ #if  defined(SDP_MSPI_WITH_RESET )
814+ 	if  (dev_config -> reset .port ) {
815+ 		if  (!gpio_is_ready_dt (& dev_config -> reset )) {
816+ 			LOG_ERR ("Device %s is not ready" ,
817+ 				dev_config -> reset .port -> name );
818+ 			return  - ENODEV ;
819+ 		}
820+ 
821+ 		rc  =  nrf_mspi_reset_pin_config (dev_config -> bus , & dev_config -> mspi_id ,
822+ 					       & dev_config -> reset , dev_config -> reset_port_num ,
823+ 					       GPIO_OUTPUT_ACTIVE );
824+ 
825+ 		if  (rc  <  0 ) {
826+ 			LOG_ERR ("Failed to activate RESET: %d" , rc );
827+ 			return  - EIO ;
828+ 		}
829+ 
830+ 		if  (dev_config -> reset_pulse_us  !=  0 ) {
831+ 			k_busy_wait (dev_config -> reset_pulse_us );
832+ 		}
833+ 
834+ 		rc  =  nrf_mspi_reset_pin_set (dev_config -> bus , & dev_config -> reset ,
835+ 					    & dev_config -> mspi_id , 0 );
836+ 		if  (rc  <  0 ) {
837+ 			LOG_ERR ("Failed to deactivate RESET: %d" , rc );
838+ 			return  - EIO ;
839+ 		}
840+ 
841+ 		if  (dev_config -> reset_recovery_us  !=  0 ) {
842+ 			k_busy_wait (dev_config -> reset_recovery_us );
843+ 		}
844+ 	}
845+ #elif  defined(WITH_RESET_GPIO )
803846	if  (dev_config -> reset .port ) {
804847		if  (!gpio_is_ready_dt (& dev_config -> reset )) {
805848			LOG_ERR ("Device %s is not ready" ,
@@ -935,6 +978,9 @@ BUILD_ASSERT((FLASH_SIZE_INST(inst) % CONFIG_FLASH_MSPI_NOR_LAYOUT_PAGE_SIZE) ==
935978				/ 1000,						\
936979		.reset_recovery_us = DT_INST_PROP_OR(inst, t_reset_recovery, 0)	\
937980				   / 1000,))					\
981+ 	IF_ENABLED(SDP_MSPI_WITH_RESET,				                \
982+ 		(.reset_port_num = DT_PROP_BY_PHANDLE_IDX(DT_DRV_INST(inst),    \
983+ 				reset_gpios, 0, port),))                        \
938984		FLASH_PAGE_LAYOUT_DEFINE(inst)					\
939985		.jedec_id = DT_INST_PROP(inst, jedec_id),			\
940986		.jedec_cmds = FLASH_CMDS(inst),					\
0 commit comments