From patchwork Mon Apr 23 04:26:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 902733 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="df/ZABMW"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40Ttjq654Wz9s1B for ; Mon, 23 Apr 2018 14:27:58 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id D9C76C21D8A; Mon, 23 Apr 2018 04:27:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 90330C21C29; Mon, 23 Apr 2018 04:27:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C6720C21C29; Mon, 23 Apr 2018 04:27:47 +0000 (UTC) Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lists.denx.de (Postfix) with ESMTPS id CC4A6C21BE5 for ; Mon, 23 Apr 2018 04:27:46 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id w3N4QtHb009312; Mon, 23 Apr 2018 13:26:55 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w3N4QtHb009312 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1524457616; bh=sqxXJ/dMZL2ZeKa6za+9iFBj5/BWtALmlUZqcq2rt0Y=; h=From:To:Cc:Subject:Date:From; b=df/ZABMW+0NZTGPNejuDEYGW1iRBKJ2YIW/Gvziftf5SfO9ZXKfcP4AHYL/Zcny6l dzYFmRe69yNfNkGAGxeBGIUE4ZztPVDmoyRLqXd/EoRyOLPNCiO6kw/8W2rYlWRG9w ZGbjSx7a6GZ3/Hn9u+ACzi14CK1slWOfZvXCa6sWCh2rxFFZJw4VcEG8W96DnME+Jj +pNELDcbBPhMd9PEVq4zCHWAtuGblfl2DggzS5to8AgPYjwtZ3FlvMgkVX47/HdO8U Px2Vy4gFzGbDSnavc5pDFdx6jWS/5n0wyxSnV5QC0eCV1MJ6jH5WMhA3vMpR5K2SCq Svu4m+HBvYL2w== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Mon, 23 Apr 2018 13:26:53 +0900 Message-Id: <1524457613-8107-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Cc: Martin Fuzzey Subject: [U-Boot] [PATCH] test: regmap: test Linux-compatible syscon_node_to_regmap() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- arch/sandbox/dts/test.dts | 8 ++++++++ test/dm/regmap.c | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) 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);