@@ -542,10 +542,12 @@ static int xfer_packet(struct mspi_xfer_packet *packet, uint32_t timeout)
542
542
xfer_packet -> num_bytes = packet -> num_bytes ;
543
543
544
544
#ifdef CONFIG_MSPI_NRFE_IPC_NO_COPY
545
- /* Check for alignlemt problems. */
545
+ /* Check for alignment problems. */
546
546
if (((uint32_t )packet -> data_buf ) % sizeof (uint32_t ) != 0 ) {
547
- memcpy ((void * )(buffer + sizeof (nrfe_mspi_xfer_packet_msg_t )),
548
- (void * )packet -> data_buf , packet -> num_bytes );
547
+ if (packet -> dir == MSPI_TX ) {
548
+ memcpy ((void * )(buffer + sizeof (nrfe_mspi_xfer_packet_msg_t )),
549
+ (void * )packet -> data_buf , packet -> num_bytes );
550
+ }
549
551
xfer_packet -> data = buffer + sizeof (nrfe_mspi_xfer_packet_msg_t );
550
552
} else {
551
553
xfer_packet -> data = packet -> data_buf ;
@@ -557,20 +559,32 @@ static int xfer_packet(struct mspi_xfer_packet *packet, uint32_t timeout)
557
559
rc = send_data (xfer_packet -> opcode , xfer_packet , len );
558
560
559
561
/* Wait for the transfer to complete and receive data. */
560
- if ((packet -> dir == MSPI_RX ) && (ipc_receive_buffer != NULL ) && (ipc_received > 0 )) {
561
- /*
562
- * It is not possible to check whether received data is valid, so packet->num_bytes
563
- * should always be equal to ipc_received. If it is not, then something went wrong.
564
- */
565
- if (packet -> num_bytes != ipc_received ) {
566
- rc = - EIO ;
567
- } else {
568
- memcpy ((void * )packet -> data_buf , (void * )ipc_receive_buffer , ipc_received );
562
+ if (packet -> dir == MSPI_RX ) {
563
+ #ifdef CONFIG_MSPI_NRFE_IPC_NO_COPY
564
+ /* Not aligned buffer. */
565
+ if (((uint32_t )packet -> data_buf ) % sizeof (uint32_t ) != 0 ) {
566
+ memcpy ((void * )packet -> data_buf , (void * )xfer_packet -> data ,
567
+ packet -> num_bytes );
569
568
}
569
+ #else
570
+ if ((ipc_receive_buffer != NULL ) && (ipc_received > 0 )) {
571
+ /*
572
+ * It is not possible to check whether received data is valid, so
573
+ * packet->num_bytes should always be equal to ipc_received. If it is not,
574
+ * then something went wrong.
575
+ */
576
+ if (packet -> num_bytes != ipc_received ) {
577
+ rc = - EIO ;
578
+ } else {
579
+ memcpy ((void * )packet -> data_buf , (void * )ipc_receive_buffer ,
580
+ ipc_received );
581
+ }
570
582
571
- /* Clear the receive buffer pointer and size */
572
- ipc_receive_buffer = NULL ;
573
- ipc_received = 0 ;
583
+ /* Clear the receive buffer pointer and size */
584
+ ipc_receive_buffer = NULL ;
585
+ ipc_received = 0 ;
586
+ }
587
+ #endif
574
588
}
575
589
576
590
return rc ;
@@ -731,8 +745,7 @@ static int nrfe_mspi_init(const struct device *dev)
731
745
.callback = flpr_fault_handler ,
732
746
.user_data = NULL ,
733
747
.flags = 0 ,
734
- .ticks = counter_us_to_ticks (flpr_fault_timer , CONFIG_MSPI_NRFE_FAULT_TIMEOUT )
735
- };
748
+ .ticks = counter_us_to_ticks (flpr_fault_timer , CONFIG_MSPI_NRFE_FAULT_TIMEOUT )};
736
749
#endif
737
750
738
751
ret = pinctrl_apply_state (drv_cfg -> pcfg , PINCTRL_STATE_DEFAULT );
0 commit comments