Skip to content

Commit 74378f3

Browse files
nordic-seglcarlescufi
authored andcommitted
tests: drivers: spi: spi_error_cases: Enable test execution on nrf54h20
Add overlay file for nrf54h20. Align code and DTS between spi_error_cases and spi_controller_peripheral. Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
1 parent 008ee25 commit 74378f3

File tree

5 files changed

+124
-53
lines changed

5 files changed

+124
-53
lines changed

tests/drivers/spi/spi_error_cases/boards/nrf52840dk_nrf52840.overlay

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
group1 {
1010
psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
1111
<NRF_PSEL(SPIM_MISO, 1, 3)>,
12-
<NRF_PSEL(SPIM_MOSI, 1, 5)>;
12+
<NRF_PSEL(SPIM_MOSI, 1, 7)>;
1313
};
1414
};
1515

1616
spi3_sleep_alt: spi3_sleep_alt {
1717
group1 {
1818
psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
1919
<NRF_PSEL(SPIM_MISO, 1, 3)>,
20-
<NRF_PSEL(SPIM_MOSI, 1, 5)>;
20+
<NRF_PSEL(SPIM_MOSI, 1, 7)>;
2121
low-power-enable;
2222
};
2323
};
@@ -26,34 +26,34 @@
2626
group1 {
2727
psels = <NRF_PSEL(SPIS_SCK, 1, 2)>,
2828
<NRF_PSEL(SPIS_MISO, 1, 4)>,
29-
<NRF_PSEL(SPIS_MOSI, 1, 6)>,
30-
<NRF_PSEL(SPIS_CSN, 1, 8)>;
29+
<NRF_PSEL(SPIS_MOSI, 1, 8)>,
30+
<NRF_PSEL(SPIS_CSN, 1, 10)>;
3131
};
3232
};
3333

3434
spi1_sleep_alt: spi1_sleep_alt {
3535
group1 {
3636
psels = <NRF_PSEL(SPIS_SCK, 1, 2)>,
3737
<NRF_PSEL(SPIS_MISO, 1, 4)>,
38-
<NRF_PSEL(SPIS_MOSI, 1, 6)>,
39-
<NRF_PSEL(SPIS_CSN, 1, 8)>;
38+
<NRF_PSEL(SPIS_MOSI, 1, 8)>,
39+
<NRF_PSEL(SPIS_CSN, 1, 10)>;
4040
low-power-enable;
4141
};
4242
};
4343

4444
};
4545

