165a1f0deddc0cab184e27c497461d45d81f67c1
[openwrt.git] / target / linux / ramips / patches-3.10 / 999-memory-detect.patch
1 --- a/arch/mips/ralink/of.c
2 +++ b/arch/mips/ralink/of.c
3 @@ -80,6 +80,16 @@ void __init device_tree_init(void)
4  }
5  
6  extern struct boot_param_header __image_dtb;
7 +static int memory_dtb;
8 +
9 +static int __init early_init_dt_find_memory(unsigned long node, const char *uname,
10 +                                    int depth, void *data)
11 +{
12 +       if (depth == 1 && !strcmp(uname, "memory@0"))
13 +               memory_dtb = 1;
14 +
15 +       return 0;
16 +}
17  
18  void __init plat_mem_setup(void)
19  {
20 @@ -90,8 +100,10 @@ void __init plat_mem_setup(void)
21          * parsed resulting in our memory appearing
22          */
23         __dt_setup_arch(&__image_dtb);
24 -
25 -       if (soc_info.mem_size)
26 +       of_scan_flat_dt(early_init_dt_find_memory, NULL);
27 +       if (memory_dtb)
28 +               of_scan_flat_dt(early_init_dt_scan_memory, NULL);
29 +       else if (soc_info.mem_size)
30                 add_memory_region(soc_info.mem_base, soc_info.mem_size * SZ_1M,
31                                   BOOT_MEM_RAM);
32         else