diff options
author | Patrick Delaunay <patrick.delaunay@foss.st.com> | 2021-05-21 12:25:00 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-06-05 07:35:47 -0600 |
commit | 269fa8468df40952d538ac945db3d98a8d44f79e (patch) | |
tree | 2e805f45993dd684704a360e47ee8fca79d3f740 | |
parent | 0d1ab576f2e706f221b42e229eeabc80e5b51d35 (diff) | |
download | u-boot-269fa8468df40952d538ac945db3d98a8d44f79e.zip u-boot-269fa8468df40952d538ac945db3d98a8d44f79e.tar.gz u-boot-269fa8468df40952d538ac945db3d98a8d44f79e.tar.bz2 |
test: add dm_test_read_resource
Add a test of dev_read_resource with translation or without translation
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | test/dm/test-fdt.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 9b771fd..d273e21 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -19,6 +19,7 @@ #include <dm/util.h> #include <dm/lists.h> #include <dm/of_access.h> +#include <linux/ioport.h> #include <test/test.h> #include <test/ut.h> @@ -1165,3 +1166,35 @@ static int dm_test_decode_display_timing(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_decode_display_timing, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +/* Test read_resourcee() */ +static int dm_test_read_resource(struct unit_test_state *uts) +{ + struct udevice *dev; + struct resource res; + + /* test resource without translation */ + ut_assertok(uclass_find_device_by_name(UCLASS_SIMPLE_BUS, "syscon@2", &dev)); + ut_assertok(dev_read_resource(dev, 0, &res)); + ut_asserteq(0x40, res.start); + ut_asserteq(0x44, res.end); + ut_assertok(dev_read_resource(dev, 1, &res)); + ut_asserteq(0x48, res.start); + ut_asserteq(0x4d, res.end); + + /* test resource with translation */ + ut_assertok(uclass_find_device_by_name(UCLASS_TEST_DUMMY, "dev@1,100", &dev)); + ut_assertok(dev_read_resource(dev, 0, &res)); + ut_asserteq(0x9000, res.start); + ut_asserteq(0x9fff, res.end); + + /* test named resource */ + ut_assertok(uclass_find_device_by_name(UCLASS_TEST_DUMMY, "dev@0,0", &dev)); + ut_assertok(dev_read_resource_byname(dev, "sandbox-dummy-0", &res)); + ut_asserteq(0x8000, res.start); + ut_asserteq(0x8fff, res.end); + + return 0; +} + +DM_TEST(dm_test_read_resource, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |