diff options
author | Michal Simek <michal.simek@xilinx.com> | 2020-07-10 13:34:44 +0200 |
---|---|---|
committer | Michal Simek <michal.simek@xilinx.com> | 2020-08-20 09:49:20 +0200 |
commit | c2f0950c33ef9d89573609b6352a9964af8833a1 (patch) | |
tree | a7e003c8abaa0ed39594847c4a7f8892bbb8ca0b /lib/fdtdec.c | |
parent | 7fce7396659c162f55b1747d84599d822b11c6a7 (diff) | |
download | u-boot-c2f0950c33ef9d89573609b6352a9964af8833a1.tar.gz |
lib: fdt: Convert fdtdes_setup_mem..() to livetree API
Convert fdtdec_setup_mem_size_base(), get_next_memory_node(),
fdtdec_setup_memory_banksize() and fdtdec_setup_mem_size_base_lowest() to
livetree API.
Tested on ZynqMP zcu104 board.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/fdtdec.c')
-rw-r--r-- | lib/fdtdec.c | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index da94bc5e15..30a1c6a217 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -24,6 +24,7 @@ #include <asm/sections.h> #include <linux/ctype.h> #include <linux/lzo.h> +#include <linux/ioport.h> DECLARE_GLOBAL_DATA_PTR; @@ -1032,16 +1033,17 @@ int fdtdec_decode_display_timing(const void *blob, int parent, int index, int fdtdec_setup_mem_size_base(void) { - int ret, mem; - struct fdt_resource res; + int ret; + ofnode mem; + struct resource res; - mem = fdt_path_offset(gd->fdt_blob, "/memory"); - if (mem < 0) { + mem = ofnode_path("/memory"); + if (!ofnode_valid(mem)) { debug("%s: Missing /memory node\n", __func__); return -EINVAL; } - ret = fdt_get_resource(gd->fdt_blob, mem, "reg", 0, &res); + ret = ofnode_read_resource(mem, 0, &res); if (ret != 0) { debug("%s: Unable to decode first memory bank\n", __func__); return -EINVAL; @@ -1057,42 +1059,42 @@ int fdtdec_setup_mem_size_base(void) #if defined(CONFIG_NR_DRAM_BANKS) -static int get_next_memory_node(const void *blob, int mem) +ofnode get_next_memory_node(ofnode mem) { do { - mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem, - "device_type", "memory", 7); - } while (!fdtdec_get_is_enabled(blob, mem)); + mem = ofnode_by_prop_value(mem, "device_type", "memory", 7); + } while (!ofnode_is_available(mem)); return mem; } int fdtdec_setup_memory_banksize(void) { - int bank, ret, mem, reg = 0; - struct fdt_resource res; + int bank, ret, reg = 0; + struct resource res; + ofnode mem = ofnode_null(); - mem = get_next_memory_node(gd->fdt_blob, -1); - if (mem < 0) { + mem = get_next_memory_node(mem); + if (!ofnode_valid(mem)) { debug("%s: Missing /memory node\n", __func__); return -EINVAL; } for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { - ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res); - if (ret == -FDT_ERR_NOTFOUND) { + ret = ofnode_read_resource(mem, reg++, &res); + if (ret < 0) { reg = 0; - mem = get_next_memory_node(gd->fdt_blob, mem); - if (mem == -FDT_ERR_NOTFOUND) + mem = get_next_memory_node(mem); + if (ofnode_valid(mem)) break; - ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res); - if (ret == -FDT_ERR_NOTFOUND) + ret = ofnode_read_resource(mem, reg++, &res); + if (ret < 0) break; } - if (ret != 0) { + + if (ret != 0) return -EINVAL; - } gd->bd->bi_dram[bank].start = (phys_addr_t)res.start; gd->bd->bi_dram[bank].size = @@ -1109,32 +1111,33 @@ int fdtdec_setup_memory_banksize(void) int fdtdec_setup_mem_size_base_lowest(void) { - int bank, ret, mem, reg = 0; - struct fdt_resource res; + int bank, ret, reg = 0; + struct resource res; unsigned long base; phys_size_t size; - const void *blob = gd->fdt_blob; + ofnode mem = ofnode_null(); gd->ram_base = (unsigned long)~0; - mem = get_next_memory_node(blob, -1); - if (mem < 0) { + mem = get_next_memory_node(mem); + if (!ofnode_valid(mem)) { debug("%s: Missing /memory node\n", __func__); return -EINVAL; } for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { - ret = fdt_get_resource(blob, mem, "reg", reg++, &res); - if (ret == -FDT_ERR_NOTFOUND) { + ret = ofnode_read_resource(mem, reg++, &res); + if (ret < 0) { reg = 0; - mem = get_next_memory_node(blob, mem); - if (mem == -FDT_ERR_NOTFOUND) + mem = get_next_memory_node(mem); + if (ofnode_valid(mem)) break; - ret = fdt_get_resource(blob, mem, "reg", reg++, &res); - if (ret == -FDT_ERR_NOTFOUND) + ret = ofnode_read_resource(mem, reg++, &res); + if (ret < 0) break; } + if (ret != 0) return -EINVAL; |