Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cris-mirror.git] / arch / mips / mti-sead3 / sead3-setup.c
blobedfcaf06680d37c917bdf9f3d58a5ec042943a76
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
7 * Copyright (C) 2013 Imagination Technologies Ltd.
8 */
9 #include <linux/init.h>
10 #include <linux/libfdt.h>
11 #include <linux/of_fdt.h>
13 #include <asm/prom.h>
14 #include <asm/fw/fw.h>
16 #include <asm/mips-boards/generic.h>
18 const char *get_system_type(void)
20 return "MIPS SEAD3";
23 static uint32_t get_memsize_from_cmdline(void)
25 int memsize = 0;
26 char *p = arcs_cmdline;
27 char *s = "memsize=";
29 p = strstr(p, s);
30 if (p) {
31 p += strlen(s);
32 memsize = memparse(p, NULL);
35 return memsize;
38 static uint32_t get_memsize_from_env(void)
40 int memsize = 0;
41 char *p;
43 p = fw_getenv("memsize");
44 if (p)
45 memsize = memparse(p, NULL);
47 return memsize;
50 static uint32_t get_memsize(void)
52 uint32_t memsize;
54 memsize = get_memsize_from_cmdline();
55 if (memsize)
56 return memsize;
58 return get_memsize_from_env();
61 static void __init parse_memsize_param(void)
63 int offset;
64 const uint64_t *prop_value;
65 int prop_len;
66 uint32_t memsize = get_memsize();
68 if (!memsize)
69 return;
71 offset = fdt_path_offset(__dtb_start, "/memory");
72 if (offset > 0) {
73 uint64_t new_value;
75 * reg contains 2 32-bits BE values, offset and size. We just
76 * want to replace the size value without affecting the offset
78 prop_value = fdt_getprop(__dtb_start, offset, "reg", &prop_len);
79 new_value = be64_to_cpu(*prop_value);
80 new_value = (new_value & ~0xffffffffllu) | memsize;
81 fdt_setprop_inplace_u64(__dtb_start, offset, "reg", new_value);
85 void __init *plat_get_fdt(void)
87 return (void *)__dtb_start;
90 void __init plat_mem_setup(void)
92 /* allow command line/bootloader env to override memory size in DT */
93 parse_memsize_param();
96 * Load the builtin devicetree. This causes the chosen node to be
97 * parsed resulting in our memory appearing
99 __dt_setup_arch(__dtb_start);
102 void __init device_tree_init(void)
104 if (!initial_boot_params)
105 return;
107 unflatten_and_copy_device_tree();