X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Ffdt_support.c;h=9e501484625d8583cd1d122e8e6c83f9c6948ac5;hb=04e3c4eb930a761b561cb87f964aa8a5d694c501;hp=127e17c114310fa0b5fbbd12a4968f510a3c1b9a;hpb=e48f3741c357246c78aa367bbd56fe2684f7bf8d;p=oweals%2Fu-boot.git diff --git a/common/fdt_support.c b/common/fdt_support.c index 127e17c114..9e50148462 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -371,22 +371,22 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, int n) { int i; - int address_len = fdt_address_cells(fdt, 0); - int size_len = fdt_size_cells(fdt, 0); + int address_cells = fdt_address_cells(fdt, 0); + int size_cells = fdt_size_cells(fdt, 0); char *p = buf; for (i = 0; i < n; i++) { - if (address_len == 2) + if (address_cells == 2) *(fdt64_t *)p = cpu_to_fdt64(address[i]); else *(fdt32_t *)p = cpu_to_fdt32(address[i]); - p += address_len; + p += 4 * address_cells; - if (size_len == 2) + if (size_cells == 2) *(fdt64_t *)p = cpu_to_fdt64(size[i]); else *(fdt32_t *)p = cpu_to_fdt32(size[i]); - p += size_len; + p += 4 * size_cells; } return p - (char *)buf; @@ -1533,7 +1533,7 @@ int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width, if (ret < 0) return ret; - snprintf(name, sizeof(name), "framebuffer@%llx", base_address); + snprintf(name, sizeof(name), "framebuffer@%" PRIx64, base_address); ret = fdt_set_name(fdt, node, name); if (ret < 0) return ret; @@ -1560,3 +1560,32 @@ int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width, return 0; } + +/* + * Update native-mode in display-timings from display environment variable. + * The node to update are specified by path. + */ +int fdt_fixup_display(void *blob, const char *path, const char *display) +{ + int off, toff; + + if (!display || !path) + return -FDT_ERR_NOTFOUND; + + toff = fdt_path_offset(blob, path); + if (toff >= 0) + toff = fdt_subnode_offset(blob, toff, "display-timings"); + if (toff < 0) + return toff; + + for (off = fdt_first_subnode(blob, toff); + off >= 0; + off = fdt_next_subnode(blob, off)) { + uint32_t h = fdt_get_phandle(blob, off); + debug("%s:0x%x\n", fdt_get_name(blob, off, NULL), + fdt32_to_cpu(h)); + if (strcasecmp(fdt_get_name(blob, off, NULL), display) == 0) + return fdt_setprop_u32(blob, toff, "native-mode", h); + } + return toff; +}