Commit | Line | Data |
---|---|---|
29dd78cf JH |
1 | /* |
2 | * linux/arch/metag/kernel/devtree.c | |
3 | * | |
4 | * Copyright (C) 2012 Imagination Technologies Ltd. | |
5 | * | |
6 | * Based on ARM version: | |
7 | * Copyright (C) 2009 Canonical Ltd. <jeremy.kerr@canonical.com> | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License version 2 as | |
11 | * published by the Free Software Foundation. | |
12 | */ | |
13 | ||
14 | #include <linux/init.h> | |
15 | #include <linux/export.h> | |
16 | #include <linux/types.h> | |
17 | #include <linux/bootmem.h> | |
18 | #include <linux/memblock.h> | |
19 | #include <linux/of.h> | |
20 | #include <linux/of_fdt.h> | |
21 | ||
22 | #include <asm/setup.h> | |
23 | #include <asm/page.h> | |
24 | #include <asm/mach/arch.h> | |
25 | ||
26 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) | |
27 | { | |
28 | pr_err("%s(%llx, %llx)\n", | |
29 | __func__, base, size); | |
30 | } | |
31 | ||
32 | void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) | |
33 | { | |
34 | return alloc_bootmem_align(size, align); | |
35 | } | |
36 | ||
986c494b RH |
37 | static const void * __init arch_get_next_mach(const char *const **match) |
38 | { | |
39 | static const struct machine_desc *mdesc = __arch_info_begin; | |
40 | const struct machine_desc *m = mdesc; | |
41 | ||
42 | if (m >= __arch_info_end) | |
43 | return NULL; | |
44 | ||
45 | mdesc++; | |
46 | *match = m->dt_compat; | |
47 | return m; | |
48 | } | |
49 | ||
29dd78cf JH |
50 | /** |
51 | * setup_machine_fdt - Machine setup when an dtb was passed to the kernel | |
52 | * @dt: virtual address pointer to dt blob | |
53 | * | |
54 | * If a dtb was passed to the kernel, then use it to choose the correct | |
55 | * machine_desc and to setup the system. | |
56 | */ | |
986c494b | 57 | const struct machine_desc * __init setup_machine_fdt(void *dt) |
29dd78cf | 58 | { |
986c494b | 59 | const struct machine_desc *mdesc; |
29dd78cf JH |
60 | |
61 | /* check device tree validity */ | |
e5d65993 | 62 | if (!early_init_dt_scan(dt)) |
29dd78cf JH |
63 | return NULL; |
64 | ||
986c494b RH |
65 | mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach); |
66 | if (!mdesc) | |
29dd78cf | 67 | dump_machine_table(); /* does not return */ |
986c494b | 68 | pr_info("Machine name: %s\n", mdesc->name); |
2270e6d3 | 69 | |
986c494b | 70 | return mdesc; |
2270e6d3 | 71 | } |