46-
dut_spi: &spi3 {
46+
&spi3 {
4747
status = "okay";
4848
pinctrl-0 = <&spi3_default_alt>;
4949
pinctrl-1 = <&spi3_sleep_alt>;
5050
pinctrl-names = "default", "sleep";
5151
overrun-character = <0x00>;
52-
cs-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
52+
cs-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>;
5353
dut_spi_dt: test-spi-dev@0 {
5454
compatible = "vnd,spi-device";
5555
reg = <0>;
56-
spi-max-frequency = <200000>;
56+
spi-max-frequency = <4000000>;
5757
};
5858
};
5959

@@ -64,9 +64,4 @@ dut_spis: &spi1 {
6464
pinctrl-0 = <&spi1_default_alt>;
6565
pinctrl-1 = <&spi1_sleep_alt>;
6666
pinctrl-names = "default", "sleep";
67-
dut_spis_dt: test-spis-dev@0 {
68-
compatible = "vnd,spi-device";
69-
reg = <0>;
70-
spi-max-frequency = <200000>;
71-
};
7267
};
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&pinctrl {
8+
spi130_default_alt: spi130_default_alt {
9+
group1 {
10+
psels = <NRF_PSEL(SPIM_SCK, 0, 0)>,
11+
<NRF_PSEL(SPIM_MISO, 0, 6)>,
12+
<NRF_PSEL(SPIM_MOSI, 0, 8)>;
13+
};
14+
};
15+
16+
spi130_sleep_alt: spi130_sleep_alt {
17+
group1 {
18+
psels = <NRF_PSEL(SPIM_SCK, 0, 0)>,
19+
<NRF_PSEL(SPIM_MISO, 0, 6)>,
20+
<NRF_PSEL(SPIM_MOSI, 0, 8)>;
21+
low-power-enable;
22+
};
23+
};
24+
25+
spis131_default_alt: spis131_default_alt {
26+
group1 {
27+
psels = <NRF_PSEL(SPIS_SCK, 0, 1)>,
28+
<NRF_PSEL(SPIS_MISO, 0, 7)>,
29+
<NRF_PSEL(SPIS_MOSI, 0, 9)>,
30+
<NRF_PSEL(SPIS_CSN, 0, 11)>;
31+
};
32+
};
33+
34+
spis131_sleep_alt: spis131_sleep_alt {
35+
group1 {
36+
psels = <NRF_PSEL(SPIS_SCK, 0, 1)>,
37+
<NRF_PSEL(SPIS_MISO, 0, 7)>,
38+
<NRF_PSEL(SPIS_MOSI, 0, 9)>,
39+
<NRF_PSEL(SPIS_CSN, 0, 11)>;
40+
low-power-enable;
41+
};
42+
};
43+
44+
};
45+
46+
&gpio0 {
47+
status = "okay";
48+
};
49+
50+
&spi130 {
51+
compatible = "nordic,nrf-spim";
52+
status = "okay";
53+
pinctrl-0 = <&spi130_default_alt>;
54+
pinctrl-1 = <&spi130_sleep_alt>;
55+
pinctrl-names = "default", "sleep";
56+
overrun-character = <0x00>;
57+
cs-gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
58+
dut_spi_dt: test-spi-dev@0 {
59+
compatible = "vnd,spi-device";
60+
reg = <0>;
61+
spi-max-frequency = <500000>;
62+
};
63+
memory-regions = <&cpuapp_dma_region>;
64+
};
65+
66+
dut_spis: &spi131 {
67+
compatible = "nordic,nrf-spis";
68+
status = "okay";
69+
def-char = <0x00>;
70+
pinctrl-0 = <&spis131_default_alt>;
71+
pinctrl-1 = <&spis131_sleep_alt>;
72+
pinctrl-names = "default", "sleep";
73+
memory-regions = <&cpuapp_dma_region>;
74+
/delete-property/rx-delay-supported;
75+
/delete-property/rx-delay;
76+
};

tests/drivers/spi/spi_error_cases/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
status = "okay";
4848
};
4949

