]> git.sur5r.net Git - u-boot/commitdiff
test: regmap: test Linux-compatible syscon_node_to_regmap()
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 23 Apr 2018 04:26:53 +0000 (13:26 +0900)
committerTom Rini <trini@konsulko.com>
Mon, 7 May 2018 19:49:52 +0000 (15:49 -0400)
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>
arch/sandbox/dts/test.dts
test/dm/regmap.c

index 06d0e8ce8506ae28add3fe8064c52b3583a409b9..3c25cb79ef194055c7ac70381bb802a4f0b65838 100644 (file)
                        0x38 8>;
        };
 
+       syscon@2 {
+               compatible = "simple-mfd", "syscon";
+               reg = <0x40 5
+                       0x48 6
+                       0x50 7
+                       0x58 8>;
+       };
+
        timer {
                compatible = "sandbox,timer";
                clock-frequency = <1000000>;
index 77b82ce8ac99b86ea5fa23c67198aacb3b7fdaa3..5b51a9048877f1489222d4052d053aa292ef45d3 100644 (file)
@@ -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);