Merge branch '2021-09-24-arm64-optimized-str-funcs' into next
[platform/kernel/u-boot.git] / common / fdt_support.c
index a9a32df..8992ac5 100644 (file)
@@ -420,6 +420,24 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,
 #else
 #define MEMORY_BANKS_MAX 4
 #endif
+
+/**
+ * fdt_fixup_memory_banks - Update DT memory node
+ * @blob: Pointer to DT blob
+ * @start: Pointer to memory start addresses array
+ * @size: Pointer to memory sizes array
+ * @banks: Number of memory banks
+ *
+ * Return: 0 on success, negative value on failure
+ *
+ * Based on the passed number of banks and arrays, the function is able to
+ * update existing DT memory nodes to match run time detected/changed memory
+ * configuration. Implementation is handling one specific case with only one
+ * memory node where multiple tuples could be added/updated.
+ * The case where multiple memory nodes with a single tuple (base, size) are
+ * used, this function is only updating the first memory node without removing
+ * others.
+ */
 int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
 {
        int err, nodeoffset;
@@ -579,7 +597,7 @@ void fdt_fixup_ethernet(void *fdt)
 
                        for (j = 0; j < 6; j++) {
                                mac_addr[j] = tmp ?
-                                             simple_strtoul(tmp, &end, 16) : 0;
+                                             hextoul(tmp, &end) : 0;
                                if (tmp)
                                        tmp = (*end) ? end + 1 : end;
                        }
@@ -594,7 +612,7 @@ void fdt_fixup_ethernet(void *fdt)
 
 int fdt_record_loadable(void *blob, u32 index, const char *name,
                        uintptr_t load_addr, u32 size, uintptr_t entry_point,
-                       const char *type, const char *os)
+                       const char *type, const char *os, const char *arch)
 {
        int err, node;
 
@@ -622,6 +640,8 @@ int fdt_record_loadable(void *blob, u32 index, const char *name,
                fdt_setprop_string(blob, node, "type", type);
        if (os)
                fdt_setprop_string(blob, node, "os", os);
+       if (arch)
+               fdt_setprop_string(blob, node, "arch", arch);
 
        return node;
 }