X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=common%2Ffdt_support.c;h=dbceec6f2dcc00e4d8c3e4829fa61f4cdb1f6fea;hb=ac2587907b5473779c80e0eb8478b67997c14439;hp=c6b93e788905fae13f034fdc10d1bfa78a0f4507;hpb=b24b201b6063f4d1ad093ad0399bca8eff4f1cff;p=platform%2Fkernel%2Fu-boot.git diff --git a/common/fdt_support.c b/common/fdt_support.c index c6b93e7..dbceec6 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include /** * fdt_getprop_u32_default_node - Return a node's property or a default @@ -278,6 +280,7 @@ __weak char *board_fdt_chosen_bootargs(void) int fdt_chosen(void *fdt) { + struct abuf buf = {}; int nodeoffset; int err; char *str; /* used to set string properties */ @@ -293,6 +296,17 @@ int fdt_chosen(void *fdt) if (nodeoffset < 0) return nodeoffset; + if (IS_ENABLED(CONFIG_BOARD_RNG_SEED) && !board_rng_seed(&buf)) { + err = fdt_setprop(fdt, nodeoffset, "rng-seed", + abuf_data(&buf), abuf_size(&buf)); + abuf_uninit(&buf); + if (err < 0) { + printf("WARNING: could not set rng-seed %s.\n", + fdt_strerror(err)); + return err; + } + } + str = board_fdt_chosen_bootargs(); if (str) { @@ -305,6 +319,15 @@ int fdt_chosen(void *fdt) } } + /* add u-boot version */ + err = fdt_setprop(fdt, nodeoffset, "u-boot,version", PLAIN_VERSION, + strlen(PLAIN_VERSION) + 1); + if (err < 0) { + printf("WARNING: could not set u-boot,version %s.\n", + fdt_strerror(err)); + return err; + } + return fdt_fixup_stdout(fdt, nodeoffset); } @@ -371,12 +394,9 @@ void do_fixup_by_compat(void *fdt, const char *compat, debug(" %.2x", *(u8*)(val+i)); debug("\n"); #endif - off = fdt_node_offset_by_compatible(fdt, -1, compat); - while (off != -FDT_ERR_NOTFOUND) { + fdt_for_each_node_by_compatible(off, fdt, -1, compat) if (create || (fdt_get_property(fdt, off, prop, NULL) != NULL)) fdt_setprop(fdt, off, prop, val, len); - off = fdt_node_offset_by_compatible(fdt, off, compat); - } } void do_fixup_by_compat_u32(void *fdt, const char *compat, @@ -719,7 +739,7 @@ int fdt_delete_disabled_nodes(void *blob) } #ifdef CONFIG_PCI -#define CONFIG_SYS_PCI_NR_INBOUND_WIN 4 +#define CFG_SYS_PCI_NR_INBOUND_WIN 4 #define FDT_PCI_PREFETCH (0x40000000) #define FDT_PCI_MEM32 (0x02000000) @@ -731,7 +751,7 @@ int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose) { int addrcell, sizecell, len, r; u32 *dma_range; /* sized based on pci addr cells, size-cells, & address-cells */ - u32 dma_ranges[(3 + 2 + 2) * CONFIG_SYS_PCI_NR_INBOUND_WIN]; + u32 dma_ranges[(3 + 2 + 2) * CFG_SYS_PCI_NR_INBOUND_WIN]; addrcell = fdt_getprop_u32_default(blob, "/", "#address-cells", 1); sizecell = fdt_getprop_u32_default(blob, "/", "#size-cells", 1); @@ -991,15 +1011,14 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, { struct mtd_device *dev; int i, idx; - int noff; + int noff, parts; bool inited = false; for (i = 0; i < node_info_size; i++) { idx = 0; - noff = -1; - while ((noff = fdt_node_offset_by_compatible(blob, noff, - node_info[i].compat)) >= 0) { + fdt_for_each_node_by_compatible(noff, blob, -1, + node_info[i].compat) { const char *prop; prop = fdt_getprop(blob, noff, "status", NULL); @@ -1018,7 +1037,12 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, dev = device_find(node_info[i].type, idx++); if (dev) { - if (fdt_node_set_part_info(blob, noff, dev)) + parts = fdt_subnode_offset(blob, noff, + "partitions"); + if (parts < 0) + parts = noff; + + if (fdt_node_set_part_info(blob, parts, dev)) return; /* return on error */ } } @@ -1473,14 +1497,12 @@ out: int fdt_node_offset_by_compat_reg(void *blob, const char *compat, phys_addr_t compat_off) { - int len, off = fdt_node_offset_by_compatible(blob, -1, compat); - while (off != -FDT_ERR_NOTFOUND) { + int len, off; + + fdt_for_each_node_by_compatible(off, blob, -1, compat) { const fdt32_t *reg = fdt_getprop(blob, off, "reg", &len); - if (reg) { - if (compat_off == fdt_translate_address(blob, off, reg)) - return off; - } - off = fdt_node_offset_by_compatible(blob, off, compat); + if (reg && compat_off == fdt_translate_address(blob, off, reg)) + return off; } return -FDT_ERR_NOTFOUND; @@ -1545,14 +1567,6 @@ int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle) #endif ret = fdt_setprop_cell(fdt, nodeoffset, "phandle", phandle); - if (ret < 0) - return ret; - - /* - * For now, also set the deprecated "linux,phandle" property, so that we - * don't break older kernels. - */ - ret = fdt_setprop_cell(fdt, nodeoffset, "linux,phandle", phandle); return ret; } @@ -1726,35 +1740,6 @@ int fdt_set_status_by_pathf(void *fdt, enum fdt_status status, const char *fmt, return fdt_set_node_status(fdt, offset, status); } -#if defined(CONFIG_VIDEO) || defined(CONFIG_LCD) -int fdt_add_edid(void *blob, const char *compat, unsigned char *edid_buf) -{ - int noff; - int ret; - - noff = fdt_node_offset_by_compatible(blob, -1, compat); - if (noff != -FDT_ERR_NOTFOUND) { - debug("%s: %s\n", fdt_get_name(blob, noff, 0), compat); -add_edid: - ret = fdt_setprop(blob, noff, "edid", edid_buf, 128); - if (ret == -FDT_ERR_NOSPACE) { - ret = fdt_increase_size(blob, 512); - if (!ret) - goto add_edid; - else - goto err_size; - } else if (ret < 0) { - printf("Can't add property: %s\n", fdt_strerror(ret)); - return ret; - } - } - return 0; -err_size: - printf("Can't increase blob size: %s\n", fdt_strerror(ret)); - return ret; -} -#endif - /* * Verify the physical address of device tree node for a given alias * @@ -2049,7 +2034,7 @@ int fdt_overlay_apply_verbose(void *fdt, void *fdto) * fdt_valid() - Check if an FDT is valid. If not, change it to NULL * * @blobp: Pointer to FDT pointer - * @return 1 if OK, 0 if bad (in which case *blobp is set to NULL) + * Return: 1 if OK, 0 if bad (in which case *blobp is set to NULL) */ int fdt_valid(struct fdt_header **blobp) {