ramips: ramips_esw: use rt305x_esw prefix in function names
[openwrt.git] / target / linux / generic / patches-2.6.36 / 992-mips_of_2.6.37_bp.patch
1 From: Dezhong Diao <dediao@cisco.com>
2 Date: Wed, 13 Oct 2010 06:52:46 +0000 (-0600)
3 Subject: of/mips: Add device tree support to MIPS
4 X-Git-Tag: v2.6.37-rc1~129^2~3
5 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=f2ffa5ab74f4dfd598860f96ca37a71c4d0a28a8
6
7 of/mips: Add device tree support to MIPS
8
9 Add the ability to enable CONFIG_OF on the MIPS architecture.
10
11 Signed-off-by: Dezhong Diao <dediao@cisco.com>
12 [grant.likely@secretlab.ca: cleared out obsolete hooks,
13 removed ARCH_HAS_DEVTREE_MEM,
14 remove __init tags from header file,
15 removed debugfs support hunk]
16 [ddaney@linux-mips.org: backed out over aggressive trimming of hooks]
17 Acked-by: Ralf Baechle <ralf@linux-mips.org>
18 Tested-by: David Daney <ddaney@caviumnetworks.com>
19 Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
20 ---
21
22 --- a/arch/mips/Kconfig
23 +++ b/arch/mips/Kconfig
24 @@ -2146,6 +2146,13 @@ config SECCOMP
25
26 If unsure, say Y. Only embedded should say N here.
27
28 +config USE_OF
29 + bool "Flattened Device Tree support"
30 + select OF
31 + select OF_FLATTREE
32 + help
33 + Include support for flattened device tree machine descriptions.
34 +
35 endmenu
36
37 config LOCKDEP_SUPPORT
38 --- a/arch/mips/include/asm/irq.h
39 +++ b/arch/mips/include/asm/irq.h
40 @@ -16,6 +16,11 @@
41
42 #include <irq.h>
43
44 +static inline void irq_dispose_mapping(unsigned int virq)
45 +{
46 + return;
47 +}
48 +
49 #ifdef CONFIG_I8259
50 static inline int irq_canonicalize(int irq)
51 {
52 --- /dev/null
53 +++ b/arch/mips/include/asm/prom.h
54 @@ -0,0 +1,35 @@
55 +/*
56 + * arch/mips/include/asm/prom.h
57 + *
58 + * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
59 + *
60 + * This program is free software; you can redistribute it and/or modify
61 + * it under the terms of the GNU General Public License version 2 as
62 + * published by the Free Software Foundation.
63 + *
64 + */
65 +#ifndef __ASM_MIPS_PROM_H
66 +#define __ASM_MIPS_PROM_H
67 +
68 +#ifdef CONFIG_OF
69 +#include <linux/init.h>
70 +
71 +#include <asm/setup.h>
72 +#include <asm/irq.h>
73 +#include <asm/bootinfo.h>
74 +
75 +/* which is compatible with the flattened device tree (FDT) */
76 +#define cmd_line arcs_cmdline
77 +
78 +extern int early_init_dt_scan_memory_arch(unsigned long node,
79 + const char *uname, int depth, void *data);
80 +
81 +extern int reserve_mem_mach(unsigned long addr, unsigned long size);
82 +extern void free_mem_mach(unsigned long addr, unsigned long size);
83 +
84 +extern void __init device_tree_init(void);
85 +#else /* CONFIG_OF */
86 +static inline void __init device_tree_init(void) { }
87 +#endif /* CONFIG_OF */
88 +
89 +#endif /* _ASM_MIPS_PROM_H */
90 --- a/arch/mips/kernel/Makefile
91 +++ b/arch/mips/kernel/Makefile
92 @@ -97,6 +97,8 @@ obj-$(CONFIG_EARLY_PRINTK) += early_prin
93 obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o
94 obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o
95
96 +obj-$(CONFIG_OF) += prom.o
97 +
98 CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
99
100 obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o
101 --- /dev/null
102 +++ b/arch/mips/kernel/prom.c
103 @@ -0,0 +1,112 @@
104 +/*
105 + * MIPS support for CONFIG_OF device tree support
106 + *
107 + * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
108 + *
109 + * This program is free software; you can redistribute it and/or modify
110 + * it under the terms of the GNU General Public License version 2 as
111 + * published by the Free Software Foundation.
112 + */
113 +
114 +#include <linux/init.h>
115 +#include <linux/module.h>
116 +#include <linux/errno.h>
117 +#include <linux/types.h>
118 +#include <linux/bootmem.h>
119 +#include <linux/initrd.h>
120 +#include <linux/debugfs.h>
121 +#include <linux/of.h>
122 +#include <linux/of_fdt.h>
123 +#include <linux/of_irq.h>
124 +#include <linux/of_platform.h>
125 +
126 +#include <asm/page.h>
127 +#include <asm/prom.h>
128 +
129 +int __init early_init_dt_scan_memory_arch(unsigned long node,
130 + const char *uname, int depth,
131 + void *data)
132 +{
133 + return early_init_dt_scan_memory(node, uname, depth, data);
134 +}
135 +
136 +void __init early_init_dt_add_memory_arch(u64 base, u64 size)
137 +{
138 + return add_memory_region(base, size, BOOT_MEM_RAM);
139 +}
140 +
141 +int __init reserve_mem_mach(unsigned long addr, unsigned long size)
142 +{
143 + return reserve_bootmem(addr, size, BOOTMEM_DEFAULT);
144 +}
145 +
146 +void __init free_mem_mach(unsigned long addr, unsigned long size)
147 +{
148 + return free_bootmem(addr, size);
149 +}
150 +
151 +u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
152 +{
153 + return virt_to_phys(
154 + __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS))
155 + );
156 +}
157 +
158 +#ifdef CONFIG_BLK_DEV_INITRD
159 +void __init early_init_dt_setup_initrd_arch(unsigned long start,
160 + unsigned long end)
161 +{
162 + initrd_start = (unsigned long)__va(start);
163 + initrd_end = (unsigned long)__va(end);
164 + initrd_below_start_ok = 1;
165 +}
166 +#endif
167 +
168 +/*
169 + * irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
170 + *
171 + * Currently the mapping mechanism is trivial; simple flat hwirq numbers are
172 + * mapped 1:1 onto Linux irq numbers. Cascaded irq controllers are not
173 + * supported.
174 + */
175 +unsigned int irq_create_of_mapping(struct device_node *controller,
176 + const u32 *intspec, unsigned int intsize)
177 +{
178 + return intspec[0];
179 +}
180 +EXPORT_SYMBOL_GPL(irq_create_of_mapping);
181 +
182 +void __init early_init_devtree(void *params)
183 +{
184 + /* Setup flat device-tree pointer */
185 + initial_boot_params = params;
186 +
187 + /* Retrieve various informations from the /chosen node of the
188 + * device-tree, including the platform type, initrd location and
189 + * size, and more ...
190 + */
191 + of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
192 +
193 + /* Scan memory nodes */
194 + of_scan_flat_dt(early_init_dt_scan_root, NULL);
195 + of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
196 +}
197 +
198 +void __init device_tree_init(void)
199 +{
200 + unsigned long base, size;
201 +
202 + if (!initial_boot_params)
203 + return;
204 +
205 + base = virt_to_phys((void *)initial_boot_params);
206 + size = initial_boot_params->totalsize;
207 +
208 + /* Before we do anything, lets reserve the dt blob */
209 + reserve_mem_mach(base, size);
210 +
211 + unflatten_device_tree();
212 +
213 + /* free the space reserved for the dt blob */
214 + free_mem_mach(base, size);
215 +}
216 --- a/arch/mips/kernel/setup.c
217 +++ b/arch/mips/kernel/setup.c
218 @@ -31,6 +31,7 @@
219 #include <asm/setup.h>
220 #include <asm/smp-ops.h>
221 #include <asm/system.h>
222 +#include <asm/prom.h>
223
224 struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly;
225
226 @@ -487,6 +488,7 @@ static void __init arch_mem_init(char **
227 }
228
229 bootmem_init();
230 + device_tree_init();
231 sparse_init();
232 paging_init();
233 }
This page took 0.051729 seconds and 5 git commands to generate.