@@ -28,6 +28,8 @@ LOG_MODULE_REGISTER(mspi_nrfe, CONFIG_MSPI_LOG_LEVEL);
2828#define EP_SEND_TIMEOUT_MS 10
2929#define EXTREME_DRIVE_FREQ_THRESHOLD 32000000
3030#define CNT0_TOP_CALCULATE (freq ) (NRFX_CEIL_DIV(SystemCoreClock, freq * 2) - 1)
31+ #define DATA_LINE_INDEX (pinctr_fun ) (pinctr_fun - NRF_FUN_SDP_MSPI_DQ0)
32+ #define DATA_PIN_UNUSED UINT8_MAX
3133
3234#ifdef CONFIG_SOC_NRF54L15
3335
@@ -327,6 +329,11 @@ static int check_pin_assignments(const struct pinctrl_state *state)
327329 uint8_t cs_pins [NRFE_MSPI_PINS_MAX ];
328330 uint8_t cs_pins_cnt = 0 ;
329331 uint32_t psel = 0 ;
332+ uint32_t pin_fun = 0 ;
333+
334+ for (uint8_t i = 0 ; i < NRFE_MSPI_DATA_LINE_CNT_MAX ; i ++ ) {
335+ data_pins [i ] = DATA_PIN_UNUSED ;
336+ }
330337
331338 for (uint8_t i = 0 ; i < state -> pin_cnt ; i ++ ) {
332339 psel = NRF_GET_PIN (state -> pins [i ]);
@@ -335,7 +342,8 @@ static int check_pin_assignments(const struct pinctrl_state *state)
335342 NRFE_MSPI_PORT_NUMBER );
336343 return - ENOTSUP ;
337344 }
338- switch (NRF_GET_FUN (state -> pins [i ])) {
345+ pin_fun = NRF_GET_FUN (state -> pins [i ]);
346+ switch (pin_fun ) {
339347 case NRF_FUN_SDP_MSPI_DQ0 :
340348 case NRF_FUN_SDP_MSPI_DQ1 :
341349 case NRF_FUN_SDP_MSPI_DQ2 :
@@ -344,7 +352,13 @@ static int check_pin_assignments(const struct pinctrl_state *state)
344352 case NRF_FUN_SDP_MSPI_DQ5 :
345353 case NRF_FUN_SDP_MSPI_DQ6 :
346354 case NRF_FUN_SDP_MSPI_DQ7 :
347- data_pins [data_pins_cnt ] = NRF_PIN_NUMBER_TO_PIN (psel );
355+ if (data_pins [DATA_LINE_INDEX (pin_fun )] != DATA_PIN_UNUSED ) {
356+ LOG_ERR ("This pin is assigned to an already taken data line: "
357+ "%d.%d." ,
358+ NRF_PIN_NUMBER_TO_PORT (psel ), NRF_PIN_NUMBER_TO_PIN (psel ));
359+ return - EINVAL ;
360+ }
361+ data_pins [DATA_LINE_INDEX (pin_fun )] = NRF_PIN_NUMBER_TO_PIN (psel );
348362 data_pins_cnt ++ ;
349363 break ;
350364 case NRF_FUN_SDP_MSPI_CS0 :
@@ -363,7 +377,7 @@ static int check_pin_assignments(const struct pinctrl_state *state)
363377 }
364378 break ;
365379 default :
366- LOG_ERR ("Not supported pin function: %d" , NRF_GET_FUN ( state -> pins [ i ]) );
380+ LOG_ERR ("Not supported pin function: %d" , pin_fun );
367381 return - ENOTSUP ;
368382 }
369383 }
0 commit comments