Skip to content

Commit 7a30d4a

Browse files
committed
drivers: mspi: add checking if data pins are not overlapping
Add checking if one data line is not assigned to more than one GPIO pin. Signed-off-by: Magdalena Pastula <magdalena.pastula@nordicsemi.no>
1 parent b79fcb1 commit 7a30d4a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

drivers/mspi/mspi_nrfe.c

+15-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ 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)
3132

3233
#ifdef CONFIG_SOC_NRF54L15
3334

@@ -348,6 +349,11 @@ static int check_pin_assignments(const struct pinctrl_state *state)
348349
uint8_t cs_pins[NRFE_MSPI_PINS_MAX];
349350
uint8_t cs_pins_cnt = 0;
350351
uint32_t psel = 0;
352+
uint32_t pin_fun = 0;
353+
354+
for (uint8_t i = 0; i < NRFE_MSPI_DATA_LINE_CNT_MAX; i++) {
355+
data_pins[i] = UINT8_MAX;
356+
}
351357

352358
for (uint8_t i = 0; i < state->pin_cnt; i++) {
353359
psel = NRF_GET_PIN(state->pins[i]);
@@ -356,12 +362,18 @@ static int check_pin_assignments(const struct pinctrl_state *state)
356362
NRFE_MSPI_PORT_NUMBER);
357363
return -ENOTSUP;
358364
}
359-
switch (NRF_GET_FUN(state->pins[i])) {
365+
pin_fun = NRF_GET_FUN(state->pins[i]);
366+
switch (pin_fun) {
360367
case NRF_FUN_SDP_MSPI_DQ0:
361368
case NRF_FUN_SDP_MSPI_DQ1:
362369
case NRF_FUN_SDP_MSPI_DQ2:
363370
case NRF_FUN_SDP_MSPI_DQ3:
364-
data_pins[data_pins_cnt] = NRF_PIN_NUMBER_TO_PIN(psel);
371+
if (data_pins[DATA_LINE_INDEX(pin_fun)] != UINT8_MAX) {
372+
LOG_ERR("This pin is assigned to an already taken data line: %d.%d.",
373+
NRF_PIN_NUMBER_TO_PORT(psel), NRF_PIN_NUMBER_TO_PIN(psel));
374+
return -EINVAL;
375+
}
376+
data_pins[DATA_LINE_INDEX(pin_fun)] = NRF_PIN_NUMBER_TO_PIN(psel);
365377
data_pins_cnt++;
366378
break;
367379
case NRF_FUN_SDP_MSPI_DQ4:
@@ -386,7 +398,7 @@ static int check_pin_assignments(const struct pinctrl_state *state)
386398
}
387399
break;
388400
default:
389-
LOG_ERR("Not supported pin function: %d", NRF_GET_FUN(state->pins[i]));
401+
LOG_ERR("Not supported pin function: %d", pin_fun);
390402
return -ENOTSUP;
391403
}
392404
}

0 commit comments

Comments
 (0)