memory: VIM2: auto to allocate the memory with 'ddr_size'
authorterry <terry@szwesion.com>
Mon, 3 Jul 2017 08:23:21 +0000 (16:23 +0800)
committerNick <nick@khadas.com>
Sat, 1 Jun 2019 10:21:16 +0000 (18:21 +0800)
Signed-off-by: Nick <nick@khadas.com>
arch/arm64/boot/dts/amlogic/kvim2_linux.dts
drivers/of/fdt.c

index 64df263..e1e724b 100644 (file)
@@ -42,7 +42,8 @@
 
        memory@00000000 {
                device_type = "memory";
-               linux,usable-memory = <0x0 0x0100000 0x0 0x7ff00000>;
+               linux,usable-memory-2g = <0x0 0x00100000 0x0 0x7ff00000>;
+               linux,usable-memory-3g = <0x0 0x00100000 0x0 0xbff00000>;
        };
 
        reserved-memory {
                display_size_default = <1920 1080 1920 3240 32>;
                /*1920*1080*4*3 = 0x17BB000*/
                mem_alloc = <1>;
-               logo_addr = "0x7dc00000";
+               logo_addr_2g = "0x7dc00000";
+               logo_addr_3g = "0xbdc00000";
        };
        ge2d {
                compatible = "amlogic, ge2d-gxm";
index e37a2a5..99779be 100644 (file)
@@ -1015,6 +1015,19 @@ u64 __init dt_mem_next_cell(int s, const __be32 **cellp)
        return of_read_number(p, s);
 }
 
+static int get_ddr_size(void)
+{
+       int ddr_size = 0;
+       if (strstr(boot_command_line, "ddr_size=2"))
+               ddr_size = 2;
+       else if (strstr(boot_command_line, "ddr_size=3"))
+               ddr_size = 3;
+       else
+               ddr_size = 0;
+
+       return ddr_size;
+}
+
 /**
  * early_init_dt_scan_memory - Look for an parse memory nodes
  */
@@ -1023,7 +1036,7 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
 {
        const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
        const __be32 *reg, *endp;
-       int l;
+       int l, ddr_size;
 
        /* We are scanning "memory" nodes only */
        if (type == NULL) {
@@ -1036,7 +1049,14 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
        } else if (strcmp(type, "memory") != 0)
                return 0;
 
-       reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l);
+       ddr_size = get_ddr_size();
+       if (ddr_size == 2)
+               reg = of_get_flat_dt_prop(node, "linux,usable-memory-2g", &l);
+       else if (ddr_size == 3)
+               reg = of_get_flat_dt_prop(node, "linux,usable-memory-3g", &l);
+       else
+               reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l);
+
        if (reg == NULL)
                reg = of_get_flat_dt_prop(node, "reg", &l);
        if (reg == NULL)