blob: 48e157efad1573493bb4f34ad7035c28ef67d56e [file] [log] [blame]
Vineet Gupta999159a2013-01-22 17:00:52 +05301/*
2 * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com)
3 *
4 * Based on reduced version of METAG
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11
12#include <linux/init.h>
13#include <linux/reboot.h>
14#include <linux/memblock.h>
15#include <linux/of.h>
16#include <linux/of_fdt.h>
17#include <asm/prom.h>
18
19/* called from unflatten_device_tree() to bootstrap devicetree itself */
20void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
21{
22 return __va(memblock_alloc(size, align));
23}
24
25/**
26 * setup_machine_fdt - Machine setup when an dtb was passed to the kernel
27 * @dt: virtual address pointer to dt blob
28 *
29 * If a dtb was passed to the kernel, then use it to choose the correct
30 * machine_desc and to setup the system.
31 */
32int __init setup_machine_fdt(void *dt)
33{
34 struct boot_param_header *devtree = dt;
35 unsigned long dt_root;
36 char *model, *compat;
37 char manufacturer[16];
38
39 /* check device tree validity */
40 if (be32_to_cpu(devtree->magic) != OF_DT_HEADER)
41 return 1;
42
43 /* Search the mdescs for the 'best' compatible value match */
44 initial_boot_params = devtree;
45 dt_root = of_get_flat_dt_root();
46
47 /* compat = "<manufacturer>,<model>" */
48 compat = of_get_flat_dt_prop(dt_root, "compatible", NULL);
49 if (!compat)
50 compat = "<unknown>";
51
52 model = strchr(compat, ',');
53 if (model)
54 model++;
55
56 strlcpy(manufacturer, compat, model ? model - compat : strlen(compat));
57
58 pr_info("Board \"%s\" from %s (Manufacturer)\n", model, manufacturer);
59
60 /* Retrieve various information from the /chosen node */
61 of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
62
63 return 0;
64}