@@ -849,6 +849,77 @@ static int gpio_reset(const struct device *dev)
849849}
850850#endif 
851851
852+ #if  defined(WITH_SOFT_RESET )
853+ static  int  soft_reset_66_99 (const  struct  device  * dev )
854+ {
855+ 	int  rc ;
856+ 
857+ 	set_up_xfer (dev , MSPI_TX );
858+ 	rc  =  perform_xfer (dev , SPI_NOR_CMD_RESET_EN , false);
859+ 	if  (rc  <  0 ) {
860+ 		LOG_ERR ("CMD_RESET_EN failed: %d" , rc );
861+ 		return  rc ;
862+ 	}
863+ 
864+ 	set_up_xfer (dev , MSPI_TX );
865+ 	rc  =  perform_xfer (dev , SPI_NOR_CMD_RESET_MEM , false);
866+ 	if  (rc  <  0 ) {
867+ 		LOG_ERR ("CMD_RESET_MEM failed: %d" , rc );
868+ 		return  rc ;
869+ 	}
870+ 
871+ 	return  0 ;
872+ }
873+ 
874+ static  int  soft_reset (const  struct  device  * dev )
875+ {
876+ 	const  struct  flash_mspi_nor_config  * dev_config  =  dev -> config ;
877+ 	struct  flash_mspi_nor_data  * dev_data  =  dev -> data ;
878+ 	int  rc ;
879+ 
880+ 	/* If the flash may expect commands sent in multi-line mode, 
881+ 	 * send additionally the reset sequence this way. 
882+ 	 */ 
883+ 	if  (dev_config -> multi_io_cmd ) {
884+ 		rc  =  mspi_dev_config (dev_config -> bus , & dev_config -> mspi_id ,
885+ 				     MSPI_DEVICE_CONFIG_IO_MODE ,
886+ 				     & dev_config -> mspi_nor_cfg );
887+ 		if  (rc  <  0 ) {
888+ 			LOG_ERR ("%s: dev_config() failed: %d" , __func__ , rc );
889+ 			return  rc ;
890+ 		}
891+ 
892+ 		dev_data -> in_target_io_mode  =  true;
893+ 
894+ 		rc  =  soft_reset_66_99 (dev );
895+ 		if  (rc  <  0 ) {
896+ 			return  rc ;
897+ 		}
898+ 
899+ 		rc  =  mspi_dev_config (dev_config -> bus , & dev_config -> mspi_id ,
900+ 				     MSPI_DEVICE_CONFIG_IO_MODE ,
901+ 				     & dev_config -> mspi_nor_init_cfg );
902+ 		if  (rc  <  0 ) {
903+ 			LOG_ERR ("%s: dev_config() failed: %d" , __func__ , rc );
904+ 			return  rc ;
905+ 		}
906+ 
907+ 		dev_data -> in_target_io_mode  =  false;
908+ 	}
909+ 
910+ 	rc  =  soft_reset_66_99 (dev );
911+ 	if  (rc  <  0 ) {
912+ 		return  rc ;
913+ 	}
914+ 
915+ 	if  (dev_config -> reset_recovery_us  !=  0 ) {
916+ 		k_busy_wait (dev_config -> reset_recovery_us );
917+ 	}
918+ 
919+ 	return  0 ;
920+ }
921+ #endif  /* WITH_SOFT_RESET */ 
922+ 
852923static  int  flash_chip_init (const  struct  device  * dev )
853924{
854925	const  struct  flash_mspi_nor_config  * dev_config  =  dev -> config ;
@@ -897,6 +968,15 @@ static int flash_chip_init(const struct device *dev)
897968	}
898969#endif 
899970
971+ #if  defined(WITH_SOFT_RESET )
972+ 	if  (dev_config -> initial_soft_reset ) {
973+ 		rc  =  soft_reset (dev );
974+ 		if  (rc  <  0 ) {
975+ 			return  rc ;
976+ 		}
977+ 	}
978+ #endif 
979+ 
900980	if  (dev_config -> quirks  !=  NULL  && 
901981	    dev_config -> quirks -> pre_init  !=  NULL ) {
902982		rc  =  dev_config -> quirks -> pre_init (dev );
@@ -1117,10 +1197,10 @@ BUILD_ASSERT((FLASH_SIZE(inst) % CONFIG_FLASH_MSPI_NOR_LAYOUT_PAGE_SIZE) == 0, \
11171197		(.xip_cfg = MSPI_XIP_CONFIG_DT_INST(inst),))			\
11181198	IF_ENABLED(WITH_RESET_GPIO,						\
11191199		(.reset = GPIO_DT_SPEC_INST_GET_OR(inst, reset_gpios, {0}),	\
1120- 		.reset_pulse_us = DT_INST_PROP_OR(inst, t_reset_pulse, 0)	\
1121- 				/ 1000,	 					\
1200+ 		  .reset_pulse_us = DT_INST_PROP_OR(inst, t_reset_pulse, 0)	\
1201+ 				  / 1000,)) 					\
11221202		.reset_recovery_us = DT_INST_PROP_OR(inst, t_reset_recovery, 0)	\
1123- 				   / 1000,)) 					\
1203+ 				   / 1000,					\
11241204		.transfer_timeout = DT_INST_PROP(inst, transfer_timeout),	\
11251205		FLASH_PAGE_LAYOUT_DEFINE(inst)					\
11261206		.jedec_id = DT_INST_PROP(inst, jedec_id),			\
@@ -1135,6 +1215,7 @@ BUILD_ASSERT((FLASH_SIZE(inst) % CONFIG_FLASH_MSPI_NOR_LAYOUT_PAGE_SIZE) == 0, \
11351215		.multiperipheral_bus = DT_PROP(DT_INST_BUS(inst),		\
11361216					       software_multiperipheral),	\
11371217		IO_MODE_FLAGS(DT_INST_ENUM_IDX(inst, mspi_io_mode)),		\
1218+ 		.initial_soft_reset = DT_INST_PROP(inst, initial_soft_reset),	\
11381219	};									\
11391220	FLASH_PAGE_LAYOUT_CHECK(inst)						\
11401221	DEVICE_DT_INST_DEFINE(inst,						\
0 commit comments