All of lore.kernel.org
 help / color / mirror / Atom feed
From: Walter Lozano <walter.lozano@collabora.com>
To: u-boot@lists.denx.de
Subject: [RFC 6/6] dtoc add test for cd-gpios
Date: Wed, 13 May 2020 17:13:45 -0300	[thread overview]
Message-ID: <20200513201345.26769-7-walter.lozano@collabora.com> (raw)
In-Reply-To: <20200513201345.26769-1-walter.lozano@collabora.com>

Add a test for dtoc taking into account the cd-gpios property.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
---
 tools/dtoc/dtoc_test_phandle_cd_gpios.dts | 42 +++++++++++++
 tools/dtoc/test_dtoc.py                   | 72 +++++++++++++++++++++++
 2 files changed, 114 insertions(+)
 create mode 100644 tools/dtoc/dtoc_test_phandle_cd_gpios.dts

diff --git a/tools/dtoc/dtoc_test_phandle_cd_gpios.dts b/tools/dtoc/dtoc_test_phandle_cd_gpios.dts
new file mode 100644
index 0000000000..1029ce03b8
--- /dev/null
+++ b/tools/dtoc/dtoc_test_phandle_cd_gpios.dts
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test device tree file for dtoc
+ *
+ * Copyright 2017 Google, Inc
+ */
+
+ /dts-v1/;
+
+/ {
+	phandle: phandle-target {
+		u-boot,dm-pre-reloc;
+		compatible = "target";
+		intval = <0>;
+                #gpio-cells = <0>;
+	};
+
+	phandle_1: phandle2-target {
+		u-boot,dm-pre-reloc;
+		compatible = "target";
+		intval = <1>;
+		#gpio-cells = <1>;
+	};
+	phandle_2: phandle3-target {
+		u-boot,dm-pre-reloc;
+		compatible = "target";
+		intval = <2>;
+		#gpio-cells = <2>;
+	};
+
+	phandle-source {
+		u-boot,dm-pre-reloc;
+		compatible = "source";
+		cd-gpios = <&phandle &phandle_1 11 &phandle_2 12 13 &phandle>;
+	};
+
+	phandle-source2 {
+		u-boot,dm-pre-reloc;
+		compatible = "source";
+		cd-gpios = <&phandle>;
+	};
+};
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 814988c374..f3d5e77880 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -407,6 +407,78 @@ U_BOOT_DEVICE(phandle_source2) = {
 void populate_phandle_data(void) {
 \tdtv_phandle_source2.clocks[0].node = DM_GET_DEVICE(phandle_target);
 }
+''', data)
+
+    def test_phandle_cd_gpio(self):
+        """Test that phandle targets are generated when unsing cd-gpios"""
+        dtb_file = get_dtb_file('dtoc_test_phandle_cd_gpios.dts')
+        output = tools.GetOutputFilename('output')
+        dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
+        with open(output) as infile:
+            data = infile.read()
+        self._CheckStrings(C_HEADER + '''
+static struct dtd_target dtv_phandle_target = {
+\t.intval\t\t\t= 0x0,
+};
+U_BOOT_DEVICE(phandle_target) = {
+\t.name\t\t= "target",
+\t.platdata\t= &dtv_phandle_target,
+\t.platdata_size\t= sizeof(dtv_phandle_target),
+\t.dev\t\t= NULL,
+};
+
+static struct dtd_target dtv_phandle2_target = {
+\t.intval\t\t\t= 0x1,
+};
+U_BOOT_DEVICE(phandle2_target) = {
+\t.name\t\t= "target",
+\t.platdata\t= &dtv_phandle2_target,
+\t.platdata_size\t= sizeof(dtv_phandle2_target),
+\t.dev\t\t= NULL,
+};
+
+static struct dtd_target dtv_phandle3_target = {
+\t.intval\t\t\t= 0x2,
+};
+U_BOOT_DEVICE(phandle3_target) = {
+\t.name\t\t= "target",
+\t.platdata\t= &dtv_phandle3_target,
+\t.platdata_size\t= sizeof(dtv_phandle3_target),
+\t.dev\t\t= NULL,
+};
+
+static struct dtd_source dtv_phandle_source = {
+\t.cd_gpios\t\t= {
+\t\t\t{NULL, {}},
+\t\t\t{NULL, {11}},
+\t\t\t{NULL, {12, 13}},
+\t\t\t{NULL, {}},},
+};
+U_BOOT_DEVICE(phandle_source) = {
+\t.name\t\t= "source",
+\t.platdata\t= &dtv_phandle_source,
+\t.platdata_size\t= sizeof(dtv_phandle_source),
+\t.dev\t\t= NULL,
+};
+
+static struct dtd_source dtv_phandle_source2 = {
+\t.cd_gpios\t\t= {
+\t\t\t{NULL, {}},},
+};
+U_BOOT_DEVICE(phandle_source2) = {
+\t.name\t\t= "source",
+\t.platdata\t= &dtv_phandle_source2,
+\t.platdata_size\t= sizeof(dtv_phandle_source2),
+\t.dev\t\t= NULL,
+};
+
+void populate_phandle_data(void) {
+\tdtv_phandle_source.cd_gpios[0].node = DM_GET_DEVICE(phandle_target);
+\tdtv_phandle_source.cd_gpios[1].node = DM_GET_DEVICE(phandle2_target);
+\tdtv_phandle_source.cd_gpios[2].node = DM_GET_DEVICE(phandle3_target);
+\tdtv_phandle_source.cd_gpios[3].node = DM_GET_DEVICE(phandle_target);
+\tdtv_phandle_source2.cd_gpios[0].node = DM_GET_DEVICE(phandle_target);
+}
 ''', data)
 
     def test_phandle_bad(self):
-- 
2.20.1

  parent reply	other threads:[~2020-05-13 20:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 20:13 [RFC 0/6] improve OF_PLATDATA support Walter Lozano
2020-05-13 20:13 ` [RFC 1/6] dtoc: add support to scan drivers Walter Lozano
2020-05-20  3:07   ` Simon Glass
2020-05-21 13:15     ` Walter Lozano
2020-05-22 23:13       ` Simon Glass
2020-05-13 20:13 ` [RFC 2/6] core: extend struct driver_info to point to device Walter Lozano
2020-05-20  3:07   ` Simon Glass
2020-05-21 13:15     ` Walter Lozano
2020-05-22 23:13       ` Simon Glass
2020-05-13 20:13 ` [RFC 3/6] dtoc: extend dtoc to use struct driver_info when linking nodes Walter Lozano
2020-05-20  3:07   ` Simon Glass
2020-05-21 13:16     ` Walter Lozano
2020-05-13 20:13 ` [RFC 4/6] dtoc: update tests to match new platdata Walter Lozano
2020-05-20  3:07   ` Simon Glass
2020-05-21 13:16     ` Walter Lozano
2020-05-13 20:13 ` [RFC 5/6] dtoc: update dtb_platdata to support cd-gpios Walter Lozano
2020-05-20  3:07   ` Simon Glass
2020-05-13 20:13 ` Walter Lozano [this message]
2020-05-20  3:07   ` [RFC 6/6] dtoc add test for cd-gpios Simon Glass
2020-05-21 13:16     ` Walter Lozano
2020-05-20  3:07 ` [RFC 0/6] improve OF_PLATDATA support Simon Glass
2020-05-21 13:15   ` Walter Lozano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200513201345.26769-7-walter.lozano@collabora.com \
    --to=walter.lozano@collabora.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.