]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dtoc: Adjust detection of 64-bit properties
authorSimon Glass <sjg@chromium.org>
Fri, 26 Mar 2021 03:17:26 +0000 (16:17 +1300)
committerSimon Glass <sjg@chromium.org>
Tue, 6 Apr 2021 04:33:19 +0000 (16:33 +1200)
At present an empty size is considered to be a 64-bit value. This does not
seem useful and wastes space. Limit the 64-bit detection to where one or
both of the addr/size is two cells or more.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/dtoc/dtb_platdata.py
tools/dtoc/test_dtoc.py

index dd97a6be705eaa26cfa53e03b5b1aa58f5942a2f..b989b4f4fcf3d28e88b9db3619518bfc6e5200b6 100644 (file)
@@ -467,6 +467,8 @@ class DtbPlatdata():
             if reg.type != fdt.Type.INT:
                 raise ValueError("Node '%s' reg property is not an int" %
                                  node.name)
+            if not isinstance(reg.value, list):
+                reg.value = [reg.value]
             if len(reg.value) % total:
                 raise ValueError(
                     "Node '%s' reg property has %d cells "
@@ -474,13 +476,11 @@ class DtbPlatdata():
                     (node.name, len(reg.value), num_addr, num_size))
             reg.num_addr = num_addr
             reg.num_size = num_size
-            if num_addr != 1 or num_size != 1:
+            if num_addr > 1 or num_size > 1:
                 reg.type = fdt.Type.INT64
                 i = 0
                 new_value = []
                 val = reg.value
-                if not isinstance(val, list):
-                    val = [val]
                 while i < len(val):
                     addr = fdt_util.fdt_cells_to_cpu(val[i:], reg.num_addr)
                     i += num_addr
index 458d68351e097e67016daa16b7530cc1fb6ddf45..cff522567edc9e650d6bc1d4adf9a637abf4468b 100755 (executable)
@@ -293,7 +293,7 @@ struct dtd_sandbox_i2c {
 };
 struct dtd_sandbox_pmic {
 \tbool\t\tlow_power;
-\tfdt64_t\t\treg[2];
+\tfdt32_t\t\treg[1];
 };
 struct dtd_sandbox_spl_test {
 \tconst char * acpi_name;
@@ -341,7 +341,7 @@ U_BOOT_DRVINFO(i2c_at_0) = {
  */
 static struct dtd_sandbox_pmic dtv_pmic_at_9 = {
 \t.low_power\t\t= true,
-\t.reg\t\t\t= {0x9, 0x0},
+\t.reg\t\t\t= {0x9},
 };
 U_BOOT_DRVINFO(pmic_at_9) = {
 \t.name\t\t= "sandbox_pmic",
@@ -721,7 +721,7 @@ struct dm_test_pdata __attribute__ ((section (".priv_data")))
 \t.dtplat = {
 \t\t.ping_add\t\t= 0x5,
 \t\t.ping_expect\t\t= 0x5,
-\t\t.reg\t\t\t= {0x5, 0x0},
+\t\t.reg\t\t\t= {0x5},
 \t},
 };
 #include <dm/test.h>