@@ -524,10 +524,12 @@ static int xfer_packet(struct mspi_xfer_packet *packet, uint32_t timeout)
524
524
xfer_packet -> num_bytes = packet -> num_bytes ;
525
525
526
526
#ifdef CONFIG_MSPI_NRFE_IPC_NO_COPY
527
- /* Check for alignlemt problems. */
527
+ /* Check for alignment problems. */
528
528
if (((uint32_t )packet -> data_buf ) % sizeof (uint32_t ) != 0 ) {
529
- memcpy ((void * )(buffer + sizeof (nrfe_mspi_xfer_packet_msg_t )),
530
- (void * )packet -> data_buf , packet -> num_bytes );
529
+ if (packet -> dir == MSPI_TX ) {
530
+ memcpy ((void * )(buffer + sizeof (nrfe_mspi_xfer_packet_msg_t )),
531
+ (void * )packet -> data_buf , packet -> num_bytes );
532
+ }
531
533
xfer_packet -> data = buffer + sizeof (nrfe_mspi_xfer_packet_msg_t );
532
534
} else {
533
535
xfer_packet -> data = packet -> data_buf ;
@@ -539,20 +541,32 @@ static int xfer_packet(struct mspi_xfer_packet *packet, uint32_t timeout)
539
541
rc = send_data (xfer_packet -> opcode , xfer_packet , len );
540
542
541
543
/* Wait for the transfer to complete and receive data. */
542
- if ((packet -> dir == MSPI_RX ) && (ipc_receive_buffer != NULL ) && (ipc_received > 0 )) {
543
- /*
544
- * It is not possible to check whether received data is valid, so packet->num_bytes
545
- * should always be equal to ipc_received. If it is not, then something went wrong.
546
- */
547
- if (packet -> num_bytes != ipc_received ) {
548
- rc = - EIO ;
549
- } else {
550
- memcpy ((void * )packet -> data_buf , (void * )ipc_receive_buffer , ipc_received );
544
+ if (packet -> dir == MSPI_RX ) {
545
+ #ifdef CONFIG_MSPI_NRFE_IPC_NO_COPY
546
+ /* Not aligned buffer. */
547
+ if (((uint32_t )packet -> data_buf ) % sizeof (uint32_t ) != 0 ) {
548
+ memcpy ((void * )packet -> data_buf , (void * )xfer_packet -> data ,
549
+ packet -> num_bytes );
551
550
}
552
-
553
- /* Clear the receive buffer pointer and size */
554
- ipc_receive_buffer = NULL ;
555
- ipc_received = 0 ;
551
+ #else
552
+ if ((ipc_receive_buffer != NULL ) && (ipc_received > 0 )) {
553
+ /*
554
+ * It is not possible to check whether received data is valid, so
555
+ * packet->num_bytes should always be equal to ipc_received. If it is not,
556
+ * then something went wrong.
557
+ */
558
+ if (packet -> num_bytes != ipc_received ) {
559
+ rc = - EIO ;
560
+ } else {
561
+ memcpy ((void * )packet -> data_buf , (void * )ipc_receive_buffer ,
562
+ ipc_received );
563
+ }
564
+
565
+ /* Clear the receive buffer pointer and size */
566
+ ipc_receive_buffer = NULL ;
567
+ ipc_received = 0 ;
568
+ }
569
+ #endif
556
570
}
557
571
558
572
return rc ;
@@ -713,8 +727,7 @@ static int nrfe_mspi_init(const struct device *dev)
713
727
.callback = flpr_fault_handler ,
714
728
.user_data = NULL ,
715
729
.flags = 0 ,
716
- .ticks = counter_us_to_ticks (flpr_fault_timer , CONFIG_MSPI_NRFE_FAULT_TIMEOUT )
717
- };
730
+ .ticks = counter_us_to_ticks (flpr_fault_timer , CONFIG_MSPI_NRFE_FAULT_TIMEOUT )};
718
731
#endif
719
732
720
733
ret = pinctrl_apply_state (drv_cfg -> pcfg , PINCTRL_STATE_DEFAULT );
0 commit comments