diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-02-25 18:38:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-02-25 18:38:37 -0500 |
commit | 6ebdc661b608671e9ca572af8bb42d58108cc008 (patch) | |
tree | e99caacb964a27caeae699160fa5eddcb14526e9 | |
parent | d7930c9ef9cc67044f5ddaac54d06ca22645a012 (diff) | |
parent | df0edeb59eb559be0bee53452fda2f5cc0ae133f (diff) |
Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6
* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6: (41 commits)
of: remove undefined request_OF_resource & release_OF_resource
of/sparc: Remove sparc-local declaration of allnodes and devtree_lock
of: move definition of of_chosen into common code.
of: remove unused extern reference to devtree_lock
of: put default string compare and #a/s-cell values into common header
of/flattree: Don't assume HAVE_LMB
of: protect linux/of.h with CONFIG_OF
proc_devtree: fix THIS_MODULE without module.h
of: Remove old and misplaced function declarations
of/flattree: Make the kernel accept ePAPR style phandle information
of/flattree: endian-convert members of boot_param_header
of: assume big-endian properties, adding conversions where necessary
of: use __be32 for cell value accessors
of/flattree: use OF_ROOT_NODE_{SIZE,ADDR}_CELLS DEFAULT for fdt parsing
of/flattree: use callback to setup initrd from /chosen
proc_devtree: include linux/of.h
of: make set_node_proc_entry private to proc_devtree.c
of: include linux/proc_fs.h
of/flattree: merge early_init_dt_scan_memory() common code
of: add 'of_' prefix to machine_is_compatible()
...
67 files changed, 1244 insertions, 2096 deletions
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index cd5837e298b2..b008168ae946 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig | |||
@@ -130,6 +130,7 @@ config CMDLINE_FORCE | |||
130 | 130 | ||
131 | config OF | 131 | config OF |
132 | def_bool y | 132 | def_bool y |
133 | select OF_FLATTREE | ||
133 | 134 | ||
134 | config PROC_DEVICETREE | 135 | config PROC_DEVICETREE |
135 | bool "Support for device tree in /proc" | 136 | bool "Support for device tree in /proc" |
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h index ef3ec1d6ceb3..03f45a963204 100644 --- a/arch/microblaze/include/asm/prom.h +++ b/arch/microblaze/include/asm/prom.h | |||
@@ -26,31 +26,11 @@ | |||
26 | #include <asm/irq.h> | 26 | #include <asm/irq.h> |
27 | #include <asm/atomic.h> | 27 | #include <asm/atomic.h> |
28 | 28 | ||
29 | #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 | ||
30 | #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 | ||
31 | |||
32 | #define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l)) | ||
33 | #define of_prop_cmp(s1, s2) strcmp((s1), (s2)) | ||
34 | #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) | ||
35 | |||
36 | extern struct device_node *of_chosen; | ||
37 | |||
38 | #define HAVE_ARCH_DEVTREE_FIXUPS | 29 | #define HAVE_ARCH_DEVTREE_FIXUPS |
39 | 30 | ||
40 | extern struct device_node *allnodes; /* temporary while merging */ | ||
41 | extern rwlock_t devtree_lock; /* temporary while merging */ | ||
42 | |||
43 | /* For updating the device tree at runtime */ | ||
44 | extern void of_attach_node(struct device_node *); | ||
45 | extern void of_detach_node(struct device_node *); | ||
46 | |||
47 | /* Other Prototypes */ | 31 | /* Other Prototypes */ |
48 | extern int early_uartlite_console(void); | 32 | extern int early_uartlite_console(void); |
49 | 33 | ||
50 | extern struct resource *request_OF_resource(struct device_node *node, | ||
51 | int index, const char *name_postfix); | ||
52 | extern int release_OF_resource(struct device_node *node, int index); | ||
53 | |||
54 | /* | 34 | /* |
55 | * OF address retreival & translation | 35 | * OF address retreival & translation |
56 | */ | 36 | */ |
diff --git a/arch/microblaze/kernel/of_platform.c b/arch/microblaze/kernel/of_platform.c index acf4574d0f18..1c6d684996d7 100644 --- a/arch/microblaze/kernel/of_platform.c +++ b/arch/microblaze/kernel/of_platform.c | |||
@@ -185,7 +185,7 @@ EXPORT_SYMBOL(of_find_device_by_node); | |||
185 | static int of_dev_phandle_match(struct device *dev, void *data) | 185 | static int of_dev_phandle_match(struct device *dev, void *data) |
186 | { | 186 | { |
187 | phandle *ph = data; | 187 | phandle *ph = data; |
188 | return to_of_device(dev)->node->linux_phandle == *ph; | 188 | return to_of_device(dev)->node->phandle == *ph; |
189 | } | 189 | } |
190 | 190 | ||
191 | struct of_device *of_find_device_by_phandle(phandle ph) | 191 | struct of_device *of_find_device_by_phandle(phandle ph) |
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c index b817df172aa9..a15ef6d67ca9 100644 --- a/arch/microblaze/kernel/prom.c +++ b/arch/microblaze/kernel/prom.c | |||
@@ -42,698 +42,21 @@ | |||
42 | #include <asm/sections.h> | 42 | #include <asm/sections.h> |
43 | #include <asm/pci-bridge.h> | 43 | #include <asm/pci-bridge.h> |
44 | 44 | ||
45 | static int __initdata dt_root_addr_cells; | 45 | void __init early_init_dt_scan_chosen_arch(unsigned long node) |
46 | static int __initdata dt_root_size_cells; | ||
47 | |||
48 | typedef u32 cell_t; | ||
49 | |||
50 | static struct boot_param_header *initial_boot_params; | ||
51 | |||
52 | /* export that to outside world */ | ||
53 | struct device_node *of_chosen; | ||
54 | |||
55 | static inline char *find_flat_dt_string(u32 offset) | ||
56 | { | ||
57 | return ((char *)initial_boot_params) + | ||
58 | initial_boot_params->off_dt_strings + offset; | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * This function is used to scan the flattened device-tree, it is | ||
63 | * used to extract the memory informations at boot before we can | ||
64 | * unflatten the tree | ||
65 | */ | ||
66 | int __init of_scan_flat_dt(int (*it)(unsigned long node, | ||
67 | const char *uname, int depth, | ||
68 | void *data), | ||
69 | void *data) | ||
70 | { | ||
71 | unsigned long p = ((unsigned long)initial_boot_params) + | ||
72 | initial_boot_params->off_dt_struct; | ||
73 | int rc = 0; | ||
74 | int depth = -1; | ||
75 | |||
76 | do { | ||
77 | u32 tag = *((u32 *)p); | ||
78 | char *pathp; | ||
79 | |||
80 | p += 4; | ||
81 | if (tag == OF_DT_END_NODE) { | ||
82 | depth--; | ||
83 | continue; | ||
84 | } | ||
85 | if (tag == OF_DT_NOP) | ||
86 | continue; | ||
87 | if (tag == OF_DT_END) | ||
88 | break; | ||
89 | if (tag == OF_DT_PROP) { | ||
90 | u32 sz = *((u32 *)p); | ||
91 | p += 8; | ||
92 | if (initial_boot_params->version < 0x10) | ||
93 | p = _ALIGN(p, sz >= 8 ? 8 : 4); | ||
94 | p += sz; | ||
95 | p = _ALIGN(p, 4); | ||
96 | continue; | ||
97 | } | ||
98 | if (tag != OF_DT_BEGIN_NODE) { | ||
99 | printk(KERN_WARNING "Invalid tag %x scanning flattened" | ||
100 | " device tree !\n", tag); | ||
101 | return -EINVAL; | ||
102 | } | ||
103 | depth++; | ||
104 | pathp = (char *)p; | ||
105 | p = _ALIGN(p + strlen(pathp) + 1, 4); | ||
106 | if ((*pathp) == '/') { | ||
107 | char *lp, *np; | ||
108 | for (lp = NULL, np = pathp; *np; np++) | ||
109 | if ((*np) == '/') | ||
110 | lp = np+1; | ||
111 | if (lp != NULL) | ||
112 | pathp = lp; | ||
113 | } | ||
114 | rc = it(p, pathp, depth, data); | ||
115 | if (rc != 0) | ||
116 | break; | ||
117 | } while (1); | ||
118 | |||
119 | return rc; | ||
120 | } | ||
121 | |||
122 | unsigned long __init of_get_flat_dt_root(void) | ||
123 | { | ||
124 | unsigned long p = ((unsigned long)initial_boot_params) + | ||
125 | initial_boot_params->off_dt_struct; | ||
126 | |||
127 | while (*((u32 *)p) == OF_DT_NOP) | ||
128 | p += 4; | ||
129 | BUG_ON(*((u32 *)p) != OF_DT_BEGIN_NODE); | ||
130 | p += 4; | ||
131 | return _ALIGN(p + strlen((char *)p) + 1, 4); | ||
132 | } | ||
133 | |||
134 | /** | ||
135 | * This function can be used within scan_flattened_dt callback to get | ||
136 | * access to properties | ||
137 | */ | ||
138 | void *__init of_get_flat_dt_prop(unsigned long node, const char *name, | ||
139 | unsigned long *size) | ||
140 | { | ||
141 | unsigned long p = node; | ||
142 | |||
143 | do { | ||
144 | u32 tag = *((u32 *)p); | ||
145 | u32 sz, noff; | ||
146 | const char *nstr; | ||
147 | |||
148 | p += 4; | ||
149 | if (tag == OF_DT_NOP) | ||
150 | continue; | ||
151 | if (tag != OF_DT_PROP) | ||
152 | return NULL; | ||
153 | |||
154 | sz = *((u32 *)p); | ||
155 | noff = *((u32 *)(p + 4)); | ||
156 | p += 8; | ||
157 | if (initial_boot_params->version < 0x10) | ||
158 | p = _ALIGN(p, sz >= 8 ? 8 : 4); | ||
159 | |||
160 | nstr = find_flat_dt_string(noff); | ||
161 | if (nstr == NULL) { | ||
162 | printk(KERN_WARNING "Can't find property index" | ||
163 | " name !\n"); | ||
164 | return NULL; | ||
165 | } | ||
166 | if (strcmp(name, nstr) == 0) { | ||
167 | if (size) | ||
168 | *size = sz; | ||
169 | return (void *)p; | ||
170 | } | ||
171 | p += sz; | ||
172 | p = _ALIGN(p, 4); | ||
173 | } while (1); | ||
174 | } | ||
175 | |||
176 | int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) | ||
177 | { | ||
178 | const char *cp; | ||
179 | unsigned long cplen, l; | ||
180 | |||
181 | cp = of_get_flat_dt_prop(node, "compatible", &cplen); | ||
182 | if (cp == NULL) | ||
183 | return 0; | ||
184 | while (cplen > 0) { | ||
185 | if (strncasecmp(cp, compat, strlen(compat)) == 0) | ||
186 | return 1; | ||
187 | l = strlen(cp) + 1; | ||
188 | cp += l; | ||
189 | cplen -= l; | ||
190 | } | ||
191 | |||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size, | ||
196 | unsigned long align) | ||
197 | { | ||
198 | void *res; | ||
199 | |||
200 | *mem = _ALIGN(*mem, align); | ||
201 | res = (void *)*mem; | ||
202 | *mem += size; | ||
203 | |||
204 | return res; | ||
205 | } | ||
206 | |||
207 | static unsigned long __init unflatten_dt_node(unsigned long mem, | ||
208 | unsigned long *p, | ||
209 | struct device_node *dad, | ||
210 | struct device_node ***allnextpp, | ||
211 | unsigned long fpsize) | ||
212 | { | ||
213 | struct device_node *np; | ||
214 | struct property *pp, **prev_pp = NULL; | ||
215 | char *pathp; | ||
216 | u32 tag; | ||
217 | unsigned int l, allocl; | ||
218 | int has_name = 0; | ||
219 | int new_format = 0; | ||
220 | |||
221 | tag = *((u32 *)(*p)); | ||
222 | if (tag != OF_DT_BEGIN_NODE) { | ||
223 | printk("Weird tag at start of node: %x\n", tag); | ||
224 | return mem; | ||
225 | } | ||
226 | *p += 4; | ||
227 | pathp = (char *)*p; | ||
228 | l = allocl = strlen(pathp) + 1; | ||
229 | *p = _ALIGN(*p + l, 4); | ||
230 | |||
231 | /* version 0x10 has a more compact unit name here instead of the full | ||
232 | * path. we accumulate the full path size using "fpsize", we'll rebuild | ||
233 | * it later. We detect this because the first character of the name is | ||
234 | * not '/'. | ||
235 | */ | ||
236 | if ((*pathp) != '/') { | ||
237 | new_format = 1; | ||
238 | if (fpsize == 0) { | ||
239 | /* root node: special case. fpsize accounts for path | ||
240 | * plus terminating zero. root node only has '/', so | ||
241 | * fpsize should be 2, but we want to avoid the first | ||
242 | * level nodes to have two '/' so we use fpsize 1 here | ||
243 | */ | ||
244 | fpsize = 1; | ||
245 | allocl = 2; | ||
246 | } else { | ||
247 | /* account for '/' and path size minus terminal 0 | ||
248 | * already in 'l' | ||
249 | */ | ||
250 | fpsize += l; | ||
251 | allocl = fpsize; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl, | ||
256 | __alignof__(struct device_node)); | ||
257 | if (allnextpp) { | ||
258 | memset(np, 0, sizeof(*np)); | ||
259 | np->full_name = ((char *)np) + sizeof(struct device_node); | ||
260 | if (new_format) { | ||
261 | char *p2 = np->full_name; | ||
262 | /* rebuild full path for new format */ | ||
263 | if (dad && dad->parent) { | ||
264 | strcpy(p2, dad->full_name); | ||
265 | #ifdef DEBUG | ||
266 | if ((strlen(p2) + l + 1) != allocl) { | ||
267 | pr_debug("%s: p: %d, l: %d, a: %d\n", | ||
268 | pathp, (int)strlen(p2), | ||
269 | l, allocl); | ||
270 | } | ||
271 | #endif | ||
272 | p2 += strlen(p2); | ||
273 | } | ||
274 | *(p2++) = '/'; | ||
275 | memcpy(p2, pathp, l); | ||
276 | } else | ||
277 | memcpy(np->full_name, pathp, l); | ||
278 | prev_pp = &np->properties; | ||
279 | **allnextpp = np; | ||
280 | *allnextpp = &np->allnext; | ||
281 | if (dad != NULL) { | ||
282 | np->parent = dad; | ||
283 | /* we temporarily use the next field as `last_child'*/ | ||
284 | if (dad->next == NULL) | ||
285 | dad->child = np; | ||
286 | else | ||
287 | dad->next->sibling = np; | ||
288 | dad->next = np; | ||
289 | } | ||
290 | kref_init(&np->kref); | ||
291 | } | ||
292 | while (1) { | ||
293 | u32 sz, noff; | ||
294 | char *pname; | ||
295 | |||
296 | tag = *((u32 *)(*p)); | ||
297 | if (tag == OF_DT_NOP) { | ||
298 | *p += 4; | ||
299 | continue; | ||
300 | } | ||
301 | if (tag != OF_DT_PROP) | ||
302 | break; | ||
303 | *p += 4; | ||
304 | sz = *((u32 *)(*p)); | ||
305 | noff = *((u32 *)((*p) + 4)); | ||
306 | *p += 8; | ||
307 | if (initial_boot_params->version < 0x10) | ||
308 | *p = _ALIGN(*p, sz >= 8 ? 8 : 4); | ||
309 | |||
310 | pname = find_flat_dt_string(noff); | ||
311 | if (pname == NULL) { | ||
312 | printk(KERN_INFO | ||
313 | "Can't find property name in list !\n"); | ||
314 | break; | ||
315 | } | ||
316 | if (strcmp(pname, "name") == 0) | ||
317 | has_name = 1; | ||
318 | l = strlen(pname) + 1; | ||
319 | pp = unflatten_dt_alloc(&mem, sizeof(struct property), | ||
320 | __alignof__(struct property)); | ||
321 | if (allnextpp) { | ||
322 | if (strcmp(pname, "linux,phandle") == 0) { | ||
323 | np->node = *((u32 *)*p); | ||
324 | if (np->linux_phandle == 0) | ||
325 | np->linux_phandle = np->node; | ||
326 | } | ||
327 | if (strcmp(pname, "ibm,phandle") == 0) | ||
328 | np->linux_phandle = *((u32 *)*p); | ||
329 | pp->name = pname; | ||
330 | pp->length = sz; | ||
331 | pp->value = (void *)*p; | ||
332 | *prev_pp = pp; | ||
333 | prev_pp = &pp->next; | ||
334 | } | ||
335 | *p = _ALIGN((*p) + sz, 4); | ||
336 | } | ||
337 | /* with version 0x10 we may not have the name property, recreate | ||
338 | * it here from the unit name if absent | ||
339 | */ | ||
340 | if (!has_name) { | ||
341 | char *p1 = pathp, *ps = pathp, *pa = NULL; | ||
342 | int sz; | ||
343 | |||
344 | while (*p1) { | ||
345 | if ((*p1) == '@') | ||
346 | pa = p1; | ||
347 | if ((*p1) == '/') | ||
348 | ps = p1 + 1; | ||
349 | p1++; | ||
350 | } | ||
351 | if (pa < ps) | ||
352 | pa = p1; | ||
353 | sz = (pa - ps) + 1; | ||
354 | pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz, | ||
355 | __alignof__(struct property)); | ||
356 | if (allnextpp) { | ||
357 | pp->name = "name"; | ||
358 | pp->length = sz; | ||
359 | pp->value = pp + 1; | ||
360 | *prev_pp = pp; | ||
361 | prev_pp = &pp->next; | ||
362 | memcpy(pp->value, ps, sz - 1); | ||
363 | ((char *)pp->value)[sz - 1] = 0; | ||
364 | pr_debug("fixed up name for %s -> %s\n", pathp, | ||
365 | (char *)pp->value); | ||
366 | } | ||
367 | } | ||
368 | if (allnextpp) { | ||
369 | *prev_pp = NULL; | ||
370 | np->name = of_get_property(np, "name", NULL); | ||
371 | np->type = of_get_property(np, "device_type", NULL); | ||
372 | |||
373 | if (!np->name) | ||
374 | np->name = "<NULL>"; | ||
375 | if (!np->type) | ||
376 | np->type = "<NULL>"; | ||
377 | } | ||
378 | while (tag == OF_DT_BEGIN_NODE) { | ||
379 | mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize); | ||
380 | tag = *((u32 *)(*p)); | ||
381 | } | ||
382 | if (tag != OF_DT_END_NODE) { | ||
383 | printk(KERN_INFO "Weird tag at end of node: %x\n", tag); | ||
384 | return mem; | ||
385 | } | ||
386 | *p += 4; | ||
387 | return mem; | ||
388 | } | ||
389 | |||
390 | /** | ||
391 | * unflattens the device-tree passed by the firmware, creating the | ||
392 | * tree of struct device_node. It also fills the "name" and "type" | ||
393 | * pointers of the nodes so the normal device-tree walking functions | ||
394 | * can be used (this used to be done by finish_device_tree) | ||
395 | */ | ||
396 | void __init unflatten_device_tree(void) | ||
397 | { | ||
398 | unsigned long start, mem, size; | ||
399 | struct device_node **allnextp = &allnodes; | ||
400 | |||
401 | pr_debug(" -> unflatten_device_tree()\n"); | ||
402 | |||
403 | /* First pass, scan for size */ | ||
404 | start = ((unsigned long)initial_boot_params) + | ||
405 | initial_boot_params->off_dt_struct; | ||
406 | size = unflatten_dt_node(0, &start, NULL, NULL, 0); | ||
407 | size = (size | 3) + 1; | ||
408 | |||
409 | pr_debug(" size is %lx, allocating...\n", size); | ||
410 | |||
411 | /* Allocate memory for the expanded device tree */ | ||
412 | mem = lmb_alloc(size + 4, __alignof__(struct device_node)); | ||
413 | mem = (unsigned long) __va(mem); | ||
414 | |||
415 | ((u32 *)mem)[size / 4] = 0xdeadbeef; | ||
416 | |||
417 | pr_debug(" unflattening %lx...\n", mem); | ||
418 | |||
419 | /* Second pass, do actual unflattening */ | ||
420 | start = ((unsigned long)initial_boot_params) + | ||
421 | initial_boot_params->off_dt_struct; | ||
422 | unflatten_dt_node(mem, &start, NULL, &allnextp, 0); | ||
423 | if (*((u32 *)start) != OF_DT_END) | ||
424 | printk(KERN_WARNING "Weird tag at end of tree: %08x\n", | ||
425 | *((u32 *)start)); | ||
426 | if (((u32 *)mem)[size / 4] != 0xdeadbeef) | ||
427 | printk(KERN_WARNING "End of tree marker overwritten: %08x\n", | ||
428 | ((u32 *)mem)[size / 4]); | ||
429 | *allnextp = NULL; | ||
430 | |||
431 | /* Get pointer to OF "/chosen" node for use everywhere */ | ||
432 | of_chosen = of_find_node_by_path("/chosen"); | ||
433 | if (of_chosen == NULL) | ||
434 | of_chosen = of_find_node_by_path("/chosen@0"); | ||
435 | |||
436 | pr_debug(" <- unflatten_device_tree()\n"); | ||
437 | } | ||
438 | |||
439 | #define early_init_dt_scan_drconf_memory(node) 0 | ||
440 | |||
441 | static int __init early_init_dt_scan_cpus(unsigned long node, | ||
442 | const char *uname, int depth, | ||
443 | void *data) | ||
444 | { | ||
445 | static int logical_cpuid; | ||
446 | char *type = of_get_flat_dt_prop(node, "device_type", NULL); | ||
447 | const u32 *intserv; | ||
448 | int i, nthreads; | ||
449 | int found = 0; | ||
450 | |||
451 | /* We are scanning "cpu" nodes only */ | ||
452 | if (type == NULL || strcmp(type, "cpu") != 0) | ||
453 | return 0; | ||
454 | |||
455 | /* Get physical cpuid */ | ||
456 | intserv = of_get_flat_dt_prop(node, "reg", NULL); | ||
457 | nthreads = 1; | ||
458 | |||
459 | /* | ||
460 | * Now see if any of these threads match our boot cpu. | ||
461 | * NOTE: This must match the parsing done in smp_setup_cpu_maps. | ||
462 | */ | ||
463 | for (i = 0; i < nthreads; i++) { | ||
464 | /* | ||
465 | * version 2 of the kexec param format adds the phys cpuid of | ||
466 | * booted proc. | ||
467 | */ | ||
468 | if (initial_boot_params && initial_boot_params->version >= 2) { | ||
469 | if (intserv[i] == | ||
470 | initial_boot_params->boot_cpuid_phys) { | ||
471 | found = 1; | ||
472 | break; | ||
473 | } | ||
474 | } else { | ||
475 | /* | ||
476 | * Check if it's the boot-cpu, set it's hw index now, | ||
477 | * unfortunately this format did not support booting | ||
478 | * off secondary threads. | ||
479 | */ | ||
480 | if (of_get_flat_dt_prop(node, | ||
481 | "linux,boot-cpu", NULL) != NULL) { | ||
482 | found = 1; | ||
483 | break; | ||
484 | } | ||
485 | } | ||
486 | |||
487 | #ifdef CONFIG_SMP | ||
488 | /* logical cpu id is always 0 on UP kernels */ | ||
489 | logical_cpuid++; | ||
490 | #endif | ||
491 | } | ||
492 | |||
493 | if (found) { | ||
494 | pr_debug("boot cpu: logical %d physical %d\n", logical_cpuid, | ||
495 | intserv[i]); | ||
496 | boot_cpuid = logical_cpuid; | ||
497 | } | ||
498 | |||
499 | return 0; | ||
500 | } | ||
501 | |||
502 | #ifdef CONFIG_BLK_DEV_INITRD | ||
503 | static void __init early_init_dt_check_for_initrd(unsigned long node) | ||
504 | { | ||
505 | unsigned long l; | ||
506 | u32 *prop; | ||
507 | |||
508 | pr_debug("Looking for initrd properties... "); | ||
509 | |||
510 | prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l); | ||
511 | if (prop) { | ||
512 | initrd_start = (unsigned long) | ||
513 | __va((u32)of_read_ulong(prop, l/4)); | ||
514 | |||
515 | prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l); | ||
516 | if (prop) { | ||
517 | initrd_end = (unsigned long) | ||
518 | __va((u32)of_read_ulong(prop, 1/4)); | ||
519 | initrd_below_start_ok = 1; | ||
520 | } else { | ||
521 | initrd_start = 0; | ||
522 | } | ||
523 | } | ||
524 | |||
525 | pr_debug("initrd_start=0x%lx initrd_end=0x%lx\n", | ||
526 | initrd_start, initrd_end); | ||
527 | } | ||
528 | #else | ||
529 | static inline void early_init_dt_check_for_initrd(unsigned long node) | ||
530 | { | ||
531 | } | ||
532 | #endif /* CONFIG_BLK_DEV_INITRD */ | ||
533 | |||
534 | static int __init early_init_dt_scan_chosen(unsigned long node, | ||
535 | const char *uname, int depth, void *data) | ||
536 | { | ||
537 | unsigned long l; | ||
538 | char *p; | ||
539 | |||
540 | pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname); | ||
541 | |||
542 | if (depth != 1 || | ||
543 | (strcmp(uname, "chosen") != 0 && | ||
544 | strcmp(uname, "chosen@0") != 0)) | ||
545 | return 0; | ||
546 | |||
547 | #ifdef CONFIG_KEXEC | ||
548 | lprop = (u64 *)of_get_flat_dt_prop(node, | ||
549 | "linux,crashkernel-base", NULL); | ||
550 | if (lprop) | ||
551 | crashk_res.start = *lprop; | ||
552 | |||
553 | lprop = (u64 *)of_get_flat_dt_prop(node, | ||
554 | "linux,crashkernel-size", NULL); | ||
555 | if (lprop) | ||
556 | crashk_res.end = crashk_res.start + *lprop - 1; | ||
557 | #endif | ||
558 | |||
559 | early_init_dt_check_for_initrd(node); | ||
560 | |||
561 | /* Retreive command line */ | ||
562 | p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
563 | if (p != NULL && l > 0) | ||
564 | strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE)); | ||
565 | |||
566 | #ifdef CONFIG_CMDLINE | ||
567 | #ifndef CONFIG_CMDLINE_FORCE | ||
568 | if (p == NULL || l == 0 || (l == 1 && (*p) == 0)) | ||
569 | #endif | ||
570 | strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); | ||
571 | #endif /* CONFIG_CMDLINE */ | ||
572 | |||
573 | pr_debug("Command line is: %s\n", cmd_line); | ||
574 | |||
575 | /* break now */ | ||
576 | return 1; | ||
577 | } | ||
578 | |||
579 | static int __init early_init_dt_scan_root(unsigned long node, | ||
580 | const char *uname, int depth, void *data) | ||
581 | { | ||
582 | u32 *prop; | ||
583 | |||
584 | if (depth != 0) | ||
585 | return 0; | ||
586 | |||
587 | prop = of_get_flat_dt_prop(node, "#size-cells", NULL); | ||
588 | dt_root_size_cells = (prop == NULL) ? 1 : *prop; | ||
589 | pr_debug("dt_root_size_cells = %x\n", dt_root_size_cells); | ||
590 | |||
591 | prop = of_get_flat_dt_prop(node, "#address-cells", NULL); | ||
592 | dt_root_addr_cells = (prop == NULL) ? 2 : *prop; | ||
593 | pr_debug("dt_root_addr_cells = %x\n", dt_root_addr_cells); | ||
594 | |||
595 | /* break now */ | ||
596 | return 1; | ||
597 | } | ||
598 | |||
599 | static u64 __init dt_mem_next_cell(int s, cell_t **cellp) | ||
600 | { | 46 | { |
601 | cell_t *p = *cellp; | 47 | /* No Microblaze specific code here */ |
602 | |||
603 | *cellp = p + s; | ||
604 | return of_read_number(p, s); | ||
605 | } | 48 | } |
606 | 49 | ||
607 | static int __init early_init_dt_scan_memory(unsigned long node, | 50 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) |
608 | const char *uname, int depth, void *data) | ||
609 | { | 51 | { |
610 | char *type = of_get_flat_dt_prop(node, "device_type", NULL); | 52 | lmb_add(base, size); |
611 | cell_t *reg, *endp; | ||
612 | unsigned long l; | ||
613 | |||
614 | /* Look for the ibm,dynamic-reconfiguration-memory node */ | ||
615 | /* if (depth == 1 && | ||
616 | strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) | ||
617 | return early_init_dt_scan_drconf_memory(node); | ||
618 | */ | ||
619 | /* We are scanning "memory" nodes only */ | ||
620 | if (type == NULL) { | ||
621 | /* | ||
622 | * The longtrail doesn't have a device_type on the | ||
623 | * /memory node, so look for the node called /memory@0. | ||
624 | */ | ||
625 | if (depth != 1 || strcmp(uname, "memory@0") != 0) | ||
626 | return 0; | ||
627 | } else if (strcmp(type, "memory") != 0) | ||
628 | return 0; | ||
629 | |||
630 | reg = (cell_t *)of_get_flat_dt_prop(node, "linux,usable-memory", &l); | ||
631 | if (reg == NULL) | ||
632 | reg = (cell_t *)of_get_flat_dt_prop(node, "reg", &l); | ||
633 | if (reg == NULL) | ||
634 | return 0; | ||
635 | |||
636 | endp = reg + (l / sizeof(cell_t)); | ||
637 | |||
638 | pr_debug("memory scan node %s, reg size %ld, data: %x %x %x %x,\n", | ||
639 | uname, l, reg[0], reg[1], reg[2], reg[3]); | ||
640 | |||
641 | while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { | ||
642 | u64 base, size; | ||
643 | |||
644 | base = dt_mem_next_cell(dt_root_addr_cells, ®); | ||
645 | size = dt_mem_next_cell(dt_root_size_cells, ®); | ||
646 | |||
647 | if (size == 0) | ||
648 | continue; | ||
649 | pr_debug(" - %llx , %llx\n", (unsigned long long)base, | ||
650 | (unsigned long long)size); | ||
651 | |||
652 | lmb_add(base, size); | ||
653 | } | ||
654 | return 0; | ||
655 | } | 53 | } |
656 | 54 | ||
657 | #ifdef CONFIG_PHYP_DUMP | 55 | u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align) |
658 | /** | ||
659 | * phyp_dump_calculate_reserve_size() - reserve variable boot area 5% or arg | ||
660 | * | ||
661 | * Function to find the largest size we need to reserve | ||
662 | * during early boot process. | ||
663 | * | ||
664 | * It either looks for boot param and returns that OR | ||
665 | * returns larger of 256 or 5% rounded down to multiples of 256MB. | ||
666 | * | ||
667 | */ | ||
668 | static inline unsigned long phyp_dump_calculate_reserve_size(void) | ||
669 | { | 56 | { |
670 | unsigned long tmp; | 57 | return lmb_alloc(size, align); |
671 | |||
672 | if (phyp_dump_info->reserve_bootvar) | ||
673 | return phyp_dump_info->reserve_bootvar; | ||
674 | |||
675 | /* divide by 20 to get 5% of value */ | ||
676 | tmp = lmb_end_of_DRAM(); | ||
677 | do_div(tmp, 20); | ||
678 | |||
679 | /* round it down in multiples of 256 */ | ||
680 | tmp = tmp & ~0x0FFFFFFFUL; | ||
681 | |||
682 | return (tmp > PHYP_DUMP_RMR_END ? tmp : PHYP_DUMP_RMR_END); | ||
683 | } | 58 | } |
684 | 59 | ||
685 | /** | ||
686 | * phyp_dump_reserve_mem() - reserve all not-yet-dumped mmemory | ||
687 | * | ||
688 | * This routine may reserve memory regions in the kernel only | ||
689 | * if the system is supported and a dump was taken in last | ||
690 | * boot instance or if the hardware is supported and the | ||
691 | * scratch area needs to be setup. In other instances it returns | ||
692 | * without reserving anything. The memory in case of dump being | ||
693 | * active is freed when the dump is collected (by userland tools). | ||
694 | */ | ||
695 | static void __init phyp_dump_reserve_mem(void) | ||
696 | { | ||
697 | unsigned long base, size; | ||
698 | unsigned long variable_reserve_size; | ||
699 | |||
700 | if (!phyp_dump_info->phyp_dump_configured) { | ||
701 | printk(KERN_ERR "Phyp-dump not supported on this hardware\n"); | ||
702 | return; | ||
703 | } | ||
704 | |||
705 | if (!phyp_dump_info->phyp_dump_at_boot) { | ||
706 | printk(KERN_INFO "Phyp-dump disabled at boot time\n"); | ||
707 | return; | ||
708 | } | ||
709 | |||
710 | variable_reserve_size = phyp_dump_calculate_reserve_size(); | ||
711 | |||
712 | if (phyp_dump_info->phyp_dump_is_active) { | ||
713 | /* Reserve *everything* above RMR.Area freed by userland tools*/ | ||
714 | base = variable_reserve_size; | ||
715 | size = lmb_end_of_DRAM() - base; | ||
716 | |||
717 | /* XXX crashed_ram_end is wrong, since it may be beyond | ||
718 | * the memory_limit, it will need to be adjusted. */ | ||
719 | lmb_reserve(base, size); | ||
720 | |||
721 | phyp_dump_info->init_reserve_start = base; | ||
722 | phyp_dump_info->init_reserve_size = size; | ||
723 | } else { | ||
724 | size = phyp_dump_info->cpu_state_size + | ||
725 | phyp_dump_info->hpte_region_size + | ||
726 | variable_reserve_size; | ||
727 | base = lmb_end_of_DRAM() - size; | ||
728 | lmb_reserve(base, size); | ||
729 | phyp_dump_info->init_reserve_start = base; | ||
730 | phyp_dump_info->init_reserve_size = size; | ||
731 | } | ||
732 | } | ||
733 | #else | ||
734 | static inline void __init phyp_dump_reserve_mem(void) {} | ||
735 | #endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */ | ||
736 | |||
737 | #ifdef CONFIG_EARLY_PRINTK | 60 | #ifdef CONFIG_EARLY_PRINTK |
738 | /* MS this is Microblaze specifig function */ | 61 | /* MS this is Microblaze specifig function */ |
739 | static int __init early_init_dt_scan_serial(unsigned long node, | 62 | static int __init early_init_dt_scan_serial(unsigned long node, |
@@ -775,11 +98,6 @@ void __init early_init_devtree(void *params) | |||
775 | /* Setup flat device-tree pointer */ | 98 | /* Setup flat device-tree pointer */ |
776 | initial_boot_params = params; | 99 | initial_boot_params = params; |
777 | 100 | ||
778 | #ifdef CONFIG_PHYP_DUMP | ||
779 | /* scan tree to see if dump occured during last boot */ | ||
780 | of_scan_flat_dt(early_init_dt_scan_phyp_dump, NULL); | ||
781 | #endif | ||
782 | |||
783 | /* Retrieve various informations from the /chosen node of the | 101 | /* Retrieve various informations from the /chosen node of the |
784 | * device-tree, including the platform type, initrd location and | 102 | * device-tree, including the platform type, initrd location and |
785 | * size, TCE reserve, and more ... | 103 | * size, TCE reserve, and more ... |
@@ -799,33 +117,18 @@ void __init early_init_devtree(void *params) | |||
799 | 117 | ||
800 | pr_debug("Phys. mem: %lx\n", (unsigned long) lmb_phys_mem_size()); | 118 | pr_debug("Phys. mem: %lx\n", (unsigned long) lmb_phys_mem_size()); |
801 | 119 | ||
802 | pr_debug("Scanning CPUs ...\n"); | ||
803 | |||
804 | /* Retreive CPU related informations from the flat tree | ||
805 | * (altivec support, boot CPU ID, ...) | ||
806 | */ | ||
807 | of_scan_flat_dt(early_init_dt_scan_cpus, NULL); | ||
808 | |||
809 | pr_debug(" <- early_init_devtree()\n"); | 120 | pr_debug(" <- early_init_devtree()\n"); |
810 | } | 121 | } |
811 | 122 | ||
812 | /** | 123 | #ifdef CONFIG_BLK_DEV_INITRD |
813 | * Indicates whether the root node has a given value in its | 124 | void __init early_init_dt_setup_initrd_arch(unsigned long start, |
814 | * compatible property. | 125 | unsigned long end) |
815 | */ | ||
816 | int machine_is_compatible(const char *compat) | ||
817 | { | 126 | { |
818 | struct device_node *root; | 127 | initrd_start = (unsigned long)__va(start); |
819 | int rc = 0; | 128 | initrd_end = (unsigned long)__va(end); |
820 | 129 | initrd_below_start_ok = 1; | |
821 | root = of_find_node_by_path("/"); | ||
822 | if (root) { | ||
823 | rc = of_device_is_compatible(root, compat); | ||
824 | of_node_put(root); | ||
825 | } | ||
826 | return rc; | ||
827 | } | 130 | } |
828 | EXPORT_SYMBOL(machine_is_compatible); | 131 | #endif |
829 | 132 | ||
830 | /******* | 133 | /******* |
831 | * | 134 | * |
@@ -838,273 +141,6 @@ EXPORT_SYMBOL(machine_is_compatible); | |||
838 | * | 141 | * |
839 | *******/ | 142 | *******/ |
840 | 143 | ||
841 | /** | ||
842 | * of_find_node_by_phandle - Find a node given a phandle | ||
843 | * @handle: phandle of the node to find | ||
844 | * | ||
845 | * Returns a node pointer with refcount incremented, use | ||
846 | * of_node_put() on it when done. | ||
847 | */ | ||
848 | struct device_node *of_find_node_by_phandle(phandle handle) | ||
849 | { | ||
850 | struct device_node *np; | ||
851 | |||
852 | read_lock(&devtree_lock); | ||
853 | for (np = allnodes; np != NULL; np = np->allnext) | ||
854 | if (np->linux_phandle == handle) | ||
855 | break; | ||
856 | of_node_get(np); | ||
857 | read_unlock(&devtree_lock); | ||
858 | return np; | ||
859 | } | ||
860 | EXPORT_SYMBOL(of_find_node_by_phandle); | ||
861 | |||
862 | /** | ||
863 | * of_node_get - Increment refcount of a node | ||
864 | * @node: Node to inc refcount, NULL is supported to | ||
865 | * simplify writing of callers | ||
866 | * | ||
867 | * Returns node. | ||
868 | */ | ||
869 | struct device_node *of_node_get(struct device_node *node) | ||
870 | { | ||
871 | if (node) | ||
872 | kref_get(&node->kref); | ||
873 | return node; | ||
874 | } | ||
875 | EXPORT_SYMBOL(of_node_get); | ||
876 | |||
877 | static inline struct device_node *kref_to_device_node(struct kref *kref) | ||
878 | { | ||
879 | return container_of(kref, struct device_node, kref); | ||
880 | } | ||
881 | |||
882 | /** | ||
883 | * of_node_release - release a dynamically allocated node | ||
884 | * @kref: kref element of the node to be released | ||
885 | * | ||
886 | * In of_node_put() this function is passed to kref_put() | ||
887 | * as the destructor. | ||
888 | */ | ||
889 | static void of_node_release(struct kref *kref) | ||
890 | { | ||
891 | struct device_node *node = kref_to_device_node(kref); | ||
892 | struct property *prop = node->properties; | ||
893 | |||
894 | /* We should never be releasing nodes that haven't been detached. */ | ||
895 | if (!of_node_check_flag(node, OF_DETACHED)) { | ||
896 | printk(KERN_INFO "WARNING: Bad of_node_put() on %s\n", | ||
897 | node->full_name); | ||
898 | dump_stack(); | ||
899 | kref_init(&node->kref); | ||
900 | return; | ||
901 | } | ||
902 | |||
903 | if (!of_node_check_flag(node, OF_DYNAMIC)) | ||
904 | return; | ||
905 | |||
906 | while (prop) { | ||
907 | struct property *next = prop->next; | ||
908 | kfree(prop->name); | ||
909 | kfree(prop->value); | ||
910 | kfree(prop); | ||
911 | prop = next; | ||
912 | |||
913 | if (!prop) { | ||
914 | prop = node->deadprops; | ||
915 | node->deadprops = NULL; | ||
916 | } | ||
917 | } | ||
918 | kfree(node->full_name); | ||
919 | kfree(node->data); | ||
920 | kfree(node); | ||
921 | } | ||
922 | |||
923 | /** | ||
924 | * of_node_put - Decrement refcount of a node | ||
925 | * @node: Node to dec refcount, NULL is supported to | ||
926 | * simplify writing of callers | ||
927 | * | ||
928 | */ | ||
929 | void of_node_put(struct device_node *node) | ||
930 | { | ||
931 | if (node) | ||
932 | kref_put(&node->kref, of_node_release); | ||
933 | } | ||
934 | EXPORT_SYMBOL(of_node_put); | ||
935 | |||
936 | /* | ||
937 | * Plug a device node into the tree and global list. | ||
938 | */ | ||
939 | void of_attach_node(struct device_node *np) | ||
940 | { | ||
941 | unsigned long flags; | ||
942 | |||
943 | write_lock_irqsave(&devtree_lock, flags); | ||
944 | np->sibling = np->parent->child; | ||
945 | np->allnext = allnodes; | ||
946 | np->parent->child = np; | ||
947 | allnodes = np; | ||
948 | write_unlock_irqrestore(&devtree_lock, flags); | ||
949 | } | ||
950 | |||
951 | /* | ||
952 | * "Unplug" a node from the device tree. The caller must hold | ||
953 | * a reference to the node. The memory associated with the node | ||
954 | * is not freed until its refcount goes to zero. | ||
955 | */ | ||
956 | void of_detach_node(struct device_node *np) | ||
957 | { | ||
958 | struct device_node *parent; | ||
959 | unsigned long flags; | ||
960 | |||
961 | write_lock_irqsave(&devtree_lock, flags); | ||
962 | |||
963 | parent = np->parent; | ||
964 | if (!parent) | ||
965 | goto out_unlock; | ||
966 | |||
967 | if (allnodes == np) | ||
968 | allnodes = np->allnext; | ||
969 | else { | ||
970 | struct device_node *prev; | ||
971 | for (prev = allnodes; | ||
972 | prev->allnext != np; | ||
973 | prev = prev->allnext) | ||
974 | ; | ||
975 | prev->allnext = np->allnext; | ||
976 | } | ||
977 | |||
978 | if (parent->child == np) | ||
979 | parent->child = np->sibling; | ||
980 | else { | ||
981 | struct device_node *prevsib; | ||
982 | for (prevsib = np->parent->child; | ||
983 | prevsib->sibling != np; | ||
984 | prevsib = prevsib->sibling) | ||
985 | ; | ||
986 | prevsib->sibling = np->sibling; | ||
987 | } | ||
988 | |||
989 | of_node_set_flag(np, OF_DETACHED); | ||
990 | |||
991 | out_unlock: | ||
992 | write_unlock_irqrestore(&devtree_lock, flags); | ||
993 | } | ||
994 | |||
995 | /* | ||
996 | * Add a property to a node | ||
997 | */ | ||
998 | int prom_add_property(struct device_node *np, struct property *prop) | ||
999 | { | ||
1000 | struct property **next; | ||
1001 | unsigned long flags; | ||
1002 | |||
1003 | prop->next = NULL; | ||
1004 | write_lock_irqsave(&devtree_lock, flags); | ||
1005 | next = &np->properties; | ||
1006 | while (*next) { | ||
1007 | if (strcmp(prop->name, (*next)->name) == 0) { | ||
1008 | /* duplicate ! don't insert it */ | ||
1009 | write_unlock_irqrestore(&devtree_lock, flags); | ||
1010 | return -1; | ||
1011 | } | ||
1012 | next = &(*next)->next; | ||
1013 | } | ||
1014 | *next = prop; | ||
1015 | write_unlock_irqrestore(&devtree_lock, flags); | ||
1016 | |||
1017 | #ifdef CONFIG_PROC_DEVICETREE | ||
1018 | /* try to add to proc as well if it was initialized */ | ||
1019 | if (np->pde) | ||
1020 | proc_device_tree_add_prop(np->pde, prop); | ||
1021 | #endif /* CONFIG_PROC_DEVICETREE */ | ||
1022 | |||
1023 | return 0; | ||
1024 | } | ||
1025 | |||
1026 | /* | ||
1027 | * Remove a property from a node. Note that we don't actually | ||
1028 | * remove it, since we have given out who-knows-how-many pointers | ||
1029 | * to the data using get-property. Instead we just move the property | ||
1030 | * to the "dead properties" list, so it won't be found any more. | ||
1031 | */ | ||
1032 | int prom_remove_property(struct device_node *np, struct property *prop) | ||
1033 | { | ||
1034 | struct property **next; | ||
1035 | unsigned long flags; | ||
1036 | int found = 0; | ||
1037 | |||
1038 | write_lock_irqsave(&devtree_lock, flags); | ||
1039 | next = &np->properties; | ||
1040 | while (*next) { | ||
1041 | if (*next == prop) { | ||
1042 | /* found the node */ | ||
1043 | *next = prop->next; | ||
1044 | prop->next = np->deadprops; | ||
1045 | np->deadprops = prop; | ||
1046 | found = 1; | ||
1047 | break; | ||
1048 | } | ||
1049 | next = &(*next)->next; | ||
1050 | } | ||
1051 | write_unlock_irqrestore(&devtree_lock, flags); | ||
1052 | |||
1053 | if (!found) | ||
1054 | return -ENODEV; | ||
1055 | |||
1056 | #ifdef CONFIG_PROC_DEVICETREE | ||
1057 | /* try to remove the proc node as well */ | ||
1058 | if (np->pde) | ||
1059 | proc_device_tree_remove_prop(np->pde, prop); | ||
1060 | #endif /* CONFIG_PROC_DEVICETREE */ | ||
1061 | |||
1062 | return 0; | ||
1063 | } | ||
1064 | |||
1065 | /* | ||
1066 | * Update a property in a node. Note that we don't actually | ||
1067 | * remove it, since we have given out who-knows-how-many pointers | ||
1068 | * to the data using get-property. Instead we just move the property | ||
1069 | * to the "dead properties" list, and add the new property to the | ||
1070 | * property list | ||
1071 | */ | ||
1072 | int prom_update_property(struct device_node *np, | ||
1073 | struct property *newprop, | ||
1074 | struct property *oldprop) | ||
1075 | { | ||
1076 | struct property **next; | ||
1077 | unsigned long flags; | ||
1078 | int found = 0; | ||
1079 | |||
1080 | write_lock_irqsave(&devtree_lock, flags); | ||
1081 | next = &np->properties; | ||
1082 | while (*next) { | ||
1083 | if (*next == oldprop) { | ||
1084 | /* found the node */ | ||
1085 | newprop->next = oldprop->next; | ||
1086 | *next = newprop; | ||
1087 | oldprop->next = np->deadprops; | ||
1088 | np->deadprops = oldprop; | ||
1089 | found = 1; | ||
1090 | break; | ||
1091 | } | ||
1092 | next = &(*next)->next; | ||
1093 | } | ||
1094 | write_unlock_irqrestore(&devtree_lock, flags); | ||
1095 | |||
1096 | if (!found) | ||
1097 | return -ENODEV; | ||
1098 | |||
1099 | #ifdef CONFIG_PROC_DEVICETREE | ||
1100 | /* try to add to proc as well if it was initialized */ | ||
1101 | if (np->pde) | ||
1102 | proc_device_tree_update_prop(np->pde, newprop, oldprop); | ||
1103 | #endif /* CONFIG_PROC_DEVICETREE */ | ||
1104 | |||
1105 | return 0; | ||
1106 | } | ||
1107 | |||
1108 | #if defined(CONFIG_DEBUG_FS) && defined(DEBUG) | 144 | #if defined(CONFIG_DEBUG_FS) && defined(DEBUG) |
1109 | static struct debugfs_blob_wrapper flat_dt_blob; | 145 | static struct debugfs_blob_wrapper flat_dt_blob; |
1110 | 146 | ||
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index ba3948c70072..50c9af43e017 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -173,6 +173,7 @@ config PPC_OF | |||
173 | 173 | ||
174 | config OF | 174 | config OF |
175 | def_bool y | 175 | def_bool y |
176 | select OF_FLATTREE | ||
176 | 177 | ||
177 | config PPC_UDBG_16550 | 178 | config PPC_UDBG_16550 |
178 | bool | 179 | bool |
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h index 2ab9cbd98826..ddd408a93b5a 100644 --- a/arch/powerpc/include/asm/prom.h +++ b/arch/powerpc/include/asm/prom.h | |||
@@ -23,21 +23,8 @@ | |||
23 | #include <asm/irq.h> | 23 | #include <asm/irq.h> |
24 | #include <asm/atomic.h> | 24 | #include <asm/atomic.h> |
25 | 25 | ||
26 | #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 | ||
27 | #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 | ||
28 | |||
29 | #define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2)) | ||
30 | #define of_prop_cmp(s1, s2) strcmp((s1), (s2)) | ||
31 | #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) | ||
32 | |||
33 | extern struct device_node *of_chosen; | ||
34 | |||
35 | #define HAVE_ARCH_DEVTREE_FIXUPS | 26 | #define HAVE_ARCH_DEVTREE_FIXUPS |
36 | 27 | ||
37 | /* For updating the device tree at runtime */ | ||
38 | extern void of_attach_node(struct device_node *); | ||
39 | extern void of_detach_node(struct device_node *); | ||
40 | |||
41 | #ifdef CONFIG_PPC32 | 28 | #ifdef CONFIG_PPC32 |
42 | /* | 29 | /* |
43 | * PCI <-> OF matching functions | 30 | * PCI <-> OF matching functions |
@@ -52,11 +39,6 @@ extern struct device_node* pci_device_to_OF_node(struct pci_dev *); | |||
52 | extern void pci_create_OF_bus_map(void); | 39 | extern void pci_create_OF_bus_map(void); |
53 | #endif | 40 | #endif |
54 | 41 | ||
55 | extern struct resource *request_OF_resource(struct device_node* node, | ||
56 | int index, const char* name_postfix); | ||
57 | extern int release_OF_resource(struct device_node* node, int index); | ||
58 | |||
59 | |||
60 | /* | 42 | /* |
61 | * OF address retreival & translation | 43 | * OF address retreival & translation |
62 | */ | 44 | */ |
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c index 1a4fc0d11a03..666d08db319e 100644 --- a/arch/powerpc/kernel/of_platform.c +++ b/arch/powerpc/kernel/of_platform.c | |||
@@ -214,7 +214,7 @@ EXPORT_SYMBOL(of_find_device_by_node); | |||
214 | static int of_dev_phandle_match(struct device *dev, void *data) | 214 | static int of_dev_phandle_match(struct device *dev, void *data) |
215 | { | 215 | { |
216 | phandle *ph = data; | 216 | phandle *ph = data; |
217 | return to_of_device(dev)->node->linux_phandle == *ph; | 217 | return to_of_device(dev)->node->phandle == *ph; |
218 | } | 218 | } |
219 | 219 | ||
220 | struct of_device *of_find_device_by_phandle(phandle ph) | 220 | struct of_device *of_find_device_by_phandle(phandle ph) |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index ccf56ac92de5..d43fc65749c1 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
@@ -224,7 +224,7 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus, | |||
224 | * G5 machines... So when something asks for bus 0 io base | 224 | * G5 machines... So when something asks for bus 0 io base |
225 | * (bus 0 is HT root), we return the AGP one instead. | 225 | * (bus 0 is HT root), we return the AGP one instead. |
226 | */ | 226 | */ |
227 | if (in_bus == 0 && machine_is_compatible("MacRISC4")) { | 227 | if (in_bus == 0 && of_machine_is_compatible("MacRISC4")) { |
228 | struct device_node *agp; | 228 | struct device_node *agp; |
229 | 229 | ||
230 | agp = of_find_compatible_node(NULL, NULL, "u3-agp"); | 230 | agp = of_find_compatible_node(NULL, NULL, "u3-agp"); |
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 4ec300862466..43238b2054b6 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c | |||
@@ -61,365 +61,12 @@ | |||
61 | #define DBG(fmt...) | 61 | #define DBG(fmt...) |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | |||
65 | static int __initdata dt_root_addr_cells; | ||
66 | static int __initdata dt_root_size_cells; | ||
67 | |||
68 | #ifdef CONFIG_PPC64 | 64 | #ifdef CONFIG_PPC64 |
69 | int __initdata iommu_is_off; | 65 | int __initdata iommu_is_off; |
70 | int __initdata iommu_force_on; | 66 | int __initdata iommu_force_on; |
71 | unsigned long tce_alloc_start, tce_alloc_end; | 67 | unsigned long tce_alloc_start, tce_alloc_end; |
72 | #endif | 68 | #endif |
73 | 69 | ||
74 | typedef u32 cell_t; | ||
75 | |||
76 | #if 0 | ||
77 | static struct boot_param_header *initial_boot_params __initdata; | ||
78 | #else | ||
79 | struct boot_param_header *initial_boot_params; | ||
80 | #endif | ||
81 | |||
82 | extern struct device_node *allnodes; /* temporary while merging */ | ||
83 | |||
84 | extern rwlock_t devtree_lock; /* temporary while merging */ | ||
85 | |||
86 | /* export that to outside world */ | ||
87 | struct device_node *of_chosen; | ||
88 | |||
89 | static inline char *find_flat_dt_string(u32 offset) | ||
90 | { | ||
91 | return ((char *)initial_boot_params) + | ||
92 | initial_boot_params->off_dt_strings + offset; | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * This function is used to scan the flattened device-tree, it is | ||
97 | * used to extract the memory informations at boot before we can | ||
98 | * unflatten the tree | ||
99 | */ | ||
100 | int __init of_scan_flat_dt(int (*it)(unsigned long node, | ||
101 | const char *uname, int depth, | ||
102 | void *data), | ||
103 | void *data) | ||
104 | { | ||
105 | unsigned long p = ((unsigned long)initial_boot_params) + | ||
106 | initial_boot_params->off_dt_struct; | ||
107 | int rc = 0; | ||
108 | int depth = -1; | ||
109 | |||
110 | do { | ||
111 | u32 tag = *((u32 *)p); | ||
112 | char *pathp; | ||
113 | |||
114 | p += 4; | ||
115 | if (tag == OF_DT_END_NODE) { | ||
116 | depth --; | ||
117 | continue; | ||
118 | } | ||
119 | if (tag == OF_DT_NOP) | ||
120 | continue; | ||
121 | if (tag == OF_DT_END) | ||
122 | break; | ||
123 | if (tag == OF_DT_PROP) { | ||
124 | u32 sz = *((u32 *)p); | ||
125 | p += 8; | ||
126 | if (initial_boot_params->version < 0x10) | ||
127 | p = _ALIGN(p, sz >= 8 ? 8 : 4); | ||
128 | p += sz; | ||
129 | p = _ALIGN(p, 4); | ||
130 | continue; | ||
131 | } | ||
132 | if (tag != OF_DT_BEGIN_NODE) { | ||
133 | printk(KERN_WARNING "Invalid tag %x scanning flattened" | ||
134 | " device tree !\n", tag); | ||
135 | return -EINVAL; | ||
136 | } | ||
137 | depth++; | ||
138 | pathp = (char *)p; | ||
139 | p = _ALIGN(p + strlen(pathp) + 1, 4); | ||
140 | if ((*pathp) == '/') { | ||
141 | char *lp, *np; | ||
142 | for (lp = NULL, np = pathp; *np; np++) | ||
143 | if ((*np) == '/') | ||
144 | lp = np+1; | ||
145 | if (lp != NULL) | ||
146 | pathp = lp; | ||
147 | } | ||
148 | rc = it(p, pathp, depth, data); | ||
149 | if (rc != 0) | ||
150 | break; | ||
151 | } while(1); | ||
152 | |||
153 | return rc; | ||
154 | } | ||
155 | |||
156 | unsigned long __init of_get_flat_dt_root(void) | ||
157 | { | ||
158 | unsigned long p = ((unsigned long)initial_boot_params) + | ||
159 | initial_boot_params->off_dt_struct; | ||
160 | |||
161 | while(*((u32 *)p) == OF_DT_NOP) | ||
162 | p += 4; | ||
163 | BUG_ON (*((u32 *)p) != OF_DT_BEGIN_NODE); | ||
164 | p += 4; | ||
165 | return _ALIGN(p + strlen((char *)p) + 1, 4); | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * This function can be used within scan_flattened_dt callback to get | ||
170 | * access to properties | ||
171 | */ | ||
172 | void* __init of_get_flat_dt_prop(unsigned long node, const char *name, | ||
173 | unsigned long *size) | ||
174 | { | ||
175 | unsigned long p = node; | ||
176 | |||
177 | do { | ||
178 | u32 tag = *((u32 *)p); | ||
179 | u32 sz, noff; | ||
180 | const char *nstr; | ||
181 | |||
182 | p += 4; | ||
183 | if (tag == OF_DT_NOP) | ||
184 | continue; | ||
185 | if (tag != OF_DT_PROP) | ||
186 | return NULL; | ||
187 | |||
188 | sz = *((u32 *)p); | ||
189 | noff = *((u32 *)(p + 4)); | ||
190 | p += 8; | ||
191 | if (initial_boot_params->version < 0x10) | ||
192 | p = _ALIGN(p, sz >= 8 ? 8 : 4); | ||
193 | |||
194 | nstr = find_flat_dt_string(noff); | ||
195 | if (nstr == NULL) { | ||
196 | printk(KERN_WARNING "Can't find property index" | ||
197 | " name !\n"); | ||
198 | return NULL; | ||
199 | } | ||
200 | if (strcmp(name, nstr) == 0) { | ||
201 | if (size) | ||
202 | *size = sz; | ||
203 | return (void *)p; | ||
204 | } | ||
205 | p += sz; | ||
206 | p = _ALIGN(p, 4); | ||
207 | } while(1); | ||
208 | } | ||
209 | |||
210 | int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) | ||
211 | { | ||
212 | const char* cp; | ||
213 | unsigned long cplen, l; | ||
214 | |||
215 | cp = of_get_flat_dt_prop(node, "compatible", &cplen); | ||
216 | if (cp == NULL) | ||
217 | return 0; | ||
218 | while (cplen > 0) { | ||
219 | if (strncasecmp(cp, compat, strlen(compat)) == 0) | ||
220 | return 1; | ||
221 | l = strlen(cp) + 1; | ||
222 | cp += l; | ||
223 | cplen -= l; | ||
224 | } | ||
225 | |||
226 | return 0; | ||
227 | } | ||
228 | |||
229 | static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size, | ||
230 | unsigned long align) | ||
231 | { | ||
232 | void *res; | ||
233 | |||
234 | *mem = _ALIGN(*mem, align); | ||
235 | res = (void *)*mem; | ||
236 | *mem += size; | ||
237 | |||
238 | return res; | ||
239 | } | ||
240 | |||
241 | static unsigned long __init unflatten_dt_node(unsigned long mem, | ||
242 | unsigned long *p, | ||
243 | struct device_node *dad, | ||
244 | struct device_node ***allnextpp, | ||
245 | unsigned long fpsize) | ||
246 | { | ||
247 | struct device_node *np; | ||
248 | struct property *pp, **prev_pp = NULL; | ||
249 | char *pathp; | ||
250 | u32 tag; | ||
251 | unsigned int l, allocl; | ||
252 | int has_name = 0; | ||
253 | int new_format = 0; | ||
254 | |||
255 | tag = *((u32 *)(*p)); | ||
256 | if (tag != OF_DT_BEGIN_NODE) { | ||
257 | printk("Weird tag at start of node: %x\n", tag); | ||
258 | return mem; | ||
259 | } | ||
260 | *p += 4; | ||
261 | pathp = (char *)*p; | ||
262 | l = allocl = strlen(pathp) + 1; | ||
263 | *p = _ALIGN(*p + l, 4); | ||
264 | |||
265 | /* version 0x10 has a more compact unit name here instead of the full | ||
266 | * path. we accumulate the full path size using "fpsize", we'll rebuild | ||
267 | * it later. We detect this because the first character of the name is | ||
268 | * not '/'. | ||
269 | */ | ||
270 | if ((*pathp) != '/') { | ||
271 | new_format = 1; | ||
272 | if (fpsize == 0) { | ||
273 | /* root node: special case. fpsize accounts for path | ||
274 | * plus terminating zero. root node only has '/', so | ||
275 | * fpsize should be 2, but we want to avoid the first | ||
276 | * level nodes to have two '/' so we use fpsize 1 here | ||
277 | */ | ||
278 | fpsize = 1; | ||
279 | allocl = 2; | ||
280 | } else { | ||
281 | /* account for '/' and path size minus terminal 0 | ||
282 | * already in 'l' | ||
283 | */ | ||
284 | fpsize += l; | ||
285 | allocl = fpsize; | ||
286 | } | ||
287 | } | ||
288 | |||
289 | |||
290 | np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl, | ||
291 | __alignof__(struct device_node)); | ||
292 | if (allnextpp) { | ||
293 | memset(np, 0, sizeof(*np)); | ||
294 | np->full_name = ((char*)np) + sizeof(struct device_node); | ||
295 | if (new_format) { | ||
296 | char *p = np->full_name; | ||
297 | /* rebuild full path for new format */ | ||
298 | if (dad && dad->parent) { | ||
299 | strcpy(p, dad->full_name); | ||
300 | #ifdef DEBUG | ||
301 | if ((strlen(p) + l + 1) != allocl) { | ||
302 | DBG("%s: p: %d, l: %d, a: %d\n", | ||
303 | pathp, (int)strlen(p), l, allocl); | ||
304 | } | ||
305 | #endif | ||
306 | p += strlen(p); | ||
307 | } | ||
308 | *(p++) = '/'; | ||
309 | memcpy(p, pathp, l); | ||
310 | } else | ||
311 | memcpy(np->full_name, pathp, l); | ||
312 | prev_pp = &np->properties; | ||
313 | **allnextpp = np; | ||
314 | *allnextpp = &np->allnext; | ||
315 | if (dad != NULL) { | ||
316 | np->parent = dad; | ||
317 | /* we temporarily use the next field as `last_child'*/ | ||
318 | if (dad->next == 0) | ||
319 | dad->child = np; | ||
320 | else | ||
321 | dad->next->sibling = np; | ||
322 | dad->next = np; | ||
323 | } | ||
324 | kref_init(&np->kref); | ||
325 | } | ||
326 | while(1) { | ||
327 | u32 sz, noff; | ||
328 | char *pname; | ||
329 | |||
330 | tag = *((u32 *)(*p)); | ||
331 | if (tag == OF_DT_NOP) { | ||
332 | *p += 4; | ||
333 | continue; | ||
334 | } | ||
335 | if (tag != OF_DT_PROP) | ||
336 | break; | ||
337 | *p += 4; | ||
338 | sz = *((u32 *)(*p)); | ||
339 | noff = *((u32 *)((*p) + 4)); | ||
340 | *p += 8; | ||
341 | if (initial_boot_params->version < 0x10) | ||
342 | *p = _ALIGN(*p, sz >= 8 ? 8 : 4); | ||
343 | |||
344 | pname = find_flat_dt_string(noff); | ||
345 | if (pname == NULL) { | ||
346 | printk("Can't find property name in list !\n"); | ||
347 | break; | ||
348 | } | ||
349 | if (strcmp(pname, "name") == 0) | ||
350 | has_name = 1; | ||
351 | l = strlen(pname) + 1; | ||
352 | pp = unflatten_dt_alloc(&mem, sizeof(struct property), | ||
353 | __alignof__(struct property)); | ||
354 | if (allnextpp) { | ||
355 | if (strcmp(pname, "linux,phandle") == 0) { | ||
356 | np->node = *((u32 *)*p); | ||
357 | if (np->linux_phandle == 0) | ||
358 | np->linux_phandle = np->node; | ||
359 | } | ||
360 | if (strcmp(pname, "ibm,phandle") == 0) | ||
361 | np->linux_phandle = *((u32 *)*p); | ||
362 | pp->name = pname; | ||
363 | pp->length = sz; | ||
364 | pp->value = (void *)*p; | ||
365 | *prev_pp = pp; | ||
366 | prev_pp = &pp->next; | ||
367 | } | ||
368 | *p = _ALIGN((*p) + sz, 4); | ||
369 | } | ||
370 | /* with version 0x10 we may not have the name property, recreate | ||
371 | * it here from the unit name if absent | ||
372 | */ | ||
373 | if (!has_name) { | ||
374 | char *p = pathp, *ps = pathp, *pa = NULL; | ||
375 | int sz; | ||
376 | |||
377 | while (*p) { | ||
378 | if ((*p) == '@') | ||
379 | pa = p; | ||
380 | if ((*p) == '/') | ||
381 | ps = p + 1; | ||
382 | p++; | ||
383 | } | ||
384 | if (pa < ps) | ||
385 | pa = p; | ||
386 | sz = (pa - ps) + 1; | ||
387 | pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz, | ||
388 | __alignof__(struct property)); | ||
389 | if (allnextpp) { | ||
390 | pp->name = "name"; | ||
391 | pp->length = sz; | ||
392 | pp->value = pp + 1; | ||
393 | *prev_pp = pp; | ||
394 | prev_pp = &pp->next; | ||
395 | memcpy(pp->value, ps, sz - 1); | ||
396 | ((char *)pp->value)[sz - 1] = 0; | ||
397 | DBG("fixed up name for %s -> %s\n", pathp, | ||
398 | (char *)pp->value); | ||
399 | } | ||
400 | } | ||
401 | if (allnextpp) { | ||
402 | *prev_pp = NULL; | ||
403 | np->name = of_get_property(np, "name", NULL); | ||
404 | np->type = of_get_property(np, "device_type", NULL); | ||
405 | |||
406 | if (!np->name) | ||
407 | np->name = "<NULL>"; | ||
408 | if (!np->type) | ||
409 | np->type = "<NULL>"; | ||
410 | } | ||
411 | while (tag == OF_DT_BEGIN_NODE) { | ||
412 | mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize); | ||
413 | tag = *((u32 *)(*p)); | ||
414 | } | ||
415 | if (tag != OF_DT_END_NODE) { | ||
416 | printk("Weird tag at end of node: %x\n", tag); | ||
417 | return mem; | ||
418 | } | ||
419 | *p += 4; | ||
420 | return mem; | ||
421 | } | ||
422 | |||
423 | static int __init early_parse_mem(char *p) | 70 | static int __init early_parse_mem(char *p) |
424 | { | 71 | { |
425 | if (!p) | 72 | if (!p) |
@@ -446,7 +93,7 @@ static void __init move_device_tree(void) | |||
446 | DBG("-> move_device_tree\n"); | 93 | DBG("-> move_device_tree\n"); |
447 | 94 | ||
448 | start = __pa(initial_boot_params); | 95 | start = __pa(initial_boot_params); |
449 | size = initial_boot_params->totalsize; | 96 | size = be32_to_cpu(initial_boot_params->totalsize); |
450 | 97 | ||
451 | if ((memory_limit && (start + size) > memory_limit) || | 98 | if ((memory_limit && (start + size) > memory_limit) || |
452 | overlaps_crashkernel(start, size)) { | 99 | overlaps_crashkernel(start, size)) { |
@@ -459,54 +106,6 @@ static void __init move_device_tree(void) | |||
459 | DBG("<- move_device_tree\n"); | 106 | DBG("<- move_device_tree\n"); |
460 | } | 107 | } |
461 | 108 | ||
462 | /** | ||
463 | * unflattens the device-tree passed by the firmware, creating the | ||
464 | * tree of struct device_node. It also fills the "name" and "type" | ||
465 | * pointers of the nodes so the normal device-tree walking functions | ||
466 | * can be used (this used to be done by finish_device_tree) | ||
467 | */ | ||
468 | void __init unflatten_device_tree(void) | ||
469 | { | ||
470 | unsigned long start, mem, size; | ||
471 | struct device_node **allnextp = &allnodes; | ||
472 | |||
473 | DBG(" -> unflatten_device_tree()\n"); | ||
474 | |||
475 | /* First pass, scan for size */ | ||
476 | start = ((unsigned long)initial_boot_params) + | ||
477 | initial_boot_params->off_dt_struct; | ||
478 | size = unflatten_dt_node(0, &start, NULL, NULL, 0); | ||
479 | size = (size | 3) + 1; | ||
480 | |||
481 | DBG(" size is %lx, allocating...\n", size); | ||
482 | |||
483 | /* Allocate memory for the expanded device tree */ | ||
484 | mem = lmb_alloc(size + 4, __alignof__(struct device_node)); | ||
485 | mem = (unsigned long) __va(mem); | ||
486 | |||
487 | ((u32 *)mem)[size / 4] = 0xdeadbeef; | ||
488 | |||
489 | DBG(" unflattening %lx...\n", mem); | ||
490 | |||
491 | /* Second pass, do actual unflattening */ | ||
492 | start = ((unsigned long)initial_boot_params) + | ||
493 | initial_boot_params->off_dt_struct; | ||
494 | unflatten_dt_node(mem, &start, NULL, &allnextp, 0); | ||
495 | if (*((u32 *)start) != OF_DT_END) | ||
496 | printk(KERN_WARNING "Weird tag at end of tree: %08x\n", *((u32 *)start)); | ||
497 | if (((u32 *)mem)[size / 4] != 0xdeadbeef) | ||
498 | printk(KERN_WARNING "End of tree marker overwritten: %08x\n", | ||
499 | ((u32 *)mem)[size / 4] ); | ||
500 | *allnextp = NULL; | ||
501 | |||
502 | /* Get pointer to OF "/chosen" node for use everywhere */ | ||
503 | of_chosen = of_find_node_by_path("/chosen"); | ||
504 | if (of_chosen == NULL) | ||
505 | of_chosen = of_find_node_by_path("/chosen@0"); | ||
506 | |||
507 | DBG(" <- unflatten_device_tree()\n"); | ||
508 | } | ||
509 | |||
510 | /* | 109 | /* |
511 | * ibm,pa-features is a per-cpu property that contains a string of | 110 | * ibm,pa-features is a per-cpu property that contains a string of |
512 | * attribute descriptors, each of which has a 2 byte header plus up | 111 | * attribute descriptors, each of which has a 2 byte header plus up |
@@ -763,48 +362,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node, | |||
763 | return 0; | 362 | return 0; |
764 | } | 363 | } |
765 | 364 | ||
766 | #ifdef CONFIG_BLK_DEV_INITRD | 365 | void __init early_init_dt_scan_chosen_arch(unsigned long node) |
767 | static void __init early_init_dt_check_for_initrd(unsigned long node) | ||
768 | { | ||
769 | unsigned long l; | ||
770 | u32 *prop; | ||
771 | |||
772 | DBG("Looking for initrd properties... "); | ||
773 | |||
774 | prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l); | ||
775 | if (prop) { | ||
776 | initrd_start = (unsigned long)__va(of_read_ulong(prop, l/4)); | ||
777 | |||
778 | prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l); | ||
779 | if (prop) { | ||
780 | initrd_end = (unsigned long) | ||
781 | __va(of_read_ulong(prop, l/4)); | ||
782 | initrd_below_start_ok = 1; | ||
783 | } else { | ||
784 | initrd_start = 0; | ||
785 | } | ||
786 | } | ||
787 | |||
788 | DBG("initrd_start=0x%lx initrd_end=0x%lx\n", initrd_start, initrd_end); | ||
789 | } | ||
790 | #else | ||
791 | static inline void early_init_dt_check_for_initrd(unsigned long node) | ||
792 | { | ||
793 | } | ||
794 | #endif /* CONFIG_BLK_DEV_INITRD */ | ||
795 | |||
796 | static int __init early_init_dt_scan_chosen(unsigned long node, | ||
797 | const char *uname, int depth, void *data) | ||
798 | { | 366 | { |
799 | unsigned long *lprop; | 367 | unsigned long *lprop; |
800 | unsigned long l; | ||
801 | char *p; | ||
802 | |||
803 | DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname); | ||
804 | |||
805 | if (depth != 1 || | ||
806 | (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) | ||
807 | return 0; | ||
808 | 368 | ||
809 | #ifdef CONFIG_PPC64 | 369 | #ifdef CONFIG_PPC64 |
810 | /* check if iommu is forced on or off */ | 370 | /* check if iommu is forced on or off */ |
@@ -815,17 +375,17 @@ static int __init early_init_dt_scan_chosen(unsigned long node, | |||
815 | #endif | 375 | #endif |
816 | 376 | ||
817 | /* mem=x on the command line is the preferred mechanism */ | 377 | /* mem=x on the command line is the preferred mechanism */ |
818 | lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL); | 378 | lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL); |
819 | if (lprop) | 379 | if (lprop) |
820 | memory_limit = *lprop; | 380 | memory_limit = *lprop; |
821 | 381 | ||
822 | #ifdef CONFIG_PPC64 | 382 | #ifdef CONFIG_PPC64 |
823 | lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-start", NULL); | 383 | lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-start", NULL); |
824 | if (lprop) | 384 | if (lprop) |
825 | tce_alloc_start = *lprop; | 385 | tce_alloc_start = *lprop; |
826 | lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL); | 386 | lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL); |
827 | if (lprop) | 387 | if (lprop) |
828 | tce_alloc_end = *lprop; | 388 | tce_alloc_end = *lprop; |
829 | #endif | 389 | #endif |
830 | 390 | ||
831 | #ifdef CONFIG_KEXEC | 391 | #ifdef CONFIG_KEXEC |
@@ -837,51 +397,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node, | |||
837 | if (lprop) | 397 | if (lprop) |
838 | crashk_res.end = crashk_res.start + *lprop - 1; | 398 | crashk_res.end = crashk_res.start + *lprop - 1; |
839 | #endif | 399 | #endif |
840 | |||
841 | early_init_dt_check_for_initrd(node); | ||
842 | |||
843 | /* Retreive command line */ | ||
844 | p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
845 | if (p != NULL && l > 0) | ||
846 | strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE)); | ||
847 | |||
848 | #ifdef CONFIG_CMDLINE | ||
849 | if (p == NULL || l == 0 || (l == 1 && (*p) == 0)) | ||
850 | strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); | ||
851 | #endif /* CONFIG_CMDLINE */ | ||
852 | |||
853 | DBG("Command line is: %s\n", cmd_line); | ||
854 | |||
855 | /* break now */ | ||
856 | return 1; | ||
857 | } | ||
858 | |||
859 | static int __init early_init_dt_scan_root(unsigned long node, | ||
860 | const char *uname, int depth, void *data) | ||
861 | { | ||
862 | u32 *prop; | ||
863 | |||
864 | if (depth != 0) | ||
865 | return 0; | ||
866 | |||
867 | prop = of_get_flat_dt_prop(node, "#size-cells", NULL); | ||
868 | dt_root_size_cells = (prop == NULL) ? 1 : *prop; | ||
869 | DBG("dt_root_size_cells = %x\n", dt_root_size_cells); | ||
870 | |||
871 | prop = of_get_flat_dt_prop(node, "#address-cells", NULL); | ||
872 | dt_root_addr_cells = (prop == NULL) ? 2 : *prop; | ||
873 | DBG("dt_root_addr_cells = %x\n", dt_root_addr_cells); | ||
874 | |||
875 | /* break now */ | ||
876 | return 1; | ||
877 | } | ||
878 | |||
879 | static u64 __init dt_mem_next_cell(int s, cell_t **cellp) | ||
880 | { | ||
881 | cell_t *p = *cellp; | ||
882 | |||
883 | *cellp = p + s; | ||
884 | return of_read_number(p, s); | ||
885 | } | 400 | } |
886 | 401 | ||
887 | #ifdef CONFIG_PPC_PSERIES | 402 | #ifdef CONFIG_PPC_PSERIES |
@@ -893,22 +408,22 @@ static u64 __init dt_mem_next_cell(int s, cell_t **cellp) | |||
893 | */ | 408 | */ |
894 | static int __init early_init_dt_scan_drconf_memory(unsigned long node) | 409 | static int __init early_init_dt_scan_drconf_memory(unsigned long node) |
895 | { | 410 | { |
896 | cell_t *dm, *ls, *usm; | 411 | __be32 *dm, *ls, *usm; |
897 | unsigned long l, n, flags; | 412 | unsigned long l, n, flags; |
898 | u64 base, size, lmb_size; | 413 | u64 base, size, lmb_size; |
899 | unsigned int is_kexec_kdump = 0, rngs; | 414 | unsigned int is_kexec_kdump = 0, rngs; |
900 | 415 | ||
901 | ls = of_get_flat_dt_prop(node, "ibm,lmb-size", &l); | 416 | ls = of_get_flat_dt_prop(node, "ibm,lmb-size", &l); |
902 | if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t)) | 417 | if (ls == NULL || l < dt_root_size_cells * sizeof(__be32)) |
903 | return 0; | 418 | return 0; |
904 | lmb_size = dt_mem_next_cell(dt_root_size_cells, &ls); | 419 | lmb_size = dt_mem_next_cell(dt_root_size_cells, &ls); |
905 | 420 | ||
906 | dm = of_get_flat_dt_prop(node, "ibm,dynamic-memory", &l); | 421 | dm = of_get_flat_dt_prop(node, "ibm,dynamic-memory", &l); |
907 | if (dm == NULL || l < sizeof(cell_t)) | 422 | if (dm == NULL || l < sizeof(__be32)) |
908 | return 0; | 423 | return 0; |
909 | 424 | ||
910 | n = *dm++; /* number of entries */ | 425 | n = *dm++; /* number of entries */ |
911 | if (l < (n * (dt_root_addr_cells + 4) + 1) * sizeof(cell_t)) | 426 | if (l < (n * (dt_root_addr_cells + 4) + 1) * sizeof(__be32)) |
912 | return 0; | 427 | return 0; |
913 | 428 | ||
914 | /* check if this is a kexec/kdump kernel. */ | 429 | /* check if this is a kexec/kdump kernel. */ |
@@ -963,65 +478,47 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node) | |||
963 | #define early_init_dt_scan_drconf_memory(node) 0 | 478 | #define early_init_dt_scan_drconf_memory(node) 0 |
964 | #endif /* CONFIG_PPC_PSERIES */ | 479 | #endif /* CONFIG_PPC_PSERIES */ |
965 | 480 | ||
966 | static int __init early_init_dt_scan_memory(unsigned long node, | 481 | static int __init early_init_dt_scan_memory_ppc(unsigned long node, |
967 | const char *uname, int depth, void *data) | 482 | const char *uname, |
483 | int depth, void *data) | ||
968 | { | 484 | { |
969 | char *type = of_get_flat_dt_prop(node, "device_type", NULL); | ||
970 | cell_t *reg, *endp; | ||
971 | unsigned long l; | ||
972 | |||
973 | /* Look for the ibm,dynamic-reconfiguration-memory node */ | ||
974 | if (depth == 1 && | 485 | if (depth == 1 && |
975 | strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) | 486 | strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) |
976 | return early_init_dt_scan_drconf_memory(node); | 487 | return early_init_dt_scan_drconf_memory(node); |
488 | |||
489 | return early_init_dt_scan_memory(node, uname, depth, data); | ||
490 | } | ||
977 | 491 | ||
978 | /* We are scanning "memory" nodes only */ | 492 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) |
979 | if (type == NULL) { | 493 | { |
980 | /* | 494 | #if defined(CONFIG_PPC64) |
981 | * The longtrail doesn't have a device_type on the | 495 | if (iommu_is_off) { |
982 | * /memory node, so look for the node called /memory@0. | 496 | if (base >= 0x80000000ul) |
983 | */ | 497 | return; |
984 | if (depth != 1 || strcmp(uname, "memory@0") != 0) | 498 | if ((base + size) > 0x80000000ul) |
985 | return 0; | 499 | size = 0x80000000ul - base; |
986 | } else if (strcmp(type, "memory") != 0) | 500 | } |
987 | return 0; | 501 | #endif |
988 | |||
989 | reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); | ||
990 | if (reg == NULL) | ||
991 | reg = of_get_flat_dt_prop(node, "reg", &l); | ||
992 | if (reg == NULL) | ||
993 | return 0; | ||
994 | |||
995 | endp = reg + (l / sizeof(cell_t)); | ||
996 | |||
997 | DBG("memory scan node %s, reg size %ld, data: %x %x %x %x,\n", | ||
998 | uname, l, reg[0], reg[1], reg[2], reg[3]); | ||
999 | |||
1000 | while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { | ||
1001 | u64 base, size; | ||
1002 | 502 | ||
1003 | base = dt_mem_next_cell(dt_root_addr_cells, ®); | 503 | lmb_add(base, size); |
1004 | size = dt_mem_next_cell(dt_root_size_cells, ®); | ||
1005 | 504 | ||
1006 | if (size == 0) | 505 | memstart_addr = min((u64)memstart_addr, base); |
1007 | continue; | 506 | } |
1008 | DBG(" - %llx , %llx\n", (unsigned long long)base, | ||
1009 | (unsigned long long)size); | ||
1010 | #ifdef CONFIG_PPC64 | ||
1011 | if (iommu_is_off) { | ||
1012 | if (base >= 0x80000000ul) | ||
1013 | continue; | ||
1014 | if ((base + size) > 0x80000000ul) | ||
1015 | size = 0x80000000ul - base; | ||
1016 | } | ||
1017 | #endif | ||
1018 | lmb_add(base, size); | ||
1019 | 507 | ||
1020 | memstart_addr = min((u64)memstart_addr, base); | 508 | u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align) |
1021 | } | 509 | { |
510 | return lmb_alloc(size, align); | ||
511 | } | ||
1022 | 512 | ||
1023 | return 0; | 513 | #ifdef CONFIG_BLK_DEV_INITRD |
514 | void __init early_init_dt_setup_initrd_arch(unsigned long start, | ||
515 | unsigned long end) | ||
516 | { | ||
517 | initrd_start = (unsigned long)__va(start); | ||
518 | initrd_end = (unsigned long)__va(end); | ||
519 | initrd_below_start_ok = 1; | ||
1024 | } | 520 | } |
521 | #endif | ||
1025 | 522 | ||
1026 | static void __init early_reserve_mem(void) | 523 | static void __init early_reserve_mem(void) |
1027 | { | 524 | { |
@@ -1186,7 +683,7 @@ void __init early_init_devtree(void *params) | |||
1186 | /* Scan memory nodes and rebuild LMBs */ | 683 | /* Scan memory nodes and rebuild LMBs */ |
1187 | lmb_init(); | 684 | lmb_init(); |
1188 | of_scan_flat_dt(early_init_dt_scan_root, NULL); | 685 | of_scan_flat_dt(early_init_dt_scan_root, NULL); |
1189 | of_scan_flat_dt(early_init_dt_scan_memory, NULL); | 686 | of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); |
1190 | 687 | ||
1191 | /* Save command line for /proc/cmdline and then parse parameters */ | 688 | /* Save command line for /proc/cmdline and then parse parameters */ |
1192 | strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); | 689 | strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); |
@@ -1234,25 +731,6 @@ void __init early_init_devtree(void *params) | |||
1234 | DBG(" <- early_init_devtree()\n"); | 731 | DBG(" <- early_init_devtree()\n"); |
1235 | } | 732 | } |
1236 | 733 | ||
1237 | |||
1238 | /** | ||
1239 | * Indicates whether the root node has a given value in its | ||
1240 | * compatible property. | ||
1241 | */ | ||
1242 | int machine_is_compatible(const char *compat) | ||
1243 | { | ||
1244 | struct device_node *root; | ||
1245 | int rc = 0; | ||
1246 | |||
1247 | root = of_find_node_by_path("/"); | ||
1248 | if (root) { | ||
1249 | rc = of_device_is_compatible(root, compat); | ||
1250 | of_node_put(root); | ||
1251 | } | ||
1252 | return rc; | ||
1253 | } | ||
1254 | EXPORT_SYMBOL(machine_is_compatible); | ||
1255 | |||
1256 | /******* | 734 | /******* |
1257 | * | 735 | * |
1258 | * New implementation of the OF "find" APIs, return a refcounted | 736 | * New implementation of the OF "find" APIs, return a refcounted |
@@ -1265,27 +743,6 @@ EXPORT_SYMBOL(machine_is_compatible); | |||
1265 | *******/ | 743 | *******/ |
1266 | 744 | ||
1267 | /** | 745 | /** |
1268 | * of_find_node_by_phandle - Find a node given a phandle | ||
1269 | * @handle: phandle of the node to find | ||
1270 | * | ||
1271 | * Returns a node pointer with refcount incremented, use | ||
1272 | * of_node_put() on it when done. | ||
1273 | */ | ||
1274 | struct device_node *of_find_node_by_phandle(phandle handle) | ||
1275 | { | ||
1276 | struct device_node *np; | ||
1277 | |||
1278 | read_lock(&devtree_lock); | ||
1279 | for (np = allnodes; np != 0; np = np->allnext) | ||
1280 | if (np->linux_phandle == handle) | ||
1281 | break; | ||
1282 | of_node_get(np); | ||
1283 | read_unlock(&devtree_lock); | ||
1284 | return np; | ||
1285 | } | ||
1286 | EXPORT_SYMBOL(of_find_node_by_phandle); | ||
1287 | |||
1288 | /** | ||
1289 | * of_find_next_cache_node - Find a node's subsidiary cache | 746 | * of_find_next_cache_node - Find a node's subsidiary cache |
1290 | * @np: node of type "cpu" or "cache" | 747 | * @np: node of type "cpu" or "cache" |
1291 | * | 748 | * |
@@ -1316,138 +773,6 @@ struct device_node *of_find_next_cache_node(struct device_node *np) | |||
1316 | return NULL; | 773 | return NULL; |
1317 | } | 774 | } |
1318 | 775 | ||
1319 | /** | ||
1320 | * of_node_get - Increment refcount of a node | ||
1321 | * @node: Node to inc refcount, NULL is supported to | ||
1322 | * simplify writing of callers | ||
1323 | * | ||
1324 | * Returns node. | ||
1325 | */ | ||
1326 | struct device_node *of_node_get(struct device_node *node) | ||
1327 | { | ||
1328 | if (node) | ||
1329 | kref_get(&node->kref); | ||
1330 | return node; | ||
1331 | } | ||
1332 | EXPORT_SYMBOL(of_node_get); | ||
1333 | |||
1334 | static inline struct device_node * kref_to_device_node(struct kref *kref) | ||
1335 | { | ||
1336 | return container_of(kref, struct device_node, kref); | ||
1337 | } | ||
1338 | |||
1339 | /** | ||
1340 | * of_node_release - release a dynamically allocated node | ||
1341 | * @kref: kref element of the node to be released | ||
1342 | * | ||
1343 | * In of_node_put() this function is passed to kref_put() | ||
1344 | * as the destructor. | ||
1345 | */ | ||
1346 | static void of_node_release(struct kref *kref) | ||
1347 | { | ||
1348 | struct device_node *node = kref_to_device_node(kref); | ||
1349 | struct property *prop = node->properties; | ||
1350 | |||
1351 | /* We should never be releasing nodes that haven't been detached. */ | ||
1352 | if (!of_node_check_flag(node, OF_DETACHED)) { | ||
1353 | printk("WARNING: Bad of_node_put() on %s\n", node->full_name); | ||
1354 | dump_stack(); | ||
1355 | kref_init(&node->kref); | ||
1356 | return; | ||
1357 | } | ||
1358 | |||
1359 | if (!of_node_check_flag(node, OF_DYNAMIC)) | ||
1360 | return; | ||
1361 | |||
1362 | while (prop) { | ||
1363 | struct property *next = prop->next; | ||
1364 | kfree(prop->name); | ||
1365 | kfree(prop->value); | ||
1366 | kfree(prop); | ||
1367 | prop = next; | ||
1368 | |||
1369 | if (!prop) { | ||
1370 | prop = node->deadprops; | ||
1371 | node->deadprops = NULL; | ||
1372 | } | ||
1373 | } | ||
1374 | kfree(node->full_name); | ||
1375 | kfree(node->data); | ||
1376 | kfree(node); | ||
1377 | } | ||
1378 | |||
1379 | /** | ||
1380 | * of_node_put - Decrement refcount of a node | ||
1381 | * @node: Node to dec refcount, NULL is supported to | ||
1382 | * simplify writing of callers | ||
1383 | * | ||
1384 | */ | ||
1385 | void of_node_put(struct device_node *node) | ||
1386 | { | ||
1387 | if (node) | ||
1388 | kref_put(&node->kref, of_node_release); | ||
1389 | } | ||
1390 | EXPORT_SYMBOL(of_node_put); | ||
1391 | |||
1392 | /* | ||
1393 | * Plug a device node into the tree and global list. | ||
1394 | */ | ||
1395 | void of_attach_node(struct device_node *np) | ||
1396 | { | ||
1397 | unsigned long flags; | ||
1398 | |||
1399 | write_lock_irqsave(&devtree_lock, flags); | ||
1400 | np->sibling = np->parent->child; | ||
1401 | np->allnext = allnodes; | ||
1402 | np->parent->child = np; | ||
1403 | allnodes = np; | ||
1404 | write_unlock_irqrestore(&devtree_lock, flags); | ||
1405 | } | ||
1406 | |||
1407 | /* | ||
1408 | * "Unplug" a node from the device tree. The caller must hold | ||
1409 | * a reference to the node. The memory associated with the node | ||
1410 | * is not freed until its refcount goes to zero. | ||
1411 | */ | ||
1412 | void of_detach_node(struct device_node *np) | ||
1413 | { | ||
1414 | struct device_node *parent; | ||
1415 | unsigned long flags; | ||
1416 | |||
1417 | write_lock_irqsave(&devtree_lock, flags); | ||
1418 | |||
1419 | parent = np->parent; | ||
1420 | if (!parent) | ||
1421 | goto out_unlock; | ||
1422 | |||
1423 | if (allnodes == np) | ||
1424 | allnodes = np->allnext; | ||
1425 | else { | ||
1426 | struct device_node *prev; | ||
1427 | for (prev = allnodes; | ||
1428 | prev->allnext != np; | ||
1429 | prev = prev->allnext) | ||
1430 | ; | ||
1431 | prev->allnext = np->allnext; | ||
1432 | } | ||
1433 | |||
1434 | if (parent->child == np) | ||
1435 | parent->child = np->sibling; | ||
1436 | else { | ||
1437 | struct device_node *prevsib; | ||
1438 | for (prevsib = np->parent->child; | ||
1439 | prevsib->sibling != np; | ||
1440 | prevsib = prevsib->sibling) | ||
1441 | ; | ||
1442 | prevsib->sibling = np->sibling; | ||
1443 | } | ||
1444 | |||
1445 | of_node_set_flag(np, OF_DETACHED); | ||
1446 | |||
1447 | out_unlock: | ||
1448 | write_unlock_irqrestore(&devtree_lock, flags); | ||
1449 | } | ||
1450 | |||
1451 | #ifdef CONFIG_PPC_PSERIES | 776 | #ifdef CONFIG_PPC_PSERIES |
1452 | /* | 777 | /* |
1453 | * Fix up the uninitialized fields in a new device node: | 778 | * Fix up the uninitialized fields in a new device node: |
@@ -1479,9 +804,9 @@ static int of_finish_dynamic_node(struct device_node *node) | |||
1479 | if (machine_is(powermac)) | 804 | if (machine_is(powermac)) |
1480 | return -ENODEV; | 805 | return -ENODEV; |
1481 | 806 | ||
1482 | /* fix up new node's linux_phandle field */ | 807 | /* fix up new node's phandle field */ |
1483 | if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL))) | 808 | if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL))) |
1484 | node->linux_phandle = *ibm_phandle; | 809 | node->phandle = *ibm_phandle; |
1485 | 810 | ||
1486 | out: | 811 | out: |
1487 | of_node_put(parent); | 812 | of_node_put(parent); |
@@ -1520,120 +845,6 @@ static int __init prom_reconfig_setup(void) | |||
1520 | __initcall(prom_reconfig_setup); | 845 | __initcall(prom_reconfig_setup); |
1521 | #endif | 846 | #endif |
1522 | 847 | ||
1523 | /* | ||
1524 | * Add a property to a node | ||
1525 | */ | ||
1526 | int prom_add_property(struct device_node* np, struct property* prop) | ||
1527 | { | ||
1528 | struct property **next; | ||
1529 | unsigned long flags; | ||
1530 | |||
1531 | prop->next = NULL; | ||
1532 | write_lock_irqsave(&devtree_lock, flags); | ||
1533 | next = &np->properties; | ||
1534 | while (*next) { | ||
1535 | if (strcmp(prop->name, (*next)->name) == 0) { | ||
1536 | /* duplicate ! don't insert it */ | ||
1537 | write_unlock_irqrestore(&devtree_lock, flags); | ||
1538 | return -1; | ||
1539 | } | ||
1540 | next = &(*next)->next; | ||
1541 | } | ||
1542 | *next = prop; | ||
1543 | write_unlock_irqrestore(&devtree_lock, flags); | ||
1544 | |||
1545 | #ifdef CONFIG_PROC_DEVICETREE | ||
1546 | /* try to add to proc as well if it was initialized */ | ||
1547 | if (np->pde) | ||
1548 | proc_device_tree_add_prop(np->pde, prop); | ||
1549 | #endif /* CONFIG_PROC_DEVICETREE */ | ||
1550 | |||
1551 | return 0; | ||
1552 | } | ||
1553 | |||
1554 | /* | ||
1555 | * Remove a property from a node. Note that we don't actually | ||
1556 | * remove it, since we have given out who-knows-how-many pointers | ||
1557 | * to the data using get-property. Instead we just move the property | ||
1558 | * to the "dead properties" list, so it won't be found any more. | ||
1559 | */ | ||
1560 | int prom_remove_property(struct device_node *np, struct property *prop) | ||
1561 | { | ||
1562 | struct property **next; | ||
1563 | unsigned long flags; | ||
1564 | int found = 0; | ||
1565 | |||
1566 | write_lock_irqsave(&devtree_lock, flags); | ||
1567 | next = &np->properties; | ||
1568 | while (*next) { | ||
1569 | if (*next == prop) { | ||
1570 | /* found the node */ | ||
1571 | *next = prop->next; | ||
1572 | prop->next = np->deadprops; | ||
1573 | np->deadprops = prop; | ||
1574 | found = 1; | ||
1575 | break; | ||
1576 | } | ||
1577 | next = &(*next)->next; | ||
1578 | } | ||
1579 | write_unlock_irqrestore(&devtree_lock, flags); | ||
1580 | |||
1581 | if (!found) | ||
1582 | return -ENODEV; | ||
1583 | |||
1584 | #ifdef CONFIG_PROC_DEVICETREE | ||
1585 | /* try to remove the proc node as well */ | ||
1586 | if (np->pde) | ||
1587 | proc_device_tree_remove_prop(np->pde, prop); | ||
1588 | #endif /* CONFIG_PROC_DEVICETREE */ | ||
1589 | |||
1590 | return 0; | ||
1591 | } | ||
1592 | |||
1593 | /* | ||
1594 | * Update a property in a node. Note that we don't actually | ||
1595 | * remove it, since we have given out who-knows-how-many pointers | ||
1596 | * to the data using get-property. Instead we just move the property | ||
1597 | * to the "dead properties" list, and add the new property to the | ||
1598 | * property list | ||
1599 | */ | ||
1600 | int prom_update_property(struct device_node *np, | ||
1601 | struct property *newprop, | ||
1602 | struct property *oldprop) | ||
1603 | { | ||
1604 | struct property **next; | ||
1605 | unsigned long flags; | ||
1606 | int found = 0; | ||
1607 | |||
1608 | write_lock_irqsave(&devtree_lock, flags); | ||
1609 | next = &np->properties; | ||
1610 | while (*next) { | ||
1611 | if (*next == oldprop) { | ||
1612 | /* found the node */ | ||
1613 | newprop->next = oldprop->next; | ||
1614 | *next = newprop; | ||
1615 | oldprop->next = np->deadprops; | ||
1616 | np->deadprops = oldprop; | ||
1617 | found = 1; | ||
1618 | break; | ||
1619 | } | ||
1620 | next = &(*next)->next; | ||
1621 | } | ||
1622 | write_unlock_irqrestore(&devtree_lock, flags); | ||
1623 | |||
1624 | if (!found) | ||
1625 | return -ENODEV; | ||
1626 | |||
1627 | #ifdef CONFIG_PROC_DEVICETREE | ||
1628 | /* try to add to proc as well if it was initialized */ | ||
1629 | if (np->pde) | ||
1630 | proc_device_tree_update_prop(np->pde, newprop, oldprop); | ||
1631 | #endif /* CONFIG_PROC_DEVICETREE */ | ||
1632 | |||
1633 | return 0; | ||
1634 | } | ||
1635 | |||
1636 | |||
1637 | /* Find the device node for a given logical cpu number, also returns the cpu | 848 | /* Find the device node for a given logical cpu number, also returns the cpu |
1638 | * local thread number (index in ibm,interrupt-server#s) if relevant and | 849 | * local thread number (index in ibm,interrupt-server#s) if relevant and |
1639 | * asked for (non NULL) | 850 | * asked for (non NULL) |
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c index 1b426050a2f9..0125604d096e 100644 --- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c +++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c | |||
@@ -80,8 +80,8 @@ static void xes_mpc85xx_configure_l2(void __iomem *l2_base) | |||
80 | printk(KERN_INFO "xes_mpc85xx: Enabling L2 as cache\n"); | 80 | printk(KERN_INFO "xes_mpc85xx: Enabling L2 as cache\n"); |
81 | 81 | ||
82 | ctl = MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2I; | 82 | ctl = MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2I; |
83 | if (machine_is_compatible("MPC8540") || | 83 | if (of_machine_is_compatible("MPC8540") || |
84 | machine_is_compatible("MPC8560")) | 84 | of_machine_is_compatible("MPC8560")) |
85 | /* | 85 | /* |
86 | * Assume L2 SRAM is used fully for cache, so set | 86 | * Assume L2 SRAM is used fully for cache, so set |
87 | * L2BLKSZ (bits 4:5) to match L2SIZ (bits 2:3). | 87 | * L2BLKSZ (bits 4:5) to match L2SIZ (bits 2:3). |
diff --git a/arch/powerpc/platforms/cell/cbe_powerbutton.c b/arch/powerpc/platforms/cell/cbe_powerbutton.c index dcddaa5fcb66..f75a4daa4ca2 100644 --- a/arch/powerpc/platforms/cell/cbe_powerbutton.c +++ b/arch/powerpc/platforms/cell/cbe_powerbutton.c | |||
@@ -48,7 +48,7 @@ static int __init cbe_powerbutton_init(void) | |||
48 | int ret = 0; | 48 | int ret = 0; |
49 | struct input_dev *dev; | 49 | struct input_dev *dev; |
50 | 50 | ||
51 | if (!machine_is_compatible("IBM,CBPLUS-1.0")) { | 51 | if (!of_machine_is_compatible("IBM,CBPLUS-1.0")) { |
52 | printk(KERN_ERR "%s: Not a cell blade.\n", __func__); | 52 | printk(KERN_ERR "%s: Not a cell blade.\n", __func__); |
53 | ret = -ENODEV; | 53 | ret = -ENODEV; |
54 | goto out; | 54 | goto out; |
diff --git a/arch/powerpc/platforms/cell/ras.c b/arch/powerpc/platforms/cell/ras.c index 5e0a191764fc..608fd2b584c9 100644 --- a/arch/powerpc/platforms/cell/ras.c +++ b/arch/powerpc/platforms/cell/ras.c | |||
@@ -255,7 +255,7 @@ static int __init cbe_sysreset_init(void) | |||
255 | { | 255 | { |
256 | struct cbe_pmd_regs __iomem *regs; | 256 | struct cbe_pmd_regs __iomem *regs; |
257 | 257 | ||
258 | sysreset_hack = machine_is_compatible("IBM,CBPLUS-1.0"); | 258 | sysreset_hack = of_machine_is_compatible("IBM,CBPLUS-1.0"); |
259 | if (!sysreset_hack) | 259 | if (!sysreset_hack) |
260 | return 0; | 260 | return 0; |
261 | 261 | ||
diff --git a/arch/powerpc/platforms/cell/spu_manage.c b/arch/powerpc/platforms/cell/spu_manage.c index 4c506c1463cd..891f18e337a2 100644 --- a/arch/powerpc/platforms/cell/spu_manage.c +++ b/arch/powerpc/platforms/cell/spu_manage.c | |||
@@ -457,7 +457,7 @@ neighbour_spu(int cbe, struct device_node *target, struct device_node *avoid) | |||
457 | continue; | 457 | continue; |
458 | vic_handles = of_get_property(spu_dn, "vicinity", &lenp); | 458 | vic_handles = of_get_property(spu_dn, "vicinity", &lenp); |
459 | for (i=0; i < (lenp / sizeof(phandle)); i++) { | 459 | for (i=0; i < (lenp / sizeof(phandle)); i++) { |
460 | if (vic_handles[i] == target->linux_phandle) | 460 | if (vic_handles[i] == target->phandle) |
461 | return spu; | 461 | return spu; |
462 | } | 462 | } |
463 | } | 463 | } |
@@ -499,7 +499,7 @@ static void init_affinity_node(int cbe) | |||
499 | 499 | ||
500 | if (strcmp(name, "spe") == 0) { | 500 | if (strcmp(name, "spe") == 0) { |
501 | spu = devnode_spu(cbe, vic_dn); | 501 | spu = devnode_spu(cbe, vic_dn); |
502 | avoid_ph = last_spu_dn->linux_phandle; | 502 | avoid_ph = last_spu_dn->phandle; |
503 | } else { | 503 | } else { |
504 | /* | 504 | /* |
505 | * "mic-tm" and "bif0" nodes do not have | 505 | * "mic-tm" and "bif0" nodes do not have |
@@ -514,7 +514,7 @@ static void init_affinity_node(int cbe) | |||
514 | last_spu->has_mem_affinity = 1; | 514 | last_spu->has_mem_affinity = 1; |
515 | spu->has_mem_affinity = 1; | 515 | spu->has_mem_affinity = 1; |
516 | } | 516 | } |
517 | avoid_ph = vic_dn->linux_phandle; | 517 | avoid_ph = vic_dn->phandle; |
518 | } | 518 | } |
519 | 519 | ||
520 | list_add_tail(&spu->aff_list, &last_spu->aff_list); | 520 | list_add_tail(&spu->aff_list, &last_spu->aff_list); |
diff --git a/arch/powerpc/platforms/pasemi/cpufreq.c b/arch/powerpc/platforms/pasemi/cpufreq.c index be2527a516ea..d35e0520abf0 100644 --- a/arch/powerpc/platforms/pasemi/cpufreq.c +++ b/arch/powerpc/platforms/pasemi/cpufreq.c | |||
@@ -304,8 +304,8 @@ static struct cpufreq_driver pas_cpufreq_driver = { | |||
304 | 304 | ||
305 | static int __init pas_cpufreq_init(void) | 305 | static int __init pas_cpufreq_init(void) |
306 | { | 306 | { |
307 | if (!machine_is_compatible("PA6T-1682M") && | 307 | if (!of_machine_is_compatible("PA6T-1682M") && |
308 | !machine_is_compatible("pasemi,pwrficient")) | 308 | !of_machine_is_compatible("pasemi,pwrficient")) |
309 | return -ENODEV; | 309 | return -ENODEV; |
310 | 310 | ||
311 | return cpufreq_register_driver(&pas_cpufreq_driver); | 311 | return cpufreq_register_driver(&pas_cpufreq_driver); |
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/arch/powerpc/platforms/powermac/cpufreq_32.c index 08d94e4cedd3..d4f127d18141 100644 --- a/arch/powerpc/platforms/powermac/cpufreq_32.c +++ b/arch/powerpc/platforms/powermac/cpufreq_32.c | |||
@@ -657,31 +657,31 @@ static int __init pmac_cpufreq_setup(void) | |||
657 | cur_freq = (*value) / 1000; | 657 | cur_freq = (*value) / 1000; |
658 | 658 | ||
659 | /* Check for 7447A based MacRISC3 */ | 659 | /* Check for 7447A based MacRISC3 */ |
660 | if (machine_is_compatible("MacRISC3") && | 660 | if (of_machine_is_compatible("MacRISC3") && |
661 | of_get_property(cpunode, "dynamic-power-step", NULL) && | 661 | of_get_property(cpunode, "dynamic-power-step", NULL) && |
662 | PVR_VER(mfspr(SPRN_PVR)) == 0x8003) { | 662 | PVR_VER(mfspr(SPRN_PVR)) == 0x8003) { |
663 | pmac_cpufreq_init_7447A(cpunode); | 663 | pmac_cpufreq_init_7447A(cpunode); |
664 | /* Check for other MacRISC3 machines */ | 664 | /* Check for other MacRISC3 machines */ |
665 | } else if (machine_is_compatible("PowerBook3,4") || | 665 | } else if (of_machine_is_compatible("PowerBook3,4") || |
666 | machine_is_compatible("PowerBook3,5") || | 666 | of_machine_is_compatible("PowerBook3,5") || |
667 | machine_is_compatible("MacRISC3")) { | 667 | of_machine_is_compatible("MacRISC3")) { |
668 | pmac_cpufreq_init_MacRISC3(cpunode); | 668 | pmac_cpufreq_init_MacRISC3(cpunode); |
669 | /* Else check for iBook2 500/600 */ | 669 | /* Else check for iBook2 500/600 */ |
670 | } else if (machine_is_compatible("PowerBook4,1")) { | 670 | } else if (of_machine_is_compatible("PowerBook4,1")) { |
671 | hi_freq = cur_freq; | 671 | hi_freq = cur_freq; |
672 | low_freq = 400000; | 672 | low_freq = 400000; |
673 | set_speed_proc = pmu_set_cpu_speed; | 673 | set_speed_proc = pmu_set_cpu_speed; |
674 | is_pmu_based = 1; | 674 | is_pmu_based = 1; |
675 | } | 675 | } |
676 | /* Else check for TiPb 550 */ | 676 | /* Else check for TiPb 550 */ |
677 | else if (machine_is_compatible("PowerBook3,3") && cur_freq == 550000) { | 677 | else if (of_machine_is_compatible("PowerBook3,3") && cur_freq == 550000) { |
678 | hi_freq = cur_freq; | 678 | hi_freq = cur_freq; |
679 | low_freq = 500000; | 679 | low_freq = 500000; |
680 | set_speed_proc = pmu_set_cpu_speed; | 680 | set_speed_proc = pmu_set_cpu_speed; |
681 | is_pmu_based = 1; | 681 | is_pmu_based = 1; |
682 | } | 682 | } |
683 | /* Else check for TiPb 400 & 500 */ | 683 | /* Else check for TiPb 400 & 500 */ |
684 | else if (machine_is_compatible("PowerBook3,2")) { | 684 | else if (of_machine_is_compatible("PowerBook3,2")) { |
685 | /* We only know about the 400 MHz and the 500Mhz model | 685 | /* We only know about the 400 MHz and the 500Mhz model |
686 | * they both have 300 MHz as low frequency | 686 | * they both have 300 MHz as low frequency |
687 | */ | 687 | */ |
diff --git a/arch/powerpc/platforms/powermac/cpufreq_64.c b/arch/powerpc/platforms/powermac/cpufreq_64.c index 708c75133377..3ed288e68ec4 100644 --- a/arch/powerpc/platforms/powermac/cpufreq_64.c +++ b/arch/powerpc/platforms/powermac/cpufreq_64.c | |||
@@ -398,11 +398,11 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus) | |||
398 | int rc = -ENODEV; | 398 | int rc = -ENODEV; |
399 | 399 | ||
400 | /* Check supported platforms */ | 400 | /* Check supported platforms */ |
401 | if (machine_is_compatible("PowerMac8,1") || | 401 | if (of_machine_is_compatible("PowerMac8,1") || |
402 | machine_is_compatible("PowerMac8,2") || | 402 | of_machine_is_compatible("PowerMac8,2") || |
403 | machine_is_compatible("PowerMac9,1")) | 403 | of_machine_is_compatible("PowerMac9,1")) |
404 | use_volts_smu = 1; | 404 | use_volts_smu = 1; |
405 | else if (machine_is_compatible("PowerMac11,2")) | 405 | else if (of_machine_is_compatible("PowerMac11,2")) |
406 | use_volts_vdnap = 1; | 406 | use_volts_vdnap = 1; |
407 | else | 407 | else |
408 | return -ENODEV; | 408 | return -ENODEV; |
@@ -729,9 +729,9 @@ static int __init g5_cpufreq_init(void) | |||
729 | return -ENODEV; | 729 | return -ENODEV; |
730 | } | 730 | } |
731 | 731 | ||
732 | if (machine_is_compatible("PowerMac7,2") || | 732 | if (of_machine_is_compatible("PowerMac7,2") || |
733 | machine_is_compatible("PowerMac7,3") || | 733 | of_machine_is_compatible("PowerMac7,3") || |
734 | machine_is_compatible("RackMac3,1")) | 734 | of_machine_is_compatible("RackMac3,1")) |
735 | rc = g5_pm72_cpufreq_init(cpus); | 735 | rc = g5_pm72_cpufreq_init(cpus); |
736 | #ifdef CONFIG_PMAC_SMU | 736 | #ifdef CONFIG_PMAC_SMU |
737 | else | 737 | else |
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c index fbc9bbd74dbd..33e815f4466c 100644 --- a/arch/powerpc/platforms/powermac/feature.c +++ b/arch/powerpc/platforms/powermac/feature.c | |||
@@ -2426,7 +2426,7 @@ static int __init probe_motherboard(void) | |||
2426 | } | 2426 | } |
2427 | } | 2427 | } |
2428 | for(i=0; i<ARRAY_SIZE(pmac_mb_defs); i++) { | 2428 | for(i=0; i<ARRAY_SIZE(pmac_mb_defs); i++) { |
2429 | if (machine_is_compatible(pmac_mb_defs[i].model_string)) { | 2429 | if (of_machine_is_compatible(pmac_mb_defs[i].model_string)) { |
2430 | pmac_mb = pmac_mb_defs[i]; | 2430 | pmac_mb = pmac_mb_defs[i]; |
2431 | goto found; | 2431 | goto found; |
2432 | } | 2432 | } |
diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c b/arch/powerpc/platforms/powermac/pfunc_core.c index 96d5ce50364e..ede49e78a8da 100644 --- a/arch/powerpc/platforms/powermac/pfunc_core.c +++ b/arch/powerpc/platforms/powermac/pfunc_core.c | |||
@@ -842,7 +842,7 @@ struct pmf_function *__pmf_find_function(struct device_node *target, | |||
842 | list_for_each_entry(func, &dev->functions, link) { | 842 | list_for_each_entry(func, &dev->functions, link) { |
843 | if (name && strcmp(name, func->name)) | 843 | if (name && strcmp(name, func->name)) |
844 | continue; | 844 | continue; |
845 | if (func->phandle && target->node != func->phandle) | 845 | if (func->phandle && target->phandle != func->phandle) |
846 | continue; | 846 | continue; |
847 | if ((func->flags & flags) == 0) | 847 | if ((func->flags & flags) == 0) |
848 | continue; | 848 | continue; |
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c index b40c22d697f0..6898e8241cd0 100644 --- a/arch/powerpc/platforms/powermac/smp.c +++ b/arch/powerpc/platforms/powermac/smp.c | |||
@@ -693,9 +693,9 @@ static void __init smp_core99_setup(int ncpus) | |||
693 | #ifdef CONFIG_PPC64 | 693 | #ifdef CONFIG_PPC64 |
694 | 694 | ||
695 | /* i2c based HW sync on some G5s */ | 695 | /* i2c based HW sync on some G5s */ |
696 | if (machine_is_compatible("PowerMac7,2") || | 696 | if (of_machine_is_compatible("PowerMac7,2") || |
697 | machine_is_compatible("PowerMac7,3") || | 697 | of_machine_is_compatible("PowerMac7,3") || |
698 | machine_is_compatible("RackMac3,1")) | 698 | of_machine_is_compatible("RackMac3,1")) |
699 | smp_core99_setup_i2c_hwsync(ncpus); | 699 | smp_core99_setup_i2c_hwsync(ncpus); |
700 | 700 | ||
701 | /* pfunc based HW sync on recent G5s */ | 701 | /* pfunc based HW sync on recent G5s */ |
@@ -713,7 +713,7 @@ static void __init smp_core99_setup(int ncpus) | |||
713 | #else /* CONFIG_PPC64 */ | 713 | #else /* CONFIG_PPC64 */ |
714 | 714 | ||
715 | /* GPIO based HW sync on ppc32 Core99 */ | 715 | /* GPIO based HW sync on ppc32 Core99 */ |
716 | if (pmac_tb_freeze == NULL && !machine_is_compatible("MacRISC4")) { | 716 | if (pmac_tb_freeze == NULL && !of_machine_is_compatible("MacRISC4")) { |
717 | struct device_node *cpu; | 717 | struct device_node *cpu; |
718 | const u32 *tbprop = NULL; | 718 | const u32 *tbprop = NULL; |
719 | 719 | ||
@@ -750,7 +750,7 @@ static void __init smp_core99_setup(int ncpus) | |||
750 | #endif | 750 | #endif |
751 | 751 | ||
752 | /* 32 bits SMP can't NAP */ | 752 | /* 32 bits SMP can't NAP */ |
753 | if (!machine_is_compatible("MacRISC4")) | 753 | if (!of_machine_is_compatible("MacRISC4")) |
754 | powersave_nap = 0; | 754 | powersave_nap = 0; |
755 | } | 755 | } |
756 | 756 | ||
@@ -852,7 +852,7 @@ static void __devinit smp_core99_setup_cpu(int cpu_nr) | |||
852 | /* If we didn't start the second CPU, we must take | 852 | /* If we didn't start the second CPU, we must take |
853 | * it off the bus | 853 | * it off the bus |
854 | */ | 854 | */ |
855 | if (machine_is_compatible("MacRISC4") && | 855 | if (of_machine_is_compatible("MacRISC4") && |
856 | num_online_cpus() < 2) | 856 | num_online_cpus() < 2) |
857 | g5_phy_disable_cpu1(); | 857 | g5_phy_disable_cpu1(); |
858 | #endif /* CONFIG_PPC64 */ | 858 | #endif /* CONFIG_PPC64 */ |
diff --git a/arch/powerpc/platforms/powermac/time.c b/arch/powerpc/platforms/powermac/time.c index 1810e4226e56..48211ca134c3 100644 --- a/arch/powerpc/platforms/powermac/time.c +++ b/arch/powerpc/platforms/powermac/time.c | |||
@@ -317,9 +317,9 @@ void __init pmac_calibrate_decr(void) | |||
317 | * calibration. That's better since the VIA itself seems | 317 | * calibration. That's better since the VIA itself seems |
318 | * to be slightly off. --BenH | 318 | * to be slightly off. --BenH |
319 | */ | 319 | */ |
320 | if (!machine_is_compatible("MacRISC2") && | 320 | if (!of_machine_is_compatible("MacRISC2") && |
321 | !machine_is_compatible("MacRISC3") && | 321 | !of_machine_is_compatible("MacRISC3") && |
322 | !machine_is_compatible("MacRISC4")) | 322 | !of_machine_is_compatible("MacRISC4")) |
323 | if (via_calibrate_decr()) | 323 | if (via_calibrate_decr()) |
324 | return; | 324 | return; |
325 | 325 | ||
@@ -328,7 +328,7 @@ void __init pmac_calibrate_decr(void) | |||
328 | * probably implement calibration based on the KL timer on these | 328 | * probably implement calibration based on the KL timer on these |
329 | * machines anyway... -BenH | 329 | * machines anyway... -BenH |
330 | */ | 330 | */ |
331 | if (machine_is_compatible("PowerMac3,5")) | 331 | if (of_machine_is_compatible("PowerMac3,5")) |
332 | if (via_calibrate_decr()) | 332 | if (via_calibrate_decr()) |
333 | return; | 333 | return; |
334 | #endif | 334 | #endif |
diff --git a/arch/powerpc/platforms/powermac/udbg_scc.c b/arch/powerpc/platforms/powermac/udbg_scc.c index 9490157da62e..d83135a9830e 100644 --- a/arch/powerpc/platforms/powermac/udbg_scc.c +++ b/arch/powerpc/platforms/powermac/udbg_scc.c | |||
@@ -132,9 +132,9 @@ void udbg_scc_init(int force_scc) | |||
132 | scc_inittab[1] = in_8(sccc); | 132 | scc_inittab[1] = in_8(sccc); |
133 | out_8(sccc, 12); | 133 | out_8(sccc, 12); |
134 | scc_inittab[3] = in_8(sccc); | 134 | scc_inittab[3] = in_8(sccc); |
135 | } else if (machine_is_compatible("RackMac1,1") | 135 | } else if (of_machine_is_compatible("RackMac1,1") |
136 | || machine_is_compatible("RackMac1,2") | 136 | || of_machine_is_compatible("RackMac1,2") |
137 | || machine_is_compatible("MacRISC4")) { | 137 | || of_machine_is_compatible("MacRISC4")) { |
138 | /* Xserves and G5s default to 57600 */ | 138 | /* Xserves and G5s default to 57600 */ |
139 | scc_inittab[1] = 0; | 139 | scc_inittab[1] = 0; |
140 | scc_inittab[3] = 0; | 140 | scc_inittab[3] = 0; |
diff --git a/arch/powerpc/sysdev/grackle.c b/arch/powerpc/sysdev/grackle.c index 5da37c2f22ee..cf27df6e508b 100644 --- a/arch/powerpc/sysdev/grackle.c +++ b/arch/powerpc/sysdev/grackle.c | |||
@@ -56,9 +56,9 @@ static inline void grackle_set_loop_snoop(struct pci_controller *bp, int enable) | |||
56 | void __init setup_grackle(struct pci_controller *hose) | 56 | void __init setup_grackle(struct pci_controller *hose) |
57 | { | 57 | { |
58 | setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0); | 58 | setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0); |
59 | if (machine_is_compatible("PowerMac1,1")) | 59 | if (of_machine_is_compatible("PowerMac1,1")) |
60 | ppc_pci_add_flags(PPC_PCI_REASSIGN_ALL_BUS); | 60 | ppc_pci_add_flags(PPC_PCI_REASSIGN_ALL_BUS); |
61 | if (machine_is_compatible("AAPL,PowerBook1998")) | 61 | if (of_machine_is_compatible("AAPL,PowerBook1998")) |
62 | grackle_set_loop_snoop(hose, 1); | 62 | grackle_set_loop_snoop(hose, 1); |
63 | #if 0 /* Disabled for now, HW problems ??? */ | 63 | #if 0 /* Disabled for now, HW problems ??? */ |
64 | grackle_set_stg(hose, 1); | 64 | grackle_set_stg(hose, 1); |
diff --git a/arch/sparc/kernel/devices.c b/arch/sparc/kernel/devices.c index b171ae8de90d..b062de9424a4 100644 --- a/arch/sparc/kernel/devices.c +++ b/arch/sparc/kernel/devices.c | |||
@@ -59,7 +59,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg, | |||
59 | 59 | ||
60 | cur_inst = 0; | 60 | cur_inst = 0; |
61 | for_each_node_by_type(dp, "cpu") { | 61 | for_each_node_by_type(dp, "cpu") { |
62 | int err = check_cpu_node(dp->node, &cur_inst, | 62 | int err = check_cpu_node(dp->phandle, &cur_inst, |
63 | compare, compare_arg, | 63 | compare, compare_arg, |
64 | prom_node, mid); | 64 | prom_node, mid); |
65 | if (!err) { | 65 | if (!err) { |
diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c index 53a58b349849..da527b33ebc7 100644 --- a/arch/sparc/kernel/of_device_32.c +++ b/arch/sparc/kernel/of_device_32.c | |||
@@ -433,7 +433,7 @@ build_resources: | |||
433 | if (!parent) | 433 | if (!parent) |
434 | dev_set_name(&op->dev, "root"); | 434 | dev_set_name(&op->dev, "root"); |
435 | else | 435 | else |
436 | dev_set_name(&op->dev, "%08x", dp->node); | 436 | dev_set_name(&op->dev, "%08x", dp->phandle); |
437 | 437 | ||
438 | if (of_device_register(op)) { | 438 | if (of_device_register(op)) { |
439 | printk("%s: Could not register of device.\n", | 439 | printk("%s: Could not register of device.\n", |
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c index 0a6f2d1798d1..b3d4cb5d21b3 100644 --- a/arch/sparc/kernel/of_device_64.c +++ b/arch/sparc/kernel/of_device_64.c | |||
@@ -676,7 +676,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp, | |||
676 | if (!parent) | 676 | if (!parent) |
677 | dev_set_name(&op->dev, "root"); | 677 | dev_set_name(&op->dev, "root"); |
678 | else | 678 | else |
679 | dev_set_name(&op->dev, "%08x", dp->node); | 679 | dev_set_name(&op->dev, "%08x", dp->phandle); |
680 | 680 | ||
681 | if (of_device_register(op)) { | 681 | if (of_device_register(op)) { |
682 | printk("%s: Could not register of device.\n", | 682 | printk("%s: Could not register of device.\n", |
diff --git a/arch/sparc/kernel/prom.h b/arch/sparc/kernel/prom.h index 453397fe5e14..a8591ef2636d 100644 --- a/arch/sparc/kernel/prom.h +++ b/arch/sparc/kernel/prom.h | |||
@@ -4,9 +4,6 @@ | |||
4 | #include <linux/spinlock.h> | 4 | #include <linux/spinlock.h> |
5 | #include <asm/prom.h> | 5 | #include <asm/prom.h> |
6 | 6 | ||
7 | extern struct device_node *allnodes; /* temporary while merging */ | ||
8 | extern rwlock_t devtree_lock; /* temporary while merging */ | ||
9 | |||
10 | extern void * prom_early_alloc(unsigned long size); | 7 | extern void * prom_early_alloc(unsigned long size); |
11 | extern void irq_trans_init(struct device_node *dp); | 8 | extern void irq_trans_init(struct device_node *dp); |
12 | 9 | ||
diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c index d80a65d9e893..57ac9e28be0c 100644 --- a/arch/sparc/kernel/prom_common.c +++ b/arch/sparc/kernel/prom_common.c | |||
@@ -37,18 +37,6 @@ EXPORT_SYMBOL(of_console_path); | |||
37 | char *of_console_options; | 37 | char *of_console_options; |
38 | EXPORT_SYMBOL(of_console_options); | 38 | EXPORT_SYMBOL(of_console_options); |
39 | 39 | ||
40 | struct device_node *of_find_node_by_phandle(phandle handle) | ||
41 | { | ||
42 | struct device_node *np; | ||
43 | |||
44 | for (np = allnodes; np; np = np->allnext) | ||
45 | if (np->node == handle) | ||
46 | break; | ||
47 | |||
48 | return np; | ||
49 | } | ||
50 | EXPORT_SYMBOL(of_find_node_by_phandle); | ||
51 | |||
52 | int of_getintprop_default(struct device_node *np, const char *name, int def) | 40 | int of_getintprop_default(struct device_node *np, const char *name, int def) |
53 | { | 41 | { |
54 | struct property *prop; | 42 | struct property *prop; |
@@ -89,7 +77,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len | |||
89 | void *old_val = prop->value; | 77 | void *old_val = prop->value; |
90 | int ret; | 78 | int ret; |
91 | 79 | ||
92 | ret = prom_setprop(dp->node, name, val, len); | 80 | ret = prom_setprop(dp->phandle, name, val, len); |
93 | 81 | ||
94 | err = -EINVAL; | 82 | err = -EINVAL; |
95 | if (ret >= 0) { | 83 | if (ret >= 0) { |
@@ -236,7 +224,7 @@ static struct device_node * __init prom_create_node(phandle node, | |||
236 | 224 | ||
237 | dp->name = get_one_property(node, "name"); | 225 | dp->name = get_one_property(node, "name"); |
238 | dp->type = get_one_property(node, "device_type"); | 226 | dp->type = get_one_property(node, "device_type"); |
239 | dp->node = node; | 227 | dp->phandle = node; |
240 | 228 | ||
241 | dp->properties = build_prop_list(node); | 229 | dp->properties = build_prop_list(node); |
242 | 230 | ||
@@ -313,7 +301,7 @@ void __init prom_build_devicetree(void) | |||
313 | 301 | ||
314 | nextp = &allnodes->allnext; | 302 | nextp = &allnodes->allnext; |
315 | allnodes->child = prom_build_tree(allnodes, | 303 | allnodes->child = prom_build_tree(allnodes, |
316 | prom_getchild(allnodes->node), | 304 | prom_getchild(allnodes->phandle), |
317 | &nextp); | 305 | &nextp); |
318 | of_console_init(); | 306 | of_console_init(); |
319 | 307 | ||
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index aa36223497b9..eb14844a0021 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c | |||
@@ -370,7 +370,7 @@ static int __cpuinit smp_boot_one_cpu(unsigned int cpu) | |||
370 | } else { | 370 | } else { |
371 | struct device_node *dp = of_find_node_by_cpuid(cpu); | 371 | struct device_node *dp = of_find_node_by_cpuid(cpu); |
372 | 372 | ||
373 | prom_startcpu(dp->node, entry, cookie); | 373 | prom_startcpu(dp->phandle, entry, cookie); |
374 | } | 374 | } |
375 | 375 | ||
376 | for (timeout = 0; timeout < 50000; timeout++) { | 376 | for (timeout = 0; timeout < 50000; timeout++) { |
diff --git a/drivers/char/hvc_beat.c b/drivers/char/hvc_beat.c index 6913fc33270c..5fe4631e2a61 100644 --- a/drivers/char/hvc_beat.c +++ b/drivers/char/hvc_beat.c | |||
@@ -99,7 +99,7 @@ static int hvc_beat_config(char *p) | |||
99 | 99 | ||
100 | static int __init hvc_beat_console_init(void) | 100 | static int __init hvc_beat_console_init(void) |
101 | { | 101 | { |
102 | if (hvc_beat_useit && machine_is_compatible("Beat")) { | 102 | if (hvc_beat_useit && of_machine_is_compatible("Beat")) { |
103 | hvc_instantiate(0, 0, &hvc_beat_get_put_ops); | 103 | hvc_instantiate(0, 0, &hvc_beat_get_put_ops); |
104 | } | 104 | } |
105 | return 0; | 105 | return 0; |
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c index e7b19440102e..22d476160d52 100644 --- a/drivers/gpu/drm/radeon/radeon_combios.c +++ b/drivers/gpu/drm/radeon/radeon_combios.c | |||
@@ -1279,47 +1279,47 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) | |||
1279 | rdev->mode_info.connector_table = radeon_connector_table; | 1279 | rdev->mode_info.connector_table = radeon_connector_table; |
1280 | if (rdev->mode_info.connector_table == CT_NONE) { | 1280 | if (rdev->mode_info.connector_table == CT_NONE) { |
1281 | #ifdef CONFIG_PPC_PMAC | 1281 | #ifdef CONFIG_PPC_PMAC |
1282 | if (machine_is_compatible("PowerBook3,3")) { | 1282 | if (of_machine_is_compatible("PowerBook3,3")) { |
1283 | /* powerbook with VGA */ | 1283 | /* powerbook with VGA */ |
1284 | rdev->mode_info.connector_table = CT_POWERBOOK_VGA; | 1284 | rdev->mode_info.connector_table = CT_POWERBOOK_VGA; |
1285 | } else if (machine_is_compatible("PowerBook3,4") || | 1285 | } else if (of_machine_is_compatible("PowerBook3,4") || |
1286 | machine_is_compatible("PowerBook3,5")) { | 1286 | of_machine_is_compatible("PowerBook3,5")) { |
1287 | /* powerbook with internal tmds */ | 1287 | /* powerbook with internal tmds */ |
1288 | rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; | 1288 | rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; |
1289 | } else if (machine_is_compatible("PowerBook5,1") || | 1289 | } else if (of_machine_is_compatible("PowerBook5,1") || |
1290 | machine_is_compatible("PowerBook5,2") || | 1290 | of_machine_is_compatible("PowerBook5,2") || |
1291 | machine_is_compatible("PowerBook5,3") || | 1291 | of_machine_is_compatible("PowerBook5,3") || |
1292 | machine_is_compatible("PowerBook5,4") || | 1292 | of_machine_is_compatible("PowerBook5,4") || |
1293 | machine_is_compatible("PowerBook5,5")) { | 1293 | of_machine_is_compatible("PowerBook5,5")) { |
1294 | /* powerbook with external single link tmds (sil164) */ | 1294 | /* powerbook with external single link tmds (sil164) */ |
1295 | rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; | 1295 | rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; |
1296 | } else if (machine_is_compatible("PowerBook5,6")) { | 1296 | } else if (of_machine_is_compatible("PowerBook5,6")) { |
1297 | /* powerbook with external dual or single link tmds */ | 1297 | /* powerbook with external dual or single link tmds */ |
1298 | rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; | 1298 | rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; |
1299 | } else if (machine_is_compatible("PowerBook5,7") || | 1299 | } else if (of_machine_is_compatible("PowerBook5,7") || |
1300 | machine_is_compatible("PowerBook5,8") || | 1300 | of_machine_is_compatible("PowerBook5,8") || |
1301 | machine_is_compatible("PowerBook5,9")) { | 1301 | of_machine_is_compatible("PowerBook5,9")) { |
1302 | /* PowerBook6,2 ? */ | 1302 | /* PowerBook6,2 ? */ |
1303 | /* powerbook with external dual link tmds (sil1178?) */ | 1303 | /* powerbook with external dual link tmds (sil1178?) */ |
1304 | rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; | 1304 | rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; |
1305 | } else if (machine_is_compatible("PowerBook4,1") || | 1305 | } else if (of_machine_is_compatible("PowerBook4,1") || |
1306 | machine_is_compatible("PowerBook4,2") || | 1306 | of_machine_is_compatible("PowerBook4,2") || |
1307 | machine_is_compatible("PowerBook4,3") || | 1307 | of_machine_is_compatible("PowerBook4,3") || |
1308 | machine_is_compatible("PowerBook6,3") || | 1308 | of_machine_is_compatible("PowerBook6,3") || |
1309 | machine_is_compatible("PowerBook6,5") || | 1309 | of_machine_is_compatible("PowerBook6,5") || |
1310 | machine_is_compatible("PowerBook6,7")) { | 1310 | of_machine_is_compatible("PowerBook6,7")) { |
1311 | /* ibook */ | 1311 | /* ibook */ |
1312 | rdev->mode_info.connector_table = CT_IBOOK; | 1312 | rdev->mode_info.connector_table = CT_IBOOK; |
1313 | } else if (machine_is_compatible("PowerMac4,4")) { | 1313 | } else if (of_machine_is_compatible("PowerMac4,4")) { |
1314 | /* emac */ | 1314 | /* emac */ |
1315 | rdev->mode_info.connector_table = CT_EMAC; | 1315 | rdev->mode_info.connector_table = CT_EMAC; |
1316 | } else if (machine_is_compatible("PowerMac10,1")) { | 1316 | } else if (of_machine_is_compatible("PowerMac10,1")) { |
1317 | /* mini with internal tmds */ | 1317 | /* mini with internal tmds */ |
1318 | rdev->mode_info.connector_table = CT_MINI_INTERNAL; | 1318 | rdev->mode_info.connector_table = CT_MINI_INTERNAL; |
1319 | } else if (machine_is_compatible("PowerMac10,2")) { | 1319 | } else if (of_machine_is_compatible("PowerMac10,2")) { |
1320 | /* mini with external tmds */ | 1320 | /* mini with external tmds */ |
1321 | rdev->mode_info.connector_table = CT_MINI_EXTERNAL; | 1321 | rdev->mode_info.connector_table = CT_MINI_EXTERNAL; |
1322 | } else if (machine_is_compatible("PowerMac12,1")) { | 1322 | } else if (of_machine_is_compatible("PowerMac12,1")) { |
1323 | /* PowerMac8,1 ? */ | 1323 | /* PowerMac8,1 ? */ |
1324 | /* imac g5 isight */ | 1324 | /* imac g5 isight */ |
1325 | rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; | 1325 | rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; |
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index 23741cec45e3..d840a109f833 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c | |||
@@ -322,8 +322,8 @@ static int __init adb_init(void) | |||
322 | adb_controller = NULL; | 322 | adb_controller = NULL; |
323 | } else { | 323 | } else { |
324 | #ifdef CONFIG_PPC | 324 | #ifdef CONFIG_PPC |
325 | if (machine_is_compatible("AAPL,PowerBook1998") || | 325 | if (of_machine_is_compatible("AAPL,PowerBook1998") || |
326 | machine_is_compatible("PowerBook1,1")) | 326 | of_machine_is_compatible("PowerBook1,1")) |
327 | sleepy_trackpad = 1; | 327 | sleepy_trackpad = 1; |
328 | #endif /* CONFIG_PPC */ | 328 | #endif /* CONFIG_PPC */ |
329 | 329 | ||
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index 454bc501df3c..5738d8bf2d97 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c | |||
@@ -1899,7 +1899,7 @@ static int create_control_loops(void) | |||
1899 | */ | 1899 | */ |
1900 | if (rackmac) | 1900 | if (rackmac) |
1901 | cpu_pid_type = CPU_PID_TYPE_RACKMAC; | 1901 | cpu_pid_type = CPU_PID_TYPE_RACKMAC; |
1902 | else if (machine_is_compatible("PowerMac7,3") | 1902 | else if (of_machine_is_compatible("PowerMac7,3") |
1903 | && (cpu_count > 1) | 1903 | && (cpu_count > 1) |
1904 | && fcu_fans[CPUA_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID | 1904 | && fcu_fans[CPUA_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID |
1905 | && fcu_fans[CPUB_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID) { | 1905 | && fcu_fans[CPUB_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID) { |
@@ -2234,10 +2234,10 @@ static int __init therm_pm72_init(void) | |||
2234 | { | 2234 | { |
2235 | struct device_node *np; | 2235 | struct device_node *np; |
2236 | 2236 | ||
2237 | rackmac = machine_is_compatible("RackMac3,1"); | 2237 | rackmac = of_machine_is_compatible("RackMac3,1"); |
2238 | 2238 | ||
2239 | if (!machine_is_compatible("PowerMac7,2") && | 2239 | if (!of_machine_is_compatible("PowerMac7,2") && |
2240 | !machine_is_compatible("PowerMac7,3") && | 2240 | !of_machine_is_compatible("PowerMac7,3") && |
2241 | !rackmac) | 2241 | !rackmac) |
2242 | return -ENODEV; | 2242 | return -ENODEV; |
2243 | 2243 | ||
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index ba48fd76396e..7fb8b4da35a7 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c | |||
@@ -490,7 +490,7 @@ g4fan_init( void ) | |||
490 | info = of_get_property(np, "thermal-info", NULL); | 490 | info = of_get_property(np, "thermal-info", NULL); |
491 | of_node_put(np); | 491 | of_node_put(np); |
492 | 492 | ||
493 | if( !info || !machine_is_compatible("PowerMac3,6") ) | 493 | if( !info || !of_machine_is_compatible("PowerMac3,6") ) |
494 | return -ENODEV; | 494 | return -ENODEV; |
495 | 495 | ||
496 | if( info->id != 3 ) { | 496 | if( info->id != 3 ) { |
diff --git a/drivers/macintosh/via-pmu-backlight.c b/drivers/macintosh/via-pmu-backlight.c index a348bb0791d3..4f3c4479c16a 100644 --- a/drivers/macintosh/via-pmu-backlight.c +++ b/drivers/macintosh/via-pmu-backlight.c | |||
@@ -150,13 +150,13 @@ void __init pmu_backlight_init() | |||
150 | 150 | ||
151 | /* Special case for the old PowerBook since I can't test on it */ | 151 | /* Special case for the old PowerBook since I can't test on it */ |
152 | autosave = | 152 | autosave = |
153 | machine_is_compatible("AAPL,3400/2400") || | 153 | of_machine_is_compatible("AAPL,3400/2400") || |
154 | machine_is_compatible("AAPL,3500"); | 154 | of_machine_is_compatible("AAPL,3500"); |
155 | 155 | ||
156 | if (!autosave && | 156 | if (!autosave && |
157 | !pmac_has_backlight_type("pmu") && | 157 | !pmac_has_backlight_type("pmu") && |
158 | !machine_is_compatible("AAPL,PowerBook1998") && | 158 | !of_machine_is_compatible("AAPL,PowerBook1998") && |
159 | !machine_is_compatible("PowerBook1,1")) | 159 | !of_machine_is_compatible("PowerBook1,1")) |
160 | return; | 160 | return; |
161 | 161 | ||
162 | snprintf(name, sizeof(name), "pmubl"); | 162 | snprintf(name, sizeof(name), "pmubl"); |
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index db379c381432..42764849eb78 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -463,8 +463,8 @@ static int __init via_pmu_dev_init(void) | |||
463 | #endif | 463 | #endif |
464 | 464 | ||
465 | #ifdef CONFIG_PPC32 | 465 | #ifdef CONFIG_PPC32 |
466 | if (machine_is_compatible("AAPL,3400/2400") || | 466 | if (of_machine_is_compatible("AAPL,3400/2400") || |
467 | machine_is_compatible("AAPL,3500")) { | 467 | of_machine_is_compatible("AAPL,3500")) { |
468 | int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO, | 468 | int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO, |
469 | NULL, PMAC_MB_INFO_MODEL, 0); | 469 | NULL, PMAC_MB_INFO_MODEL, 0); |
470 | pmu_battery_count = 1; | 470 | pmu_battery_count = 1; |
@@ -472,8 +472,8 @@ static int __init via_pmu_dev_init(void) | |||
472 | pmu_batteries[0].flags |= PMU_BATT_TYPE_COMET; | 472 | pmu_batteries[0].flags |= PMU_BATT_TYPE_COMET; |
473 | else | 473 | else |
474 | pmu_batteries[0].flags |= PMU_BATT_TYPE_HOOPER; | 474 | pmu_batteries[0].flags |= PMU_BATT_TYPE_HOOPER; |
475 | } else if (machine_is_compatible("AAPL,PowerBook1998") || | 475 | } else if (of_machine_is_compatible("AAPL,PowerBook1998") || |
476 | machine_is_compatible("PowerBook1,1")) { | 476 | of_machine_is_compatible("PowerBook1,1")) { |
477 | pmu_battery_count = 2; | 477 | pmu_battery_count = 2; |
478 | pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART; | 478 | pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART; |
479 | pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; | 479 | pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; |
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c index 075b4d99e354..437f55c5d18d 100644 --- a/drivers/macintosh/windfarm_core.c +++ b/drivers/macintosh/windfarm_core.c | |||
@@ -468,9 +468,9 @@ static int __init windfarm_core_init(void) | |||
468 | DBG("wf: core loaded\n"); | 468 | DBG("wf: core loaded\n"); |
469 | 469 | ||
470 | /* Don't register on old machines that use therm_pm72 for now */ | 470 | /* Don't register on old machines that use therm_pm72 for now */ |
471 | if (machine_is_compatible("PowerMac7,2") || | 471 | if (of_machine_is_compatible("PowerMac7,2") || |
472 | machine_is_compatible("PowerMac7,3") || | 472 | of_machine_is_compatible("PowerMac7,3") || |
473 | machine_is_compatible("RackMac3,1")) | 473 | of_machine_is_compatible("RackMac3,1")) |
474 | return -ENODEV; | 474 | return -ENODEV; |
475 | platform_device_register(&wf_platform_device); | 475 | platform_device_register(&wf_platform_device); |
476 | return 0; | 476 | return 0; |
diff --git a/drivers/macintosh/windfarm_cpufreq_clamp.c b/drivers/macintosh/windfarm_cpufreq_clamp.c index 900aade06198..1a77a7c97d0e 100644 --- a/drivers/macintosh/windfarm_cpufreq_clamp.c +++ b/drivers/macintosh/windfarm_cpufreq_clamp.c | |||
@@ -76,9 +76,9 @@ static int __init wf_cpufreq_clamp_init(void) | |||
76 | struct wf_control *clamp; | 76 | struct wf_control *clamp; |
77 | 77 | ||
78 | /* Don't register on old machines that use therm_pm72 for now */ | 78 | /* Don't register on old machines that use therm_pm72 for now */ |
79 | if (machine_is_compatible("PowerMac7,2") || | 79 | if (of_machine_is_compatible("PowerMac7,2") || |
80 | machine_is_compatible("PowerMac7,3") || | 80 | of_machine_is_compatible("PowerMac7,3") || |
81 | machine_is_compatible("RackMac3,1")) | 81 | of_machine_is_compatible("RackMac3,1")) |
82 | return -ENODEV; | 82 | return -ENODEV; |
83 | 83 | ||
84 | clamp = kmalloc(sizeof(struct wf_control), GFP_KERNEL); | 84 | clamp = kmalloc(sizeof(struct wf_control), GFP_KERNEL); |
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c index ed6426a10773..d8257d35afde 100644 --- a/drivers/macintosh/windfarm_lm75_sensor.c +++ b/drivers/macintosh/windfarm_lm75_sensor.c | |||
@@ -239,9 +239,9 @@ static struct i2c_driver wf_lm75_driver = { | |||
239 | static int __init wf_lm75_sensor_init(void) | 239 | static int __init wf_lm75_sensor_init(void) |
240 | { | 240 | { |
241 | /* Don't register on old machines that use therm_pm72 for now */ | 241 | /* Don't register on old machines that use therm_pm72 for now */ |
242 | if (machine_is_compatible("PowerMac7,2") || | 242 | if (of_machine_is_compatible("PowerMac7,2") || |
243 | machine_is_compatible("PowerMac7,3") || | 243 | of_machine_is_compatible("PowerMac7,3") || |
244 | machine_is_compatible("RackMac3,1")) | 244 | of_machine_is_compatible("RackMac3,1")) |
245 | return -ENODEV; | 245 | return -ENODEV; |
246 | return i2c_add_driver(&wf_lm75_driver); | 246 | return i2c_add_driver(&wf_lm75_driver); |
247 | } | 247 | } |
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c b/drivers/macintosh/windfarm_max6690_sensor.c index a67b349319e9..b486eb929fde 100644 --- a/drivers/macintosh/windfarm_max6690_sensor.c +++ b/drivers/macintosh/windfarm_max6690_sensor.c | |||
@@ -188,9 +188,9 @@ static struct i2c_driver wf_max6690_driver = { | |||
188 | static int __init wf_max6690_sensor_init(void) | 188 | static int __init wf_max6690_sensor_init(void) |
189 | { | 189 | { |
190 | /* Don't register on old machines that use therm_pm72 for now */ | 190 | /* Don't register on old machines that use therm_pm72 for now */ |
191 | if (machine_is_compatible("PowerMac7,2") || | 191 | if (of_machine_is_compatible("PowerMac7,2") || |
192 | machine_is_compatible("PowerMac7,3") || | 192 | of_machine_is_compatible("PowerMac7,3") || |
193 | machine_is_compatible("RackMac3,1")) | 193 | of_machine_is_compatible("RackMac3,1")) |
194 | return -ENODEV; | 194 | return -ENODEV; |
195 | return i2c_add_driver(&wf_max6690_driver); | 195 | return i2c_add_driver(&wf_max6690_driver); |
196 | } | 196 | } |
diff --git a/drivers/macintosh/windfarm_pm112.c b/drivers/macintosh/windfarm_pm112.c index 73d695dc9e50..e0ee80700cde 100644 --- a/drivers/macintosh/windfarm_pm112.c +++ b/drivers/macintosh/windfarm_pm112.c | |||
@@ -676,7 +676,7 @@ static int __init wf_pm112_init(void) | |||
676 | { | 676 | { |
677 | struct device_node *cpu; | 677 | struct device_node *cpu; |
678 | 678 | ||
679 | if (!machine_is_compatible("PowerMac11,2")) | 679 | if (!of_machine_is_compatible("PowerMac11,2")) |
680 | return -ENODEV; | 680 | return -ENODEV; |
681 | 681 | ||
682 | /* Count the number of CPU cores */ | 682 | /* Count the number of CPU cores */ |
diff --git a/drivers/macintosh/windfarm_pm121.c b/drivers/macintosh/windfarm_pm121.c index 66ec4fb115bb..947d4afa25ca 100644 --- a/drivers/macintosh/windfarm_pm121.c +++ b/drivers/macintosh/windfarm_pm121.c | |||
@@ -1008,7 +1008,7 @@ static int __init pm121_init(void) | |||
1008 | { | 1008 | { |
1009 | int rc = -ENODEV; | 1009 | int rc = -ENODEV; |
1010 | 1010 | ||
1011 | if (machine_is_compatible("PowerMac12,1")) | 1011 | if (of_machine_is_compatible("PowerMac12,1")) |
1012 | rc = pm121_init_pm(); | 1012 | rc = pm121_init_pm(); |
1013 | 1013 | ||
1014 | if (rc == 0) { | 1014 | if (rc == 0) { |
diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c index abbe206474f5..565d5b2adc95 100644 --- a/drivers/macintosh/windfarm_pm81.c +++ b/drivers/macintosh/windfarm_pm81.c | |||
@@ -779,8 +779,8 @@ static int __init wf_smu_init(void) | |||
779 | { | 779 | { |
780 | int rc = -ENODEV; | 780 | int rc = -ENODEV; |
781 | 781 | ||
782 | if (machine_is_compatible("PowerMac8,1") || | 782 | if (of_machine_is_compatible("PowerMac8,1") || |
783 | machine_is_compatible("PowerMac8,2")) | 783 | of_machine_is_compatible("PowerMac8,2")) |
784 | rc = wf_init_pm(); | 784 | rc = wf_init_pm(); |
785 | 785 | ||
786 | if (rc == 0) { | 786 | if (rc == 0) { |
diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c index 764c525b2117..bea99168ff35 100644 --- a/drivers/macintosh/windfarm_pm91.c +++ b/drivers/macintosh/windfarm_pm91.c | |||
@@ -711,7 +711,7 @@ static int __init wf_smu_init(void) | |||
711 | { | 711 | { |
712 | int rc = -ENODEV; | 712 | int rc = -ENODEV; |
713 | 713 | ||
714 | if (machine_is_compatible("PowerMac9,1")) | 714 | if (of_machine_is_compatible("PowerMac9,1")) |
715 | rc = wf_init_pm(); | 715 | rc = wf_init_pm(); |
716 | 716 | ||
717 | if (rc == 0) { | 717 | if (rc == 0) { |
diff --git a/drivers/macintosh/windfarm_smu_sensors.c b/drivers/macintosh/windfarm_smu_sensors.c index 9c567b93f417..3c193504bb80 100644 --- a/drivers/macintosh/windfarm_smu_sensors.c +++ b/drivers/macintosh/windfarm_smu_sensors.c | |||
@@ -363,9 +363,9 @@ smu_cpu_power_create(struct wf_sensor *volts, struct wf_sensor *amps) | |||
363 | * I yet have to figure out what's up with 8,2 and will have to | 363 | * I yet have to figure out what's up with 8,2 and will have to |
364 | * adjust for later, unless we can 100% trust the SDB partition... | 364 | * adjust for later, unless we can 100% trust the SDB partition... |
365 | */ | 365 | */ |
366 | if ((machine_is_compatible("PowerMac8,1") || | 366 | if ((of_machine_is_compatible("PowerMac8,1") || |
367 | machine_is_compatible("PowerMac8,2") || | 367 | of_machine_is_compatible("PowerMac8,2") || |
368 | machine_is_compatible("PowerMac9,1")) && | 368 | of_machine_is_compatible("PowerMac9,1")) && |
369 | cpuvcp_version >= 2) { | 369 | cpuvcp_version >= 2) { |
370 | pow->quadratic = 1; | 370 | pow->quadratic = 1; |
371 | DBG("windfarm: CPU Power using quadratic transform\n"); | 371 | DBG("windfarm: CPU Power using quadratic transform\n"); |
diff --git a/drivers/net/mace.c b/drivers/net/mace.c index d9fbad386389..43aea91e3369 100644 --- a/drivers/net/mace.c +++ b/drivers/net/mace.c | |||
@@ -206,7 +206,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i | |||
206 | mp->port_aaui = port_aaui; | 206 | mp->port_aaui = port_aaui; |
207 | else { | 207 | else { |
208 | /* Apple Network Server uses the AAUI port */ | 208 | /* Apple Network Server uses the AAUI port */ |
209 | if (machine_is_compatible("AAPL,ShinerESB")) | 209 | if (of_machine_is_compatible("AAPL,ShinerESB")) |
210 | mp->port_aaui = 1; | 210 | mp->port_aaui = 1; |
211 | else { | 211 | else { |
212 | #ifdef CONFIG_MACE_AAUI_PORT | 212 | #ifdef CONFIG_MACE_AAUI_PORT |
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index d2fa27c5c1b2..7cecc8fea9bd 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig | |||
@@ -1,3 +1,11 @@ | |||
1 | config OF_FLATTREE | ||
2 | bool | ||
3 | depends on OF | ||
4 | |||
5 | config OF_DYNAMIC | ||
6 | def_bool y | ||
7 | depends on OF && PPC_OF | ||
8 | |||
1 | config OF_DEVICE | 9 | config OF_DEVICE |
2 | def_bool y | 10 | def_bool y |
3 | depends on OF && (SPARC || PPC_OF || MICROBLAZE) | 11 | depends on OF && (SPARC || PPC_OF || MICROBLAZE) |
diff --git a/drivers/of/Makefile b/drivers/of/Makefile index bdfb5f5d4b06..f232cc98ce00 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile | |||
@@ -1,4 +1,5 @@ | |||
1 | obj-y = base.o | 1 | obj-y = base.o |
2 | obj-$(CONFIG_OF_FLATTREE) += fdt.o | ||
2 | obj-$(CONFIG_OF_DEVICE) += device.o platform.o | 3 | obj-$(CONFIG_OF_DEVICE) += device.o platform.o |
3 | obj-$(CONFIG_OF_GPIO) += gpio.o | 4 | obj-$(CONFIG_OF_GPIO) += gpio.o |
4 | obj-$(CONFIG_OF_I2C) += of_i2c.o | 5 | obj-$(CONFIG_OF_I2C) += of_i2c.o |
diff --git a/drivers/of/base.c b/drivers/of/base.c index e6627b2320f1..cb96888d1427 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -20,8 +20,10 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/of.h> | 21 | #include <linux/of.h> |
22 | #include <linux/spinlock.h> | 22 | #include <linux/spinlock.h> |
23 | #include <linux/proc_fs.h> | ||
23 | 24 | ||
24 | struct device_node *allnodes; | 25 | struct device_node *allnodes; |
26 | struct device_node *of_chosen; | ||
25 | 27 | ||
26 | /* use when traversing tree through the allnext, child, sibling, | 28 | /* use when traversing tree through the allnext, child, sibling, |
27 | * or parent members of struct device_node. | 29 | * or parent members of struct device_node. |
@@ -37,7 +39,7 @@ int of_n_addr_cells(struct device_node *np) | |||
37 | np = np->parent; | 39 | np = np->parent; |
38 | ip = of_get_property(np, "#address-cells", NULL); | 40 | ip = of_get_property(np, "#address-cells", NULL); |
39 | if (ip) | 41 | if (ip) |
40 | return *ip; | 42 | return be32_to_cpup(ip); |
41 | } while (np->parent); | 43 | } while (np->parent); |
42 | /* No #address-cells property for the root node */ | 44 | /* No #address-cells property for the root node */ |
43 | return OF_ROOT_NODE_ADDR_CELLS_DEFAULT; | 45 | return OF_ROOT_NODE_ADDR_CELLS_DEFAULT; |
@@ -53,13 +55,88 @@ int of_n_size_cells(struct device_node *np) | |||
53 | np = np->parent; | 55 | np = np->parent; |
54 | ip = of_get_property(np, "#size-cells", NULL); | 56 | ip = of_get_property(np, "#size-cells", NULL); |
55 | if (ip) | 57 | if (ip) |
56 | return *ip; | 58 | return be32_to_cpup(ip); |
57 | } while (np->parent); | 59 | } while (np->parent); |
58 | /* No #size-cells property for the root node */ | 60 | /* No #size-cells property for the root node */ |
59 | return OF_ROOT_NODE_SIZE_CELLS_DEFAULT; | 61 | return OF_ROOT_NODE_SIZE_CELLS_DEFAULT; |
60 | } | 62 | } |
61 | EXPORT_SYMBOL(of_n_size_cells); | 63 | EXPORT_SYMBOL(of_n_size_cells); |
62 | 64 | ||
65 | #if !defined(CONFIG_SPARC) /* SPARC doesn't do ref counting (yet) */ | ||
66 | /** | ||
67 | * of_node_get - Increment refcount of a node | ||
68 | * @node: Node to inc refcount, NULL is supported to | ||
69 | * simplify writing of callers | ||
70 | * | ||
71 | * Returns node. | ||
72 | */ | ||
73 | struct device_node *of_node_get(struct device_node *node) | ||
74 | { | ||
75 | if (node) | ||
76 | kref_get(&node->kref); | ||
77 | return node; | ||
78 | } | ||
79 | EXPORT_SYMBOL(of_node_get); | ||
80 | |||
81 | static inline struct device_node *kref_to_device_node(struct kref *kref) | ||
82 | { | ||
83 | return container_of(kref, struct device_node, kref); | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * of_node_release - release a dynamically allocated node | ||
88 | * @kref: kref element of the node to be released | ||
89 | * | ||
90 | * In of_node_put() this function is passed to kref_put() | ||
91 | * as the destructor. | ||
92 | */ | ||
93 | static void of_node_release(struct kref *kref) | ||
94 | { | ||
95 | struct device_node *node = kref_to_device_node(kref); | ||
96 | struct property *prop = node->properties; | ||
97 | |||
98 | /* We should never be releasing nodes that haven't been detached. */ | ||
99 | if (!of_node_check_flag(node, OF_DETACHED)) { | ||
100 | pr_err("ERROR: Bad of_node_put() on %s\n", node->full_name); | ||
101 | dump_stack(); | ||
102 | kref_init(&node->kref); | ||
103 | return; | ||
104 | } | ||
105 | |||
106 | if (!of_node_check_flag(node, OF_DYNAMIC)) | ||
107 | return; | ||
108 | |||
109 | while (prop) { | ||
110 | struct property *next = prop->next; | ||
111 | kfree(prop->name); | ||
112 | kfree(prop->value); | ||
113 | kfree(prop); | ||
114 | prop = next; | ||
115 | |||
116 | if (!prop) { | ||
117 | prop = node->deadprops; | ||
118 | node->deadprops = NULL; | ||
119 | } | ||
120 | } | ||
121 | kfree(node->full_name); | ||
122 | kfree(node->data); | ||
123 | kfree(node); | ||
124 | } | ||
125 | |||
126 | /** | ||
127 | * of_node_put - Decrement refcount of a node | ||
128 | * @node: Node to dec refcount, NULL is supported to | ||
129 | * simplify writing of callers | ||
130 | * | ||
131 | */ | ||
132 | void of_node_put(struct device_node *node) | ||
133 | { | ||
134 | if (node) | ||
135 | kref_put(&node->kref, of_node_release); | ||
136 | } | ||
137 | EXPORT_SYMBOL(of_node_put); | ||
138 | #endif /* !CONFIG_SPARC */ | ||
139 | |||
63 | struct property *of_find_property(const struct device_node *np, | 140 | struct property *of_find_property(const struct device_node *np, |
64 | const char *name, | 141 | const char *name, |
65 | int *lenp) | 142 | int *lenp) |
@@ -144,6 +221,27 @@ int of_device_is_compatible(const struct device_node *device, | |||
144 | EXPORT_SYMBOL(of_device_is_compatible); | 221 | EXPORT_SYMBOL(of_device_is_compatible); |
145 | 222 | ||
146 | /** | 223 | /** |
224 | * of_machine_is_compatible - Test root of device tree for a given compatible value | ||
225 | * @compat: compatible string to look for in root node's compatible property. | ||
226 | * | ||
227 | * Returns true if the root node has the given value in its | ||
228 | * compatible property. | ||
229 | */ | ||
230 | int of_machine_is_compatible(const char *compat) | ||
231 | { | ||
232 | struct device_node *root; | ||
233 | int rc = 0; | ||
234 | |||
235 | root = of_find_node_by_path("/"); | ||
236 | if (root) { | ||
237 | rc = of_device_is_compatible(root, compat); | ||
238 | of_node_put(root); | ||
239 | } | ||
240 | return rc; | ||
241 | } | ||
242 | EXPORT_SYMBOL(of_machine_is_compatible); | ||
243 | |||
244 | /** | ||
147 | * of_device_is_available - check if a device is available for use | 245 | * of_device_is_available - check if a device is available for use |
148 | * | 246 | * |
149 | * @device: Node to check for availability | 247 | * @device: Node to check for availability |
@@ -519,6 +617,27 @@ int of_modalias_node(struct device_node *node, char *modalias, int len) | |||
519 | EXPORT_SYMBOL_GPL(of_modalias_node); | 617 | EXPORT_SYMBOL_GPL(of_modalias_node); |
520 | 618 | ||
521 | /** | 619 | /** |
620 | * of_find_node_by_phandle - Find a node given a phandle | ||
621 | * @handle: phandle of the node to find | ||
622 | * | ||
623 | * Returns a node pointer with refcount incremented, use | ||
624 | * of_node_put() on it when done. | ||
625 | */ | ||
626 | struct device_node *of_find_node_by_phandle(phandle handle) | ||
627 | { | ||
628 | struct device_node *np; | ||
629 | |||
630 | read_lock(&devtree_lock); | ||
631 | for (np = allnodes; np; np = np->allnext) | ||
632 | if (np->phandle == handle) | ||
633 | break; | ||
634 | of_node_get(np); | ||
635 | read_unlock(&devtree_lock); | ||
636 | return np; | ||
637 | } | ||
638 | EXPORT_SYMBOL(of_find_node_by_phandle); | ||
639 | |||
640 | /** | ||
522 | * of_parse_phandle - Resolve a phandle property to a device_node pointer | 641 | * of_parse_phandle - Resolve a phandle property to a device_node pointer |
523 | * @np: Pointer to device node holding phandle property | 642 | * @np: Pointer to device node holding phandle property |
524 | * @phandle_name: Name of property holding a phandle value | 643 | * @phandle_name: Name of property holding a phandle value |
@@ -578,8 +697,8 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name, | |||
578 | const void **out_args) | 697 | const void **out_args) |
579 | { | 698 | { |
580 | int ret = -EINVAL; | 699 | int ret = -EINVAL; |
581 | const u32 *list; | 700 | const __be32 *list; |
582 | const u32 *list_end; | 701 | const __be32 *list_end; |
583 | int size; | 702 | int size; |
584 | int cur_index = 0; | 703 | int cur_index = 0; |
585 | struct device_node *node = NULL; | 704 | struct device_node *node = NULL; |
@@ -593,7 +712,7 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name, | |||
593 | list_end = list + size / sizeof(*list); | 712 | list_end = list + size / sizeof(*list); |
594 | 713 | ||
595 | while (list < list_end) { | 714 | while (list < list_end) { |
596 | const u32 *cells; | 715 | const __be32 *cells; |
597 | const phandle *phandle; | 716 | const phandle *phandle; |
598 | 717 | ||
599 | phandle = list++; | 718 | phandle = list++; |
@@ -617,7 +736,7 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name, | |||
617 | goto err1; | 736 | goto err1; |
618 | } | 737 | } |
619 | 738 | ||
620 | list += *cells; | 739 | list += be32_to_cpup(cells); |
621 | if (list > list_end) { | 740 | if (list > list_end) { |
622 | pr_debug("%s: insufficient arguments length\n", | 741 | pr_debug("%s: insufficient arguments length\n", |
623 | np->full_name); | 742 | np->full_name); |
@@ -658,3 +777,190 @@ err0: | |||
658 | return ret; | 777 | return ret; |
659 | } | 778 | } |
660 | EXPORT_SYMBOL(of_parse_phandles_with_args); | 779 | EXPORT_SYMBOL(of_parse_phandles_with_args); |
780 | |||
781 | /** | ||
782 | * prom_add_property - Add a property to a node | ||
783 | */ | ||
784 | int prom_add_property(struct device_node *np, struct property *prop) | ||
785 | { | ||
786 | struct property **next; | ||
787 | unsigned long flags; | ||
788 | |||
789 | prop->next = NULL; | ||
790 | write_lock_irqsave(&devtree_lock, flags); | ||
791 | next = &np->properties; | ||
792 | while (*next) { | ||
793 | if (strcmp(prop->name, (*next)->name) == 0) { | ||
794 | /* duplicate ! don't insert it */ | ||
795 | write_unlock_irqrestore(&devtree_lock, flags); | ||
796 | return -1; | ||
797 | } | ||
798 | next = &(*next)->next; | ||
799 | } | ||
800 | *next = prop; | ||
801 | write_unlock_irqrestore(&devtree_lock, flags); | ||
802 | |||
803 | #ifdef CONFIG_PROC_DEVICETREE | ||
804 | /* try to add to proc as well if it was initialized */ | ||
805 | if (np->pde) | ||
806 | proc_device_tree_add_prop(np->pde, prop); | ||
807 | #endif /* CONFIG_PROC_DEVICETREE */ | ||
808 | |||
809 | return 0; | ||
810 | } | ||
811 | |||
812 | /** | ||
813 | * prom_remove_property - Remove a property from a node. | ||
814 | * | ||
815 | * Note that we don't actually remove it, since we have given out | ||
816 | * who-knows-how-many pointers to the data using get-property. | ||
817 | * Instead we just move the property to the "dead properties" | ||
818 | * list, so it won't be found any more. | ||
819 | */ | ||
820 | int prom_remove_property(struct device_node *np, struct property *prop) | ||
821 | { | ||
822 | struct property **next; | ||
823 | unsigned long flags; | ||
824 | int found = 0; | ||
825 | |||
826 | write_lock_irqsave(&devtree_lock, flags); | ||
827 | next = &np->properties; | ||
828 | while (*next) { | ||
829 | if (*next == prop) { | ||
830 | /* found the node */ | ||
831 | *next = prop->next; | ||
832 | prop->next = np->deadprops; | ||
833 | np->deadprops = prop; | ||
834 | found = 1; | ||
835 | break; | ||
836 | } | ||
837 | next = &(*next)->next; | ||
838 | } | ||
839 | write_unlock_irqrestore(&devtree_lock, flags); | ||
840 | |||
841 | if (!found) | ||
842 | return -ENODEV; | ||
843 | |||
844 | #ifdef CONFIG_PROC_DEVICETREE | ||
845 | /* try to remove the proc node as well */ | ||
846 | if (np->pde) | ||
847 | proc_device_tree_remove_prop(np->pde, prop); | ||
848 | #endif /* CONFIG_PROC_DEVICETREE */ | ||
849 | |||
850 | return 0; | ||
851 | } | ||
852 | |||
853 | /* | ||
854 | * prom_update_property - Update a property in a node. | ||
855 | * | ||
856 | * Note that we don't actually remove it, since we have given out | ||
857 | * who-knows-how-many pointers to the data using get-property. | ||
858 | * Instead we just move the property to the "dead properties" list, | ||
859 | * and add the new property to the property list | ||
860 | */ | ||
861 | int prom_update_property(struct device_node *np, | ||
862 | struct property *newprop, | ||
863 | struct property *oldprop) | ||
864 | { | ||
865 | struct property **next; | ||
866 | unsigned long flags; | ||
867 | int found = 0; | ||
868 | |||
869 | write_lock_irqsave(&devtree_lock, flags); | ||
870 | next = &np->properties; | ||
871 | while (*next) { | ||
872 | if (*next == oldprop) { | ||
873 | /* found the node */ | ||
874 | newprop->next = oldprop->next; | ||
875 | *next = newprop; | ||
876 | oldprop->next = np->deadprops; | ||
877 | np->deadprops = oldprop; | ||
878 | found = 1; | ||
879 | break; | ||
880 | } | ||
881 | next = &(*next)->next; | ||
882 | } | ||
883 | write_unlock_irqrestore(&devtree_lock, flags); | ||
884 | |||
885 | if (!found) | ||
886 | return -ENODEV; | ||
887 | |||
888 | #ifdef CONFIG_PROC_DEVICETREE | ||
889 | /* try to add to proc as well if it was initialized */ | ||
890 | if (np->pde) | ||
891 | proc_device_tree_update_prop(np->pde, newprop, oldprop); | ||
892 | #endif /* CONFIG_PROC_DEVICETREE */ | ||
893 | |||
894 | return 0; | ||
895 | } | ||
896 | |||
897 | #if defined(CONFIG_OF_DYNAMIC) | ||
898 | /* | ||
899 | * Support for dynamic device trees. | ||
900 | * | ||
901 | * On some platforms, the device tree can be manipulated at runtime. | ||
902 | * The routines in this section support adding, removing and changing | ||
903 | * device tree nodes. | ||
904 | */ | ||
905 | |||
906 | /** | ||
907 | * of_attach_node - Plug a device node into the tree and global list. | ||
908 | */ | ||
909 | void of_attach_node(struct device_node *np) | ||
910 | { | ||
911 | unsigned long flags; | ||
912 | |||
913 | write_lock_irqsave(&devtree_lock, flags); | ||
914 | np->sibling = np->parent->child; | ||
915 | np->allnext = allnodes; | ||
916 | np->parent->child = np; | ||
917 | allnodes = np; | ||
918 | write_unlock_irqrestore(&devtree_lock, flags); | ||
919 | } | ||
920 | |||
921 | /** | ||
922 | * of_detach_node - "Unplug" a node from the device tree. | ||
923 | * | ||
924 | * The caller must hold a reference to the node. The memory associated with | ||
925 | * the node is not freed until its refcount goes to zero. | ||
926 | */ | ||
927 | void of_detach_node(struct device_node *np) | ||
928 | { | ||
929 | struct device_node *parent; | ||
930 | unsigned long flags; | ||
931 | |||
932 | write_lock_irqsave(&devtree_lock, flags); | ||
933 | |||
934 | parent = np->parent; | ||
935 | if (!parent) | ||
936 | goto out_unlock; | ||
937 | |||
938 | if (allnodes == np) | ||
939 | allnodes = np->allnext; | ||
940 | else { | ||
941 | struct device_node *prev; | ||
942 | for (prev = allnodes; | ||
943 | prev->allnext != np; | ||
944 | prev = prev->allnext) | ||
945 | ; | ||
946 | prev->allnext = np->allnext; | ||
947 | } | ||
948 | |||
949 | if (parent->child == np) | ||
950 | parent->child = np->sibling; | ||
951 | else { | ||
952 | struct device_node *prevsib; | ||
953 | for (prevsib = np->parent->child; | ||
954 | prevsib->sibling != np; | ||
955 | prevsib = prevsib->sibling) | ||
956 | ; | ||
957 | prevsib->sibling = np->sibling; | ||
958 | } | ||
959 | |||
960 | of_node_set_flag(np, OF_DETACHED); | ||
961 | |||
962 | out_unlock: | ||
963 | write_unlock_irqrestore(&devtree_lock, flags); | ||
964 | } | ||
965 | #endif /* defined(CONFIG_OF_DYNAMIC) */ | ||
966 | |||
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c new file mode 100644 index 000000000000..406757a9d7ea --- /dev/null +++ b/drivers/of/fdt.c | |||
@@ -0,0 +1,590 @@ | |||
1 | /* | ||
2 | * Functions for working with the Flattened Device Tree data format | ||
3 | * | ||
4 | * Copyright 2009 Benjamin Herrenschmidt, IBM Corp | ||
5 | * benh@kernel.crashing.org | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/initrd.h> | ||
14 | #include <linux/of.h> | ||
15 | #include <linux/of_fdt.h> | ||
16 | #include <linux/string.h> | ||
17 | #include <linux/errno.h> | ||
18 | |||
19 | #ifdef CONFIG_PPC | ||
20 | #include <asm/machdep.h> | ||
21 | #endif /* CONFIG_PPC */ | ||
22 | |||
23 | #include <asm/page.h> | ||
24 | |||
25 | int __initdata dt_root_addr_cells; | ||
26 | int __initdata dt_root_size_cells; | ||
27 | |||
28 | struct boot_param_header *initial_boot_params; | ||
29 | |||
30 | char *find_flat_dt_string(u32 offset) | ||
31 | { | ||
32 | return ((char *)initial_boot_params) + | ||
33 | be32_to_cpu(initial_boot_params->off_dt_strings) + offset; | ||
34 | } | ||
35 | |||
36 | /** | ||
37 | * of_scan_flat_dt - scan flattened tree blob and call callback on each. | ||
38 | * @it: callback function | ||
39 | * @data: context data pointer | ||
40 | * | ||
41 | * This function is used to scan the flattened device-tree, it is | ||
42 | * used to extract the memory information at boot before we can | ||
43 | * unflatten the tree | ||
44 | */ | ||
45 | int __init of_scan_flat_dt(int (*it)(unsigned long node, | ||
46 | const char *uname, int depth, | ||
47 | void *data), | ||
48 | void *data) | ||
49 | { | ||
50 | unsigned long p = ((unsigned long)initial_boot_params) + | ||
51 | be32_to_cpu(initial_boot_params->off_dt_struct); | ||
52 | int rc = 0; | ||
53 | int depth = -1; | ||
54 | |||
55 | do { | ||
56 | u32 tag = be32_to_cpup((__be32 *)p); | ||
57 | char *pathp; | ||
58 | |||
59 | p += 4; | ||
60 | if (tag == OF_DT_END_NODE) { | ||
61 | depth--; | ||
62 | continue; | ||
63 | } | ||
64 | if (tag == OF_DT_NOP) | ||
65 | continue; | ||
66 | if (tag == OF_DT_END) | ||
67 | break; | ||
68 | if (tag == OF_DT_PROP) { | ||
69 | u32 sz = be32_to_cpup((__be32 *)p); | ||
70 | p += 8; | ||
71 | if (be32_to_cpu(initial_boot_params->version) < 0x10) | ||
72 | p = _ALIGN(p, sz >= 8 ? 8 : 4); | ||
73 | p += sz; | ||
74 | p = _ALIGN(p, 4); | ||
75 | continue; | ||
76 | } | ||
77 | if (tag != OF_DT_BEGIN_NODE) { | ||
78 | pr_err("Invalid tag %x in flat device tree!\n", tag); | ||
79 | return -EINVAL; | ||
80 | } | ||
81 | depth++; | ||
82 | pathp = (char *)p; | ||
83 | p = _ALIGN(p + strlen(pathp) + 1, 4); | ||
84 | if ((*pathp) == '/') { | ||
85 | char *lp, *np; | ||
86 | for (lp = NULL, np = pathp; *np; np++) | ||
87 | if ((*np) == '/') | ||
88 | lp = np+1; | ||
89 | if (lp != NULL) | ||
90 | pathp = lp; | ||
91 | } | ||
92 | rc = it(p, pathp, depth, data); | ||
93 | if (rc != 0) | ||
94 | break; | ||
95 | } while (1); | ||
96 | |||
97 | return rc; | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * of_get_flat_dt_root - find the root node in the flat blob | ||
102 | */ | ||
103 | unsigned long __init of_get_flat_dt_root(void) | ||
104 | { | ||
105 | unsigned long p = ((unsigned long)initial_boot_params) + | ||
106 | be32_to_cpu(initial_boot_params->off_dt_struct); | ||
107 | |||
108 | while (be32_to_cpup((__be32 *)p) == OF_DT_NOP) | ||
109 | p += 4; | ||
110 | BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE); | ||
111 | p += 4; | ||
112 | return _ALIGN(p + strlen((char *)p) + 1, 4); | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr | ||
117 | * | ||
118 | * This function can be used within scan_flattened_dt callback to get | ||
119 | * access to properties | ||
120 | */ | ||
121 | void *__init of_get_flat_dt_prop(unsigned long node, const char *name, | ||
122 | unsigned long *size) | ||
123 | { | ||
124 | unsigned long p = node; | ||
125 | |||
126 | do { | ||
127 | u32 tag = be32_to_cpup((__be32 *)p); | ||
128 | u32 sz, noff; | ||
129 | const char *nstr; | ||
130 | |||
131 | p += 4; | ||
132 | if (tag == OF_DT_NOP) | ||
133 | continue; | ||
134 | if (tag != OF_DT_PROP) | ||
135 | return NULL; | ||
136 | |||
137 | sz = be32_to_cpup((__be32 *)p); | ||
138 | noff = be32_to_cpup((__be32 *)(p + 4)); | ||
139 | p += 8; | ||
140 | if (be32_to_cpu(initial_boot_params->version) < 0x10) | ||
141 | p = _ALIGN(p, sz >= 8 ? 8 : 4); | ||
142 | |||
143 | nstr = find_flat_dt_string(noff); | ||
144 | if (nstr == NULL) { | ||
145 | pr_warning("Can't find property index name !\n"); | ||
146 | return NULL; | ||
147 | } | ||
148 | if (strcmp(name, nstr) == 0) { | ||
149 | if (size) | ||
150 | *size = sz; | ||
151 | return (void *)p; | ||
152 | } | ||
153 | p += sz; | ||
154 | p = _ALIGN(p, 4); | ||
155 | } while (1); | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * of_flat_dt_is_compatible - Return true if given node has compat in compatible list | ||
160 | * @node: node to test | ||
161 | * @compat: compatible string to compare with compatible list. | ||
162 | */ | ||
163 | int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) | ||
164 | { | ||
165 | const char *cp; | ||
166 | unsigned long cplen, l; | ||
167 | |||
168 | cp = of_get_flat_dt_prop(node, "compatible", &cplen); | ||
169 | if (cp == NULL) | ||
170 | return 0; | ||
171 | while (cplen > 0) { | ||
172 | if (strncasecmp(cp, compat, strlen(compat)) == 0) | ||
173 | return 1; | ||
174 | l = strlen(cp) + 1; | ||
175 | cp += l; | ||
176 | cplen -= l; | ||
177 | } | ||
178 | |||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size, | ||
183 | unsigned long align) | ||
184 | { | ||
185 | void *res; | ||
186 | |||
187 | *mem = _ALIGN(*mem, align); | ||
188 | res = (void *)*mem; | ||
189 | *mem += size; | ||
190 | |||
191 | return res; | ||
192 | } | ||
193 | |||
194 | /** | ||
195 | * unflatten_dt_node - Alloc and populate a device_node from the flat tree | ||
196 | * @p: pointer to node in flat tree | ||
197 | * @dad: Parent struct device_node | ||
198 | * @allnextpp: pointer to ->allnext from last allocated device_node | ||
199 | * @fpsize: Size of the node path up at the current depth. | ||
200 | */ | ||
201 | unsigned long __init unflatten_dt_node(unsigned long mem, | ||
202 | unsigned long *p, | ||
203 | struct device_node *dad, | ||
204 | struct device_node ***allnextpp, | ||
205 | unsigned long fpsize) | ||
206 | { | ||
207 | struct device_node *np; | ||
208 | struct property *pp, **prev_pp = NULL; | ||
209 | char *pathp; | ||
210 | u32 tag; | ||
211 | unsigned int l, allocl; | ||
212 | int has_name = 0; | ||
213 | int new_format = 0; | ||
214 | |||
215 | tag = be32_to_cpup((__be32 *)(*p)); | ||
216 | if (tag != OF_DT_BEGIN_NODE) { | ||
217 | pr_err("Weird tag at start of node: %x\n", tag); | ||
218 | return mem; | ||
219 | } | ||
220 | *p += 4; | ||
221 | pathp = (char *)*p; | ||
222 | l = allocl = strlen(pathp) + 1; | ||
223 | *p = _ALIGN(*p + l, 4); | ||
224 | |||
225 | /* version 0x10 has a more compact unit name here instead of the full | ||
226 | * path. we accumulate the full path size using "fpsize", we'll rebuild | ||
227 | * it later. We detect this because the first character of the name is | ||
228 | * not '/'. | ||
229 | */ | ||
230 | if ((*pathp) != '/') { | ||
231 | new_format = 1; | ||
232 | if (fpsize == 0) { | ||
233 | /* root node: special case. fpsize accounts for path | ||
234 | * plus terminating zero. root node only has '/', so | ||
235 | * fpsize should be 2, but we want to avoid the first | ||
236 | * level nodes to have two '/' so we use fpsize 1 here | ||
237 | */ | ||
238 | fpsize = 1; | ||
239 | allocl = 2; | ||
240 | } else { | ||
241 | /* account for '/' and path size minus terminal 0 | ||
242 | * already in 'l' | ||
243 | */ | ||
244 | fpsize += l; | ||
245 | allocl = fpsize; | ||
246 | } | ||
247 | } | ||
248 | |||
249 | np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl, | ||
250 | __alignof__(struct device_node)); | ||
251 | if (allnextpp) { | ||
252 | memset(np, 0, sizeof(*np)); | ||
253 | np->full_name = ((char *)np) + sizeof(struct device_node); | ||
254 | if (new_format) { | ||
255 | char *fn = np->full_name; | ||
256 | /* rebuild full path for new format */ | ||
257 | if (dad && dad->parent) { | ||
258 | strcpy(fn, dad->full_name); | ||
259 | #ifdef DEBUG | ||
260 | if ((strlen(fn) + l + 1) != allocl) { | ||
261 | pr_debug("%s: p: %d, l: %d, a: %d\n", | ||
262 | pathp, (int)strlen(fn), | ||
263 | l, allocl); | ||
264 | } | ||
265 | #endif | ||
266 | fn += strlen(fn); | ||
267 | } | ||
268 | *(fn++) = '/'; | ||
269 | memcpy(fn, pathp, l); | ||
270 | } else | ||
271 | memcpy(np->full_name, pathp, l); | ||
272 | prev_pp = &np->properties; | ||
273 | **allnextpp = np; | ||
274 | *allnextpp = &np->allnext; | ||
275 | if (dad != NULL) { | ||
276 | np->parent = dad; | ||
277 | /* we temporarily use the next field as `last_child'*/ | ||
278 | if (dad->next == NULL) | ||
279 | dad->child = np; | ||
280 | else | ||
281 | dad->next->sibling = np; | ||
282 | dad->next = np; | ||
283 | } | ||
284 | kref_init(&np->kref); | ||
285 | } | ||
286 | while (1) { | ||
287 | u32 sz, noff; | ||
288 | char *pname; | ||
289 | |||
290 | tag = be32_to_cpup((__be32 *)(*p)); | ||
291 | if (tag == OF_DT_NOP) { | ||
292 | *p += 4; | ||
293 | continue; | ||
294 | } | ||
295 | if (tag != OF_DT_PROP) | ||
296 | break; | ||
297 | *p += 4; | ||
298 | sz = be32_to_cpup((__be32 *)(*p)); | ||
299 | noff = be32_to_cpup((__be32 *)((*p) + 4)); | ||
300 | *p += 8; | ||
301 | if (be32_to_cpu(initial_boot_params->version) < 0x10) | ||
302 | *p = _ALIGN(*p, sz >= 8 ? 8 : 4); | ||
303 | |||
304 | pname = find_flat_dt_string(noff); | ||
305 | if (pname == NULL) { | ||
306 | pr_info("Can't find property name in list !\n"); | ||
307 | break; | ||
308 | } | ||
309 | if (strcmp(pname, "name") == 0) | ||
310 | has_name = 1; | ||
311 | l = strlen(pname) + 1; | ||
312 | pp = unflatten_dt_alloc(&mem, sizeof(struct property), | ||
313 | __alignof__(struct property)); | ||
314 | if (allnextpp) { | ||
315 | /* We accept flattened tree phandles either in | ||
316 | * ePAPR-style "phandle" properties, or the | ||
317 | * legacy "linux,phandle" properties. If both | ||
318 | * appear and have different values, things | ||
319 | * will get weird. Don't do that. */ | ||
320 | if ((strcmp(pname, "phandle") == 0) || | ||
321 | (strcmp(pname, "linux,phandle") == 0)) { | ||
322 | if (np->phandle == 0) | ||
323 | np->phandle = *((u32 *)*p); | ||
324 | } | ||
325 | /* And we process the "ibm,phandle" property | ||
326 | * used in pSeries dynamic device tree | ||
327 | * stuff */ | ||
328 | if (strcmp(pname, "ibm,phandle") == 0) | ||
329 | np->phandle = *((u32 *)*p); | ||
330 | pp->name = pname; | ||
331 | pp->length = sz; | ||
332 | pp->value = (void *)*p; | ||
333 | *prev_pp = pp; | ||
334 | prev_pp = &pp->next; | ||
335 | } | ||
336 | *p = _ALIGN((*p) + sz, 4); | ||
337 | } | ||
338 | /* with version 0x10 we may not have the name property, recreate | ||
339 | * it here from the unit name if absent | ||
340 | */ | ||
341 | if (!has_name) { | ||
342 | char *p1 = pathp, *ps = pathp, *pa = NULL; | ||
343 | int sz; | ||
344 | |||
345 | while (*p1) { | ||
346 | if ((*p1) == '@') | ||
347 | pa = p1; | ||
348 | if ((*p1) == '/') | ||
349 | ps = p1 + 1; | ||
350 | p1++; | ||
351 | } | ||
352 | if (pa < ps) | ||
353 | pa = p1; | ||
354 | sz = (pa - ps) + 1; | ||
355 | pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz, | ||
356 | __alignof__(struct property)); | ||
357 | if (allnextpp) { | ||
358 | pp->name = "name"; | ||
359 | pp->length = sz; | ||
360 | pp->value = pp + 1; | ||
361 | *prev_pp = pp; | ||
362 | prev_pp = &pp->next; | ||
363 | memcpy(pp->value, ps, sz - 1); | ||
364 | ((char *)pp->value)[sz - 1] = 0; | ||
365 | pr_debug("fixed up name for %s -> %s\n", pathp, | ||
366 | (char *)pp->value); | ||
367 | } | ||
368 | } | ||
369 | if (allnextpp) { | ||
370 | *prev_pp = NULL; | ||
371 | np->name = of_get_property(np, "name", NULL); | ||
372 | np->type = of_get_property(np, "device_type", NULL); | ||
373 | |||
374 | if (!np->name) | ||
375 | np->name = "<NULL>"; | ||
376 | if (!np->type) | ||
377 | np->type = "<NULL>"; | ||
378 | } | ||
379 | while (tag == OF_DT_BEGIN_NODE) { | ||
380 | mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize); | ||
381 | tag = be32_to_cpup((__be32 *)(*p)); | ||
382 | } | ||
383 | if (tag != OF_DT_END_NODE) { | ||
384 | pr_err("Weird tag at end of node: %x\n", tag); | ||
385 | return mem; | ||
386 | } | ||
387 | *p += 4; | ||
388 | return mem; | ||
389 | } | ||
390 | |||
391 | #ifdef CONFIG_BLK_DEV_INITRD | ||
392 | /** | ||
393 | * early_init_dt_check_for_initrd - Decode initrd location from flat tree | ||
394 | * @node: reference to node containing initrd location ('chosen') | ||
395 | */ | ||
396 | void __init early_init_dt_check_for_initrd(unsigned long node) | ||
397 | { | ||
398 | unsigned long start, end, len; | ||
399 | __be32 *prop; | ||
400 | |||
401 | pr_debug("Looking for initrd properties... "); | ||
402 | |||
403 | prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len); | ||
404 | if (!prop) | ||
405 | return; | ||
406 | start = of_read_ulong(prop, len/4); | ||
407 | |||
408 | prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len); | ||
409 | if (!prop) | ||
410 | return; | ||
411 | end = of_read_ulong(prop, len/4); | ||
412 | |||
413 | early_init_dt_setup_initrd_arch(start, end); | ||
414 | pr_debug("initrd_start=0x%lx initrd_end=0x%lx\n", start, end); | ||
415 | } | ||
416 | #else | ||
417 | inline void early_init_dt_check_for_initrd(unsigned long node) | ||
418 | { | ||
419 | } | ||
420 | #endif /* CONFIG_BLK_DEV_INITRD */ | ||
421 | |||
422 | /** | ||
423 | * early_init_dt_scan_root - fetch the top level address and size cells | ||
424 | */ | ||
425 | int __init early_init_dt_scan_root(unsigned long node, const char *uname, | ||
426 | int depth, void *data) | ||
427 | { | ||
428 | __be32 *prop; | ||
429 | |||
430 | if (depth != 0) | ||
431 | return 0; | ||
432 | |||
433 | dt_root_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; | ||
434 | dt_root_addr_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; | ||
435 | |||
436 | prop = of_get_flat_dt_prop(node, "#size-cells", NULL); | ||
437 | if (prop) | ||
438 | dt_root_size_cells = be32_to_cpup(prop); | ||
439 | pr_debug("dt_root_size_cells = %x\n", dt_root_size_cells); | ||
440 | |||
441 | prop = of_get_flat_dt_prop(node, "#address-cells", NULL); | ||
442 | if (prop) | ||
443 | dt_root_addr_cells = be32_to_cpup(prop); | ||
444 | pr_debug("dt_root_addr_cells = %x\n", dt_root_addr_cells); | ||
445 | |||
446 | /* break now */ | ||
447 | return 1; | ||
448 | } | ||
449 | |||
450 | u64 __init dt_mem_next_cell(int s, __be32 **cellp) | ||
451 | { | ||
452 | __be32 *p = *cellp; | ||
453 | |||
454 | *cellp = p + s; | ||
455 | return of_read_number(p, s); | ||
456 | } | ||
457 | |||
458 | /** | ||
459 | * early_init_dt_scan_memory - Look for an parse memory nodes | ||
460 | */ | ||
461 | int __init early_init_dt_scan_memory(unsigned long node, const char *uname, | ||
462 | int depth, void *data) | ||
463 | { | ||
464 | char *type = of_get_flat_dt_prop(node, "device_type", NULL); | ||
465 | __be32 *reg, *endp; | ||
466 | unsigned long l; | ||
467 | |||
468 | /* We are scanning "memory" nodes only */ | ||
469 | if (type == NULL) { | ||
470 | /* | ||
471 | * The longtrail doesn't have a device_type on the | ||
472 | * /memory node, so look for the node called /memory@0. | ||
473 | */ | ||
474 | if (depth != 1 || strcmp(uname, "memory@0") != 0) | ||
475 | return 0; | ||
476 | } else if (strcmp(type, "memory") != 0) | ||
477 | return 0; | ||
478 | |||
479 | reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); | ||
480 | if (reg == NULL) | ||
481 | reg = of_get_flat_dt_prop(node, "reg", &l); | ||
482 | if (reg == NULL) | ||
483 | return 0; | ||
484 | |||
485 | endp = reg + (l / sizeof(__be32)); | ||
486 | |||
487 | pr_debug("memory scan node %s, reg size %ld, data: %x %x %x %x,\n", | ||
488 | uname, l, reg[0], reg[1], reg[2], reg[3]); | ||
489 | |||
490 | while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { | ||
491 | u64 base, size; | ||
492 | |||
493 | base = dt_mem_next_cell(dt_root_addr_cells, ®); | ||
494 | size = dt_mem_next_cell(dt_root_size_cells, ®); | ||
495 | |||
496 | if (size == 0) | ||
497 | continue; | ||
498 | pr_debug(" - %llx , %llx\n", (unsigned long long)base, | ||
499 | (unsigned long long)size); | ||
500 | |||
501 | early_init_dt_add_memory_arch(base, size); | ||
502 | } | ||
503 | |||
504 | return 0; | ||
505 | } | ||
506 | |||
507 | int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, | ||
508 | int depth, void *data) | ||
509 | { | ||
510 | unsigned long l; | ||
511 | char *p; | ||
512 | |||
513 | pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname); | ||
514 | |||
515 | if (depth != 1 || | ||
516 | (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) | ||
517 | return 0; | ||
518 | |||
519 | early_init_dt_check_for_initrd(node); | ||
520 | |||
521 | /* Retreive command line */ | ||
522 | p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
523 | if (p != NULL && l > 0) | ||
524 | strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE)); | ||
525 | |||
526 | #ifdef CONFIG_CMDLINE | ||
527 | #ifndef CONFIG_CMDLINE_FORCE | ||
528 | if (p == NULL || l == 0 || (l == 1 && (*p) == 0)) | ||
529 | #endif | ||
530 | strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); | ||
531 | #endif /* CONFIG_CMDLINE */ | ||
532 | |||
533 | early_init_dt_scan_chosen_arch(node); | ||
534 | |||
535 | pr_debug("Command line is: %s\n", cmd_line); | ||
536 | |||
537 | /* break now */ | ||
538 | return 1; | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * unflatten_device_tree - create tree of device_nodes from flat blob | ||
543 | * | ||
544 | * unflattens the device-tree passed by the firmware, creating the | ||
545 | * tree of struct device_node. It also fills the "name" and "type" | ||
546 | * pointers of the nodes so the normal device-tree walking functions | ||
547 | * can be used. | ||
548 | */ | ||
549 | void __init unflatten_device_tree(void) | ||
550 | { | ||
551 | unsigned long start, mem, size; | ||
552 | struct device_node **allnextp = &allnodes; | ||
553 | |||
554 | pr_debug(" -> unflatten_device_tree()\n"); | ||
555 | |||
556 | /* First pass, scan for size */ | ||
557 | start = ((unsigned long)initial_boot_params) + | ||
558 | be32_to_cpu(initial_boot_params->off_dt_struct); | ||
559 | size = unflatten_dt_node(0, &start, NULL, NULL, 0); | ||
560 | size = (size | 3) + 1; | ||
561 | |||
562 | pr_debug(" size is %lx, allocating...\n", size); | ||
563 | |||
564 | /* Allocate memory for the expanded device tree */ | ||
565 | mem = early_init_dt_alloc_memory_arch(size + 4, | ||
566 | __alignof__(struct device_node)); | ||
567 | mem = (unsigned long) __va(mem); | ||
568 | |||
569 | ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef); | ||
570 | |||
571 | pr_debug(" unflattening %lx...\n", mem); | ||
572 | |||
573 | /* Second pass, do actual unflattening */ | ||
574 | start = ((unsigned long)initial_boot_params) + | ||
575 | be32_to_cpu(initial_boot_params->off_dt_struct); | ||
576 | unflatten_dt_node(mem, &start, NULL, &allnextp, 0); | ||
577 | if (be32_to_cpup((__be32 *)start) != OF_DT_END) | ||
578 | pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start)); | ||
579 | if (be32_to_cpu(((__be32 *)mem)[size / 4]) != 0xdeadbeef) | ||
580 | pr_warning("End of tree marker overwritten: %08x\n", | ||
581 | be32_to_cpu(((__be32 *)mem)[size / 4])); | ||
582 | *allnextp = NULL; | ||
583 | |||
584 | /* Get pointer to OF "/chosen" node for use everywhere */ | ||
585 | of_chosen = of_find_node_by_path("/chosen"); | ||
586 | if (of_chosen == NULL) | ||
587 | of_chosen = of_find_node_by_path("/chosen@0"); | ||
588 | |||
589 | pr_debug(" <- unflatten_device_tree()\n"); | ||
590 | } | ||
diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c index 6eea601a9204..24c3606217f8 100644 --- a/drivers/of/gpio.c +++ b/drivers/of/gpio.c | |||
@@ -36,7 +36,7 @@ int of_get_gpio_flags(struct device_node *np, int index, | |||
36 | struct of_gpio_chip *of_gc = NULL; | 36 | struct of_gpio_chip *of_gc = NULL; |
37 | int size; | 37 | int size; |
38 | const void *gpio_spec; | 38 | const void *gpio_spec; |
39 | const u32 *gpio_cells; | 39 | const __be32 *gpio_cells; |
40 | 40 | ||
41 | ret = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, | 41 | ret = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, |
42 | &gc, &gpio_spec); | 42 | &gc, &gpio_spec); |
@@ -55,7 +55,7 @@ int of_get_gpio_flags(struct device_node *np, int index, | |||
55 | 55 | ||
56 | gpio_cells = of_get_property(gc, "#gpio-cells", &size); | 56 | gpio_cells = of_get_property(gc, "#gpio-cells", &size); |
57 | if (!gpio_cells || size != sizeof(*gpio_cells) || | 57 | if (!gpio_cells || size != sizeof(*gpio_cells) || |
58 | *gpio_cells != of_gc->gpio_cells) { | 58 | be32_to_cpup(gpio_cells) != of_gc->gpio_cells) { |
59 | pr_debug("%s: wrong #gpio-cells for %s\n", | 59 | pr_debug("%s: wrong #gpio-cells for %s\n", |
60 | np->full_name, gc->full_name); | 60 | np->full_name, gc->full_name); |
61 | ret = -EINVAL; | 61 | ret = -EINVAL; |
@@ -127,7 +127,8 @@ EXPORT_SYMBOL(of_gpio_count); | |||
127 | int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np, | 127 | int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np, |
128 | const void *gpio_spec, enum of_gpio_flags *flags) | 128 | const void *gpio_spec, enum of_gpio_flags *flags) |
129 | { | 129 | { |
130 | const u32 *gpio = gpio_spec; | 130 | const __be32 *gpio = gpio_spec; |
131 | const u32 n = be32_to_cpup(gpio); | ||
131 | 132 | ||
132 | /* | 133 | /* |
133 | * We're discouraging gpio_cells < 2, since that way you'll have to | 134 | * We're discouraging gpio_cells < 2, since that way you'll have to |
@@ -140,13 +141,13 @@ int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np, | |||
140 | return -EINVAL; | 141 | return -EINVAL; |
141 | } | 142 | } |
142 | 143 | ||
143 | if (*gpio > of_gc->gc.ngpio) | 144 | if (n > of_gc->gc.ngpio) |
144 | return -EINVAL; | 145 | return -EINVAL; |
145 | 146 | ||
146 | if (flags) | 147 | if (flags) |
147 | *flags = gpio[1]; | 148 | *flags = be32_to_cpu(gpio[1]); |
148 | 149 | ||
149 | return *gpio; | 150 | return n; |
150 | } | 151 | } |
151 | EXPORT_SYMBOL(of_gpio_simple_xlate); | 152 | EXPORT_SYMBOL(of_gpio_simple_xlate); |
152 | 153 | ||
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c index fa65a2b2ae2e..a3a708e590d0 100644 --- a/drivers/of/of_i2c.c +++ b/drivers/of/of_i2c.c | |||
@@ -25,7 +25,7 @@ void of_register_i2c_devices(struct i2c_adapter *adap, | |||
25 | for_each_child_of_node(adap_node, node) { | 25 | for_each_child_of_node(adap_node, node) { |
26 | struct i2c_board_info info = {}; | 26 | struct i2c_board_info info = {}; |
27 | struct dev_archdata dev_ad = {}; | 27 | struct dev_archdata dev_ad = {}; |
28 | const u32 *addr; | 28 | const __be32 *addr; |
29 | int len; | 29 | int len; |
30 | 30 | ||
31 | if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) | 31 | if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) |
@@ -40,7 +40,7 @@ void of_register_i2c_devices(struct i2c_adapter *adap, | |||
40 | 40 | ||
41 | info.irq = irq_of_parse_and_map(node, 0); | 41 | info.irq = irq_of_parse_and_map(node, 0); |
42 | 42 | ||
43 | info.addr = *addr; | 43 | info.addr = be32_to_cpup(addr); |
44 | 44 | ||
45 | dev_archdata_set_node(&dev_ad, node); | 45 | dev_archdata_set_node(&dev_ad, node); |
46 | info.archdata = &dev_ad; | 46 | info.archdata = &dev_ad; |
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 4b22ba568b19..18ecae4a4375 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c | |||
@@ -51,7 +51,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) | |||
51 | 51 | ||
52 | /* Loop over the child nodes and register a phy_device for each one */ | 52 | /* Loop over the child nodes and register a phy_device for each one */ |
53 | for_each_child_of_node(np, child) { | 53 | for_each_child_of_node(np, child) { |
54 | const u32 *addr; | 54 | const __be32 *addr; |
55 | int len; | 55 | int len; |
56 | 56 | ||
57 | /* A PHY must have a reg property in the range [0-31] */ | 57 | /* A PHY must have a reg property in the range [0-31] */ |
@@ -68,7 +68,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) | |||
68 | mdio->irq[*addr] = PHY_POLL; | 68 | mdio->irq[*addr] = PHY_POLL; |
69 | } | 69 | } |
70 | 70 | ||
71 | phy = get_phy_device(mdio, *addr); | 71 | phy = get_phy_device(mdio, be32_to_cpup(addr)); |
72 | if (!phy) { | 72 | if (!phy) { |
73 | dev_err(&mdio->dev, "error probing PHY at address %i\n", | 73 | dev_err(&mdio->dev, "error probing PHY at address %i\n", |
74 | *addr); | 74 | *addr); |
@@ -160,7 +160,7 @@ struct phy_device *of_phy_connect_fixed_link(struct net_device *dev, | |||
160 | struct device_node *net_np; | 160 | struct device_node *net_np; |
161 | char bus_id[MII_BUS_ID_SIZE + 3]; | 161 | char bus_id[MII_BUS_ID_SIZE + 3]; |
162 | struct phy_device *phy; | 162 | struct phy_device *phy; |
163 | const u32 *phy_id; | 163 | const __be32 *phy_id; |
164 | int sz; | 164 | int sz; |
165 | 165 | ||
166 | if (!dev->dev.parent) | 166 | if (!dev->dev.parent) |
@@ -174,7 +174,7 @@ struct phy_device *of_phy_connect_fixed_link(struct net_device *dev, | |||
174 | if (!phy_id || sz < sizeof(*phy_id)) | 174 | if (!phy_id || sz < sizeof(*phy_id)) |
175 | return NULL; | 175 | return NULL; |
176 | 176 | ||
177 | sprintf(bus_id, PHY_ID_FMT, "0", phy_id[0]); | 177 | sprintf(bus_id, PHY_ID_FMT, "0", be32_to_cpu(phy_id[0])); |
178 | 178 | ||
179 | phy = phy_connect(dev, bus_id, hndlr, 0, iface); | 179 | phy = phy_connect(dev, bus_id, hndlr, 0, iface); |
180 | return IS_ERR(phy) ? NULL : phy; | 180 | return IS_ERR(phy) ? NULL : phy; |
diff --git a/drivers/of/of_spi.c b/drivers/of/of_spi.c index bed0ed6dcdc1..f65f48b98448 100644 --- a/drivers/of/of_spi.c +++ b/drivers/of/of_spi.c | |||
@@ -23,7 +23,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np) | |||
23 | { | 23 | { |
24 | struct spi_device *spi; | 24 | struct spi_device *spi; |
25 | struct device_node *nc; | 25 | struct device_node *nc; |
26 | const u32 *prop; | 26 | const __be32 *prop; |
27 | int rc; | 27 | int rc; |
28 | int len; | 28 | int len; |
29 | 29 | ||
@@ -54,7 +54,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np) | |||
54 | spi_dev_put(spi); | 54 | spi_dev_put(spi); |
55 | continue; | 55 | continue; |
56 | } | 56 | } |
57 | spi->chip_select = *prop; | 57 | spi->chip_select = be32_to_cpup(prop); |
58 | 58 | ||
59 | /* Mode (clock phase/polarity/etc.) */ | 59 | /* Mode (clock phase/polarity/etc.) */ |
60 | if (of_find_property(nc, "spi-cpha", NULL)) | 60 | if (of_find_property(nc, "spi-cpha", NULL)) |
@@ -72,7 +72,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np) | |||
72 | spi_dev_put(spi); | 72 | spi_dev_put(spi); |
73 | continue; | 73 | continue; |
74 | } | 74 | } |
75 | spi->max_speed_hz = *prop; | 75 | spi->max_speed_hz = be32_to_cpup(prop); |
76 | 76 | ||
77 | /* IRQ */ | 77 | /* IRQ */ |
78 | spi->irq = irq_of_parse_and_map(nc, 0); | 78 | spi->irq = irq_of_parse_and_map(nc, 0); |
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c index 75ac19b1192f..fc2f676e984d 100644 --- a/drivers/sbus/char/openprom.c +++ b/drivers/sbus/char/openprom.c | |||
@@ -233,7 +233,7 @@ static int opromnext(void __user *argp, unsigned int cmd, struct device_node *dp | |||
233 | 233 | ||
234 | ph = 0; | 234 | ph = 0; |
235 | if (dp) | 235 | if (dp) |
236 | ph = dp->node; | 236 | ph = dp->phandle; |
237 | 237 | ||
238 | data->current_node = dp; | 238 | data->current_node = dp; |
239 | *((int *) op->oprom_array) = ph; | 239 | *((int *) op->oprom_array) = ph; |
@@ -256,7 +256,7 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp | |||
256 | 256 | ||
257 | dp = pci_device_to_OF_node(pdev); | 257 | dp = pci_device_to_OF_node(pdev); |
258 | data->current_node = dp; | 258 | data->current_node = dp; |
259 | *((int *)op->oprom_array) = dp->node; | 259 | *((int *)op->oprom_array) = dp->phandle; |
260 | op->oprom_size = sizeof(int); | 260 | op->oprom_size = sizeof(int); |
261 | err = copyout(argp, op, bufsize + sizeof(int)); | 261 | err = copyout(argp, op, bufsize + sizeof(int)); |
262 | 262 | ||
@@ -273,7 +273,7 @@ static int oprompath2node(void __user *argp, struct device_node *dp, struct open | |||
273 | 273 | ||
274 | dp = of_find_node_by_path(op->oprom_array); | 274 | dp = of_find_node_by_path(op->oprom_array); |
275 | if (dp) | 275 | if (dp) |
276 | ph = dp->node; | 276 | ph = dp->phandle; |
277 | data->current_node = dp; | 277 | data->current_node = dp; |
278 | *((int *)op->oprom_array) = ph; | 278 | *((int *)op->oprom_array) = ph; |
279 | op->oprom_size = sizeof(int); | 279 | op->oprom_size = sizeof(int); |
@@ -540,7 +540,7 @@ static int opiocgetnext(unsigned int cmd, void __user *argp) | |||
540 | } | 540 | } |
541 | } | 541 | } |
542 | if (dp) | 542 | if (dp) |
543 | nd = dp->node; | 543 | nd = dp->phandle; |
544 | if (copy_to_user(argp, &nd, sizeof(phandle))) | 544 | if (copy_to_user(argp, &nd, sizeof(phandle))) |
545 | return -EFAULT; | 545 | return -EFAULT; |
546 | 546 | ||
@@ -570,7 +570,7 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file, | |||
570 | case OPIOCGETOPTNODE: | 570 | case OPIOCGETOPTNODE: |
571 | BUILD_BUG_ON(sizeof(phandle) != sizeof(int)); | 571 | BUILD_BUG_ON(sizeof(phandle) != sizeof(int)); |
572 | 572 | ||
573 | if (copy_to_user(argp, &options_node->node, sizeof(phandle))) | 573 | if (copy_to_user(argp, &options_node->phandle, sizeof(phandle))) |
574 | return -EFAULT; | 574 | return -EFAULT; |
575 | 575 | ||
576 | return 0; | 576 | return 0; |
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c index 683e66f18e8c..3e2ae4807ae2 100644 --- a/drivers/serial/pmac_zilog.c +++ b/drivers/serial/pmac_zilog.c | |||
@@ -2031,9 +2031,9 @@ static int __init pmz_console_setup(struct console *co, char *options) | |||
2031 | /* | 2031 | /* |
2032 | * XServe's default to 57600 bps | 2032 | * XServe's default to 57600 bps |
2033 | */ | 2033 | */ |
2034 | if (machine_is_compatible("RackMac1,1") | 2034 | if (of_machine_is_compatible("RackMac1,1") |
2035 | || machine_is_compatible("RackMac1,2") | 2035 | || of_machine_is_compatible("RackMac1,2") |
2036 | || machine_is_compatible("MacRISC4")) | 2036 | || of_machine_is_compatible("MacRISC4")) |
2037 | baud = 57600; | 2037 | baud = 57600; |
2038 | 2038 | ||
2039 | /* | 2039 | /* |
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c index e4e4d433b007..9ee67d6da710 100644 --- a/drivers/video/aty/aty128fb.c +++ b/drivers/video/aty/aty128fb.c | |||
@@ -1931,22 +1931,22 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i | |||
1931 | * PowerMac2,2 summer 2000 iMacs | 1931 | * PowerMac2,2 summer 2000 iMacs |
1932 | * PowerMac4,1 january 2001 iMacs "flower power" | 1932 | * PowerMac4,1 january 2001 iMacs "flower power" |
1933 | */ | 1933 | */ |
1934 | if (machine_is_compatible("PowerMac2,1") || | 1934 | if (of_machine_is_compatible("PowerMac2,1") || |
1935 | machine_is_compatible("PowerMac2,2") || | 1935 | of_machine_is_compatible("PowerMac2,2") || |
1936 | machine_is_compatible("PowerMac4,1")) | 1936 | of_machine_is_compatible("PowerMac4,1")) |
1937 | default_vmode = VMODE_1024_768_75; | 1937 | default_vmode = VMODE_1024_768_75; |
1938 | 1938 | ||
1939 | /* iBook SE */ | 1939 | /* iBook SE */ |
1940 | if (machine_is_compatible("PowerBook2,2")) | 1940 | if (of_machine_is_compatible("PowerBook2,2")) |
1941 | default_vmode = VMODE_800_600_60; | 1941 | default_vmode = VMODE_800_600_60; |
1942 | 1942 | ||
1943 | /* PowerBook Firewire (Pismo), iBook Dual USB */ | 1943 | /* PowerBook Firewire (Pismo), iBook Dual USB */ |
1944 | if (machine_is_compatible("PowerBook3,1") || | 1944 | if (of_machine_is_compatible("PowerBook3,1") || |
1945 | machine_is_compatible("PowerBook4,1")) | 1945 | of_machine_is_compatible("PowerBook4,1")) |
1946 | default_vmode = VMODE_1024_768_60; | 1946 | default_vmode = VMODE_1024_768_60; |
1947 | 1947 | ||
1948 | /* PowerBook Titanium */ | 1948 | /* PowerBook Titanium */ |
1949 | if (machine_is_compatible("PowerBook3,2")) | 1949 | if (of_machine_is_compatible("PowerBook3,2")) |
1950 | default_vmode = VMODE_1152_768_60; | 1950 | default_vmode = VMODE_1152_768_60; |
1951 | 1951 | ||
1952 | if (default_cmode > 16) | 1952 | if (default_cmode > 16) |
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index 1ddeb4c34763..e45ab8db2ddc 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c | |||
@@ -2439,7 +2439,7 @@ static int __devinit aty_init(struct fb_info *info) | |||
2439 | * The Apple iBook1 uses non-standard memory frequencies. | 2439 | * The Apple iBook1 uses non-standard memory frequencies. |
2440 | * We detect it and set the frequency manually. | 2440 | * We detect it and set the frequency manually. |
2441 | */ | 2441 | */ |
2442 | if (machine_is_compatible("PowerBook2,1")) { | 2442 | if (of_machine_is_compatible("PowerBook2,1")) { |
2443 | par->pll_limits.mclk = 70; | 2443 | par->pll_limits.mclk = 70; |
2444 | par->pll_limits.xclk = 53; | 2444 | par->pll_limits.xclk = 53; |
2445 | } | 2445 | } |
@@ -2659,7 +2659,7 @@ static int __devinit aty_init(struct fb_info *info) | |||
2659 | FBINFO_HWACCEL_YPAN; | 2659 | FBINFO_HWACCEL_YPAN; |
2660 | 2660 | ||
2661 | #ifdef CONFIG_PMAC_BACKLIGHT | 2661 | #ifdef CONFIG_PMAC_BACKLIGHT |
2662 | if (M64_HAS(G3_PB_1_1) && machine_is_compatible("PowerBook1,1")) { | 2662 | if (M64_HAS(G3_PB_1_1) && of_machine_is_compatible("PowerBook1,1")) { |
2663 | /* | 2663 | /* |
2664 | * these bits let the 101 powerbook | 2664 | * these bits let the 101 powerbook |
2665 | * wake up from sleep -- paulus | 2665 | * wake up from sleep -- paulus |
@@ -2690,9 +2690,9 @@ static int __devinit aty_init(struct fb_info *info) | |||
2690 | if (M64_HAS(G3_PB_1024x768)) | 2690 | if (M64_HAS(G3_PB_1024x768)) |
2691 | /* G3 PowerBook with 1024x768 LCD */ | 2691 | /* G3 PowerBook with 1024x768 LCD */ |
2692 | default_vmode = VMODE_1024_768_60; | 2692 | default_vmode = VMODE_1024_768_60; |
2693 | else if (machine_is_compatible("iMac")) | 2693 | else if (of_machine_is_compatible("iMac")) |
2694 | default_vmode = VMODE_1024_768_75; | 2694 | default_vmode = VMODE_1024_768_75; |
2695 | else if (machine_is_compatible("PowerBook2,1")) | 2695 | else if (of_machine_is_compatible("PowerBook2,1")) |
2696 | /* iBook with 800x600 LCD */ | 2696 | /* iBook with 800x600 LCD */ |
2697 | default_vmode = VMODE_800_600_60; | 2697 | default_vmode = VMODE_800_600_60; |
2698 | else | 2698 | else |
@@ -3104,7 +3104,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, | |||
3104 | } | 3104 | } |
3105 | 3105 | ||
3106 | dp = pci_device_to_OF_node(pdev); | 3106 | dp = pci_device_to_OF_node(pdev); |
3107 | if (node == dp->node) { | 3107 | if (node == dp->phandle) { |
3108 | struct fb_var_screeninfo *var = &default_var; | 3108 | struct fb_var_screeninfo *var = &default_var; |
3109 | unsigned int N, P, Q, M, T, R; | 3109 | unsigned int N, P, Q, M, T, R; |
3110 | u32 v_total, h_total; | 3110 | u32 v_total, h_total; |
diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c index 1a056adb61c8..fa1198c4ccc5 100644 --- a/drivers/video/aty/radeon_backlight.c +++ b/drivers/video/aty/radeon_backlight.c | |||
@@ -175,9 +175,9 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo) | |||
175 | 175 | ||
176 | #ifdef CONFIG_PMAC_BACKLIGHT | 176 | #ifdef CONFIG_PMAC_BACKLIGHT |
177 | pdata->negative = pdata->negative || | 177 | pdata->negative = pdata->negative || |
178 | machine_is_compatible("PowerBook4,3") || | 178 | of_machine_is_compatible("PowerBook4,3") || |
179 | machine_is_compatible("PowerBook6,3") || | 179 | of_machine_is_compatible("PowerBook6,3") || |
180 | machine_is_compatible("PowerBook6,5"); | 180 | of_machine_is_compatible("PowerBook6,5"); |
181 | #endif | 181 | #endif |
182 | 182 | ||
183 | rinfo->info->bl_dev = bd; | 183 | rinfo->info->bl_dev = bd; |
diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c index 123257bb356b..f8650dce74fb 100644 --- a/fs/proc/proc_devtree.c +++ b/fs/proc/proc_devtree.c | |||
@@ -10,16 +10,19 @@ | |||
10 | #include <linux/seq_file.h> | 10 | #include <linux/seq_file.h> |
11 | #include <linux/stat.h> | 11 | #include <linux/stat.h> |
12 | #include <linux/string.h> | 12 | #include <linux/string.h> |
13 | #include <linux/of.h> | ||
14 | #include <linux/module.h> | ||
13 | #include <asm/prom.h> | 15 | #include <asm/prom.h> |
14 | #include <asm/uaccess.h> | 16 | #include <asm/uaccess.h> |
15 | #include "internal.h" | 17 | #include "internal.h" |
16 | 18 | ||
17 | #ifndef HAVE_ARCH_DEVTREE_FIXUPS | ||
18 | static inline void set_node_proc_entry(struct device_node *np, | 19 | static inline void set_node_proc_entry(struct device_node *np, |
19 | struct proc_dir_entry *de) | 20 | struct proc_dir_entry *de) |
20 | { | 21 | { |
21 | } | 22 | #ifdef HAVE_ARCH_DEVTREE_FIXUPS |
23 | np->pde = de; | ||
22 | #endif | 24 | #endif |
25 | } | ||
23 | 26 | ||
24 | static struct proc_dir_entry *proc_device_tree; | 27 | static struct proc_dir_entry *proc_device_tree; |
25 | 28 | ||
diff --git a/include/linux/of.h b/include/linux/of.h index e7facd8fbce8..f6d9cbc39c9c 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
@@ -19,6 +19,11 @@ | |||
19 | #include <linux/bitops.h> | 19 | #include <linux/bitops.h> |
20 | #include <linux/kref.h> | 20 | #include <linux/kref.h> |
21 | #include <linux/mod_devicetable.h> | 21 | #include <linux/mod_devicetable.h> |
22 | #include <linux/spinlock.h> | ||
23 | |||
24 | #include <asm/byteorder.h> | ||
25 | |||
26 | #ifdef CONFIG_OF | ||
22 | 27 | ||
23 | typedef u32 phandle; | 28 | typedef u32 phandle; |
24 | typedef u32 ihandle; | 29 | typedef u32 ihandle; |
@@ -39,10 +44,7 @@ struct of_irq_controller; | |||
39 | struct device_node { | 44 | struct device_node { |
40 | const char *name; | 45 | const char *name; |
41 | const char *type; | 46 | const char *type; |
42 | phandle node; | 47 | phandle phandle; |
43 | #if !defined(CONFIG_SPARC) | ||
44 | phandle linux_phandle; | ||
45 | #endif | ||
46 | char *full_name; | 48 | char *full_name; |
47 | 49 | ||
48 | struct property *properties; | 50 | struct property *properties; |
@@ -63,6 +65,11 @@ struct device_node { | |||
63 | #endif | 65 | #endif |
64 | }; | 66 | }; |
65 | 67 | ||
68 | /* Pointer for first entry in chain of all nodes. */ | ||
69 | extern struct device_node *allnodes; | ||
70 | extern struct device_node *of_chosen; | ||
71 | extern rwlock_t devtree_lock; | ||
72 | |||
66 | static inline int of_node_check_flag(struct device_node *n, unsigned long flag) | 73 | static inline int of_node_check_flag(struct device_node *n, unsigned long flag) |
67 | { | 74 | { |
68 | return test_bit(flag, &n->_flags); | 75 | return test_bit(flag, &n->_flags); |
@@ -73,12 +80,6 @@ static inline void of_node_set_flag(struct device_node *n, unsigned long flag) | |||
73 | set_bit(flag, &n->_flags); | 80 | set_bit(flag, &n->_flags); |
74 | } | 81 | } |
75 | 82 | ||
76 | static inline void | ||
77 | set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de) | ||
78 | { | ||
79 | dn->pde = de; | ||
80 | } | ||
81 | |||
82 | extern struct device_node *of_find_all_nodes(struct device_node *prev); | 83 | extern struct device_node *of_find_all_nodes(struct device_node *prev); |
83 | 84 | ||
84 | #if defined(CONFIG_SPARC) | 85 | #if defined(CONFIG_SPARC) |
@@ -101,26 +102,36 @@ extern void of_node_put(struct device_node *node); | |||
101 | */ | 102 | */ |
102 | 103 | ||
103 | /* Helper to read a big number; size is in cells (not bytes) */ | 104 | /* Helper to read a big number; size is in cells (not bytes) */ |
104 | static inline u64 of_read_number(const u32 *cell, int size) | 105 | static inline u64 of_read_number(const __be32 *cell, int size) |
105 | { | 106 | { |
106 | u64 r = 0; | 107 | u64 r = 0; |
107 | while (size--) | 108 | while (size--) |
108 | r = (r << 32) | *(cell++); | 109 | r = (r << 32) | be32_to_cpu(*(cell++)); |
109 | return r; | 110 | return r; |
110 | } | 111 | } |
111 | 112 | ||
112 | /* Like of_read_number, but we want an unsigned long result */ | 113 | /* Like of_read_number, but we want an unsigned long result */ |
113 | #ifdef CONFIG_PPC32 | 114 | static inline unsigned long of_read_ulong(const __be32 *cell, int size) |
114 | static inline unsigned long of_read_ulong(const u32 *cell, int size) | ||
115 | { | 115 | { |
116 | return cell[size-1]; | 116 | /* toss away upper bits if unsigned long is smaller than u64 */ |
117 | return of_read_number(cell, size); | ||
117 | } | 118 | } |
118 | #else | ||
119 | #define of_read_ulong(cell, size) of_read_number(cell, size) | ||
120 | #endif | ||
121 | 119 | ||
122 | #include <asm/prom.h> | 120 | #include <asm/prom.h> |
123 | 121 | ||
122 | /* Default #address and #size cells. Allow arch asm/prom.h to override */ | ||
123 | #if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT) | ||
124 | #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 | ||
125 | #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 | ||
126 | #endif | ||
127 | |||
128 | /* Default string compare functions, Allow arch asm/prom.h to override */ | ||
129 | #if !defined(of_compat_cmp) | ||
130 | #define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l)) | ||
131 | #define of_prop_cmp(s1, s2) strcmp((s1), (s2)) | ||
132 | #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) | ||
133 | #endif | ||
134 | |||
124 | /* flag descriptions */ | 135 | /* flag descriptions */ |
125 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ | 136 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ |
126 | #define OF_DETACHED 2 /* node has been detached from the device tree */ | 137 | #define OF_DETACHED 2 /* node has been detached from the device tree */ |
@@ -187,4 +198,19 @@ extern int of_parse_phandles_with_args(struct device_node *np, | |||
187 | const char *list_name, const char *cells_name, int index, | 198 | const char *list_name, const char *cells_name, int index, |
188 | struct device_node **out_node, const void **out_args); | 199 | struct device_node **out_node, const void **out_args); |
189 | 200 | ||
201 | extern int of_machine_is_compatible(const char *compat); | ||
202 | |||
203 | extern int prom_add_property(struct device_node* np, struct property* prop); | ||
204 | extern int prom_remove_property(struct device_node *np, struct property *prop); | ||
205 | extern int prom_update_property(struct device_node *np, | ||
206 | struct property *newprop, | ||
207 | struct property *oldprop); | ||
208 | |||
209 | #if defined(CONFIG_OF_DYNAMIC) | ||
210 | /* For updating the device tree at runtime */ | ||
211 | extern void of_attach_node(struct device_node *); | ||
212 | extern void of_detach_node(struct device_node *); | ||
213 | #endif | ||
214 | |||
215 | #endif /* CONFIG_OF */ | ||
190 | #endif /* _LINUX_OF_H */ | 216 | #endif /* _LINUX_OF_H */ |
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 41d432b13553..a1ca92ccb0ff 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h | |||
@@ -42,45 +42,62 @@ | |||
42 | * ends when size is 0 | 42 | * ends when size is 0 |
43 | */ | 43 | */ |
44 | struct boot_param_header { | 44 | struct boot_param_header { |
45 | u32 magic; /* magic word OF_DT_HEADER */ | 45 | __be32 magic; /* magic word OF_DT_HEADER */ |
46 | u32 totalsize; /* total size of DT block */ | 46 | __be32 totalsize; /* total size of DT block */ |
47 | u32 off_dt_struct; /* offset to structure */ | 47 | __be32 off_dt_struct; /* offset to structure */ |
48 | u32 off_dt_strings; /* offset to strings */ | 48 | __be32 off_dt_strings; /* offset to strings */ |
49 | u32 off_mem_rsvmap; /* offset to memory reserve map */ | 49 | __be32 off_mem_rsvmap; /* offset to memory reserve map */ |
50 | u32 version; /* format version */ | 50 | __be32 version; /* format version */ |
51 | u32 last_comp_version; /* last compatible version */ | 51 | __be32 last_comp_version; /* last compatible version */ |
52 | /* version 2 fields below */ | 52 | /* version 2 fields below */ |
53 | u32 boot_cpuid_phys; /* Physical CPU id we're booting on */ | 53 | __be32 boot_cpuid_phys; /* Physical CPU id we're booting on */ |
54 | /* version 3 fields below */ | 54 | /* version 3 fields below */ |
55 | u32 dt_strings_size; /* size of the DT strings block */ | 55 | __be32 dt_strings_size; /* size of the DT strings block */ |
56 | /* version 17 fields below */ | 56 | /* version 17 fields below */ |
57 | u32 dt_struct_size; /* size of the DT structure block */ | 57 | __be32 dt_struct_size; /* size of the DT structure block */ |
58 | }; | 58 | }; |
59 | 59 | ||
60 | /* TBD: Temporary export of fdt globals - remove when code fully merged */ | ||
61 | extern int __initdata dt_root_addr_cells; | ||
62 | extern int __initdata dt_root_size_cells; | ||
63 | extern struct boot_param_header *initial_boot_params; | ||
64 | |||
60 | /* For scanning the flat device-tree at boot time */ | 65 | /* For scanning the flat device-tree at boot time */ |
61 | extern int __init of_scan_flat_dt(int (*it)(unsigned long node, | 66 | extern char *find_flat_dt_string(u32 offset); |
62 | const char *uname, int depth, | 67 | extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname, |
63 | void *data), | 68 | int depth, void *data), |
64 | void *data); | 69 | void *data); |
65 | extern void __init *of_get_flat_dt_prop(unsigned long node, const char *name, | 70 | extern void *of_get_flat_dt_prop(unsigned long node, const char *name, |
66 | unsigned long *size); | 71 | unsigned long *size); |
67 | extern int __init of_flat_dt_is_compatible(unsigned long node, | 72 | extern int of_flat_dt_is_compatible(unsigned long node, const char *name); |
68 | const char *name); | 73 | extern unsigned long of_get_flat_dt_root(void); |
69 | extern unsigned long __init of_get_flat_dt_root(void); | 74 | extern void early_init_dt_scan_chosen_arch(unsigned long node); |
75 | extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, | ||
76 | int depth, void *data); | ||
77 | extern void early_init_dt_check_for_initrd(unsigned long node); | ||
78 | extern int early_init_dt_scan_memory(unsigned long node, const char *uname, | ||
79 | int depth, void *data); | ||
80 | extern void early_init_dt_add_memory_arch(u64 base, u64 size); | ||
81 | extern u64 early_init_dt_alloc_memory_arch(u64 size, u64 align); | ||
82 | extern u64 dt_mem_next_cell(int s, __be32 **cellp); | ||
83 | |||
84 | /* | ||
85 | * If BLK_DEV_INITRD, the fdt early init code will call this function, | ||
86 | * to be provided by the arch code. start and end are specified as | ||
87 | * physical addresses. | ||
88 | */ | ||
89 | #ifdef CONFIG_BLK_DEV_INITRD | ||
90 | extern void early_init_dt_setup_initrd_arch(unsigned long start, | ||
91 | unsigned long end); | ||
92 | #endif | ||
93 | |||
94 | /* Early flat tree scan hooks */ | ||
95 | extern int early_init_dt_scan_root(unsigned long node, const char *uname, | ||
96 | int depth, void *data); | ||
70 | 97 | ||
71 | /* Other Prototypes */ | 98 | /* Other Prototypes */ |
72 | extern void finish_device_tree(void); | ||
73 | extern void unflatten_device_tree(void); | 99 | extern void unflatten_device_tree(void); |
74 | extern void early_init_devtree(void *); | 100 | extern void early_init_devtree(void *); |
75 | extern int machine_is_compatible(const char *compat); | ||
76 | extern void print_properties(struct device_node *node); | ||
77 | extern int prom_n_intr_cells(struct device_node* np); | ||
78 | extern void prom_get_irq_senses(unsigned char *senses, int off, int max); | ||
79 | extern int prom_add_property(struct device_node* np, struct property* prop); | ||
80 | extern int prom_remove_property(struct device_node *np, struct property *prop); | ||
81 | extern int prom_update_property(struct device_node *np, | ||
82 | struct property *newprop, | ||
83 | struct property *oldprop); | ||
84 | 101 | ||
85 | #endif /* __ASSEMBLY__ */ | 102 | #endif /* __ASSEMBLY__ */ |
86 | #endif /* _LINUX_OF_FDT_H */ | 103 | #endif /* _LINUX_OF_FDT_H */ |
diff --git a/sound/aoa/fabrics/layout.c b/sound/aoa/fabrics/layout.c index 586965f9605f..7a437da05646 100644 --- a/sound/aoa/fabrics/layout.c +++ b/sound/aoa/fabrics/layout.c | |||
@@ -768,7 +768,7 @@ static int check_codec(struct aoa_codec *codec, | |||
768 | "required property %s not present\n", propname); | 768 | "required property %s not present\n", propname); |
769 | return -ENODEV; | 769 | return -ENODEV; |
770 | } | 770 | } |
771 | if (*ref != codec->node->linux_phandle) { | 771 | if (*ref != codec->node->phandle) { |
772 | printk(KERN_INFO "snd-aoa-fabric-layout: " | 772 | printk(KERN_INFO "snd-aoa-fabric-layout: " |
773 | "%s doesn't match!\n", propname); | 773 | "%s doesn't match!\n", propname); |
774 | return -ENODEV; | 774 | return -ENODEV; |
diff --git a/sound/ppc/awacs.c b/sound/ppc/awacs.c index 2e156467b814..b36679384b27 100644 --- a/sound/ppc/awacs.c +++ b/sound/ppc/awacs.c | |||
@@ -751,8 +751,8 @@ static void snd_pmac_awacs_suspend(struct snd_pmac *chip) | |||
751 | 751 | ||
752 | static void snd_pmac_awacs_resume(struct snd_pmac *chip) | 752 | static void snd_pmac_awacs_resume(struct snd_pmac *chip) |
753 | { | 753 | { |
754 | if (machine_is_compatible("PowerBook3,1") | 754 | if (of_machine_is_compatible("PowerBook3,1") |
755 | || machine_is_compatible("PowerBook3,2")) { | 755 | || of_machine_is_compatible("PowerBook3,2")) { |
756 | msleep(100); | 756 | msleep(100); |
757 | snd_pmac_awacs_write_reg(chip, 1, | 757 | snd_pmac_awacs_write_reg(chip, 1, |
758 | chip->awacs_reg[1] & ~MASK_PAROUT); | 758 | chip->awacs_reg[1] & ~MASK_PAROUT); |
@@ -780,16 +780,16 @@ static void snd_pmac_awacs_resume(struct snd_pmac *chip) | |||
780 | } | 780 | } |
781 | #endif /* CONFIG_PM */ | 781 | #endif /* CONFIG_PM */ |
782 | 782 | ||
783 | #define IS_PM7500 (machine_is_compatible("AAPL,7500") \ | 783 | #define IS_PM7500 (of_machine_is_compatible("AAPL,7500") \ |
784 | || machine_is_compatible("AAPL,8500") \ | 784 | || of_machine_is_compatible("AAPL,8500") \ |
785 | || machine_is_compatible("AAPL,9500")) | 785 | || of_machine_is_compatible("AAPL,9500")) |
786 | #define IS_PM5500 (machine_is_compatible("AAPL,e411")) | 786 | #define IS_PM5500 (of_machine_is_compatible("AAPL,e411")) |
787 | #define IS_BEIGE (machine_is_compatible("AAPL,Gossamer")) | 787 | #define IS_BEIGE (of_machine_is_compatible("AAPL,Gossamer")) |
788 | #define IS_IMAC1 (machine_is_compatible("PowerMac2,1")) | 788 | #define IS_IMAC1 (of_machine_is_compatible("PowerMac2,1")) |
789 | #define IS_IMAC2 (machine_is_compatible("PowerMac2,2") \ | 789 | #define IS_IMAC2 (of_machine_is_compatible("PowerMac2,2") \ |
790 | || machine_is_compatible("PowerMac4,1")) | 790 | || of_machine_is_compatible("PowerMac4,1")) |
791 | #define IS_G4AGP (machine_is_compatible("PowerMac3,1")) | 791 | #define IS_G4AGP (of_machine_is_compatible("PowerMac3,1")) |
792 | #define IS_LOMBARD (machine_is_compatible("PowerBook1,1")) | 792 | #define IS_LOMBARD (of_machine_is_compatible("PowerBook1,1")) |
793 | 793 | ||
794 | static int imac1, imac2; | 794 | static int imac1, imac2; |
795 | 795 | ||
diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c index 0accfe49735b..1f72e1c786bf 100644 --- a/sound/ppc/burgundy.c +++ b/sound/ppc/burgundy.c | |||
@@ -582,7 +582,7 @@ static int snd_pmac_burgundy_detect_headphone(struct snd_pmac *chip) | |||
582 | static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify) | 582 | static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify) |
583 | { | 583 | { |
584 | if (chip->auto_mute) { | 584 | if (chip->auto_mute) { |
585 | int imac = machine_is_compatible("iMac"); | 585 | int imac = of_machine_is_compatible("iMac"); |
586 | int reg, oreg; | 586 | int reg, oreg; |
587 | reg = oreg = snd_pmac_burgundy_rcb(chip, | 587 | reg = oreg = snd_pmac_burgundy_rcb(chip, |
588 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); | 588 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); |
@@ -620,7 +620,7 @@ static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_noti | |||
620 | */ | 620 | */ |
621 | int __devinit snd_pmac_burgundy_init(struct snd_pmac *chip) | 621 | int __devinit snd_pmac_burgundy_init(struct snd_pmac *chip) |
622 | { | 622 | { |
623 | int imac = machine_is_compatible("iMac"); | 623 | int imac = of_machine_is_compatible("iMac"); |
624 | int i, err; | 624 | int i, err; |
625 | 625 | ||
626 | /* Checks to see the chip is alive and kicking */ | 626 | /* Checks to see the chip is alive and kicking */ |
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 7bc492ee77ec..85081172403f 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c | |||
@@ -922,11 +922,11 @@ static void __devinit detect_byte_swap(struct snd_pmac *chip) | |||
922 | } | 922 | } |
923 | 923 | ||
924 | /* it seems the Pismo & iBook can't byte-swap in hardware. */ | 924 | /* it seems the Pismo & iBook can't byte-swap in hardware. */ |
925 | if (machine_is_compatible("PowerBook3,1") || | 925 | if (of_machine_is_compatible("PowerBook3,1") || |
926 | machine_is_compatible("PowerBook2,1")) | 926 | of_machine_is_compatible("PowerBook2,1")) |
927 | chip->can_byte_swap = 0 ; | 927 | chip->can_byte_swap = 0 ; |
928 | 928 | ||
929 | if (machine_is_compatible("PowerBook2,1")) | 929 | if (of_machine_is_compatible("PowerBook2,1")) |
930 | chip->can_duplex = 0; | 930 | chip->can_duplex = 0; |
931 | } | 931 | } |
932 | 932 | ||
@@ -959,11 +959,11 @@ static int __devinit snd_pmac_detect(struct snd_pmac *chip) | |||
959 | chip->control_mask = MASK_IEPC | MASK_IEE | 0x11; /* default */ | 959 | chip->control_mask = MASK_IEPC | MASK_IEE | 0x11; /* default */ |
960 | 960 | ||
961 | /* check machine type */ | 961 | /* check machine type */ |
962 | if (machine_is_compatible("AAPL,3400/2400") | 962 | if (of_machine_is_compatible("AAPL,3400/2400") |
963 | || machine_is_compatible("AAPL,3500")) | 963 | || of_machine_is_compatible("AAPL,3500")) |
964 | chip->is_pbook_3400 = 1; | 964 | chip->is_pbook_3400 = 1; |
965 | else if (machine_is_compatible("PowerBook1,1") | 965 | else if (of_machine_is_compatible("PowerBook1,1") |
966 | || machine_is_compatible("AAPL,PowerBook1998")) | 966 | || of_machine_is_compatible("AAPL,PowerBook1998")) |
967 | chip->is_pbook_G3 = 1; | 967 | chip->is_pbook_G3 = 1; |
968 | chip->node = of_find_node_by_name(NULL, "awacs"); | 968 | chip->node = of_find_node_by_name(NULL, "awacs"); |
969 | sound = of_node_get(chip->node); | 969 | sound = of_node_get(chip->node); |
@@ -1033,8 +1033,8 @@ static int __devinit snd_pmac_detect(struct snd_pmac *chip) | |||
1033 | } | 1033 | } |
1034 | if (of_device_is_compatible(sound, "tumbler")) { | 1034 | if (of_device_is_compatible(sound, "tumbler")) { |
1035 | chip->model = PMAC_TUMBLER; | 1035 | chip->model = PMAC_TUMBLER; |
1036 | chip->can_capture = machine_is_compatible("PowerMac4,2") | 1036 | chip->can_capture = of_machine_is_compatible("PowerMac4,2") |
1037 | || machine_is_compatible("PowerBook4,1"); | 1037 | || of_machine_is_compatible("PowerBook4,1"); |
1038 | chip->can_duplex = 0; | 1038 | chip->can_duplex = 0; |
1039 | // chip->can_byte_swap = 0; /* FIXME: check this */ | 1039 | // chip->can_byte_swap = 0; /* FIXME: check this */ |
1040 | chip->num_freqs = ARRAY_SIZE(tumbler_freqs); | 1040 | chip->num_freqs = ARRAY_SIZE(tumbler_freqs); |
diff --git a/sound/soc/fsl/efika-audio-fabric.c b/sound/soc/fsl/efika-audio-fabric.c index 3326e2a1e863..1a5b8e0d6a34 100644 --- a/sound/soc/fsl/efika-audio-fabric.c +++ b/sound/soc/fsl/efika-audio-fabric.c | |||
@@ -55,7 +55,7 @@ static __init int efika_fabric_init(void) | |||
55 | struct platform_device *pdev; | 55 | struct platform_device *pdev; |
56 | int rc; | 56 | int rc; |
57 | 57 | ||
58 | if (!machine_is_compatible("bplan,efika")) | 58 | if (!of_machine_is_compatible("bplan,efika")) |
59 | return -ENODEV; | 59 | return -ENODEV; |
60 | 60 | ||
61 | card.platform = &mpc5200_audio_dma_platform; | 61 | card.platform = &mpc5200_audio_dma_platform; |
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c index b928ef7d28eb..6644cba7cbf2 100644 --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c | |||
@@ -55,7 +55,7 @@ static __init int pcm030_fabric_init(void) | |||
55 | struct platform_device *pdev; | 55 | struct platform_device *pdev; |
56 | int rc; | 56 | int rc; |
57 | 57 | ||
58 | if (!machine_is_compatible("phytec,pcm030")) | 58 | if (!of_machine_is_compatible("phytec,pcm030")) |
59 | return -ENODEV; | 59 | return -ENODEV; |
60 | 60 | ||
61 | card.platform = &mpc5200_audio_dma_platform; | 61 | card.platform = &mpc5200_audio_dma_platform; |