50-
dut_spi: &spi22 {
50+
&spi22 {
5151
status = "okay";
5252
pinctrl-0 = <&spi22_default_alt>;
5353
pinctrl-1 = <&spi22_sleep_alt>;
@@ -57,7 +57,7 @@ dut_spi: &spi22 {
5757
dut_spi_dt: test-spi-dev@0 {
5858
compatible = "vnd,spi-device";
5959
reg = <0>;
60-
spi-max-frequency = <200000>;
60+
spi-max-frequency = <4000000>;
6161
};
6262
};
6363

@@ -68,11 +68,6 @@ dut_spis: &spi21 {
6868
pinctrl-0 = <&spi21_default_alt>;
6969
pinctrl-1 = <&spi21_sleep_alt>;
7070
pinctrl-names = "default", "sleep";
71-
dut_spis_dt: test-spis-dev@0 {
72-
compatible = "vnd,spi-device";
73-
reg = <0>;
74-
spi-max-frequency = <200000>;
75-
};
7671
/delete-property/rx-delay-supported;
7772
/delete-property/rx-delay;
7873
};

tests/drivers/spi/spi_error_cases/src/main.c

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,26 @@
88
#include <string.h>
99
#include <zephyr/kernel.h>
1010
#include <zephyr/drivers/spi.h>
11+
#include <zephyr/linker/devicetree_regions.h>
1112
#include <zephyr/ztest.h>
1213

1314
#define SPI_MODE (SPI_MODE_CPOL | SPI_WORD_SET(8) | SPI_LINES_SINGLE)
1415
#define SPIM_OP (SPI_OP_MODE_MASTER | SPI_MODE)
1516
#define SPIS_OP (SPI_OP_MODE_SLAVE | SPI_MODE)
1617

1718
static struct spi_dt_spec spim = SPI_DT_SPEC_GET(DT_NODELABEL(dut_spi_dt), SPIM_OP, 0);
18-
static struct spi_dt_spec spis = SPI_DT_SPEC_GET(DT_NODELABEL(dut_spis_dt), SPIS_OP, 0);
19+
static const struct device *spis_dev = DEVICE_DT_GET(DT_NODELABEL(dut_spis));
20+
static const struct spi_config spis_config = {
21+
.operation = SPIS_OP
22+
};
1923

2024
#define MEMORY_SECTION(node) \
2125
COND_CODE_1(DT_NODE_HAS_PROP(node, memory_regions), \
2226
(__attribute__((__section__( \
2327
LINKER_DT_NODE_REGION_NAME(DT_PHANDLE(node, memory_regions)))))), \
2428
())
2529

26-
static uint8_t spim_buffer[32] MEMORY_SECTION(DT_NODELABEL(dut_spi));
30+
static uint8_t spim_buffer[32] MEMORY_SECTION(DT_BUS(DT_NODELABEL(dut_spi_dt)));
2731
static uint8_t spis_buffer[32] MEMORY_SECTION(DT_NODELABEL(dut_spis));
2832

2933
struct test_data {
@@ -64,14 +68,14 @@ ZTEST(spi_error_cases, test_SPI_HALF_DUPLEX_not_supported)
6468
int rv;
6569
int slave_rv;
6670
struct spi_dt_spec spim_invalid = spim;
67-
struct spi_dt_spec spis_invalid = spis;
71+
struct spi_config spis_config_invalid = spis_config;
6872

6973
spim_invalid.config.operation |= SPI_HALF_DUPLEX;
70-
spis_invalid.config.operation |= SPI_HALF_DUPLEX;
74+
spis_config_invalid.operation |= SPI_HALF_DUPLEX;
7175

7276
rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set);
7377
zassert_equal(rv, -ENOTSUP, "Got %d instead", rv);
74-
slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set);
78+
slave_rv = spi_transceive(spis_dev, &spis_config_invalid, tdata.stx_set, tdata.srx_set);
7579
zassert_equal(slave_rv, -ENOTSUP, "Got %d instead", slave_rv);
7680
}
7781

@@ -80,16 +84,16 @@ ZTEST(spi_error_cases, test_SPI_OP_MODE_invalid)
8084
int rv;
8185
int slave_rv;
8286
struct spi_dt_spec spim_invalid = spim;
83-
struct spi_dt_spec spis_invalid = spis;
87+
struct spi_config spis_config_invalid = spis_config;
8488

8589
spim_invalid.config.operation |= SPI_OP_MODE_SLAVE;
86-
spis_invalid.config.operation &= !SPI_OP_MODE_SLAVE;
90+
spis_config_invalid.operation &= !SPI_OP_MODE_SLAVE;
8791

8892
/* Check that Operation Mode Slave on spim is not supported */
8993
rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set);
9094
zassert_equal(rv, -EINVAL, "Got %d instead", rv);
9195
/* Check that Operation Mode Master on spis is not supported */
92-
slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set);
96+
slave_rv = spi_transceive(spis_dev, &spis_config_invalid, tdata.stx_set, tdata.srx_set);
9397
zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv);
9498
}
9599

