aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorDezhong Diao <dediao@cisco.com>2010-10-13 02:52:46 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-10-21 13:10:10 -0400
commitf2ffa5ab74f4dfd598860f96ca37a71c4d0a28a8 (patch)
treebe560fcb0633ab1e7c4cc0ff9e016e82f33c5712 /arch/mips
parent32c97689c46b272302053778f1a6c2facb0e220c (diff)
of/mips: Add device tree support to MIPS
Add the ability to enable CONFIG_OF on the MIPS architecture. Signed-off-by: Dezhong Diao <dediao@cisco.com> [grant.likely@secretlab.ca: cleared out obsolete hooks, removed ARCH_HAS_DEVTREE_MEM, remove __init tags from header file, removed debugfs support hunk] [ddaney@linux-mips.org: backed out over aggressive trimming of hooks] Acked-by: Ralf Baechle <ralf@linux-mips.org> Tested-by: David Daney <ddaney@caviumnetworks.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/Kconfig7
-rw-r--r--arch/mips/include/asm/irq.h5
-rw-r--r--arch/mips/include/asm/prom.h35
-rw-r--r--arch/mips/kernel/Makefile2
-rw-r--r--arch/mips/kernel/prom.c112
-rw-r--r--arch/mips/kernel/setup.c2
6 files changed, 163 insertions, 0 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3ad59dde4852..21c75a89496a 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2107,6 +2107,13 @@ config SECCOMP
2107 2107
2108 If unsure, say Y. Only embedded should say N here. 2108 If unsure, say Y. Only embedded should say N here.
2109 2109
2110config USE_OF
2111 bool "Flattened Device Tree support"
2112 select OF
2113 select OF_FLATTREE
2114 help
2115 Include support for flattened device tree machine descriptions.
2116
2110endmenu 2117endmenu
2111 2118
2112config LOCKDEP_SUPPORT 2119config LOCKDEP_SUPPORT
diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h
index dea4aed6478f..b003ed52ed17 100644
--- a/arch/mips/include/asm/irq.h
+++ b/arch/mips/include/asm/irq.h
@@ -16,6 +16,11 @@
16 16
17#include <irq.h> 17#include <irq.h>
18 18
19static inline void irq_dispose_mapping(unsigned int virq)
20{
21 return;
22}
23
19#ifdef CONFIG_I8259 24#ifdef CONFIG_I8259
20static inline int irq_canonicalize(int irq) 25static inline int irq_canonicalize(int irq)
21{ 26{
diff --git a/arch/mips/include/asm/prom.h b/arch/mips/include/asm/prom.h
new file mode 100644
index 000000000000..23f8237e18bb
--- /dev/null
+++ b/arch/mips/include/asm/prom.h
@@ -0,0 +1,35 @@
1/*
2 * arch/mips/include/asm/prom.h
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#ifndef __ASM_MIPS_PROM_H
12#define __ASM_MIPS_PROM_H
13
14#ifdef CONFIG_OF
15#include <linux/init.h>
16
17#include <asm/setup.h>
18#include <asm/irq.h>
19#include <asm/bootinfo.h>
20
21/* which is compatible with the flattened device tree (FDT) */
22#define cmd_line arcs_cmdline
23
24extern int early_init_dt_scan_memory_arch(unsigned long node,
25 const char *uname, int depth, void *data);
26
27extern int reserve_mem_mach(unsigned long addr, unsigned long size);
28extern void free_mem_mach(unsigned long addr, unsigned long size);
29
30extern void __init device_tree_init(void);
31#else /* CONFIG_OF */
32static inline void __init device_tree_init(void) { }
33#endif /* CONFIG_OF */
34
35#endif /* _ASM_MIPS_PROM_H */
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 06f848299785..80884983270d 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -96,6 +96,8 @@ obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
96obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 96obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
97obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o 97obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o
98 98
99obj-$(CONFIG_OF) += prom.o
100
99CFLAGS_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) 101CFLAGS_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 102
101obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o 103obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o
diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
new file mode 100644
index 000000000000..e000b278f024
--- /dev/null
+++ b/arch/mips/kernel/prom.c
@@ -0,0 +1,112 @@
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
26int __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
33void __init early_init_dt_add_memory_arch(u64 base, u64 size)
34{
35 return add_memory_region(base, size, BOOT_MEM_RAM);
36}
37
38int __init reserve_mem_mach(unsigned long addr, unsigned long size)
39{
40 return reserve_bootmem(addr, size, BOOTMEM_DEFAULT);
41}
42
43void __init free_mem_mach(unsigned long addr, unsigned long size)
44{
45 return free_bootmem(addr, size);
46}
47
48u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
49{
50 return virt_to_phys(
51 __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS))
52 );
53}
54
55#ifdef CONFIG_BLK_DEV_INITRD
56void __init early_init_dt_setup_initrd_arch(unsigned long start,
57 unsigned long end)
58{
59 initrd_start = (unsigned long)__va(start);
60 initrd_end = (unsigned long)__va(end);
61 initrd_below_start_ok = 1;
62}
63#endif
64
65/*
66 * irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
67 *
68 * Currently the mapping mechanism is trivial; simple flat hwirq numbers are
69 * mapped 1:1 onto Linux irq numbers. Cascaded irq controllers are not
70 * supported.
71 */
72unsigned int irq_create_of_mapping(struct device_node *controller,
73 const u32 *intspec, unsigned int intsize)
74{
75 return intspec[0];
76}
77EXPORT_SYMBOL_GPL(irq_create_of_mapping);
78
79void __init early_init_devtree(void *params)
80{
81 /* Setup flat device-tree pointer */
82 initial_boot_params = params;
83
84 /* Retrieve various informations from the /chosen node of the
85 * device-tree, including the platform type, initrd location and
86 * size, and more ...
87 */
88 of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
89
90 /* Scan memory nodes */
91 of_scan_flat_dt(early_init_dt_scan_root, NULL);
92 of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
93}
94
95void __init device_tree_init(void)
96{
97 unsigned long base, size;
98
99 if (!initial_boot_params)
100 return;
101
102 base = virt_to_phys((void *)initial_boot_params);
103 size = initial_boot_params->totalsize;
104
105 /* Before we do anything, lets reserve the dt blob */
106 reserve_mem_mach(base, size);
107
108 unflatten_device_tree();
109
110 /* free the space reserved for the dt blob */
111 free_mem_mach(base, size);
112}
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 85aef3fc6716..a6b900f2962b 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -31,6 +31,7 @@
31#include <asm/setup.h> 31#include <asm/setup.h>
32#include <asm/smp-ops.h> 32#include <asm/smp-ops.h>
33#include <asm/system.h> 33#include <asm/system.h>
34#include <asm/prom.h>
34 35
35struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly; 36struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly;
36 37
@@ -487,6 +488,7 @@ static void __init arch_mem_init(char **cmdline_p)
487 } 488 }
488 489
489 bootmem_init(); 490 bootmem_init();
491 device_tree_init();
490 sparse_init(); 492 sparse_init();
491 paging_init(); 493 paging_init();
492} 494}