]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pstore: Use root address-cells/size-cells as defaults for reserved-memory
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Sat, 26 Aug 2023 12:16:52 +0000 (15:16 +0300)
committerTom Rini <trini@konsulko.com>
Tue, 24 Oct 2023 20:34:45 +0000 (16:34 -0400)
u-boot adds reserve-memory node, if it's missing, with following
properties:

```
    reserved-memory {
         #address-cells = <2>;
         #size-cells = <2>;
         ranges;
    }
```

But with these default address-cells and size-cells values, pstore
isn't working on A64. Root node for A64 defines 'address-cells' and
'size-cells' as 1.

dtc complains if reserved-memory has different address-cells and
size-cells.

```
     Warning (ranges_format): /reserved-memory:ranges: empty "ranges"
     property but its #address-cells (2) differs from / (1)
```

This patch takes into account address-cells and size-cells of the root
node and uses them as values for new reserved-memory node.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
cmd/pstore.c

index cd6f6feb2fd3cfc942ba0b97e926f6fa2f505e58..9795eea2dbc3fc1adc7182e142c4fbf7d89798ce 100644 (file)
@@ -486,6 +486,8 @@ void fdt_fixup_pstore(void *blob)
 {
        char node[32];
        int  nodeoffset;        /* node offset from libfdt */
+       u32 addr_cells_root;
+       u32 size_cells_root;
        u32 addr_cells;
        u32 size_cells;
 
@@ -495,6 +497,8 @@ void fdt_fixup_pstore(void *blob)
                log_err("fdt_path_offset() returned %s\n", fdt_strerror(nodeoffset));
                return;
        }
+       addr_cells_root = fdt_getprop_u32_default_node(blob, nodeoffset, 0, "#address-cells", 2);
+       size_cells_root = fdt_getprop_u32_default_node(blob, nodeoffset, 0, "#size-cells", 2);
 
        nodeoffset = fdt_find_or_add_subnode(blob, nodeoffset, "reserved-memory");
        if (nodeoffset < 0) {
@@ -503,8 +507,10 @@ void fdt_fixup_pstore(void *blob)
                return;
        }
 
-       addr_cells = fdt_getprop_u32_default_node(blob, nodeoffset, 0, "#address-cells", 2);
-       size_cells = fdt_getprop_u32_default_node(blob, nodeoffset, 0, "#size-cells", 2);
+       addr_cells = fdt_getprop_u32_default_node(blob, nodeoffset, 0,
+                                                 "#address-cells", addr_cells_root);
+       size_cells = fdt_getprop_u32_default_node(blob, nodeoffset, 0,
+                                                 "#size-cells", size_cells_root);
        fdt_setprop_u32(blob, nodeoffset, "#address-cells", addr_cells);
        fdt_setprop_u32(blob, nodeoffset, "#size-cells", size_cells);