Skip to content
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
6 changes: 6 additions & 0 deletions tests/drivers/dma/chan_link_transfer/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2025 Alex Apostolu
# SPDX-License-Identifier: Apache-2.0

config DMA_LOOP_TRANSFER_NUMBER_OF_DMAS
int "Number of DMAs to test"
default 1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

&dma0 {
test_dma0: &dma0 {
status = "okay";
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

dma0: &edma0 {};
test_dma0: &edma0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
*
*/

dma0: &edma0 {};
test_dma0: &edma0 {};
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
dma0: &edma0 {};
/*
* Copyright (c) 2025 Alex Apostolu
*
* SPDX-License-Identifier: Apache-2.0
*/

test_dma0: &edma0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
*
*/

dma0: &edma0 {};
test_dma0: &edma0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

dma0: &edma0 {};
test_dma0: &edma0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

dma0: &edma0 {};
test_dma0: &edma0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

dma0: &edma0 {};
test_dma0: &edma0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

dma0: &edma0 {};
test_dma0: &edma0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

dma0: &edma0 {};
test_dma0: &edma0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

dma0: &edma0 {};
test_dma0: &edma0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
status = "okay";
};

dma0: &dma {};
test_dma0: &dma {};
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@

/* Pico 2 is compatible with the Pico 1, so reuse. */
#include "rpi_pico.overlay"

test_dma0: &dma0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
status = "okay";
};

dma0: &edma0 {};
test_dma0: &edma0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
status = "okay";
};

dma0: &edma5 {};
test_dma0: &edma5 {};
45 changes: 30 additions & 15 deletions tests/drivers/dma/chan_link_transfer/src/test_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ static void test_done(const struct device *dma_dev, void *arg, uint32_t id,
}
}

static int test_task(int minor, int major)
static int test_task(const struct device *dma, int minor, int major)
{
struct dma_config dma_cfg = { 0 };
struct dma_block_config dma_block_cfg = { 0 };
const struct device *const dma = DEVICE_DT_GET(DT_NODELABEL(dma0));

if (!device_is_ready(dma)) {
TC_PRINT("dma controller device is not ready\n");
Expand Down Expand Up @@ -148,18 +147,34 @@ static int test_task(int minor, int major)
return TC_PASS;
}

/* export test cases */
ZTEST(dma_m2m_link, test_dma_m2m_chan0_1_major_link)
{
zassert_true((test_task(0, 1) == TC_PASS));
}
#define DMA_NAME(i, _) test_dma##i
#define DMA_LIST LISTIFY(CONFIG_DMA_LOOP_TRANSFER_NUMBER_OF_DMAS, DMA_NAME, (,))

ZTEST(dma_m2m_link, test_dma_m2m_chan0_1_minor_link)
{
zassert_true((test_task(1, 0) == TC_PASS));
}
#define TEST_MAJOR_LINK(dma_name) \
ZTEST(dma_m2m_link, test_##dma_name##_m2m_chan0_1_major_link) \
{ \
const struct device *dma = DEVICE_DT_GET(DT_NODELABEL(dma_name)); \
zassert_true((test_task(dma, 0, 1) == TC_PASS)); \
}

ZTEST(dma_m2m_link, test_dma_m2m_chan0_1_minor_major_link)
{
zassert_true((test_task(1, 1) == TC_PASS));
}
FOR_EACH(TEST_LOOP, (), DMA_LIST)
;

#define TEST_MINOR_LINK(dma_name) \
ZTEST(dma_m2m_link, test_##dma_name##_m2m_chan0_1_minor_link) \
{ \
const struct device *dma = DEVICE_DT_GET(DT_NODELABEL(dma_name)); \
zassert_true((test_task(dma, 1, 0) == TC_PASS)); \
}

FOR_EACH(TEST_LOOP_SUSPEND_RESUME, (), DMA_LIST)
;

#define TEST_MINOR_MAJOR_LINK(dma_name) \
ZTEST(dma_m2m_link, test_##dma_name##_m2m_chan0_1_minor_major_link) \
{ \
const struct device *dma = DEVICE_DT_GET(DT_NODELABEL(dma_name)); \
zassert_true((test_task(dma, 1, 1) == TC_PASS)); \
}

FOR_EACH(TEST_LOOP_REPEATED_START_STOP, (), DMA_LIST);
4 changes: 4 additions & 0 deletions tests/drivers/dma/cyclic/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ mainmenu "DMA Cyclic Test"

source "Kconfig.zephyr"

config DMA_LOOP_TRANSFER_NUMBER_OF_DMAS
int "Number of DMAs to test"
default 1

config DMA_CYCLIC_CHANNEL_NR
int "DMA channel to use"
default 0
Expand Down
8 changes: 1 addition & 7 deletions tests/drivers/dma/cyclic/boards/xmc45_relax_kit.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

/ {
aliases {
dma0 = &dma0;
};
};

&dma0 {
test_dma0: &dma0 {
status = "okay";
};
8 changes: 1 addition & 7 deletions tests/drivers/dma/cyclic/boards/xmc47_relax_kit.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

/ {
aliases {
dma0 = &dma0;
};
};

&dma0 {
test_dma0: &dma0 {
status = "okay";
};
20 changes: 12 additions & 8 deletions tests/drivers/dma/cyclic/src/test_dma_cyclic.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ static void dma_callback(const struct device *dma_dev, void *user_data,
}


static int test_cyclic(void)
static int test_cyclic(const struct device *dma)
{
const struct device *dma;
int chan_id;

TC_PRINT("Preparing DMA Controller\n");
Expand All @@ -48,7 +47,6 @@ static int test_cyclic(void)
tx_data[i] = i;
}

dma = DEVICE_DT_GET(DT_ALIAS(dma0));
if (!device_is_ready(dma)) {
TC_PRINT("dma controller device is not ready\n");
return TC_FAIL;
Expand Down Expand Up @@ -137,8 +135,14 @@ static int test_cyclic(void)
return TC_PASS;
}

/* export test cases */
ZTEST(dma_m2m_cyclic, test_dma_m2m_cyclic)
{
zassert_true((test_cyclic() == TC_PASS));
}
#define DMA_NAME(i, _) test_dma##i
#define DMA_LIST LISTIFY(CONFIG_DMA_LOOP_TRANSFER_NUMBER_OF_DMAS, DMA_NAME, (,))

#define TEST_CYCLIC(dma_name) \
ZTEST(dma_m2m_cyclic, test_##dma_name##_m2m_cyclic) \
{ \
const struct device *dma = DEVICE_DT_GET(DT_NODELABEL(dma_name)); \
zassert_true((test_cyclic(dma) == TC_PASS)); \
}

FOR_EACH(TEST_CYCLIC, (), DMA_LIST);
Loading