@@ -98,14 +102,14 @@ ZTEST(spi_error_cases, test_SPI_MODE_LOOP_not_supported)
98102
int rv;
99103
int slave_rv;
100104
struct spi_dt_spec spim_invalid = spim;
101-
struct spi_dt_spec spis_invalid = spis;
105+
struct spi_config spis_config_invalid = spis_config;
102106

103107
spim_invalid.config.operation |= SPI_MODE_LOOP;
104-
spis_invalid.config.operation |= SPI_MODE_LOOP;
108+
spis_config_invalid.operation |= SPI_MODE_LOOP;
105109

106110
rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set);
107111
zassert_equal(rv, -EINVAL, "Got %d instead", rv);
108-
slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set);
112+
slave_rv = spi_transceive(spis_dev, &spis_config_invalid, tdata.stx_set, tdata.srx_set);
109113
zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv);
110114
}
111115

@@ -114,34 +118,34 @@ ZTEST(spi_error_cases, test_only_SPI_LINES_SINGLE_supported)
114118
int rv;
115119
int slave_rv;
116120
struct spi_dt_spec spim_invalid = spim;
117-
struct spi_dt_spec spis_invalid = spis;
121+
struct spi_config spis_config_invalid = spis_config;
118122

119123
spim_invalid.config.operation |= SPI_LINES_DUAL;
120-
spis_invalid.config.operation |= SPI_LINES_DUAL;
124+
spis_config_invalid.operation |= SPI_LINES_DUAL;
121125

122126
rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set);
123127
zassert_equal(rv, -EINVAL, "Got %d instead", rv);
124-
slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set);
128+
slave_rv = spi_transceive(spis_dev, &spis_config_invalid, tdata.stx_set, tdata.srx_set);
125129
zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv);
126130

127131
spim_invalid = spim;
128-
spis_invalid = spis;
132+
spis_config_invalid = spis_config;
129133
spim_invalid.config.operation |= SPI_LINES_QUAD;
130-
spis_invalid.config.operation |= SPI_LINES_QUAD;
134+
spis_config_invalid.operation |= SPI_LINES_QUAD;
131135

132136
rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set);
133137
zassert_equal(rv, -EINVAL, "Got %d instead", rv);
134-
slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set);
138+
slave_rv = spi_transceive(spis_dev, &spis_config_invalid, tdata.stx_set, tdata.srx_set);
135139
zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv);
136140

137141
spim_invalid = spim;
138-
spis_invalid = spis;
142+
spis_config_invalid = spis_config;
139143
spim_invalid.config.operation |= SPI_LINES_OCTAL;
140-
spis_invalid.config.operation |= SPI_LINES_OCTAL;
144+
spis_config_invalid.operation |= SPI_LINES_OCTAL;
141145

142146
rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set);
143147
zassert_equal(rv, -EINVAL, "Got %d instead", rv);
144-
slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set);
148+
slave_rv = spi_transceive(spis_dev, &spis_config_invalid, tdata.stx_set, tdata.srx_set);
145149
zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv);
146150
}
147151

@@ -150,14 +154,14 @@ ZTEST(spi_error_cases, test_only_8BIT_supported)
150154
int rv;
151155
int slave_rv;
152156
struct spi_dt_spec spim_invalid = spim;
153-
struct spi_dt_spec spis_invalid = spis;
157+
struct spi_config spis_config_invalid = spis_config;
154158

155159
spim_invalid.config.operation |= SPI_WORD_SET(16);
156-
spis_invalid.config.operation |= SPI_WORD_SET(16);
160+
spis_config_invalid.operation |= SPI_WORD_SET(16);
157161

158162
rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set);
159163
zassert_equal(rv, -EINVAL, "Got %d instead", rv);
160-
slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set);
164+
slave_rv = spi_transceive(spis_dev, &spis_config_invalid, tdata.stx_set, tdata.srx_set);
161165
zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv);
162166
}
163167

