aboutsummaryrefslogtreecommitdiff
path: root/test/dm
diff options
context:
space:
mode:
authorNicolas Saenz Julienne2021-01-12 13:55:25 +0100
committerMatthias Brugger2021-02-18 11:56:25 +0100
commite88018769cd3ed69d2f1623fe03a02dcb0be073a (patch)
treedfb388767db06776ec49a596e5aec02ba237935f /test/dm
parent4abf68d57d495674e521b693191be1dcada46ecd (diff)
dm: test: Add test case for dev->dma_offset
Add test to validate dev->dma_offset is properly set on devices. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Diffstat (limited to 'test/dm')
-rw-r--r--test/dm/core.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/dm/core.c b/test/dm/core.c
index ce31d86c7da..35ca689d646 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -1180,3 +1180,33 @@ static int dm_test_all_have_seq(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_all_have_seq, UT_TESTF_SCAN_PDATA);
+
+static int dm_test_dma_offset(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+ ofnode node;
+
+ /* Make sure the bus's dma-ranges aren't taken into account here */
+ node = ofnode_path("/mmio-bus@0");
+ ut_assert(ofnode_valid(node));
+ ut_assertok(uclass_get_device_by_ofnode(UCLASS_TEST_BUS, node, &dev));
+ ut_asserteq_64(0, dev->dma_offset);
+
+ /* Device behind a bus with dma-ranges */
+ node = ofnode_path("/mmio-bus@0/subnode@0");
+ ut_assert(ofnode_valid(node));
+ ut_assertok(uclass_get_device_by_ofnode(UCLASS_TEST_FDT, node, &dev));
+ ut_asserteq_64(-0x10000000ULL, dev->dma_offset);
+
+ /* This one has no dma-ranges */
+ node = ofnode_path("/mmio-bus@1");
+ ut_assert(ofnode_valid(node));
+ ut_assertok(uclass_get_device_by_ofnode(UCLASS_TEST_BUS, node, &dev));
+ node = ofnode_path("/mmio-bus@1/subnode@0");
+ ut_assert(ofnode_valid(node));
+ ut_assertok(uclass_get_device_by_ofnode(UCLASS_TEST_FDT, node, &dev));
+ ut_asserteq_64(0, dev->dma_offset);
+
+ return 0;
+}
+DM_TEST(dm_test_dma_offset, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);