Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: drivers: mspi: Add mspi to spi loopback test #21165

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@
/tests/zephyr/drivers/i2c/i2c_target_api/ @nrfconnect/ncs-low-level-test
/tests/zephyr/drivers/i2s/ @nrfconnect/ncs-low-level-test
/tests/zephyr/drivers/mspi/api/ @nrfconnect/ncs-low-level-test @nrfconnect/ncs-ll-ursus
/tests/zephyr/drivers/mspi/controller_peripheral/ @nrfconnect/ncs-low-level-test @nrfconnect/ncs-ll-ursus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just reduce to /tests/zephyr/drivers/mspi and merge with line above?

/tests/zephyr/drivers/retained_mem/ @nrfconnect/ncs-low-level-test
/tests/zephyr/drivers/sensor/ @nrfconnect/ncs-low-level-test
/tests/zephyr/drivers/spi/ @nrfconnect/ncs-low-level-test
Expand Down
146 changes: 77 additions & 69 deletions applications/sdp/mspi/src/hrt/hrt-nrf54l15.s
Original file line number Diff line number Diff line change
Expand Up @@ -419,30 +419,38 @@ hrt_read:
csrc 3008, a2
#NO_APP
.L48:
#APP
csrr a2, 3008
#NO_APP
lw a0,4(s0)
sw a2,0(sp)
bne a0,zero,.L49
lw a0,24(s0)
bne a0,zero,.L49
lw a0,44(s0)
beq a0,zero,.L50
.L49:
sw zero,64(s0)
li a0,1
sb a0,87(s0)
mv a0,s0
sw a1,20(sp)
sw t1,16(sp)
sw a4,12(sp)
sw a3,8(sp)
sw a5,4(sp)
#APP
csrr a5, 3008
#NO_APP
li t0,1
sw zero,64(s0)
sb t0,87(s0)
mv a0,s0
sw a5,0(sp)
call hrt_write
lw a4,12(sp)
lw a1,20(sp)
lw t1,16(sp)
li t0,1
lw a4,12(sp)
lw a3,8(sp)
lw a5,4(sp)
.L50:
sw a4,64(s0)
sb t1,87(s0)
lbu a0,83(s0)
lw a5,4(sp)
lw a3,8(sp)
lw a1,20(sp)
bne a0,t0,.L49
lbu t1,83(s0)
li a0,1
bne t1,a0,.L51
lhu a0,90(s0)
slli a0,a0,16
srli a0,a0,16
Expand All @@ -451,7 +459,7 @@ hrt_read:
srli a0,a0,16
sh a0,90(s0)
lhu a0,90(s0)
.L85:
.L90:
#APP
csrw 3009, a0
csrw 3011, 2
Expand Down Expand Up @@ -506,17 +514,17 @@ hrt_read:
csrw 3017, 0
#NO_APP
li a0,1
bne a4,a0,.L51
bne a4,a0,.L53
lbu t0,68(s0)
li a0,2
bne t0,a0,.L52
bne t0,a0,.L54
lhu a4,84(s0)
li a1,65536
or a4,a4,a1
#APP
csrw 2002, a4
#NO_APP
.L53:
.L55:
#APP
csrr a1, 2005
csrr a4, 2005
Expand All @@ -525,7 +533,7 @@ hrt_read:
slli a4,a4,16
srli a1,a1,16
srli a4,a4,16
bne a1,a4,.L53
bne a1,a4,.L55
lw a4,0(sp)
slli a2,a4,24
#APP
Expand All @@ -534,12 +542,12 @@ hrt_read:
#NO_APP
lbu a3,83(s0)
li a4,8
bne a3,a4,.L54
bne a3,a4,.L56
#APP
csrr a4, 3018
#NO_APP
srli a4,a4,16
.L88:
.L93:
sw a4,72(s0)
#APP
csrw 2000, 0
Expand All @@ -551,18 +559,18 @@ hrt_read:
csrw 3019, s1
#NO_APP
lbu a5,87(s0)
bne a5,zero,.L75
bne a5,zero,.L77
lbu a5,88(s0)
lbu a4,86(s0)
bne a5,zero,.L76
bne a5,zero,.L78
li a5,1
sll a5,a5,a4
slli a5,a5,16
srli a5,a5,16
#APP
csrs 3008, a5
#NO_APP
.L75:
.L77:
lbu a4,83(s0)
li a5,1
bne a4,a5,.L45
Expand All @@ -588,18 +596,18 @@ hrt_read:
csrs 3008, a2
#NO_APP
j .L48
.L49:
.L51:
lhu a0,92(s0)
j .L85
.L54:
j .L90
.L56:
#APP
csrr a4, 3018
#NO_APP
srli a4,a4,24
j .L88
.L51:
j .L93
.L53:
li a0,2
bne a4,a0,.L82
bne a4,a0,.L87
lbu a0,69(s0)
addi a0,a0,-3
andi a0,a0,63
Expand All @@ -609,7 +617,7 @@ hrt_read:
csrw 3019, a0
#NO_APP
lbu s1,68(s0)
.L86:
.L91:
lhu a0,84(s0)
li t1,65536
addi s1,s1,-1
Expand All @@ -631,9 +639,9 @@ hrt_read:
addi a4,a4,-2
li t0,2
li t2,32
.L62:
bne a4,a2,.L67
.L68:
.L64:
bne a4,a2,.L69
.L70:
#APP
csrr a1, 2005
csrr a4, 2005
Expand All @@ -642,7 +650,7 @@ hrt_read:
slli a4,a4,16
srli a1,a1,16
srli a4,a4,16
bne a1,a4,.L68
bne a1,a4,.L70
lw a4,0(sp)
slli a2,a4,24
#APP
Expand All @@ -651,14 +659,14 @@ hrt_read:
#NO_APP
lbu a3,94(s0)
li a4,3
bne a3,a4,.L69
bne a3,a4,.L71
#APP
csrr a3, 3018
csrw 3011, 0
#NO_APP
lhu a2,84(s0)
li a4,35
bleu a2,a4,.L70
bleu a2,a4,.L72
#APP
csrw 2000, 0
#NO_APP
Expand All @@ -669,23 +677,23 @@ hrt_read:
#APP
csrw 2005, a4
#NO_APP
.L70:
.L72:
li a4,65536
addi a4,a4,-1
.L71:
.L73:
#APP
csrr a2, 3010
#NO_APP
slli a2,a2,16
srli a2,a2,16
beq a2,a4,.L71
beq a2,a4,.L73
lhu a2,84(s0)
li a4,35
bleu a2,a4,.L72
bleu a2,a4,.L74
#APP
csrw 2010, 0
#NO_APP
.L72:
.L74:
#APP
csrr a2, 3010
#NO_APP
Expand All @@ -696,10 +704,10 @@ hrt_read:
#NO_APP
lbu a1,83(s0)
li a4,4
beq a1,a4,.L78
beq a1,a4,.L80
li t1,2
li t0,4
.L73:
.L75:
slli a1,a3,24
srli a4,a3,24
or a4,a4,a1
Expand Down Expand Up @@ -733,8 +741,8 @@ hrt_read:
or a3,a3,a2
and a4,a4,a0
or a4,a3,a4
j .L88
.L52:
j .L93
.L54:
lbu a0,68(s0)
addi a0,a0,-3
andi a0,a0,63
Expand All @@ -744,12 +752,12 @@ hrt_read:
csrw 3019, a0
#NO_APP
li a0,0
.L59:
.L61:
li t1,2
bne a0,t1,.L61
bne a0,t1,.L63
lbu s1,69(s0)
j .L86
.L82:
j .L91
.L87:
lbu t0,83(s0)
li a0,32
div a0,a0,t0
Expand All @@ -761,22 +769,22 @@ hrt_read:
csrw 3019, a0
#NO_APP
addi a0,a4,-1
j .L59
.L61:
j .L61
.L63:
lbu a0,83(s0)
li s1,32
div s1,s1,a0
j .L86
.L67:
j .L91
.L69:
li a0,1
beq a4,a0,.L63
beq a4,t0,.L64
beq a4,a0,.L65
beq a4,t0,.L66
lbu s1,83(s0)
div s1,t2,s1
j .L87
.L63:
j .L92
.L65:
lbu s1,68(s0)
.L87:
.L92:
addi s1,s1,-1
andi s1,s1,0xff
#APP
Expand All @@ -791,15 +799,15 @@ hrt_read:
#NO_APP
addi a1,a1,4
addi a4,a4,-1
j .L62
.L64:
j .L64
.L66:
lbu s1,69(s0)
j .L87
.L78:
j .L92
.L80:
li t1,1
li t0,30
j .L73
.L69:
j .L75
.L71:
#APP
csrr a4, 3018
#NO_APP
Expand All @@ -809,16 +817,16 @@ hrt_read:
li a3,32
sub a3,a3,a2
srl a4,a4,a3
j .L88
.L76:
j .L93
.L78:
li a5,1
sll a5,a5,a4
slli a5,a5,16
srli a5,a5,16
#APP
csrc 3008, a5
#NO_APP
j .L75
j .L77
.size hrt_read, .-hrt_read
.section .sdata.xfer_shift_ctrl,"aw"
.align 2
Expand Down
12 changes: 8 additions & 4 deletions applications/sdp/mspi/src/hrt/hrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,14 @@ void hrt_read(volatile hrt_xfer_t *hrt_xfer_params)
/* Get state of all VIO to reset it correctly after transfer. */
prev_out = nrf_vpr_csr_vio_out_get();