@@ -175,12 +179,12 @@ ZTEST(spi_error_cases, test_unsupported_frequency)
175179
ZTEST(spi_error_cases, test_CS_unsupported_on_slave)
176180
{
177181
int slave_rv;
178-
struct spi_dt_spec spis_invalid = spis;
179-
struct gpio_dt_spec test_gpio = { DEVICE_DT_GET(DT_NODELABEL(gpio1)), 10, GPIO_ACTIVE_LOW };
182+
struct spi_config spis_config_invalid = spis_config;
183+
struct gpio_dt_spec test_gpio = { DEVICE_DT_GET(DT_NODELABEL(gpio0)), 10, GPIO_ACTIVE_LOW };
180184

181-
spis_invalid.config.cs.gpio = test_gpio;
185+
spis_config_invalid.cs.gpio = test_gpio;
182186

183-
slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set);
187+
slave_rv = spi_transceive(spis_dev, &spis_config_invalid, tdata.stx_set, tdata.srx_set);
184188
zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv);
185189
}
186190

@@ -189,7 +193,7 @@ ZTEST(spi_error_cases, test_spis_scattered_tx_buf_not_supported)
189193
int slave_rv;
190194

191195
tdata.sets[2].count = 2;
192-
slave_rv = spi_transceive_dt(&spis, tdata.stx_set, tdata.srx_set);
196+
slave_rv = spi_transceive(spis_dev, &spis_config, tdata.stx_set, tdata.srx_set);
193197
zassert_equal(slave_rv, -ENOTSUP, "Got %d instead", slave_rv);
194198
}
195199

@@ -198,7 +202,7 @@ ZTEST(spi_error_cases, test_spis_scattered_rx_buf_not_supported)
198202
int slave_rv;
199203

200204
tdata.sets[3].count = 2;
201-
slave_rv = spi_transceive_dt(&spis, tdata.stx_set, tdata.srx_set);
205+
slave_rv = spi_transceive(spis_dev, &spis_config, tdata.stx_set, tdata.srx_set);
202206
zassert_equal(slave_rv, -ENOTSUP, "Got %d instead", slave_rv);
203207
}
204208

@@ -207,7 +211,7 @@ ZTEST(spi_error_cases, test_spis_tx_buf_too_big)
207211
int slave_rv;
208212

209213
tdata.bufs[2].len = (size_t)65536;
210-
slave_rv = spi_transceive_dt(&spis, tdata.stx_set, tdata.srx_set);
214+
slave_rv = spi_transceive(spis_dev, &spis_config, tdata.stx_set, tdata.srx_set);
211215
zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv);
212216
}
213217

@@ -216,7 +220,7 @@ ZTEST(spi_error_cases, test_spis_rx_buf_too_big)
216220
int slave_rv;
217221

218222
tdata.bufs[3].len = (size_t)65536;
219-
slave_rv = spi_transceive_dt(&spis, tdata.stx_set, tdata.srx_set);
223+
slave_rv = spi_transceive(spis_dev, &spis_config, tdata.stx_set, tdata.srx_set);
220224
zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv);
221225
}
222226

@@ -225,7 +229,7 @@ ZTEST(spi_error_cases, test_spis_tx_buf_not_in_ram)
225229
int slave_rv;
226230

227231
tdata.bufs[2].buf = (void *)0x12345678;
228-
slave_rv = spi_transceive_dt(&spis, tdata.stx_set, tdata.srx_set);
232+
slave_rv = spi_transceive(spis_dev, &spis_config, tdata.stx_set, tdata.srx_set);
229233
zassert_equal(slave_rv, -ENOTSUP, "Got %d instead", slave_rv);
230234
}
231235

tests/drivers/spi/spi_error_cases/testcase.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ tests:
88
platform_allow:
99
- nrf52840dk/nrf52840
1010
- nrf54l15pdk/nrf54l15/cpuapp
11+
- nrf54h20dk/nrf54h20/cpuapp
1112
integration_platforms:
1213
- nrf52840dk/nrf52840

0 commit comments

Comments
 (0)