]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dtoc: add test for cd-gpios
authorWalter Lozano <walter.lozano@collabora.com>
Thu, 25 Jun 2020 04:10:17 +0000 (01:10 -0300)
committerSimon Glass <sjg@chromium.org>
Fri, 10 Jul 2020 04:00:29 +0000 (22:00 -0600)
Add a test for dtoc taking into account the cd-gpios property.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
tools/dtoc/dtoc_test_phandle_cd_gpios.dts [new file with mode: 0644]
tools/dtoc/test_dtoc.py

diff --git a/tools/dtoc/dtoc_test_phandle_cd_gpios.dts b/tools/dtoc/dtoc_test_phandle_cd_gpios.dts
new file mode 100644 (file)
index 0000000..241743e
--- /dev/null
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test device tree file for dtoc
+ *
+ * Copyright 2020 Collabora Ltd.
+ */
+
+/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>;
+       };
+};
index 67ca9a8da14593f1f18b5802b80618518214c0bd..3c8e343b1ff8f71a2b30ffe7175a702d3d555e96 100755 (executable)
@@ -466,6 +466,73 @@ U_BOOT_DEVICE(phandle_source2) = {
 void dm_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, True)
+        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),
+};
+
+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),
+};
+
+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),
+};
+
+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),
+};
+
+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),
+};
+
+void dm_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):