/* Write only command address and dummy cycles and keep CS active. */
hrt_xfer_params->xfer_data[HRT_FE_DATA].word_count = 0;
hrt_xfer_params->ce_hold = true;
hrt_write(hrt_xfer_params);
if ((hrt_xfer_params->xfer_data[HRT_FE_COMMAND].word_count != 0) ||
(hrt_xfer_params->xfer_data[HRT_FE_ADDRESS].word_count != 0) ||
(hrt_xfer_params->xfer_data[HRT_FE_DUMMY_CYCLES].word_count != 0)) {
/* Write only command, address and dummy cycles and keep CS active. */
hrt_xfer_params->xfer_data[HRT_FE_DATA].word_count = 0;
hrt_xfer_params->ce_hold = true;
hrt_write(hrt_xfer_params);
}

/* Restore variables values for read phase. */
hrt_xfer_params->xfer_data[HRT_FE_DATA].word_count = word_count;
Expand Down
7 changes: 7 additions & 0 deletions drivers/mspi/mspi_nrfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,13 @@ static int api_dev_config(const struct device *dev, const struct mspi_dev_id *de
}
}

if (param_mask & MSPI_DEVICE_CONFIG_ENDIAN) {
if (cfg->endian != MSPI_XFER_BIG_ENDIAN) {
LOG_ERR("Only big endian mode is supported.");
return -ENOTSUP;
}
}

mspi_dev_config_msg.opcode = NRFE_MSPI_CONFIG_DEV;
mspi_dev_config_msg.device_index = dev_id->dev_idx;
mspi_dev_config_msg.dev_config.io_mode = cfg->io_mode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
compatible = "zephyr,mspi-emul-device";
reg = <0x0>;
mspi-max-frequency = <DT_FREQ_M(1)>;
mspi-endian = "MSPI_BIG_ENDIAN";
};
};
};
Loading
Loading