aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2009-11-23 22:07:01 -0500
committerGrant Likely <grant.likely@secretlab.ca>2009-11-23 22:07:01 -0500
commit41f880091c15b039ffcc8b3d831656b81517a6d3 (patch)
treea9919151491356b6445ecd9c613a60f69d207927 /arch
parentbbd33931a08362f78266a4016211a35947b91041 (diff)
of/flattree: Merge unflatten_device_tree
Merge common code between PowerPC and MicroBlaze Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Reviewed-by: Wolfram Sang <w.sang@pengutronix.de> Tested-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch')
-rw-r--r--arch/microblaze/include/asm/prom.h1
-rw-r--r--arch/microblaze/kernel/prom.c49
-rw-r--r--arch/powerpc/kernel/prom.c50
3 files changed, 0 insertions, 100 deletions
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
index ef3ec1d6ceb3..07d1063f9aae 100644
--- a/arch/microblaze/include/asm/prom.h
+++ b/arch/microblaze/include/asm/prom.h
@@ -37,7 +37,6 @@ extern struct device_node *of_chosen;
37 37
38#define HAVE_ARCH_DEVTREE_FIXUPS 38#define HAVE_ARCH_DEVTREE_FIXUPS
39 39
40extern struct device_node *allnodes; /* temporary while merging */
41extern rwlock_t devtree_lock; /* temporary while merging */ 40extern rwlock_t devtree_lock; /* temporary while merging */
42 41
43/* For updating the device tree at runtime */ 42/* For updating the device tree at runtime */
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 021770abfbd7..901d538c15ef 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -50,55 +50,6 @@ typedef u32 cell_t;
50/* export that to outside world */ 50/* export that to outside world */
51struct device_node *of_chosen; 51struct device_node *of_chosen;
52 52
53/**
54 * unflattens the device-tree passed by the firmware, creating the
55 * tree of struct device_node. It also fills the "name" and "type"
56 * pointers of the nodes so the normal device-tree walking functions
57 * can be used (this used to be done by finish_device_tree)
58 */
59void __init unflatten_device_tree(void)
60{
61 unsigned long start, mem, size;
62 struct device_node **allnextp = &allnodes;
63
64 pr_debug(" -> unflatten_device_tree()\n");
65
66 /* First pass, scan for size */
67 start = ((unsigned long)initial_boot_params) +
68 initial_boot_params->off_dt_struct;
69 size = unflatten_dt_node(0, &start, NULL, NULL, 0);
70 size = (size | 3) + 1;
71
72 pr_debug(" size is %lx, allocating...\n", size);
73
74 /* Allocate memory for the expanded device tree */
75 mem = lmb_alloc(size + 4, __alignof__(struct device_node));
76 mem = (unsigned long) __va(mem);
77
78 ((u32 *)mem)[size / 4] = 0xdeadbeef;
79
80 pr_debug(" unflattening %lx...\n", mem);
81
82 /* Second pass, do actual unflattening */
83 start = ((unsigned long)initial_boot_params) +
84 initial_boot_params->off_dt_struct;
85 unflatten_dt_node(mem, &start, NULL, &allnextp, 0);
86 if (*((u32 *)start) != OF_DT_END)
87 printk(KERN_WARNING "Weird tag at end of tree: %08x\n",
88 *((u32 *)start));
89 if (((u32 *)mem)[size / 4] != 0xdeadbeef)
90 printk(KERN_WARNING "End of tree marker overwritten: %08x\n",
91 ((u32 *)mem)[size / 4]);
92 *allnextp = NULL;
93
94 /* Get pointer to OF "/chosen" node for use everywhere */
95 of_chosen = of_find_node_by_path("/chosen");
96 if (of_chosen == NULL)
97 of_chosen = of_find_node_by_path("/chosen@0");
98
99 pr_debug(" <- unflatten_device_tree()\n");
100}
101
102#define early_init_dt_scan_drconf_memory(node) 0 53#define early_init_dt_scan_drconf_memory(node) 0
103 54
104static int __init early_init_dt_scan_cpus(unsigned long node, 55static int __init early_init_dt_scan_cpus(unsigned long node,
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index a102a0a33ed1..1280f3484ad3 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -73,8 +73,6 @@ unsigned long tce_alloc_start, tce_alloc_end;
73 73
74typedef u32 cell_t; 74typedef u32 cell_t;
75 75
76extern struct device_node *allnodes; /* temporary while merging */
77
78extern rwlock_t devtree_lock; /* temporary while merging */ 76extern rwlock_t devtree_lock; /* temporary while merging */
79 77
80/* export that to outside world */ 78/* export that to outside world */
@@ -119,54 +117,6 @@ static void __init move_device_tree(void)
119 DBG("<- move_device_tree\n"); 117 DBG("<- move_device_tree\n");
120} 118}
121 119
122/**
123 * unflattens the device-tree passed by the firmware, creating the
124 * tree of struct device_node. It also fills the "name" and "type"
125 * pointers of the nodes so the normal device-tree walking functions
126 * can be used (this used to be done by finish_device_tree)
127 */
128void __init unflatten_device_tree(void)
129{
130 unsigned long start, mem, size;
131 struct device_node **allnextp = &allnodes;
132
133 DBG(" -> unflatten_device_tree()\n");
134
135 /* First pass, scan for size */
136 start = ((unsigned long)initial_boot_params) +
137 initial_boot_params->off_dt_struct;
138 size = unflatten_dt_node(0, &start, NULL, NULL, 0);
139 size = (size | 3) + 1;
140
141 DBG(" size is %lx, allocating...\n", size);
142
143 /* Allocate memory for the expanded device tree */
144 mem = lmb_alloc(size + 4, __alignof__(struct device_node));
145 mem = (unsigned long) __va(mem);
146
147 ((u32 *)mem)[size / 4] = 0xdeadbeef;
148
149 DBG(" unflattening %lx...\n", mem);
150
151 /* Second pass, do actual unflattening */
152 start = ((unsigned long)initial_boot_params) +
153 initial_boot_params->off_dt_struct;
154 unflatten_dt_node(mem, &start, NULL, &allnextp, 0);
155 if (*((u32 *)start) != OF_DT_END)
156 printk(KERN_WARNING "Weird tag at end of tree: %08x\n", *((u32 *)start));
157 if (((u32 *)mem)[size / 4] != 0xdeadbeef)
158 printk(KERN_WARNING "End of tree marker overwritten: %08x\n",
159 ((u32 *)mem)[size / 4] );
160 *allnextp = NULL;
161
162 /* Get pointer to OF "/chosen" node for use everywhere */
163 of_chosen = of_find_node_by_path("/chosen");
164 if (of_chosen == NULL)
165 of_chosen = of_find_node_by_path("/chosen@0");
166
167 DBG(" <- unflatten_device_tree()\n");
168}
169
170/* 120/*
171 * ibm,pa-features is a per-cpu property that contains a string of 121 * ibm,pa-features is a per-cpu property that contains a string of
172 * attribute descriptors, each of which has a 2 byte header plus up 122 * attribute descriptors, each of which has a 2 byte header plus up