3535
3636#define MAX_SHIFT_COUNT 63
3737
38- #define CE_PIN_UNUSED UINT8_MAX
38+ #define DATA_PIN_UNUSED UINT8_MAX
39+ #define CE_PIN_UNUSED UINT8_MAX
3940
4041#define HRT_IRQ_PRIORITY 2
4142#define HRT_VEVIF_IDX_READ 17
5051#error "Unsupported SoC for SDP MSPI"
5152#endif
5253
54+ #define DATA_LINE_INDEX (pinctr_fun ) (pinctr_fun - NRF_FUN_SDP_MSPI_DQ0)
55+
5356BUILD_ASSERT (CONFIG_SDP_MSPI_MAX_RESPONSE_SIZE > 0 , "Response max size should be greater that 0" );
5457
5558static const uint8_t pin_to_vio_map [NRFE_MSPI_PINS_MAX ] = {
@@ -341,6 +344,10 @@ static void config_pins(nrfe_mspi_pinctrl_soc_pin_msg_t *pins_cfg)
341344 xfer_params .tx_direction_mask = 0 ;
342345 xfer_params .rx_direction_mask = 0 ;
343346
347+ for (uint8_t i = 0 ; i < DATA_PINS_MAX ; i ++ ) {
348+ data_vios [i ] = DATA_PIN_UNUSED ;
349+ }
350+
344351 for (uint8_t i = 0 ; i < pins_cfg -> pins_count ; i ++ ) {
345352 uint32_t psel = NRF_GET_PIN (pins_cfg -> pin [i ]);
346353 uint32_t fun = NRF_GET_FUN (pins_cfg -> pin [i ]);
@@ -364,10 +371,13 @@ static void config_pins(nrfe_mspi_pinctrl_soc_pin_msg_t *pins_cfg)
364371
365372 } else if ((fun >= NRF_FUN_SDP_MSPI_DQ0 ) && (fun <= NRF_FUN_SDP_MSPI_DQ7 )) {
366373
367- data_vios [data_vios_count ] = pin_to_vio_map [pin_number ];
368- WRITE_BIT (xfer_params .tx_direction_mask , data_vios [data_vios_count ],
374+ NRFX_ASSERT (DATA_LINE_INDEX (fun ) < DATA_PINS_MAX );
375+ NRFX_ASSERT (data_vios [DATA_LINE_INDEX (fun )] == DATA_PIN_UNUSED );
376+
377+ data_vios [DATA_LINE_INDEX (fun )] = pin_to_vio_map [pin_number ];
378+ WRITE_BIT (xfer_params .tx_direction_mask , data_vios [DATA_LINE_INDEX (fun )],
369379 VPRCSR_NORDIC_DIR_OUTPUT );
370- WRITE_BIT (xfer_params .rx_direction_mask , data_vios [data_vios_count ],
380+ WRITE_BIT (xfer_params .rx_direction_mask , data_vios [DATA_LINE_INDEX ( fun ) ],
371381 VPRCSR_NORDIC_DIR_INPUT );
372382 data_vios_count ++ ;
373383 } else if (fun == NRF_FUN_SDP_MSPI_SCK ) {
@@ -443,11 +453,18 @@ static void ep_recv(const void *data, size_t len, void *priv)
443453 }
444454
445455 if (dev_config -> dev_config .io_mode == MSPI_IO_MODE_SINGLE ) {
446- nrf_vpr_csr_vio_out_or_set (BIT (3 ));
447- nrf_vpr_csr_vio_out_or_set (BIT (4 ));
456+ if (data_vios [DATA_LINE_INDEX (NRF_FUN_SDP_MSPI_DQ2 )] != DATA_PIN_UNUSED &&
457+ data_vios [DATA_LINE_INDEX (NRF_FUN_SDP_MSPI_DQ3 )] != DATA_PIN_UNUSED ) {
458+ nrf_vpr_csr_vio_out_or_set (
459+ BIT (data_vios [DATA_LINE_INDEX (NRF_FUN_SDP_MSPI_DQ2 )]));
460+ nrf_vpr_csr_vio_out_or_set (
461+ BIT (data_vios [DATA_LINE_INDEX (NRF_FUN_SDP_MSPI_DQ3 )]));
462+ }
448463 } else {
449- nrf_vpr_csr_vio_out_clear_set (BIT (3 ));
450- nrf_vpr_csr_vio_out_clear_set (BIT (4 ));
464+ nrf_vpr_csr_vio_out_clear_set (
465+ BIT (data_vios [DATA_LINE_INDEX (NRF_FUN_SDP_MSPI_DQ2 )]));
466+ nrf_vpr_csr_vio_out_clear_set (
467+ BIT (data_vios [DATA_LINE_INDEX (NRF_FUN_SDP_MSPI_DQ3 )]));
451468 }
452469
453470 break ;
0 commit comments