]>
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> | |
12 | #include <linux/module.h> | |
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 | ||
26 | int __init early_init_dt_scan_memory_arch(unsigned long node, | |
27 | const char *uname, int depth, | |
28 | void *data) | |
29 | { | |
30 | return early_init_dt_scan_memory(node, uname, depth, data); | |
31 | } | |
32 | ||
33 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) | |
34 | { | |
35 | return add_memory_region(base, size, BOOT_MEM_RAM); | |
36 | } | |
37 | ||
38 | int __init reserve_mem_mach(unsigned long addr, unsigned long size) | |
39 | { | |
40 | return reserve_bootmem(addr, size, BOOTMEM_DEFAULT); | |
41 | } | |
42 | ||
43 | void __init free_mem_mach(unsigned long addr, unsigned long size) | |
44 | { | |
45 | return free_bootmem(addr, size); | |
46 | } | |
47 | ||
672c5446 | 48 | void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) |
f2ffa5ab | 49 | { |
672c5446 | 50 | return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)); |
f2ffa5ab DD |
51 | } |
52 | ||
53 | #ifdef CONFIG_BLK_DEV_INITRD | |
54 | void __init early_init_dt_setup_initrd_arch(unsigned long start, | |
55 | unsigned long end) | |
56 | { | |
57 | initrd_start = (unsigned long)__va(start); | |
58 | initrd_end = (unsigned long)__va(end); | |
59 | initrd_below_start_ok = 1; | |
60 | } | |
61 | #endif | |
62 | ||
63 | /* | |
64 | * irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq# | |
65 | * | |
66 | * Currently the mapping mechanism is trivial; simple flat hwirq numbers are | |
67 | * mapped 1:1 onto Linux irq numbers. Cascaded irq controllers are not | |
68 | * supported. | |
69 | */ | |
70 | unsigned int irq_create_of_mapping(struct device_node *controller, | |
71 | const u32 *intspec, unsigned int intsize) | |
72 | { | |
73 | return intspec[0]; | |
74 | } | |
75 | EXPORT_SYMBOL_GPL(irq_create_of_mapping); | |
76 | ||
77 | void __init early_init_devtree(void *params) | |
78 | { | |
79 | /* Setup flat device-tree pointer */ | |
80 | initial_boot_params = params; | |
81 | ||
82 | /* Retrieve various informations from the /chosen node of the | |
83 | * device-tree, including the platform type, initrd location and | |
84 | * size, and more ... | |
85 | */ | |
86 | of_scan_flat_dt(early_init_dt_scan_chosen, NULL); | |
87 | ||
88 | /* Scan memory nodes */ | |
89 | of_scan_flat_dt(early_init_dt_scan_root, NULL); | |
90 | of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL); | |
91 | } | |
92 | ||
93 | void __init device_tree_init(void) | |
94 | { | |
95 | unsigned long base, size; | |
96 | ||
97 | if (!initial_boot_params) | |
98 | return; | |
99 | ||
100 | base = virt_to_phys((void *)initial_boot_params); | |
e31fee7c | 101 | size = be32_to_cpu(initial_boot_params->totalsize); |
f2ffa5ab DD |
102 | |
103 | /* Before we do anything, lets reserve the dt blob */ | |
104 | reserve_mem_mach(base, size); | |
105 | ||
106 | unflatten_device_tree(); | |
107 | ||
108 | /* free the space reserved for the dt blob */ | |
109 | free_mem_mach(base, size); | |
110 | } |