--- zzzz-none-000/linux-3.10.107/arch/mips/ralink/of.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/arch/mips/ralink/of.c 2021-02-04 17:41:59.000000000 +0000 @@ -21,14 +21,13 @@ #include #include #include +#include #include "common.h" __iomem void *rt_sysc_membase; __iomem void *rt_memc_membase; -extern struct boot_param_header __dtb_start; - __iomem void *plat_of_remap_node(const char *node) { struct resource res; @@ -51,30 +50,18 @@ void __init device_tree_init(void) { - unsigned long base, size; - void *fdt_copy; - - if (!initial_boot_params) - return; - - base = virt_to_phys((void *)initial_boot_params); - size = be32_to_cpu(initial_boot_params->totalsize); - - /* Before we do anything, lets reserve the dt blob */ - reserve_bootmem(base, size, BOOTMEM_DEFAULT); + unflatten_and_copy_device_tree(); +} - /* The strings in the flattened tree are referenced directly by the - * device tree, so copy the flattened device tree from init memory - * to regular memory. - */ - fdt_copy = alloc_bootmem(size); - memcpy(fdt_copy, initial_boot_params, size); - initial_boot_params = fdt_copy; +static int memory_dtb; - unflatten_device_tree(); +static int __init early_init_dt_find_memory(unsigned long node, + const char *uname, int depth, void *data) +{ + if (depth == 1 && !strcmp(uname, "memory@0")) + memory_dtb = 1; - /* free the space reserved for the dt blob */ - free_bootmem(base, size); + return 0; } void __init plat_mem_setup(void) @@ -85,9 +72,12 @@ * Load the builtin devicetree. This causes the chosen node to be * parsed resulting in our memory appearing */ - __dt_setup_arch(&__dtb_start); + __dt_setup_arch(__dtb_start); - if (soc_info.mem_size) + of_scan_flat_dt(early_init_dt_find_memory, NULL); + if (memory_dtb) + of_scan_flat_dt(early_init_dt_scan_memory, NULL); + else if (soc_info.mem_size) add_memory_region(soc_info.mem_base, soc_info.mem_size * SZ_1M, BOOT_MEM_RAM); else @@ -98,17 +88,10 @@ static int __init plat_of_setup(void) { - static struct of_device_id of_ids[3]; - int len = sizeof(of_ids[0].compatible); - - if (!of_have_populated_dt()) - panic("device tree not present"); - - strncpy(of_ids[0].compatible, soc_info.compatible, len); - strncpy(of_ids[1].compatible, "palmbus", len); + __dt_register_buses(soc_info.compatible, "palmbus"); - if (of_platform_populate(NULL, of_ids, NULL, NULL)) - panic("failed to populate DT\n"); + /* make sure that the reset controller is setup early */ + ralink_rst_init(); return 0; }