@@ -28,6 +28,8 @@ LOG_MODULE_REGISTER(mspi_nrfe, CONFIG_MSPI_LOG_LEVEL);
28
28
#define EP_SEND_TIMEOUT_MS 10
29
29
#define EXTREME_DRIVE_FREQ_THRESHOLD 32000000
30
30
#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
31
33
32
34
#ifdef CONFIG_SOC_NRF54L15
33
35
@@ -327,6 +329,11 @@ static int check_pin_assignments(const struct pinctrl_state *state)
327
329
uint8_t cs_pins [NRFE_MSPI_PINS_MAX ];
328
330
uint8_t cs_pins_cnt = 0 ;
329
331
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
+ }
330
337
331
338
for (uint8_t i = 0 ; i < state -> pin_cnt ; i ++ ) {
332
339
psel = NRF_GET_PIN (state -> pins [i ]);
@@ -335,7 +342,8 @@ static int check_pin_assignments(const struct pinctrl_state *state)
335
342
NRFE_MSPI_PORT_NUMBER );
336
343
return - ENOTSUP ;
337
344
}
338
- switch (NRF_GET_FUN (state -> pins [i ])) {
345
+ pin_fun = NRF_GET_FUN (state -> pins [i ]);
346
+ switch (pin_fun ) {
339
347
case NRF_FUN_SDP_MSPI_DQ0 :
340
348
case NRF_FUN_SDP_MSPI_DQ1 :
341
349
case NRF_FUN_SDP_MSPI_DQ2 :
@@ -344,7 +352,13 @@ static int check_pin_assignments(const struct pinctrl_state *state)
344
352
case NRF_FUN_SDP_MSPI_DQ5 :
345
353
case NRF_FUN_SDP_MSPI_DQ6 :
346
354
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 );
348
362
data_pins_cnt ++ ;
349
363
break ;
350
364
case NRF_FUN_SDP_MSPI_CS0 :
@@ -363,7 +377,7 @@ static int check_pin_assignments(const struct pinctrl_state *state)
363
377
}
364
378
break ;
365
379
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 );
367
381
return - ENOTSUP ;
368
382
}
369
383
}
0 commit comments