Skip to content

Commit

Permalink
tests: benchmarks: multicore: Test PM in SPI driver with locks
Browse files Browse the repository at this point in the history
Extend test that checks:
- current consumption in IDLE, S2RAM when SPIM was used;
- SPIM works correctly after leaving low power state.

Add test suites where SPI is configured with
SPI_HOLD_ON_CS and/or SPI_LOCK_ON.

Confirm that SPI CS line activation/deactivation is
according to:
- SPI_HOLD_ON_CS configuration;
- spi_release_dt() calls;
- not affected by the Device Runtime Power Management.

Signed-off-by: Sebastian Głąb <[email protected]>
  • Loading branch information
nordic-segl committed Nov 25, 2024
1 parent a07b87c commit 2709a0e
Show file tree
Hide file tree
Showing 10 changed files with 612 additions and 57 deletions.
32 changes: 30 additions & 2 deletions tests/benchmarks/multicore/idle_spim_loopback/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#

config TEST_SLEEP_DURATION_MS
int "Amount of time (in miliseconds) the core is sleeping"
int "Amount of time (in milliseconds) the core is sleeping"
default 1000
help
Set sleep duration to TEST_SLEEP_DURATION_MS miliseconds.
Set sleep duration to TEST_SLEEP_DURATION_MS milliseconds.
Based on the value of 'min-residency-us' specified for each power state defined in the DTS,
core enters the lowest possible power state.

Expand All @@ -19,4 +19,32 @@ config DATA_FIELD
Set number of bytes exchanged in single spi_transceive() operation.
Values from 1 to 16 bytes are confirmed to work correctly.

config TEST_SPI_HOLD_ON_CS
bool "Enable / Disable test for SPI chip select hold"
help
By default, each spi_transceive_dt() activates SPI CS signal before transmission and
deactivates it after the transmission has completed.
When this KConfig is enabled, first SPI transmission activates SPI CS signal and
it is kept active until spi_release() is executed.

config TEST_SPI_LOCK_ON
bool "Test with SPI lock enabled/disabled"
help
Keep the device locked after the transaction for the current config.
I have no idea what it does.
When this KConfig is enabled, SPI device is locked until spi_release() is executed.

config TEST_SPI_RELEASE_BEFORE_SLEEP
bool "Enable / Disable release of the SPI device"
depends on TEST_SPI_HOLD_ON_CS || TEST_SPI_LOCK_ON
default y
help
When this KConfig is enabled, SPI is released before entering low power state.
When TEST_SPI_HOLD_ON_CS=y and TEST_SPI_RELEASE_BEFORE_SLEEP=y then
each test iteration will see one rising and one falling edge on SPI CS signal.
When TEST_SPI_HOLD_ON_CS=y and TEST_SPI_RELEASE_BEFORE_SLEEP=n then
first test iteration will see SPI CS signal activation. Next test iterations
will NOT observe changes on SPI CS signal.


source "Kconfig.zephyr"
10 changes: 0 additions & 10 deletions tests/benchmarks/multicore/idle_spim_loopback/Kconfig.sysbuild

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/* Test requires two wire connections:
* - SPIM_MOSI with SPIM_MISO -> P0.07 - P0.06;
* - SPI cs-gpios with test-gpios -> P0.10 - P0.11.
* Test-gpios and cs-gpios must have identical active level flag.
*/

/ {
zephyr,user {
test-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
};
};

&gpiote130 {
status = "okay";
owned-channels = <0>;
};

&pinctrl {
spi130_default_alt: spi130_default_alt {
group1 {
Expand Down Expand Up @@ -31,6 +48,7 @@
pinctrl-names = "default", "sleep";
overrun-character = <0x00>;
memory-regions = <&cpuapp_dma_region>;
cs-gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
zephyr,pm-device-runtime-auto;
dut_spi_dt: test-spi-dev@0 {
compatible = "vnd,spi-device";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/* Test requires two wire connections:
* - SPIM_MOSI with SPIM_MISO -> P7.06 - P7.07;
* - SPI cs-gpios with test-gpios -> P0.10 - P0.11.
* Test-gpios and cs-gpios must have identical active level flag.
*/

/ {
zephyr,user {
test-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
};
};

&gpiote130 {
status = "okay";
owned-channels = <0>;
};

&pinctrl {
spi120_default: spi120_default {
group1 {
Expand Down Expand Up @@ -36,6 +53,7 @@
pinctrl-names = "default", "sleep";
overrun-character = <0x00>;
memory-regions = <&dma_fast_region>;
cs-gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>;
zephyr,pm-device-runtime-auto;
dut_spi_dt: test-spi-dev@0 {
compatible = "vnd,spi-device";
Expand Down
3 changes: 3 additions & 0 deletions tests/benchmarks/multicore/idle_spim_loopback/prj.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
CONFIG_PRINTK=y
CONFIG_LOG=y
CONFIG_SPI=y
CONFIG_GPIO=y

CONFIG_ASSERT=y

CONFIG_NRF_REGTOOL_VERBOSITY=1
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ CONFIG_UART_CONSOLE=n
CONFIG_SERIAL=n

CONFIG_SPI=y
CONFIG_GPIO=y
CONFIG_ASSERT=y
Loading

0 comments on commit 2709a0e

Please sign in to comment.