diff mbox series

[U-Boot] test: regmap: test Linux-compatible syscon_node_to_regmap()

Message ID 1524457613-8107-1-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 99552c343576051c9edcf5c9f3fe4186d5c76029
Delegated to: Tom Rini
Headers show
Series [U-Boot] test: regmap: test Linux-compatible syscon_node_to_regmap() | expand

Commit Message

Masahiro Yamada April 23, 2018, 4:26 a.m. UTC
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>
---

 arch/sandbox/dts/test.dts |  8 ++++++++
 test/dm/regmap.c          | 17 +++++++++++++++++
 2 files changed, 25 insertions(+)

Comments

Simon Glass April 25, 2018, 5:01 a.m. UTC | #1
On 22 April 2018 at 22:26, Masahiro Yamada <yamada.masahiro@socionext.com>
wrote:
> 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>
> ---
>
>  arch/sandbox/dts/test.dts |  8 ++++++++
>  test/dm/regmap.c          | 17 +++++++++++++++++
>  2 files changed, 25 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini May 8, 2018, 12:45 a.m. UTC | #2
On Mon, Apr 23, 2018 at 01:26:53PM +0900, Masahiro Yamada wrote:

> 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>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 06d0e8c..3c25cb7 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -393,6 +393,14 @@ 
 			0x38 8>;
 	};
 
+	syscon@2 {
+		compatible = "simple-mfd", "syscon";
+		reg = <0x40 5
+			0x48 6
+			0x50 7
+			0x58 8>;
+	};
+
 	timer {
 		compatible = "sandbox,timer";
 		clock-frequency = <1000000>;
diff --git a/test/dm/regmap.c b/test/dm/regmap.c
index 8125345..698a013 100644
--- a/test/dm/regmap.c
+++ b/test/dm/regmap.c
@@ -20,6 +20,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));
@@ -48,6 +49,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);