summaryrefslogtreecommitdiff
path: root/test/dm/regmap.c
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-04-23 07:26:53 +0300
committerTom Rini <trini@konsulko.com>2018-05-07 22:49:52 +0300
commit99552c343576051c9edcf5c9f3fe4186d5c76029 (patch)
treea683c5e6e43995c14ba3f124f3713de5d0c45fcf /test/dm/regmap.c
parente151a1c288bd8b3e85ca6386942e6322fa984d96 (diff)
downloadu-boot-99552c343576051c9edcf5c9f3fe4186d5c76029.tar.xz
test: regmap: test Linux-compatible syscon_node_to_regmap()
Like Linux, syscon_node_to_regmap() allows a node to work as a syscon provider without binding it to a syscon driver. Test this. Requested-by: Simon Glass <sjg@chromium.org> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm/regmap.c')
-rw-r--r--test/dm/regmap.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/dm/regmap.c b/test/dm/regmap.c
index 77b82ce8ac..5b51a90488 100644
--- a/test/dm/regmap.c
+++ b/test/dm/regmap.c
@@ -17,6 +17,7 @@ static int dm_test_regmap_base(struct unit_test_state *uts)
{
struct udevice *dev;
struct regmap *map;
+ ofnode node;
int i;
ut_assertok(uclass_get_device(UCLASS_SYSCON, 0, &dev));
@@ -45,6 +46,22 @@ static int dm_test_regmap_base(struct unit_test_state *uts)
map = syscon_get_regmap(dev);
ut_asserteq_ptr(ERR_PTR(-ENOEXEC), map);
+ /* A different device can be a syscon by using Linux-compat API */
+ node = ofnode_path("/syscon@2");
+ ut_assert(ofnode_valid(node));
+
+ map = syscon_node_to_regmap(node);
+ ut_assertok_ptr(map);
+ ut_asserteq(4, map->range_count);
+ ut_asserteq(0x40, map->ranges[0].start);
+ for (i = 0; i < 4; i++) {
+ const unsigned long addr = 0x40 + 8 * i;
+
+ ut_asserteq(addr, map->ranges[i].start);
+ ut_asserteq(5 + i, map->ranges[i].size);
+ ut_asserteq(addr, map_to_sysmem(regmap_get_range(map, i)));
+ }
+
return 0;
}
DM_TEST(dm_test_regmap_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);