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
7 of/mips: Add device tree support to MIPS
9 Add the ability to enable CONFIG_OF on the MIPS architecture.
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>
22 --- a/arch/mips/Kconfig
23 +++ b/arch/mips/Kconfig
24 @@ -2146,6 +2146,13 @@ config SECCOMP
26 If unsure, say Y. Only embedded should say N here.
29 + bool "Flattened Device Tree support"
33 + Include support for flattened device tree machine descriptions.
37 config LOCKDEP_SUPPORT
38 --- a/arch/mips/include/asm/irq.h
39 +++ b/arch/mips/include/asm/irq.h
44 +static inline void irq_dispose_mapping(unsigned int virq)
50 static inline int irq_canonicalize(int irq)
53 +++ b/arch/mips/include/asm/prom.h
56 + * arch/mips/include/asm/prom.h
58 + * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
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.
65 +#ifndef __ASM_MIPS_PROM_H
66 +#define __ASM_MIPS_PROM_H
69 +#include <linux/init.h>
71 +#include <asm/setup.h>
73 +#include <asm/bootinfo.h>
75 +/* which is compatible with the flattened device tree (FDT) */
76 +#define cmd_line arcs_cmdline
78 +extern int early_init_dt_scan_memory_arch(unsigned long node,
79 + const char *uname, int depth, void *data);
81 +extern int reserve_mem_mach(unsigned long addr, unsigned long size);
82 +extern void free_mem_mach(unsigned long addr, unsigned long size);
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 */
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
96 +obj-$(CONFIG_OF) += prom.o
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)
100 obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o
102 +++ b/arch/mips/kernel/prom.c
105 + * MIPS support for CONFIG_OF device tree support
107 + * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
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.
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>
126 +#include <asm/page.h>
127 +#include <asm/prom.h>
129 +int __init early_init_dt_scan_memory_arch(unsigned long node,
130 + const char *uname, int depth,
133 + return early_init_dt_scan_memory(node, uname, depth, data);
136 +void __init early_init_dt_add_memory_arch(u64 base, u64 size)
138 + return add_memory_region(base, size, BOOT_MEM_RAM);
141 +int __init reserve_mem_mach(unsigned long addr, unsigned long size)
143 + return reserve_bootmem(addr, size, BOOTMEM_DEFAULT);
146 +void __init free_mem_mach(unsigned long addr, unsigned long size)
148 + return free_bootmem(addr, size);
151 +u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
153 + return virt_to_phys(
154 + __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS))
158 +#ifdef CONFIG_BLK_DEV_INITRD
159 +void __init early_init_dt_setup_initrd_arch(unsigned long start,
162 + initrd_start = (unsigned long)__va(start);
163 + initrd_end = (unsigned long)__va(end);
164 + initrd_below_start_ok = 1;
169 + * irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
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
175 +unsigned int irq_create_of_mapping(struct device_node *controller,
176 + const u32 *intspec, unsigned int intsize)
180 +EXPORT_SYMBOL_GPL(irq_create_of_mapping);
182 +void __init early_init_devtree(void *params)
184 + /* Setup flat device-tree pointer */
185 + initial_boot_params = params;
187 + /* Retrieve various informations from the /chosen node of the
188 + * device-tree, including the platform type, initrd location and
189 + * size, and more ...
191 + of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
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);
198 +void __init device_tree_init(void)
200 + unsigned long base, size;
202 + if (!initial_boot_params)
205 + base = virt_to_phys((void *)initial_boot_params);
206 + size = initial_boot_params->totalsize;
208 + /* Before we do anything, lets reserve the dt blob */
209 + reserve_mem_mach(base, size);
211 + unflatten_device_tree();
213 + /* free the space reserved for the dt blob */
214 + free_mem_mach(base, size);
216 --- a/arch/mips/kernel/setup.c
217 +++ b/arch/mips/kernel/setup.c
219 #include <asm/setup.h>
220 #include <asm/smp-ops.h>
221 #include <asm/system.h>
222 +#include <asm/prom.h>
224 struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly;
226 @@ -487,6 +488,7 @@ static void __init arch_mem_init(char **
230 + device_tree_init();