]>
Commit | Line | Data |
---|---|---|
f2ffa5ab DD |
1 | /* |
2 | * MIPS support for CONFIG_OF device tree support | |
3 | * | |
4 | * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com> | |
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 | #include <linux/init.h> | |
73bc256d | 12 | #include <linux/export.h> |
f2ffa5ab DD |
13 | #include <linux/errno.h> |
14 | #include <linux/types.h> | |
15 | #include <linux/bootmem.h> | |
16 | #include <linux/initrd.h> | |
17 | #include <linux/debugfs.h> | |
18 | #include <linux/of.h> | |
19 | #include <linux/of_fdt.h> | |
20 | #include <linux/of_irq.h> | |
21 | #include <linux/of_platform.h> | |
22 | ||
23 | #include <asm/page.h> | |
24 | #include <asm/prom.h> | |
25 | ||
9169a5d0 JC |
26 | static char mips_machine_name[64] = "Unknown"; |
27 | ||
28 | __init void mips_set_machine_name(const char *name) | |
29 | { | |
30 | if (name == NULL) | |
31 | return; | |
32 | ||
41c8366b | 33 | strlcpy(mips_machine_name, name, sizeof(mips_machine_name)); |
9169a5d0 JC |
34 | pr_info("MIPS: machine is %s\n", mips_get_machine_name()); |
35 | } | |
36 | ||
37 | char *mips_get_machine_name(void) | |
38 | { | |
39 | return mips_machine_name; | |
40 | } | |
41 | ||
42 | #ifdef CONFIG_OF | |
f2ffa5ab DD |
43 | int __init early_init_dt_scan_memory_arch(unsigned long node, |
44 | const char *uname, int depth, | |
45 | void *data) | |
46 | { | |
47 | return early_init_dt_scan_memory(node, uname, depth, data); | |
48 | } | |
49 | ||
50 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) | |
51 | { | |
52 | return add_memory_region(base, size, BOOT_MEM_RAM); | |
53 | } | |
54 | ||
672c5446 | 55 | void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) |
f2ffa5ab | 56 | { |
672c5446 | 57 | return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)); |
f2ffa5ab DD |
58 | } |
59 | ||
60 | #ifdef CONFIG_BLK_DEV_INITRD | |
61 | void __init early_init_dt_setup_initrd_arch(unsigned long start, | |
62 | unsigned long end) | |
63 | { | |
64 | initrd_start = (unsigned long)__va(start); | |
65 | initrd_end = (unsigned long)__va(end); | |
66 | initrd_below_start_ok = 1; | |
67 | } | |
68 | #endif | |
69 | ||
9169a5d0 JC |
70 | int __init early_init_dt_scan_model(unsigned long node, const char *uname, |
71 | int depth, void *data) | |
72 | { | |
73 | if (!depth) { | |
74 | char *model = of_get_flat_dt_prop(node, "model", NULL); | |
75 | ||
76 | if (model) | |
77 | mips_set_machine_name(model); | |
78 | } | |
79 | return 0; | |
80 | } | |
81 | ||
f2ffa5ab DD |
82 | void __init early_init_devtree(void *params) |
83 | { | |
84 | /* Setup flat device-tree pointer */ | |
85 | initial_boot_params = params; | |
86 | ||
87 | /* Retrieve various informations from the /chosen node of the | |
88 | * device-tree, including the platform type, initrd location and | |
89 | * size, and more ... | |
90 | */ | |
85f60ae4 GL |
91 | of_scan_flat_dt(early_init_dt_scan_chosen, arcs_cmdline); |
92 | ||
f2ffa5ab DD |
93 | |
94 | /* Scan memory nodes */ | |
95 | of_scan_flat_dt(early_init_dt_scan_root, NULL); | |
96 | of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL); | |
9169a5d0 JC |
97 | |
98 | /* try to load the mips machine name */ | |
99 | of_scan_flat_dt(early_init_dt_scan_model, NULL); | |
f2ffa5ab DD |
100 | } |
101 | ||
7d6168e5 RB |
102 | void __init __dt_setup_arch(struct boot_param_header *bph) |
103 | { | |
104 | if (be32_to_cpu(bph->magic) != OF_DT_HEADER) { | |
105 | pr_err("DTB has bad magic, ignoring builtin OF DTB\n"); | |
106 | ||
107 | return; | |
108 | } | |
109 | ||
110 | initial_boot_params = bph; | |
40e91aec JC |
111 | |
112 | early_init_devtree(initial_boot_params); | |
7d6168e5 | 113 | } |
9169a5d0 | 114 | #endif |