X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=common%2Ffdt_support.c;h=f9f358e7e8308e17dd76a6268558f45f3fa0d570;hb=0782bdf89878f3b4806b127b60f8d0e72c195354;hp=b034c9835ba747aee9be296332db43a54ef00bd9;hpb=c2120fbfbc4d1f6953228f86be8bdbf38bacfdab;p=u-boot diff --git a/common/fdt_support.c b/common/fdt_support.c index b034c9835b..f9f358e7e8 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -21,6 +21,34 @@ */ DECLARE_GLOBAL_DATA_PTR; +/* + * Get cells len in bytes + * if #NNNN-cells property is 2 then len is 8 + * otherwise len is 4 + */ +static int get_cells_len(void *blob, char *nr_cells_name) +{ + const fdt32_t *cell; + + cell = fdt_getprop(blob, 0, nr_cells_name, NULL); + if (cell && fdt32_to_cpu(*cell) == 2) + return 8; + + return 4; +} + +/* + * Write a 4 or 8 byte big endian cell + */ +static void write_cell(u8 *addr, u64 val, int size) +{ + int shift = (size - 1) * 8; + while (size-- > 0) { + *addr++ = (val >> shift) & 0xff; + shift -= 8; + } +} + /** * fdt_getprop_u32_default - Find a node and return it's property or a default * @@ -131,9 +159,9 @@ static int fdt_fixup_stdout(void *fdt, int chosenoff) int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force) { - int nodeoffset; + int nodeoffset, addr_cell_len; int err, j, total; - fdt32_t tmp; + fdt64_t tmp; const char *path; uint64_t addr, size; @@ -170,20 +198,22 @@ int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force) return err; } + addr_cell_len = get_cells_len(fdt, "#address-cells"); + path = fdt_getprop(fdt, nodeoffset, "linux,initrd-start", NULL); if ((path == NULL) || force) { - tmp = cpu_to_fdt32(initrd_start); + write_cell((u8 *)&tmp, initrd_start, addr_cell_len); err = fdt_setprop(fdt, nodeoffset, - "linux,initrd-start", &tmp, sizeof(tmp)); + "linux,initrd-start", &tmp, addr_cell_len); if (err < 0) { printf("WARNING: " "could not set linux,initrd-start %s.\n", fdt_strerror(err)); return err; } - tmp = cpu_to_fdt32(initrd_end); + write_cell((u8 *)&tmp, initrd_end, addr_cell_len); err = fdt_setprop(fdt, nodeoffset, - "linux,initrd-end", &tmp, sizeof(tmp)); + "linux,initrd-end", &tmp, addr_cell_len); if (err < 0) { printf("WARNING: could not set linux,initrd-end %s.\n", fdt_strerror(err)); @@ -343,34 +373,6 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat, do_fixup_by_compat(fdt, compat, prop, &tmp, 4, create); } -/* - * Get cells len in bytes - * if #NNNN-cells property is 2 then len is 8 - * otherwise len is 4 - */ -static int get_cells_len(void *blob, char *nr_cells_name) -{ - const fdt32_t *cell; - - cell = fdt_getprop(blob, 0, nr_cells_name, NULL); - if (cell && fdt32_to_cpu(*cell) == 2) - return 8; - - return 4; -} - -/* - * Write a 4 or 8 byte big endian cell - */ -static void write_cell(u8 *addr, u64 val, int size) -{ - int shift = (size - 1) * 8; - while (size-- > 0) { - *addr++ = (val >> shift) & 0xff; - shift -= 8; - } -} - #ifdef CONFIG_NR_DRAM_BANKS #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS #else @@ -400,10 +402,11 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks) nodeoffset = fdt_path_offset(blob, "/memory"); if (nodeoffset < 0) { nodeoffset = fdt_add_subnode(blob, 0, "memory"); - if (nodeoffset < 0) + if (nodeoffset < 0) { printf("WARNING: could not create /memory: %s.\n", fdt_strerror(nodeoffset)); - return nodeoffset; + return nodeoffset; + } } err = fdt_setprop(blob, nodeoffset, "device_type", "memory", sizeof("memory")); @@ -766,11 +769,11 @@ int fdt_node_set_part_info(void *blob, int parent_offset, part = list_entry(pentry, struct part_info, link); - debug("%2d: %-20s0x%08x\t0x%08x\t%d\n", + debug("%2d: %-20s0x%08llx\t0x%08llx\t%d\n", part_num, part->name, part->size, part->offset, part->mask_flags); - sprintf(buf, "partition@%x", part->offset); + sprintf(buf, "partition@%llx", part->offset); add_sub: ret = fdt_add_subnode(blob, parent_offset, buf); if (ret == -FDT_ERR_NOSPACE) {