Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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()
...

+1249 -2101
+1
arch/microblaze/Kconfig
··· 130 130 131 131 config OF 132 132 def_bool y 133 + select OF_FLATTREE 133 134 134 135 config PROC_DEVICETREE 135 136 bool "Support for device tree in /proc"
-20
arch/microblaze/include/asm/prom.h
··· 26 26 #include <asm/irq.h> 27 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 29 #define HAVE_ARCH_DEVTREE_FIXUPS 39 - 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 30 47 31 /* Other Prototypes */ 48 32 extern int early_uartlite_console(void); 49 - 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 33 54 34 /* 55 35 * OF address retreival & translation
+1 -1
arch/microblaze/kernel/of_platform.c
··· 185 185 static int of_dev_phandle_match(struct device *dev, void *data) 186 186 { 187 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 191 struct of_device *of_find_device_by_phandle(phandle ph)
+13 -977
arch/microblaze/kernel/prom.c
··· 42 42 #include <asm/sections.h> 43 43 #include <asm/pci-bridge.h> 44 44 45 - static int __initdata dt_root_addr_cells; 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) 45 + void __init early_init_dt_scan_chosen_arch(unsigned long node) 56 46 { 57 - return ((char *)initial_boot_params) + 58 - initial_boot_params->off_dt_strings + offset; 47 + /* No Microblaze specific code here */ 59 48 } 60 49 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) 50 + void __init early_init_dt_add_memory_arch(u64 base, u64 size) 70 51 { 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; 52 + lmb_add(base, size); 120 53 } 121 54 122 - unsigned long __init of_get_flat_dt_root(void) 55 + u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 123 56 { 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); 57 + return lmb_alloc(size, align); 132 58 } 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 - { 601 - cell_t *p = *cellp; 602 - 603 - *cellp = p + s; 604 - return of_read_number(p, s); 605 - } 606 - 607 - static int __init early_init_dt_scan_memory(unsigned long node, 608 - const char *uname, int depth, void *data) 609 - { 610 - char *type = of_get_flat_dt_prop(node, "device_type", NULL); 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, &reg); 645 - size = dt_mem_next_cell(dt_root_size_cells, &reg); 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 - } 656 - 657 - #ifdef CONFIG_PHYP_DUMP 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 - { 670 - unsigned long tmp; 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 - } 684 - 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 59 737 60 #ifdef CONFIG_EARLY_PRINTK 738 61 /* MS this is Microblaze specifig function */ ··· 98 775 /* Setup flat device-tree pointer */ 99 776 initial_boot_params = params; 100 777 101 - #ifdef CONFIG_PHYP_DUMP 102 - /* scan tree to see if dump occured during last boot */ 103 - of_scan_flat_dt(early_init_dt_scan_phyp_dump, NULL); 104 - #endif 105 - 106 778 /* Retrieve various informations from the /chosen node of the 107 779 * device-tree, including the platform type, initrd location and 108 780 * size, TCE reserve, and more ... ··· 117 799 118 800 pr_debug("Phys. mem: %lx\n", (unsigned long) lmb_phys_mem_size()); 119 801 120 - pr_debug("Scanning CPUs ...\n"); 121 - 122 - /* Retreive CPU related informations from the flat tree 123 - * (altivec support, boot CPU ID, ...) 124 - */ 125 - of_scan_flat_dt(early_init_dt_scan_cpus, NULL); 126 - 127 802 pr_debug(" <- early_init_devtree()\n"); 128 803 } 129 804 130 - /** 131 - * Indicates whether the root node has a given value in its 132 - * compatible property. 133 - */ 134 - int machine_is_compatible(const char *compat) 805 + #ifdef CONFIG_BLK_DEV_INITRD 806 + void __init early_init_dt_setup_initrd_arch(unsigned long start, 807 + unsigned long end) 135 808 { 136 - struct device_node *root; 137 - int rc = 0; 138 - 139 - root = of_find_node_by_path("/"); 140 - if (root) { 141 - rc = of_device_is_compatible(root, compat); 142 - of_node_put(root); 143 - } 144 - return rc; 809 + initrd_start = (unsigned long)__va(start); 810 + initrd_end = (unsigned long)__va(end); 811 + initrd_below_start_ok = 1; 145 812 } 146 - EXPORT_SYMBOL(machine_is_compatible); 813 + #endif 147 814 148 815 /******* 149 816 * ··· 140 837 * this isn't dealt with yet. 141 838 * 142 839 *******/ 143 - 144 - /** 145 - * of_find_node_by_phandle - Find a node given a phandle 146 - * @handle: phandle of the node to find 147 - * 148 - * Returns a node pointer with refcount incremented, use 149 - * of_node_put() on it when done. 150 - */ 151 - struct device_node *of_find_node_by_phandle(phandle handle) 152 - { 153 - struct device_node *np; 154 - 155 - read_lock(&devtree_lock); 156 - for (np = allnodes; np != NULL; np = np->allnext) 157 - if (np->linux_phandle == handle) 158 - break; 159 - of_node_get(np); 160 - read_unlock(&devtree_lock); 161 - return np; 162 - } 163 - EXPORT_SYMBOL(of_find_node_by_phandle); 164 - 165 - /** 166 - * of_node_get - Increment refcount of a node 167 - * @node: Node to inc refcount, NULL is supported to 168 - * simplify writing of callers 169 - * 170 - * Returns node. 171 - */ 172 - struct device_node *of_node_get(struct device_node *node) 173 - { 174 - if (node) 175 - kref_get(&node->kref); 176 - return node; 177 - } 178 - EXPORT_SYMBOL(of_node_get); 179 - 180 - static inline struct device_node *kref_to_device_node(struct kref *kref) 181 - { 182 - return container_of(kref, struct device_node, kref); 183 - } 184 - 185 - /** 186 - * of_node_release - release a dynamically allocated node 187 - * @kref: kref element of the node to be released 188 - * 189 - * In of_node_put() this function is passed to kref_put() 190 - * as the destructor. 191 - */ 192 - static void of_node_release(struct kref *kref) 193 - { 194 - struct device_node *node = kref_to_device_node(kref); 195 - struct property *prop = node->properties; 196 - 197 - /* We should never be releasing nodes that haven't been detached. */ 198 - if (!of_node_check_flag(node, OF_DETACHED)) { 199 - printk(KERN_INFO "WARNING: Bad of_node_put() on %s\n", 200 - node->full_name); 201 - dump_stack(); 202 - kref_init(&node->kref); 203 - return; 204 - } 205 - 206 - if (!of_node_check_flag(node, OF_DYNAMIC)) 207 - return; 208 - 209 - while (prop) { 210 - struct property *next = prop->next; 211 - kfree(prop->name); 212 - kfree(prop->value); 213 - kfree(prop); 214 - prop = next; 215 - 216 - if (!prop) { 217 - prop = node->deadprops; 218 - node->deadprops = NULL; 219 - } 220 - } 221 - kfree(node->full_name); 222 - kfree(node->data); 223 - kfree(node); 224 - } 225 - 226 - /** 227 - * of_node_put - Decrement refcount of a node 228 - * @node: Node to dec refcount, NULL is supported to 229 - * simplify writing of callers 230 - * 231 - */ 232 - void of_node_put(struct device_node *node) 233 - { 234 - if (node) 235 - kref_put(&node->kref, of_node_release); 236 - } 237 - EXPORT_SYMBOL(of_node_put); 238 - 239 - /* 240 - * Plug a device node into the tree and global list. 241 - */ 242 - void of_attach_node(struct device_node *np) 243 - { 244 - unsigned long flags; 245 - 246 - write_lock_irqsave(&devtree_lock, flags); 247 - np->sibling = np->parent->child; 248 - np->allnext = allnodes; 249 - np->parent->child = np; 250 - allnodes = np; 251 - write_unlock_irqrestore(&devtree_lock, flags); 252 - } 253 - 254 - /* 255 - * "Unplug" a node from the device tree. The caller must hold 256 - * a reference to the node. The memory associated with the node 257 - * is not freed until its refcount goes to zero. 258 - */ 259 - void of_detach_node(struct device_node *np) 260 - { 261 - struct device_node *parent; 262 - unsigned long flags; 263 - 264 - write_lock_irqsave(&devtree_lock, flags); 265 - 266 - parent = np->parent; 267 - if (!parent) 268 - goto out_unlock; 269 - 270 - if (allnodes == np) 271 - allnodes = np->allnext; 272 - else { 273 - struct device_node *prev; 274 - for (prev = allnodes; 275 - prev->allnext != np; 276 - prev = prev->allnext) 277 - ; 278 - prev->allnext = np->allnext; 279 - } 280 - 281 - if (parent->child == np) 282 - parent->child = np->sibling; 283 - else { 284 - struct device_node *prevsib; 285 - for (prevsib = np->parent->child; 286 - prevsib->sibling != np; 287 - prevsib = prevsib->sibling) 288 - ; 289 - prevsib->sibling = np->sibling; 290 - } 291 - 292 - of_node_set_flag(np, OF_DETACHED); 293 - 294 - out_unlock: 295 - write_unlock_irqrestore(&devtree_lock, flags); 296 - } 297 - 298 - /* 299 - * Add a property to a node 300 - */ 301 - int prom_add_property(struct device_node *np, struct property *prop) 302 - { 303 - struct property **next; 304 - unsigned long flags; 305 - 306 - prop->next = NULL; 307 - write_lock_irqsave(&devtree_lock, flags); 308 - next = &np->properties; 309 - while (*next) { 310 - if (strcmp(prop->name, (*next)->name) == 0) { 311 - /* duplicate ! don't insert it */ 312 - write_unlock_irqrestore(&devtree_lock, flags); 313 - return -1; 314 - } 315 - next = &(*next)->next; 316 - } 317 - *next = prop; 318 - write_unlock_irqrestore(&devtree_lock, flags); 319 - 320 - #ifdef CONFIG_PROC_DEVICETREE 321 - /* try to add to proc as well if it was initialized */ 322 - if (np->pde) 323 - proc_device_tree_add_prop(np->pde, prop); 324 - #endif /* CONFIG_PROC_DEVICETREE */ 325 - 326 - return 0; 327 - } 328 - 329 - /* 330 - * Remove a property from a node. Note that we don't actually 331 - * remove it, since we have given out who-knows-how-many pointers 332 - * to the data using get-property. Instead we just move the property 333 - * to the "dead properties" list, so it won't be found any more. 334 - */ 335 - int prom_remove_property(struct device_node *np, struct property *prop) 336 - { 337 - struct property **next; 338 - unsigned long flags; 339 - int found = 0; 340 - 341 - write_lock_irqsave(&devtree_lock, flags); 342 - next = &np->properties; 343 - while (*next) { 344 - if (*next == prop) { 345 - /* found the node */ 346 - *next = prop->next; 347 - prop->next = np->deadprops; 348 - np->deadprops = prop; 349 - found = 1; 350 - break; 351 - } 352 - next = &(*next)->next; 353 - } 354 - write_unlock_irqrestore(&devtree_lock, flags); 355 - 356 - if (!found) 357 - return -ENODEV; 358 - 359 - #ifdef CONFIG_PROC_DEVICETREE 360 - /* try to remove the proc node as well */ 361 - if (np->pde) 362 - proc_device_tree_remove_prop(np->pde, prop); 363 - #endif /* CONFIG_PROC_DEVICETREE */ 364 - 365 - return 0; 366 - } 367 - 368 - /* 369 - * Update a property in a node. Note that we don't actually 370 - * remove it, since we have given out who-knows-how-many pointers 371 - * to the data using get-property. Instead we just move the property 372 - * to the "dead properties" list, and add the new property to the 373 - * property list 374 - */ 375 - int prom_update_property(struct device_node *np, 376 - struct property *newprop, 377 - struct property *oldprop) 378 - { 379 - struct property **next; 380 - unsigned long flags; 381 - int found = 0; 382 - 383 - write_lock_irqsave(&devtree_lock, flags); 384 - next = &np->properties; 385 - while (*next) { 386 - if (*next == oldprop) { 387 - /* found the node */ 388 - newprop->next = oldprop->next; 389 - *next = newprop; 390 - oldprop->next = np->deadprops; 391 - np->deadprops = oldprop; 392 - found = 1; 393 - break; 394 - } 395 - next = &(*next)->next; 396 - } 397 - write_unlock_irqrestore(&devtree_lock, flags); 398 - 399 - if (!found) 400 - return -ENODEV; 401 - 402 - #ifdef CONFIG_PROC_DEVICETREE 403 - /* try to add to proc as well if it was initialized */ 404 - if (np->pde) 405 - proc_device_tree_update_prop(np->pde, newprop, oldprop); 406 - #endif /* CONFIG_PROC_DEVICETREE */ 407 - 408 - return 0; 409 - } 410 840 411 841 #if defined(CONFIG_DEBUG_FS) && defined(DEBUG) 412 842 static struct debugfs_blob_wrapper flat_dt_blob;
+1
arch/powerpc/Kconfig
··· 173 173 174 174 config OF 175 175 def_bool y 176 + select OF_FLATTREE 176 177 177 178 config PPC_UDBG_16550 178 179 bool
-18
arch/powerpc/include/asm/prom.h
··· 23 23 #include <asm/irq.h> 24 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 26 #define HAVE_ARCH_DEVTREE_FIXUPS 36 - 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 27 41 28 #ifdef CONFIG_PPC32 42 29 /* ··· 38 51 extern struct device_node* pci_device_to_OF_node(struct pci_dev *); 39 52 extern void pci_create_OF_bus_map(void); 40 53 #endif 41 - 42 - extern struct resource *request_OF_resource(struct device_node* node, 43 - int index, const char* name_postfix); 44 - extern int release_OF_resource(struct device_node* node, int index); 45 - 46 54 47 55 /* 48 56 * OF address retreival & translation
+1 -1
arch/powerpc/kernel/of_platform.c
··· 214 214 static int of_dev_phandle_match(struct device *dev, void *data) 215 215 { 216 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 220 struct of_device *of_find_device_by_phandle(phandle ph)
+1 -1
arch/powerpc/kernel/pci_64.c
··· 224 224 * G5 machines... So when something asks for bus 0 io base 225 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 228 struct device_node *agp; 229 229 230 230 agp = of_find_compatible_node(NULL, NULL, "u3-agp");
+54 -843
arch/powerpc/kernel/prom.c
··· 61 61 #define DBG(fmt...) 62 62 #endif 63 63 64 - 65 - static int __initdata dt_root_addr_cells; 66 - static int __initdata dt_root_size_cells; 67 - 68 64 #ifdef CONFIG_PPC64 69 65 int __initdata iommu_is_off; 70 66 int __initdata iommu_force_on; 71 67 unsigned long tce_alloc_start, tce_alloc_end; 72 68 #endif 73 - 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 69 423 70 static int __init early_parse_mem(char *p) 424 71 { ··· 93 446 DBG("-> move_device_tree\n"); 94 447 95 448 start = __pa(initial_boot_params); 96 - size = initial_boot_params->totalsize; 449 + size = be32_to_cpu(initial_boot_params->totalsize); 97 450 98 451 if ((memory_limit && (start + size) > memory_limit) || 99 452 overlaps_crashkernel(start, size)) { ··· 104 457 } 105 458 106 459 DBG("<- move_device_tree\n"); 107 - } 108 - 109 - /** 110 - * unflattens the device-tree passed by the firmware, creating the 111 - * tree of struct device_node. It also fills the "name" and "type" 112 - * pointers of the nodes so the normal device-tree walking functions 113 - * can be used (this used to be done by finish_device_tree) 114 - */ 115 - void __init unflatten_device_tree(void) 116 - { 117 - unsigned long start, mem, size; 118 - struct device_node **allnextp = &allnodes; 119 - 120 - DBG(" -> unflatten_device_tree()\n"); 121 - 122 - /* First pass, scan for size */ 123 - start = ((unsigned long)initial_boot_params) + 124 - initial_boot_params->off_dt_struct; 125 - size = unflatten_dt_node(0, &start, NULL, NULL, 0); 126 - size = (size | 3) + 1; 127 - 128 - DBG(" size is %lx, allocating...\n", size); 129 - 130 - /* Allocate memory for the expanded device tree */ 131 - mem = lmb_alloc(size + 4, __alignof__(struct device_node)); 132 - mem = (unsigned long) __va(mem); 133 - 134 - ((u32 *)mem)[size / 4] = 0xdeadbeef; 135 - 136 - DBG(" unflattening %lx...\n", mem); 137 - 138 - /* Second pass, do actual unflattening */ 139 - start = ((unsigned long)initial_boot_params) + 140 - initial_boot_params->off_dt_struct; 141 - unflatten_dt_node(mem, &start, NULL, &allnextp, 0); 142 - if (*((u32 *)start) != OF_DT_END) 143 - printk(KERN_WARNING "Weird tag at end of tree: %08x\n", *((u32 *)start)); 144 - if (((u32 *)mem)[size / 4] != 0xdeadbeef) 145 - printk(KERN_WARNING "End of tree marker overwritten: %08x\n", 146 - ((u32 *)mem)[size / 4] ); 147 - *allnextp = NULL; 148 - 149 - /* Get pointer to OF "/chosen" node for use everywhere */ 150 - of_chosen = of_find_node_by_path("/chosen"); 151 - if (of_chosen == NULL) 152 - of_chosen = of_find_node_by_path("/chosen@0"); 153 - 154 - DBG(" <- unflatten_device_tree()\n"); 155 460 } 156 461 157 462 /* ··· 362 763 return 0; 363 764 } 364 765 365 - #ifdef CONFIG_BLK_DEV_INITRD 366 - static void __init early_init_dt_check_for_initrd(unsigned long node) 367 - { 368 - unsigned long l; 369 - u32 *prop; 370 - 371 - DBG("Looking for initrd properties... "); 372 - 373 - prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l); 374 - if (prop) { 375 - initrd_start = (unsigned long)__va(of_read_ulong(prop, l/4)); 376 - 377 - prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l); 378 - if (prop) { 379 - initrd_end = (unsigned long) 380 - __va(of_read_ulong(prop, l/4)); 381 - initrd_below_start_ok = 1; 382 - } else { 383 - initrd_start = 0; 384 - } 385 - } 386 - 387 - DBG("initrd_start=0x%lx initrd_end=0x%lx\n", initrd_start, initrd_end); 388 - } 389 - #else 390 - static inline void early_init_dt_check_for_initrd(unsigned long node) 391 - { 392 - } 393 - #endif /* CONFIG_BLK_DEV_INITRD */ 394 - 395 - static int __init early_init_dt_scan_chosen(unsigned long node, 396 - const char *uname, int depth, void *data) 766 + void __init early_init_dt_scan_chosen_arch(unsigned long node) 397 767 { 398 768 unsigned long *lprop; 399 - unsigned long l; 400 - char *p; 401 - 402 - DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname); 403 - 404 - if (depth != 1 || 405 - (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) 406 - return 0; 407 769 408 770 #ifdef CONFIG_PPC64 409 771 /* check if iommu is forced on or off */ ··· 375 815 #endif 376 816 377 817 /* mem=x on the command line is the preferred mechanism */ 378 - lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL); 379 - if (lprop) 380 - memory_limit = *lprop; 818 + lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL); 819 + if (lprop) 820 + memory_limit = *lprop; 381 821 382 822 #ifdef CONFIG_PPC64 383 - lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-start", NULL); 384 - if (lprop) 385 - tce_alloc_start = *lprop; 386 - lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL); 387 - if (lprop) 388 - tce_alloc_end = *lprop; 823 + lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-start", NULL); 824 + if (lprop) 825 + tce_alloc_start = *lprop; 826 + lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL); 827 + if (lprop) 828 + tce_alloc_end = *lprop; 389 829 #endif 390 830 391 831 #ifdef CONFIG_KEXEC ··· 397 837 if (lprop) 398 838 crashk_res.end = crashk_res.start + *lprop - 1; 399 839 #endif 400 - 401 - early_init_dt_check_for_initrd(node); 402 - 403 - /* Retreive command line */ 404 - p = of_get_flat_dt_prop(node, "bootargs", &l); 405 - if (p != NULL && l > 0) 406 - strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE)); 407 - 408 - #ifdef CONFIG_CMDLINE 409 - if (p == NULL || l == 0 || (l == 1 && (*p) == 0)) 410 - strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); 411 - #endif /* CONFIG_CMDLINE */ 412 - 413 - DBG("Command line is: %s\n", cmd_line); 414 - 415 - /* break now */ 416 - return 1; 417 - } 418 - 419 - static int __init early_init_dt_scan_root(unsigned long node, 420 - const char *uname, int depth, void *data) 421 - { 422 - u32 *prop; 423 - 424 - if (depth != 0) 425 - return 0; 426 - 427 - prop = of_get_flat_dt_prop(node, "#size-cells", NULL); 428 - dt_root_size_cells = (prop == NULL) ? 1 : *prop; 429 - DBG("dt_root_size_cells = %x\n", dt_root_size_cells); 430 - 431 - prop = of_get_flat_dt_prop(node, "#address-cells", NULL); 432 - dt_root_addr_cells = (prop == NULL) ? 2 : *prop; 433 - DBG("dt_root_addr_cells = %x\n", dt_root_addr_cells); 434 - 435 - /* break now */ 436 - return 1; 437 - } 438 - 439 - static u64 __init dt_mem_next_cell(int s, cell_t **cellp) 440 - { 441 - cell_t *p = *cellp; 442 - 443 - *cellp = p + s; 444 - return of_read_number(p, s); 445 840 } 446 841 447 842 #ifdef CONFIG_PPC_PSERIES ··· 408 893 */ 409 894 static int __init early_init_dt_scan_drconf_memory(unsigned long node) 410 895 { 411 - cell_t *dm, *ls, *usm; 896 + __be32 *dm, *ls, *usm; 412 897 unsigned long l, n, flags; 413 898 u64 base, size, lmb_size; 414 899 unsigned int is_kexec_kdump = 0, rngs; 415 900 416 901 ls = of_get_flat_dt_prop(node, "ibm,lmb-size", &l); 417 - if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t)) 902 + if (ls == NULL || l < dt_root_size_cells * sizeof(__be32)) 418 903 return 0; 419 904 lmb_size = dt_mem_next_cell(dt_root_size_cells, &ls); 420 905 421 906 dm = of_get_flat_dt_prop(node, "ibm,dynamic-memory", &l); 422 - if (dm == NULL || l < sizeof(cell_t)) 907 + if (dm == NULL || l < sizeof(__be32)) 423 908 return 0; 424 909 425 910 n = *dm++; /* number of entries */ 426 - if (l < (n * (dt_root_addr_cells + 4) + 1) * sizeof(cell_t)) 911 + if (l < (n * (dt_root_addr_cells + 4) + 1) * sizeof(__be32)) 427 912 return 0; 428 913 429 914 /* check if this is a kexec/kdump kernel. */ ··· 478 963 #define early_init_dt_scan_drconf_memory(node) 0 479 964 #endif /* CONFIG_PPC_PSERIES */ 480 965 481 - static int __init early_init_dt_scan_memory(unsigned long node, 482 - const char *uname, int depth, void *data) 966 + static int __init early_init_dt_scan_memory_ppc(unsigned long node, 967 + const char *uname, 968 + int depth, void *data) 483 969 { 484 - char *type = of_get_flat_dt_prop(node, "device_type", NULL); 485 - cell_t *reg, *endp; 486 - unsigned long l; 487 - 488 - /* Look for the ibm,dynamic-reconfiguration-memory node */ 489 970 if (depth == 1 && 490 971 strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) 491 972 return early_init_dt_scan_drconf_memory(node); 492 - 493 - /* We are scanning "memory" nodes only */ 494 - if (type == NULL) { 495 - /* 496 - * The longtrail doesn't have a device_type on the 497 - * /memory node, so look for the node called /memory@0. 498 - */ 499 - if (depth != 1 || strcmp(uname, "memory@0") != 0) 500 - return 0; 501 - } else if (strcmp(type, "memory") != 0) 502 - return 0; 503 - 504 - reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); 505 - if (reg == NULL) 506 - reg = of_get_flat_dt_prop(node, "reg", &l); 507 - if (reg == NULL) 508 - return 0; 509 - 510 - endp = reg + (l / sizeof(cell_t)); 511 - 512 - DBG("memory scan node %s, reg size %ld, data: %x %x %x %x,\n", 513 - uname, l, reg[0], reg[1], reg[2], reg[3]); 514 - 515 - while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { 516 - u64 base, size; 517 - 518 - base = dt_mem_next_cell(dt_root_addr_cells, &reg); 519 - size = dt_mem_next_cell(dt_root_size_cells, &reg); 520 - 521 - if (size == 0) 522 - continue; 523 - DBG(" - %llx , %llx\n", (unsigned long long)base, 524 - (unsigned long long)size); 525 - #ifdef CONFIG_PPC64 526 - if (iommu_is_off) { 527 - if (base >= 0x80000000ul) 528 - continue; 529 - if ((base + size) > 0x80000000ul) 530 - size = 0x80000000ul - base; 531 - } 532 - #endif 533 - lmb_add(base, size); 534 - 535 - memstart_addr = min((u64)memstart_addr, base); 536 - } 537 - 538 - return 0; 973 + 974 + return early_init_dt_scan_memory(node, uname, depth, data); 539 975 } 976 + 977 + void __init early_init_dt_add_memory_arch(u64 base, u64 size) 978 + { 979 + #if defined(CONFIG_PPC64) 980 + if (iommu_is_off) { 981 + if (base >= 0x80000000ul) 982 + return; 983 + if ((base + size) > 0x80000000ul) 984 + size = 0x80000000ul - base; 985 + } 986 + #endif 987 + 988 + lmb_add(base, size); 989 + 990 + memstart_addr = min((u64)memstart_addr, base); 991 + } 992 + 993 + u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 994 + { 995 + return lmb_alloc(size, align); 996 + } 997 + 998 + #ifdef CONFIG_BLK_DEV_INITRD 999 + void __init early_init_dt_setup_initrd_arch(unsigned long start, 1000 + unsigned long end) 1001 + { 1002 + initrd_start = (unsigned long)__va(start); 1003 + initrd_end = (unsigned long)__va(end); 1004 + initrd_below_start_ok = 1; 1005 + } 1006 + #endif 540 1007 541 1008 static void __init early_reserve_mem(void) 542 1009 { ··· 683 1186 /* Scan memory nodes and rebuild LMBs */ 684 1187 lmb_init(); 685 1188 of_scan_flat_dt(early_init_dt_scan_root, NULL); 686 - of_scan_flat_dt(early_init_dt_scan_memory, NULL); 1189 + of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); 687 1190 688 1191 /* Save command line for /proc/cmdline and then parse parameters */ 689 1192 strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); ··· 731 1234 DBG(" <- early_init_devtree()\n"); 732 1235 } 733 1236 734 - 735 - /** 736 - * Indicates whether the root node has a given value in its 737 - * compatible property. 738 - */ 739 - int machine_is_compatible(const char *compat) 740 - { 741 - struct device_node *root; 742 - int rc = 0; 743 - 744 - root = of_find_node_by_path("/"); 745 - if (root) { 746 - rc = of_device_is_compatible(root, compat); 747 - of_node_put(root); 748 - } 749 - return rc; 750 - } 751 - EXPORT_SYMBOL(machine_is_compatible); 752 - 753 1237 /******* 754 1238 * 755 1239 * New implementation of the OF "find" APIs, return a refcounted ··· 741 1263 * this isn't dealt with yet. 742 1264 * 743 1265 *******/ 744 - 745 - /** 746 - * of_find_node_by_phandle - Find a node given a phandle 747 - * @handle: phandle of the node to find 748 - * 749 - * Returns a node pointer with refcount incremented, use 750 - * of_node_put() on it when done. 751 - */ 752 - struct device_node *of_find_node_by_phandle(phandle handle) 753 - { 754 - struct device_node *np; 755 - 756 - read_lock(&devtree_lock); 757 - for (np = allnodes; np != 0; np = np->allnext) 758 - if (np->linux_phandle == handle) 759 - break; 760 - of_node_get(np); 761 - read_unlock(&devtree_lock); 762 - return np; 763 - } 764 - EXPORT_SYMBOL(of_find_node_by_phandle); 765 1266 766 1267 /** 767 1268 * of_find_next_cache_node - Find a node's subsidiary cache ··· 771 1314 return child; 772 1315 773 1316 return NULL; 774 - } 775 - 776 - /** 777 - * of_node_get - Increment refcount of a node 778 - * @node: Node to inc refcount, NULL is supported to 779 - * simplify writing of callers 780 - * 781 - * Returns node. 782 - */ 783 - struct device_node *of_node_get(struct device_node *node) 784 - { 785 - if (node) 786 - kref_get(&node->kref); 787 - return node; 788 - } 789 - EXPORT_SYMBOL(of_node_get); 790 - 791 - static inline struct device_node * kref_to_device_node(struct kref *kref) 792 - { 793 - return container_of(kref, struct device_node, kref); 794 - } 795 - 796 - /** 797 - * of_node_release - release a dynamically allocated node 798 - * @kref: kref element of the node to be released 799 - * 800 - * In of_node_put() this function is passed to kref_put() 801 - * as the destructor. 802 - */ 803 - static void of_node_release(struct kref *kref) 804 - { 805 - struct device_node *node = kref_to_device_node(kref); 806 - struct property *prop = node->properties; 807 - 808 - /* We should never be releasing nodes that haven't been detached. */ 809 - if (!of_node_check_flag(node, OF_DETACHED)) { 810 - printk("WARNING: Bad of_node_put() on %s\n", node->full_name); 811 - dump_stack(); 812 - kref_init(&node->kref); 813 - return; 814 - } 815 - 816 - if (!of_node_check_flag(node, OF_DYNAMIC)) 817 - return; 818 - 819 - while (prop) { 820 - struct property *next = prop->next; 821 - kfree(prop->name); 822 - kfree(prop->value); 823 - kfree(prop); 824 - prop = next; 825 - 826 - if (!prop) { 827 - prop = node->deadprops; 828 - node->deadprops = NULL; 829 - } 830 - } 831 - kfree(node->full_name); 832 - kfree(node->data); 833 - kfree(node); 834 - } 835 - 836 - /** 837 - * of_node_put - Decrement refcount of a node 838 - * @node: Node to dec refcount, NULL is supported to 839 - * simplify writing of callers 840 - * 841 - */ 842 - void of_node_put(struct device_node *node) 843 - { 844 - if (node) 845 - kref_put(&node->kref, of_node_release); 846 - } 847 - EXPORT_SYMBOL(of_node_put); 848 - 849 - /* 850 - * Plug a device node into the tree and global list. 851 - */ 852 - void of_attach_node(struct device_node *np) 853 - { 854 - unsigned long flags; 855 - 856 - write_lock_irqsave(&devtree_lock, flags); 857 - np->sibling = np->parent->child; 858 - np->allnext = allnodes; 859 - np->parent->child = np; 860 - allnodes = np; 861 - write_unlock_irqrestore(&devtree_lock, flags); 862 - } 863 - 864 - /* 865 - * "Unplug" a node from the device tree. The caller must hold 866 - * a reference to the node. The memory associated with the node 867 - * is not freed until its refcount goes to zero. 868 - */ 869 - void of_detach_node(struct device_node *np) 870 - { 871 - struct device_node *parent; 872 - unsigned long flags; 873 - 874 - write_lock_irqsave(&devtree_lock, flags); 875 - 876 - parent = np->parent; 877 - if (!parent) 878 - goto out_unlock; 879 - 880 - if (allnodes == np) 881 - allnodes = np->allnext; 882 - else { 883 - struct device_node *prev; 884 - for (prev = allnodes; 885 - prev->allnext != np; 886 - prev = prev->allnext) 887 - ; 888 - prev->allnext = np->allnext; 889 - } 890 - 891 - if (parent->child == np) 892 - parent->child = np->sibling; 893 - else { 894 - struct device_node *prevsib; 895 - for (prevsib = np->parent->child; 896 - prevsib->sibling != np; 897 - prevsib = prevsib->sibling) 898 - ; 899 - prevsib->sibling = np->sibling; 900 - } 901 - 902 - of_node_set_flag(np, OF_DETACHED); 903 - 904 - out_unlock: 905 - write_unlock_irqrestore(&devtree_lock, flags); 906 1317 } 907 1318 908 1319 #ifdef CONFIG_PPC_PSERIES ··· 804 1479 if (machine_is(powermac)) 805 1480 return -ENODEV; 806 1481 807 - /* fix up new node's linux_phandle field */ 1482 + /* fix up new node's phandle field */ 808 1483 if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL))) 809 - node->linux_phandle = *ibm_phandle; 1484 + node->phandle = *ibm_phandle; 810 1485 811 1486 out: 812 1487 of_node_put(parent); ··· 844 1519 } 845 1520 __initcall(prom_reconfig_setup); 846 1521 #endif 847 - 848 - /* 849 - * Add a property to a node 850 - */ 851 - int prom_add_property(struct device_node* np, struct property* prop) 852 - { 853 - struct property **next; 854 - unsigned long flags; 855 - 856 - prop->next = NULL; 857 - write_lock_irqsave(&devtree_lock, flags); 858 - next = &np->properties; 859 - while (*next) { 860 - if (strcmp(prop->name, (*next)->name) == 0) { 861 - /* duplicate ! don't insert it */ 862 - write_unlock_irqrestore(&devtree_lock, flags); 863 - return -1; 864 - } 865 - next = &(*next)->next; 866 - } 867 - *next = prop; 868 - write_unlock_irqrestore(&devtree_lock, flags); 869 - 870 - #ifdef CONFIG_PROC_DEVICETREE 871 - /* try to add to proc as well if it was initialized */ 872 - if (np->pde) 873 - proc_device_tree_add_prop(np->pde, prop); 874 - #endif /* CONFIG_PROC_DEVICETREE */ 875 - 876 - return 0; 877 - } 878 - 879 - /* 880 - * Remove a property from a node. Note that we don't actually 881 - * remove it, since we have given out who-knows-how-many pointers 882 - * to the data using get-property. Instead we just move the property 883 - * to the "dead properties" list, so it won't be found any more. 884 - */ 885 - int prom_remove_property(struct device_node *np, struct property *prop) 886 - { 887 - struct property **next; 888 - unsigned long flags; 889 - int found = 0; 890 - 891 - write_lock_irqsave(&devtree_lock, flags); 892 - next = &np->properties; 893 - while (*next) { 894 - if (*next == prop) { 895 - /* found the node */ 896 - *next = prop->next; 897 - prop->next = np->deadprops; 898 - np->deadprops = prop; 899 - found = 1; 900 - break; 901 - } 902 - next = &(*next)->next; 903 - } 904 - write_unlock_irqrestore(&devtree_lock, flags); 905 - 906 - if (!found) 907 - return -ENODEV; 908 - 909 - #ifdef CONFIG_PROC_DEVICETREE 910 - /* try to remove the proc node as well */ 911 - if (np->pde) 912 - proc_device_tree_remove_prop(np->pde, prop); 913 - #endif /* CONFIG_PROC_DEVICETREE */ 914 - 915 - return 0; 916 - } 917 - 918 - /* 919 - * Update a property in a node. Note that we don't actually 920 - * remove it, since we have given out who-knows-how-many pointers 921 - * to the data using get-property. Instead we just move the property 922 - * to the "dead properties" list, and add the new property to the 923 - * property list 924 - */ 925 - int prom_update_property(struct device_node *np, 926 - struct property *newprop, 927 - struct property *oldprop) 928 - { 929 - struct property **next; 930 - unsigned long flags; 931 - int found = 0; 932 - 933 - write_lock_irqsave(&devtree_lock, flags); 934 - next = &np->properties; 935 - while (*next) { 936 - if (*next == oldprop) { 937 - /* found the node */ 938 - newprop->next = oldprop->next; 939 - *next = newprop; 940 - oldprop->next = np->deadprops; 941 - np->deadprops = oldprop; 942 - found = 1; 943 - break; 944 - } 945 - next = &(*next)->next; 946 - } 947 - write_unlock_irqrestore(&devtree_lock, flags); 948 - 949 - if (!found) 950 - return -ENODEV; 951 - 952 - #ifdef CONFIG_PROC_DEVICETREE 953 - /* try to add to proc as well if it was initialized */ 954 - if (np->pde) 955 - proc_device_tree_update_prop(np->pde, newprop, oldprop); 956 - #endif /* CONFIG_PROC_DEVICETREE */ 957 - 958 - return 0; 959 - } 960 - 961 1522 962 1523 /* Find the device node for a given logical cpu number, also returns the cpu 963 1524 * local thread number (index in ibm,interrupt-server#s) if relevant and
+2 -2
arch/powerpc/platforms/85xx/xes_mpc85xx.c
··· 80 80 printk(KERN_INFO "xes_mpc85xx: Enabling L2 as cache\n"); 81 81 82 82 ctl = MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2I; 83 - if (machine_is_compatible("MPC8540") || 84 - machine_is_compatible("MPC8560")) 83 + if (of_machine_is_compatible("MPC8540") || 84 + of_machine_is_compatible("MPC8560")) 85 85 /* 86 86 * Assume L2 SRAM is used fully for cache, so set 87 87 * L2BLKSZ (bits 4:5) to match L2SIZ (bits 2:3).
+1 -1
arch/powerpc/platforms/cell/cbe_powerbutton.c
··· 48 48 int ret = 0; 49 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 52 printk(KERN_ERR "%s: Not a cell blade.\n", __func__); 53 53 ret = -ENODEV; 54 54 goto out;
+1 -1
arch/powerpc/platforms/cell/ras.c
··· 255 255 { 256 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 259 if (!sysreset_hack) 260 260 return 0; 261 261
+3 -3
arch/powerpc/platforms/cell/spu_manage.c
··· 457 457 continue; 458 458 vic_handles = of_get_property(spu_dn, "vicinity", &lenp); 459 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 461 return spu; 462 462 } 463 463 } ··· 499 499 500 500 if (strcmp(name, "spe") == 0) { 501 501 spu = devnode_spu(cbe, vic_dn); 502 - avoid_ph = last_spu_dn->linux_phandle; 502 + avoid_ph = last_spu_dn->phandle; 503 503 } else { 504 504 /* 505 505 * "mic-tm" and "bif0" nodes do not have ··· 514 514 last_spu->has_mem_affinity = 1; 515 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 520 list_add_tail(&spu->aff_list, &last_spu->aff_list);
+2 -2
arch/powerpc/platforms/pasemi/cpufreq.c
··· 304 304 305 305 static int __init pas_cpufreq_init(void) 306 306 { 307 - if (!machine_is_compatible("PA6T-1682M") && 308 - !machine_is_compatible("pasemi,pwrficient")) 307 + if (!of_machine_is_compatible("PA6T-1682M") && 308 + !of_machine_is_compatible("pasemi,pwrficient")) 309 309 return -ENODEV; 310 310 311 311 return cpufreq_register_driver(&pas_cpufreq_driver);
+7 -7
arch/powerpc/platforms/powermac/cpufreq_32.c
··· 657 657 cur_freq = (*value) / 1000; 658 658 659 659 /* Check for 7447A based MacRISC3 */ 660 - if (machine_is_compatible("MacRISC3") && 660 + if (of_machine_is_compatible("MacRISC3") && 661 661 of_get_property(cpunode, "dynamic-power-step", NULL) && 662 662 PVR_VER(mfspr(SPRN_PVR)) == 0x8003) { 663 663 pmac_cpufreq_init_7447A(cpunode); 664 664 /* Check for other MacRISC3 machines */ 665 - } else if (machine_is_compatible("PowerBook3,4") || 666 - machine_is_compatible("PowerBook3,5") || 667 - machine_is_compatible("MacRISC3")) { 665 + } else if (of_machine_is_compatible("PowerBook3,4") || 666 + of_machine_is_compatible("PowerBook3,5") || 667 + of_machine_is_compatible("MacRISC3")) { 668 668 pmac_cpufreq_init_MacRISC3(cpunode); 669 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 671 hi_freq = cur_freq; 672 672 low_freq = 400000; 673 673 set_speed_proc = pmu_set_cpu_speed; 674 674 is_pmu_based = 1; 675 675 } 676 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 678 hi_freq = cur_freq; 679 679 low_freq = 500000; 680 680 set_speed_proc = pmu_set_cpu_speed; 681 681 is_pmu_based = 1; 682 682 } 683 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 685 /* We only know about the 400 MHz and the 500Mhz model 686 686 * they both have 300 MHz as low frequency 687 687 */
+7 -7
arch/powerpc/platforms/powermac/cpufreq_64.c
··· 398 398 int rc = -ENODEV; 399 399 400 400 /* Check supported platforms */ 401 - if (machine_is_compatible("PowerMac8,1") || 402 - machine_is_compatible("PowerMac8,2") || 403 - machine_is_compatible("PowerMac9,1")) 401 + if (of_machine_is_compatible("PowerMac8,1") || 402 + of_machine_is_compatible("PowerMac8,2") || 403 + of_machine_is_compatible("PowerMac9,1")) 404 404 use_volts_smu = 1; 405 - else if (machine_is_compatible("PowerMac11,2")) 405 + else if (of_machine_is_compatible("PowerMac11,2")) 406 406 use_volts_vdnap = 1; 407 407 else 408 408 return -ENODEV; ··· 729 729 return -ENODEV; 730 730 } 731 731 732 - if (machine_is_compatible("PowerMac7,2") || 733 - machine_is_compatible("PowerMac7,3") || 734 - machine_is_compatible("RackMac3,1")) 732 + if (of_machine_is_compatible("PowerMac7,2") || 733 + of_machine_is_compatible("PowerMac7,3") || 734 + of_machine_is_compatible("RackMac3,1")) 735 735 rc = g5_pm72_cpufreq_init(cpus); 736 736 #ifdef CONFIG_PMAC_SMU 737 737 else
+1 -1
arch/powerpc/platforms/powermac/feature.c
··· 2426 2426 } 2427 2427 } 2428 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 2430 pmac_mb = pmac_mb_defs[i]; 2431 2431 goto found; 2432 2432 }
+1 -1
arch/powerpc/platforms/powermac/pfunc_core.c
··· 842 842 list_for_each_entry(func, &dev->functions, link) { 843 843 if (name && strcmp(name, func->name)) 844 844 continue; 845 - if (func->phandle && target->node != func->phandle) 845 + if (func->phandle && target->phandle != func->phandle) 846 846 continue; 847 847 if ((func->flags & flags) == 0) 848 848 continue;
+6 -6
arch/powerpc/platforms/powermac/smp.c
··· 693 693 #ifdef CONFIG_PPC64 694 694 695 695 /* i2c based HW sync on some G5s */ 696 - if (machine_is_compatible("PowerMac7,2") || 697 - machine_is_compatible("PowerMac7,3") || 698 - machine_is_compatible("RackMac3,1")) 696 + if (of_machine_is_compatible("PowerMac7,2") || 697 + of_machine_is_compatible("PowerMac7,3") || 698 + of_machine_is_compatible("RackMac3,1")) 699 699 smp_core99_setup_i2c_hwsync(ncpus); 700 700 701 701 /* pfunc based HW sync on recent G5s */ ··· 713 713 #else /* CONFIG_PPC64 */ 714 714 715 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 717 struct device_node *cpu; 718 718 const u32 *tbprop = NULL; 719 719 ··· 750 750 #endif 751 751 752 752 /* 32 bits SMP can't NAP */ 753 - if (!machine_is_compatible("MacRISC4")) 753 + if (!of_machine_is_compatible("MacRISC4")) 754 754 powersave_nap = 0; 755 755 } 756 756 ··· 852 852 /* If we didn't start the second CPU, we must take 853 853 * it off the bus 854 854 */ 855 - if (machine_is_compatible("MacRISC4") && 855 + if (of_machine_is_compatible("MacRISC4") && 856 856 num_online_cpus() < 2) 857 857 g5_phy_disable_cpu1(); 858 858 #endif /* CONFIG_PPC64 */
+4 -4
arch/powerpc/platforms/powermac/time.c
··· 317 317 * calibration. That's better since the VIA itself seems 318 318 * to be slightly off. --BenH 319 319 */ 320 - if (!machine_is_compatible("MacRISC2") && 321 - !machine_is_compatible("MacRISC3") && 322 - !machine_is_compatible("MacRISC4")) 320 + if (!of_machine_is_compatible("MacRISC2") && 321 + !of_machine_is_compatible("MacRISC3") && 322 + !of_machine_is_compatible("MacRISC4")) 323 323 if (via_calibrate_decr()) 324 324 return; 325 325 ··· 328 328 * probably implement calibration based on the KL timer on these 329 329 * machines anyway... -BenH 330 330 */ 331 - if (machine_is_compatible("PowerMac3,5")) 331 + if (of_machine_is_compatible("PowerMac3,5")) 332 332 if (via_calibrate_decr()) 333 333 return; 334 334 #endif
+3 -3
arch/powerpc/platforms/powermac/udbg_scc.c
··· 132 132 scc_inittab[1] = in_8(sccc); 133 133 out_8(sccc, 12); 134 134 scc_inittab[3] = in_8(sccc); 135 - } else if (machine_is_compatible("RackMac1,1") 136 - || machine_is_compatible("RackMac1,2") 137 - || machine_is_compatible("MacRISC4")) { 135 + } else if (of_machine_is_compatible("RackMac1,1") 136 + || of_machine_is_compatible("RackMac1,2") 137 + || of_machine_is_compatible("MacRISC4")) { 138 138 /* Xserves and G5s default to 57600 */ 139 139 scc_inittab[1] = 0; 140 140 scc_inittab[3] = 0;
+2 -2
arch/powerpc/sysdev/grackle.c
··· 56 56 void __init setup_grackle(struct pci_controller *hose) 57 57 { 58 58 setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0); 59 - if (machine_is_compatible("PowerMac1,1")) 59 + if (of_machine_is_compatible("PowerMac1,1")) 60 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 62 grackle_set_loop_snoop(hose, 1); 63 63 #if 0 /* Disabled for now, HW problems ??? */ 64 64 grackle_set_stg(hose, 1);
+1 -1
arch/sparc/kernel/devices.c
··· 59 59 60 60 cur_inst = 0; 61 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 63 compare, compare_arg, 64 64 prom_node, mid); 65 65 if (!err) {
+1 -1
arch/sparc/kernel/of_device_32.c
··· 433 433 if (!parent) 434 434 dev_set_name(&op->dev, "root"); 435 435 else 436 - dev_set_name(&op->dev, "%08x", dp->node); 436 + dev_set_name(&op->dev, "%08x", dp->phandle); 437 437 438 438 if (of_device_register(op)) { 439 439 printk("%s: Could not register of device.\n",
+1 -1
arch/sparc/kernel/of_device_64.c
··· 676 676 if (!parent) 677 677 dev_set_name(&op->dev, "root"); 678 678 else 679 - dev_set_name(&op->dev, "%08x", dp->node); 679 + dev_set_name(&op->dev, "%08x", dp->phandle); 680 680 681 681 if (of_device_register(op)) { 682 682 printk("%s: Could not register of device.\n",
-3
arch/sparc/kernel/prom.h
··· 4 4 #include <linux/spinlock.h> 5 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 7 extern void * prom_early_alloc(unsigned long size); 11 8 extern void irq_trans_init(struct device_node *dp); 12 9
+3 -15
arch/sparc/kernel/prom_common.c
··· 37 37 char *of_console_options; 38 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 40 int of_getintprop_default(struct device_node *np, const char *name, int def) 53 41 { 54 42 struct property *prop; ··· 77 89 void *old_val = prop->value; 78 90 int ret; 79 91 80 - ret = prom_setprop(dp->node, name, val, len); 92 + ret = prom_setprop(dp->phandle, name, val, len); 81 93 82 94 err = -EINVAL; 83 95 if (ret >= 0) { ··· 224 236 225 237 dp->name = get_one_property(node, "name"); 226 238 dp->type = get_one_property(node, "device_type"); 227 - dp->node = node; 239 + dp->phandle = node; 228 240 229 241 dp->properties = build_prop_list(node); 230 242 ··· 301 313 302 314 nextp = &allnodes->allnext; 303 315 allnodes->child = prom_build_tree(allnodes, 304 - prom_getchild(allnodes->node), 316 + prom_getchild(allnodes->phandle), 305 317 &nextp); 306 318 of_console_init(); 307 319
+1 -1
arch/sparc/kernel/smp_64.c
··· 370 370 } else { 371 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 376 for (timeout = 0; timeout < 50000; timeout++) {
+1 -1
drivers/char/hvc_beat.c
··· 99 99 100 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 103 hvc_instantiate(0, 0, &hvc_beat_get_put_ops); 104 104 } 105 105 return 0;
+22 -22
drivers/gpu/drm/radeon/radeon_combios.c
··· 1279 1279 rdev->mode_info.connector_table = radeon_connector_table; 1280 1280 if (rdev->mode_info.connector_table == CT_NONE) { 1281 1281 #ifdef CONFIG_PPC_PMAC 1282 - if (machine_is_compatible("PowerBook3,3")) { 1282 + if (of_machine_is_compatible("PowerBook3,3")) { 1283 1283 /* powerbook with VGA */ 1284 1284 rdev->mode_info.connector_table = CT_POWERBOOK_VGA; 1285 - } else if (machine_is_compatible("PowerBook3,4") || 1286 - machine_is_compatible("PowerBook3,5")) { 1285 + } else if (of_machine_is_compatible("PowerBook3,4") || 1286 + of_machine_is_compatible("PowerBook3,5")) { 1287 1287 /* powerbook with internal tmds */ 1288 1288 rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; 1289 - } else if (machine_is_compatible("PowerBook5,1") || 1290 - machine_is_compatible("PowerBook5,2") || 1291 - machine_is_compatible("PowerBook5,3") || 1292 - machine_is_compatible("PowerBook5,4") || 1293 - machine_is_compatible("PowerBook5,5")) { 1289 + } else if (of_machine_is_compatible("PowerBook5,1") || 1290 + of_machine_is_compatible("PowerBook5,2") || 1291 + of_machine_is_compatible("PowerBook5,3") || 1292 + of_machine_is_compatible("PowerBook5,4") || 1293 + of_machine_is_compatible("PowerBook5,5")) { 1294 1294 /* powerbook with external single link tmds (sil164) */ 1295 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 1297 /* powerbook with external dual or single link tmds */ 1298 1298 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1299 - } else if (machine_is_compatible("PowerBook5,7") || 1300 - machine_is_compatible("PowerBook5,8") || 1301 - machine_is_compatible("PowerBook5,9")) { 1299 + } else if (of_machine_is_compatible("PowerBook5,7") || 1300 + of_machine_is_compatible("PowerBook5,8") || 1301 + of_machine_is_compatible("PowerBook5,9")) { 1302 1302 /* PowerBook6,2 ? */ 1303 1303 /* powerbook with external dual link tmds (sil1178?) */ 1304 1304 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; 1305 - } else if (machine_is_compatible("PowerBook4,1") || 1306 - machine_is_compatible("PowerBook4,2") || 1307 - machine_is_compatible("PowerBook4,3") || 1308 - machine_is_compatible("PowerBook6,3") || 1309 - machine_is_compatible("PowerBook6,5") || 1310 - machine_is_compatible("PowerBook6,7")) { 1305 + } else if (of_machine_is_compatible("PowerBook4,1") || 1306 + of_machine_is_compatible("PowerBook4,2") || 1307 + of_machine_is_compatible("PowerBook4,3") || 1308 + of_machine_is_compatible("PowerBook6,3") || 1309 + of_machine_is_compatible("PowerBook6,5") || 1310 + of_machine_is_compatible("PowerBook6,7")) { 1311 1311 /* ibook */ 1312 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 1314 /* emac */ 1315 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 1317 /* mini with internal tmds */ 1318 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 1320 /* mini with external tmds */ 1321 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 1323 /* PowerMac8,1 ? */ 1324 1324 /* imac g5 isight */ 1325 1325 rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT;
+2 -2
drivers/macintosh/adb.c
··· 322 322 adb_controller = NULL; 323 323 } else { 324 324 #ifdef CONFIG_PPC 325 - if (machine_is_compatible("AAPL,PowerBook1998") || 326 - machine_is_compatible("PowerBook1,1")) 325 + if (of_machine_is_compatible("AAPL,PowerBook1998") || 326 + of_machine_is_compatible("PowerBook1,1")) 327 327 sleepy_trackpad = 1; 328 328 #endif /* CONFIG_PPC */ 329 329
+4 -4
drivers/macintosh/therm_pm72.c
··· 1899 1899 */ 1900 1900 if (rackmac) 1901 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 1903 && (cpu_count > 1) 1904 1904 && fcu_fans[CPUA_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID 1905 1905 && fcu_fans[CPUB_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID) { ··· 2234 2234 { 2235 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") && 2240 - !machine_is_compatible("PowerMac7,3") && 2239 + if (!of_machine_is_compatible("PowerMac7,2") && 2240 + !of_machine_is_compatible("PowerMac7,3") && 2241 2241 !rackmac) 2242 2242 return -ENODEV; 2243 2243
+1 -1
drivers/macintosh/therm_windtunnel.c
··· 490 490 info = of_get_property(np, "thermal-info", NULL); 491 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 494 return -ENODEV; 495 495 496 496 if( info->id != 3 ) {
+4 -4
drivers/macintosh/via-pmu-backlight.c
··· 150 150 151 151 /* Special case for the old PowerBook since I can't test on it */ 152 152 autosave = 153 - machine_is_compatible("AAPL,3400/2400") || 154 - machine_is_compatible("AAPL,3500"); 153 + of_machine_is_compatible("AAPL,3400/2400") || 154 + of_machine_is_compatible("AAPL,3500"); 155 155 156 156 if (!autosave && 157 157 !pmac_has_backlight_type("pmu") && 158 - !machine_is_compatible("AAPL,PowerBook1998") && 159 - !machine_is_compatible("PowerBook1,1")) 158 + !of_machine_is_compatible("AAPL,PowerBook1998") && 159 + !of_machine_is_compatible("PowerBook1,1")) 160 160 return; 161 161 162 162 snprintf(name, sizeof(name), "pmubl");
+4 -4
drivers/macintosh/via-pmu.c
··· 463 463 #endif 464 464 465 465 #ifdef CONFIG_PPC32 466 - if (machine_is_compatible("AAPL,3400/2400") || 467 - machine_is_compatible("AAPL,3500")) { 466 + if (of_machine_is_compatible("AAPL,3400/2400") || 467 + of_machine_is_compatible("AAPL,3500")) { 468 468 int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO, 469 469 NULL, PMAC_MB_INFO_MODEL, 0); 470 470 pmu_battery_count = 1; ··· 472 472 pmu_batteries[0].flags |= PMU_BATT_TYPE_COMET; 473 473 else 474 474 pmu_batteries[0].flags |= PMU_BATT_TYPE_HOOPER; 475 - } else if (machine_is_compatible("AAPL,PowerBook1998") || 476 - machine_is_compatible("PowerBook1,1")) { 475 + } else if (of_machine_is_compatible("AAPL,PowerBook1998") || 476 + of_machine_is_compatible("PowerBook1,1")) { 477 477 pmu_battery_count = 2; 478 478 pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART; 479 479 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
+3 -3
drivers/macintosh/windfarm_core.c
··· 468 468 DBG("wf: core loaded\n"); 469 469 470 470 /* Don't register on old machines that use therm_pm72 for now */ 471 - if (machine_is_compatible("PowerMac7,2") || 472 - machine_is_compatible("PowerMac7,3") || 473 - machine_is_compatible("RackMac3,1")) 471 + if (of_machine_is_compatible("PowerMac7,2") || 472 + of_machine_is_compatible("PowerMac7,3") || 473 + of_machine_is_compatible("RackMac3,1")) 474 474 return -ENODEV; 475 475 platform_device_register(&wf_platform_device); 476 476 return 0;
+3 -3
drivers/macintosh/windfarm_cpufreq_clamp.c
··· 76 76 struct wf_control *clamp; 77 77 78 78 /* Don't register on old machines that use therm_pm72 for now */ 79 - if (machine_is_compatible("PowerMac7,2") || 80 - machine_is_compatible("PowerMac7,3") || 81 - machine_is_compatible("RackMac3,1")) 79 + if (of_machine_is_compatible("PowerMac7,2") || 80 + of_machine_is_compatible("PowerMac7,3") || 81 + of_machine_is_compatible("RackMac3,1")) 82 82 return -ENODEV; 83 83 84 84 clamp = kmalloc(sizeof(struct wf_control), GFP_KERNEL);
+3 -3
drivers/macintosh/windfarm_lm75_sensor.c
··· 239 239 static int __init wf_lm75_sensor_init(void) 240 240 { 241 241 /* Don't register on old machines that use therm_pm72 for now */ 242 - if (machine_is_compatible("PowerMac7,2") || 243 - machine_is_compatible("PowerMac7,3") || 244 - machine_is_compatible("RackMac3,1")) 242 + if (of_machine_is_compatible("PowerMac7,2") || 243 + of_machine_is_compatible("PowerMac7,3") || 244 + of_machine_is_compatible("RackMac3,1")) 245 245 return -ENODEV; 246 246 return i2c_add_driver(&wf_lm75_driver); 247 247 }
+3 -3
drivers/macintosh/windfarm_max6690_sensor.c
··· 188 188 static int __init wf_max6690_sensor_init(void) 189 189 { 190 190 /* Don't register on old machines that use therm_pm72 for now */ 191 - if (machine_is_compatible("PowerMac7,2") || 192 - machine_is_compatible("PowerMac7,3") || 193 - machine_is_compatible("RackMac3,1")) 191 + if (of_machine_is_compatible("PowerMac7,2") || 192 + of_machine_is_compatible("PowerMac7,3") || 193 + of_machine_is_compatible("RackMac3,1")) 194 194 return -ENODEV; 195 195 return i2c_add_driver(&wf_max6690_driver); 196 196 }
+1 -1
drivers/macintosh/windfarm_pm112.c
··· 676 676 { 677 677 struct device_node *cpu; 678 678 679 - if (!machine_is_compatible("PowerMac11,2")) 679 + if (!of_machine_is_compatible("PowerMac11,2")) 680 680 return -ENODEV; 681 681 682 682 /* Count the number of CPU cores */
+1 -1
drivers/macintosh/windfarm_pm121.c
··· 1008 1008 { 1009 1009 int rc = -ENODEV; 1010 1010 1011 - if (machine_is_compatible("PowerMac12,1")) 1011 + if (of_machine_is_compatible("PowerMac12,1")) 1012 1012 rc = pm121_init_pm(); 1013 1013 1014 1014 if (rc == 0) {
+2 -2
drivers/macintosh/windfarm_pm81.c
··· 779 779 { 780 780 int rc = -ENODEV; 781 781 782 - if (machine_is_compatible("PowerMac8,1") || 783 - machine_is_compatible("PowerMac8,2")) 782 + if (of_machine_is_compatible("PowerMac8,1") || 783 + of_machine_is_compatible("PowerMac8,2")) 784 784 rc = wf_init_pm(); 785 785 786 786 if (rc == 0) {
+1 -1
drivers/macintosh/windfarm_pm91.c
··· 711 711 { 712 712 int rc = -ENODEV; 713 713 714 - if (machine_is_compatible("PowerMac9,1")) 714 + if (of_machine_is_compatible("PowerMac9,1")) 715 715 rc = wf_init_pm(); 716 716 717 717 if (rc == 0) {
+3 -3
drivers/macintosh/windfarm_smu_sensors.c
··· 363 363 * I yet have to figure out what's up with 8,2 and will have to 364 364 * adjust for later, unless we can 100% trust the SDB partition... 365 365 */ 366 - if ((machine_is_compatible("PowerMac8,1") || 367 - machine_is_compatible("PowerMac8,2") || 368 - machine_is_compatible("PowerMac9,1")) && 366 + if ((of_machine_is_compatible("PowerMac8,1") || 367 + of_machine_is_compatible("PowerMac8,2") || 368 + of_machine_is_compatible("PowerMac9,1")) && 369 369 cpuvcp_version >= 2) { 370 370 pow->quadratic = 1; 371 371 DBG("windfarm: CPU Power using quadratic transform\n");
+1 -1
drivers/net/mace.c
··· 206 206 mp->port_aaui = port_aaui; 207 207 else { 208 208 /* Apple Network Server uses the AAUI port */ 209 - if (machine_is_compatible("AAPL,ShinerESB")) 209 + if (of_machine_is_compatible("AAPL,ShinerESB")) 210 210 mp->port_aaui = 1; 211 211 else { 212 212 #ifdef CONFIG_MACE_AAUI_PORT
+8
drivers/of/Kconfig
··· 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 9 config OF_DEVICE 2 10 def_bool y 3 11 depends on OF && (SPARC || PPC_OF || MICROBLAZE)
+1
drivers/of/Makefile
··· 1 1 obj-y = base.o 2 + obj-$(CONFIG_OF_FLATTREE) += fdt.o 2 3 obj-$(CONFIG_OF_DEVICE) += device.o platform.o 3 4 obj-$(CONFIG_OF_GPIO) += gpio.o 4 5 obj-$(CONFIG_OF_I2C) += of_i2c.o
+312 -6
drivers/of/base.c
··· 20 20 #include <linux/module.h> 21 21 #include <linux/of.h> 22 22 #include <linux/spinlock.h> 23 + #include <linux/proc_fs.h> 23 24 24 25 struct device_node *allnodes; 26 + struct device_node *of_chosen; 25 27 26 28 /* use when traversing tree through the allnext, child, sibling, 27 29 * or parent members of struct device_node. ··· 39 37 np = np->parent; 40 38 ip = of_get_property(np, "#address-cells", NULL); 41 39 if (ip) 42 - return *ip; 40 + return be32_to_cpup(ip); 43 41 } while (np->parent); 44 42 /* No #address-cells property for the root node */ 45 43 return OF_ROOT_NODE_ADDR_CELLS_DEFAULT; ··· 55 53 np = np->parent; 56 54 ip = of_get_property(np, "#size-cells", NULL); 57 55 if (ip) 58 - return *ip; 56 + return be32_to_cpup(ip); 59 57 } while (np->parent); 60 58 /* No #size-cells property for the root node */ 61 59 return OF_ROOT_NODE_SIZE_CELLS_DEFAULT; 62 60 } 63 61 EXPORT_SYMBOL(of_n_size_cells); 62 + 63 + #if !defined(CONFIG_SPARC) /* SPARC doesn't do ref counting (yet) */ 64 + /** 65 + * of_node_get - Increment refcount of a node 66 + * @node: Node to inc refcount, NULL is supported to 67 + * simplify writing of callers 68 + * 69 + * Returns node. 70 + */ 71 + struct device_node *of_node_get(struct device_node *node) 72 + { 73 + if (node) 74 + kref_get(&node->kref); 75 + return node; 76 + } 77 + EXPORT_SYMBOL(of_node_get); 78 + 79 + static inline struct device_node *kref_to_device_node(struct kref *kref) 80 + { 81 + return container_of(kref, struct device_node, kref); 82 + } 83 + 84 + /** 85 + * of_node_release - release a dynamically allocated node 86 + * @kref: kref element of the node to be released 87 + * 88 + * In of_node_put() this function is passed to kref_put() 89 + * as the destructor. 90 + */ 91 + static void of_node_release(struct kref *kref) 92 + { 93 + struct device_node *node = kref_to_device_node(kref); 94 + struct property *prop = node->properties; 95 + 96 + /* We should never be releasing nodes that haven't been detached. */ 97 + if (!of_node_check_flag(node, OF_DETACHED)) { 98 + pr_err("ERROR: Bad of_node_put() on %s\n", node->full_name); 99 + dump_stack(); 100 + kref_init(&node->kref); 101 + return; 102 + } 103 + 104 + if (!of_node_check_flag(node, OF_DYNAMIC)) 105 + return; 106 + 107 + while (prop) { 108 + struct property *next = prop->next; 109 + kfree(prop->name); 110 + kfree(prop->value); 111 + kfree(prop); 112 + prop = next; 113 + 114 + if (!prop) { 115 + prop = node->deadprops; 116 + node->deadprops = NULL; 117 + } 118 + } 119 + kfree(node->full_name); 120 + kfree(node->data); 121 + kfree(node); 122 + } 123 + 124 + /** 125 + * of_node_put - Decrement refcount of a node 126 + * @node: Node to dec refcount, NULL is supported to 127 + * simplify writing of callers 128 + * 129 + */ 130 + void of_node_put(struct device_node *node) 131 + { 132 + if (node) 133 + kref_put(&node->kref, of_node_release); 134 + } 135 + EXPORT_SYMBOL(of_node_put); 136 + #endif /* !CONFIG_SPARC */ 64 137 65 138 struct property *of_find_property(const struct device_node *np, 66 139 const char *name, ··· 219 142 return 0; 220 143 } 221 144 EXPORT_SYMBOL(of_device_is_compatible); 145 + 146 + /** 147 + * of_machine_is_compatible - Test root of device tree for a given compatible value 148 + * @compat: compatible string to look for in root node's compatible property. 149 + * 150 + * Returns true if the root node has the given value in its 151 + * compatible property. 152 + */ 153 + int of_machine_is_compatible(const char *compat) 154 + { 155 + struct device_node *root; 156 + int rc = 0; 157 + 158 + root = of_find_node_by_path("/"); 159 + if (root) { 160 + rc = of_device_is_compatible(root, compat); 161 + of_node_put(root); 162 + } 163 + return rc; 164 + } 165 + EXPORT_SYMBOL(of_machine_is_compatible); 222 166 223 167 /** 224 168 * of_device_is_available - check if a device is available for use ··· 617 519 EXPORT_SYMBOL_GPL(of_modalias_node); 618 520 619 521 /** 522 + * of_find_node_by_phandle - Find a node given a phandle 523 + * @handle: phandle of the node to find 524 + * 525 + * Returns a node pointer with refcount incremented, use 526 + * of_node_put() on it when done. 527 + */ 528 + struct device_node *of_find_node_by_phandle(phandle handle) 529 + { 530 + struct device_node *np; 531 + 532 + read_lock(&devtree_lock); 533 + for (np = allnodes; np; np = np->allnext) 534 + if (np->phandle == handle) 535 + break; 536 + of_node_get(np); 537 + read_unlock(&devtree_lock); 538 + return np; 539 + } 540 + EXPORT_SYMBOL(of_find_node_by_phandle); 541 + 542 + /** 620 543 * of_parse_phandle - Resolve a phandle property to a device_node pointer 621 544 * @np: Pointer to device node holding phandle property 622 545 * @phandle_name: Name of property holding a phandle value ··· 697 578 const void **out_args) 698 579 { 699 580 int ret = -EINVAL; 700 - const u32 *list; 701 - const u32 *list_end; 581 + const __be32 *list; 582 + const __be32 *list_end; 702 583 int size; 703 584 int cur_index = 0; 704 585 struct device_node *node = NULL; ··· 712 593 list_end = list + size / sizeof(*list); 713 594 714 595 while (list < list_end) { 715 - const u32 *cells; 596 + const __be32 *cells; 716 597 const phandle *phandle; 717 598 718 599 phandle = list++; ··· 736 617 goto err1; 737 618 } 738 619 739 - list += *cells; 620 + list += be32_to_cpup(cells); 740 621 if (list > list_end) { 741 622 pr_debug("%s: insufficient arguments length\n", 742 623 np->full_name); ··· 777 658 return ret; 778 659 } 779 660 EXPORT_SYMBOL(of_parse_phandles_with_args); 661 + 662 + /** 663 + * prom_add_property - Add a property to a node 664 + */ 665 + int prom_add_property(struct device_node *np, struct property *prop) 666 + { 667 + struct property **next; 668 + unsigned long flags; 669 + 670 + prop->next = NULL; 671 + write_lock_irqsave(&devtree_lock, flags); 672 + next = &np->properties; 673 + while (*next) { 674 + if (strcmp(prop->name, (*next)->name) == 0) { 675 + /* duplicate ! don't insert it */ 676 + write_unlock_irqrestore(&devtree_lock, flags); 677 + return -1; 678 + } 679 + next = &(*next)->next; 680 + } 681 + *next = prop; 682 + write_unlock_irqrestore(&devtree_lock, flags); 683 + 684 + #ifdef CONFIG_PROC_DEVICETREE 685 + /* try to add to proc as well if it was initialized */ 686 + if (np->pde) 687 + proc_device_tree_add_prop(np->pde, prop); 688 + #endif /* CONFIG_PROC_DEVICETREE */ 689 + 690 + return 0; 691 + } 692 + 693 + /** 694 + * prom_remove_property - Remove a property from a node. 695 + * 696 + * Note that we don't actually remove it, since we have given out 697 + * who-knows-how-many pointers to the data using get-property. 698 + * Instead we just move the property to the "dead properties" 699 + * list, so it won't be found any more. 700 + */ 701 + int prom_remove_property(struct device_node *np, struct property *prop) 702 + { 703 + struct property **next; 704 + unsigned long flags; 705 + int found = 0; 706 + 707 + write_lock_irqsave(&devtree_lock, flags); 708 + next = &np->properties; 709 + while (*next) { 710 + if (*next == prop) { 711 + /* found the node */ 712 + *next = prop->next; 713 + prop->next = np->deadprops; 714 + np->deadprops = prop; 715 + found = 1; 716 + break; 717 + } 718 + next = &(*next)->next; 719 + } 720 + write_unlock_irqrestore(&devtree_lock, flags); 721 + 722 + if (!found) 723 + return -ENODEV; 724 + 725 + #ifdef CONFIG_PROC_DEVICETREE 726 + /* try to remove the proc node as well */ 727 + if (np->pde) 728 + proc_device_tree_remove_prop(np->pde, prop); 729 + #endif /* CONFIG_PROC_DEVICETREE */ 730 + 731 + return 0; 732 + } 733 + 734 + /* 735 + * prom_update_property - Update a property in a node. 736 + * 737 + * Note that we don't actually remove it, since we have given out 738 + * who-knows-how-many pointers to the data using get-property. 739 + * Instead we just move the property to the "dead properties" list, 740 + * and add the new property to the property list 741 + */ 742 + int prom_update_property(struct device_node *np, 743 + struct property *newprop, 744 + struct property *oldprop) 745 + { 746 + struct property **next; 747 + unsigned long flags; 748 + int found = 0; 749 + 750 + write_lock_irqsave(&devtree_lock, flags); 751 + next = &np->properties; 752 + while (*next) { 753 + if (*next == oldprop) { 754 + /* found the node */ 755 + newprop->next = oldprop->next; 756 + *next = newprop; 757 + oldprop->next = np->deadprops; 758 + np->deadprops = oldprop; 759 + found = 1; 760 + break; 761 + } 762 + next = &(*next)->next; 763 + } 764 + write_unlock_irqrestore(&devtree_lock, flags); 765 + 766 + if (!found) 767 + return -ENODEV; 768 + 769 + #ifdef CONFIG_PROC_DEVICETREE 770 + /* try to add to proc as well if it was initialized */ 771 + if (np->pde) 772 + proc_device_tree_update_prop(np->pde, newprop, oldprop); 773 + #endif /* CONFIG_PROC_DEVICETREE */ 774 + 775 + return 0; 776 + } 777 + 778 + #if defined(CONFIG_OF_DYNAMIC) 779 + /* 780 + * Support for dynamic device trees. 781 + * 782 + * On some platforms, the device tree can be manipulated at runtime. 783 + * The routines in this section support adding, removing and changing 784 + * device tree nodes. 785 + */ 786 + 787 + /** 788 + * of_attach_node - Plug a device node into the tree and global list. 789 + */ 790 + void of_attach_node(struct device_node *np) 791 + { 792 + unsigned long flags; 793 + 794 + write_lock_irqsave(&devtree_lock, flags); 795 + np->sibling = np->parent->child; 796 + np->allnext = allnodes; 797 + np->parent->child = np; 798 + allnodes = np; 799 + write_unlock_irqrestore(&devtree_lock, flags); 800 + } 801 + 802 + /** 803 + * of_detach_node - "Unplug" a node from the device tree. 804 + * 805 + * The caller must hold a reference to the node. The memory associated with 806 + * the node is not freed until its refcount goes to zero. 807 + */ 808 + void of_detach_node(struct device_node *np) 809 + { 810 + struct device_node *parent; 811 + unsigned long flags; 812 + 813 + write_lock_irqsave(&devtree_lock, flags); 814 + 815 + parent = np->parent; 816 + if (!parent) 817 + goto out_unlock; 818 + 819 + if (allnodes == np) 820 + allnodes = np->allnext; 821 + else { 822 + struct device_node *prev; 823 + for (prev = allnodes; 824 + prev->allnext != np; 825 + prev = prev->allnext) 826 + ; 827 + prev->allnext = np->allnext; 828 + } 829 + 830 + if (parent->child == np) 831 + parent->child = np->sibling; 832 + else { 833 + struct device_node *prevsib; 834 + for (prevsib = np->parent->child; 835 + prevsib->sibling != np; 836 + prevsib = prevsib->sibling) 837 + ; 838 + prevsib->sibling = np->sibling; 839 + } 840 + 841 + of_node_set_flag(np, OF_DETACHED); 842 + 843 + out_unlock: 844 + write_unlock_irqrestore(&devtree_lock, flags); 845 + } 846 + #endif /* defined(CONFIG_OF_DYNAMIC) */ 847 +
+590
drivers/of/fdt.c
··· 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, &reg); 494 + size = dt_mem_next_cell(dt_root_size_cells, &reg); 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 + }
+7 -6
drivers/of/gpio.c
··· 36 36 struct of_gpio_chip *of_gc = NULL; 37 37 int size; 38 38 const void *gpio_spec; 39 - const u32 *gpio_cells; 39 + const __be32 *gpio_cells; 40 40 41 41 ret = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, 42 42 &gc, &gpio_spec); ··· 55 55 56 56 gpio_cells = of_get_property(gc, "#gpio-cells", &size); 57 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 59 pr_debug("%s: wrong #gpio-cells for %s\n", 60 60 np->full_name, gc->full_name); 61 61 ret = -EINVAL; ··· 127 127 int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np, 128 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 134 * We're discouraging gpio_cells < 2, since that way you'll have to ··· 141 140 return -EINVAL; 142 141 } 143 142 144 - if (*gpio > of_gc->gc.ngpio) 143 + if (n > of_gc->gc.ngpio) 145 144 return -EINVAL; 146 145 147 146 if (flags) 148 - *flags = gpio[1]; 147 + *flags = be32_to_cpu(gpio[1]); 149 148 150 - return *gpio; 149 + return n; 151 150 } 152 151 EXPORT_SYMBOL(of_gpio_simple_xlate); 153 152
+2 -2
drivers/of/of_i2c.c
··· 25 25 for_each_child_of_node(adap_node, node) { 26 26 struct i2c_board_info info = {}; 27 27 struct dev_archdata dev_ad = {}; 28 - const u32 *addr; 28 + const __be32 *addr; 29 29 int len; 30 30 31 31 if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) ··· 40 40 41 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 45 dev_archdata_set_node(&dev_ad, node); 46 46 info.archdata = &dev_ad;
+4 -4
drivers/of/of_mdio.c
··· 51 51 52 52 /* Loop over the child nodes and register a phy_device for each one */ 53 53 for_each_child_of_node(np, child) { 54 - const u32 *addr; 54 + const __be32 *addr; 55 55 int len; 56 56 57 57 /* A PHY must have a reg property in the range [0-31] */ ··· 68 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 72 if (!phy) { 73 73 dev_err(&mdio->dev, "error probing PHY at address %i\n", 74 74 *addr); ··· 160 160 struct device_node *net_np; 161 161 char bus_id[MII_BUS_ID_SIZE + 3]; 162 162 struct phy_device *phy; 163 - const u32 *phy_id; 163 + const __be32 *phy_id; 164 164 int sz; 165 165 166 166 if (!dev->dev.parent) ··· 174 174 if (!phy_id || sz < sizeof(*phy_id)) 175 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 179 phy = phy_connect(dev, bus_id, hndlr, 0, iface); 180 180 return IS_ERR(phy) ? NULL : phy;
+3 -3
drivers/of/of_spi.c
··· 23 23 { 24 24 struct spi_device *spi; 25 25 struct device_node *nc; 26 - const u32 *prop; 26 + const __be32 *prop; 27 27 int rc; 28 28 int len; 29 29 ··· 54 54 spi_dev_put(spi); 55 55 continue; 56 56 } 57 - spi->chip_select = *prop; 57 + spi->chip_select = be32_to_cpup(prop); 58 58 59 59 /* Mode (clock phase/polarity/etc.) */ 60 60 if (of_find_property(nc, "spi-cpha", NULL)) ··· 72 72 spi_dev_put(spi); 73 73 continue; 74 74 } 75 - spi->max_speed_hz = *prop; 75 + spi->max_speed_hz = be32_to_cpup(prop); 76 76 77 77 /* IRQ */ 78 78 spi->irq = irq_of_parse_and_map(nc, 0);
+5 -5
drivers/sbus/char/openprom.c
··· 233 233 234 234 ph = 0; 235 235 if (dp) 236 - ph = dp->node; 236 + ph = dp->phandle; 237 237 238 238 data->current_node = dp; 239 239 *((int *) op->oprom_array) = ph; ··· 256 256 257 257 dp = pci_device_to_OF_node(pdev); 258 258 data->current_node = dp; 259 - *((int *)op->oprom_array) = dp->node; 259 + *((int *)op->oprom_array) = dp->phandle; 260 260 op->oprom_size = sizeof(int); 261 261 err = copyout(argp, op, bufsize + sizeof(int)); 262 262 ··· 273 273 274 274 dp = of_find_node_by_path(op->oprom_array); 275 275 if (dp) 276 - ph = dp->node; 276 + ph = dp->phandle; 277 277 data->current_node = dp; 278 278 *((int *)op->oprom_array) = ph; 279 279 op->oprom_size = sizeof(int); ··· 540 540 } 541 541 } 542 542 if (dp) 543 - nd = dp->node; 543 + nd = dp->phandle; 544 544 if (copy_to_user(argp, &nd, sizeof(phandle))) 545 545 return -EFAULT; 546 546 ··· 570 570 case OPIOCGETOPTNODE: 571 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 574 return -EFAULT; 575 575 576 576 return 0;
+3 -3
drivers/serial/pmac_zilog.c
··· 2031 2031 /* 2032 2032 * XServe's default to 57600 bps 2033 2033 */ 2034 - if (machine_is_compatible("RackMac1,1") 2035 - || machine_is_compatible("RackMac1,2") 2036 - || machine_is_compatible("MacRISC4")) 2034 + if (of_machine_is_compatible("RackMac1,1") 2035 + || of_machine_is_compatible("RackMac1,2") 2036 + || of_machine_is_compatible("MacRISC4")) 2037 2037 baud = 57600; 2038 2038 2039 2039 /*
+7 -7
drivers/video/aty/aty128fb.c
··· 1931 1931 * PowerMac2,2 summer 2000 iMacs 1932 1932 * PowerMac4,1 january 2001 iMacs "flower power" 1933 1933 */ 1934 - if (machine_is_compatible("PowerMac2,1") || 1935 - machine_is_compatible("PowerMac2,2") || 1936 - machine_is_compatible("PowerMac4,1")) 1934 + if (of_machine_is_compatible("PowerMac2,1") || 1935 + of_machine_is_compatible("PowerMac2,2") || 1936 + of_machine_is_compatible("PowerMac4,1")) 1937 1937 default_vmode = VMODE_1024_768_75; 1938 1938 1939 1939 /* iBook SE */ 1940 - if (machine_is_compatible("PowerBook2,2")) 1940 + if (of_machine_is_compatible("PowerBook2,2")) 1941 1941 default_vmode = VMODE_800_600_60; 1942 1942 1943 1943 /* PowerBook Firewire (Pismo), iBook Dual USB */ 1944 - if (machine_is_compatible("PowerBook3,1") || 1945 - machine_is_compatible("PowerBook4,1")) 1944 + if (of_machine_is_compatible("PowerBook3,1") || 1945 + of_machine_is_compatible("PowerBook4,1")) 1946 1946 default_vmode = VMODE_1024_768_60; 1947 1947 1948 1948 /* PowerBook Titanium */ 1949 - if (machine_is_compatible("PowerBook3,2")) 1949 + if (of_machine_is_compatible("PowerBook3,2")) 1950 1950 default_vmode = VMODE_1152_768_60; 1951 1951 1952 1952 if (default_cmode > 16)
+5 -5
drivers/video/aty/atyfb_base.c
··· 2439 2439 * The Apple iBook1 uses non-standard memory frequencies. 2440 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 2443 par->pll_limits.mclk = 70; 2444 2444 par->pll_limits.xclk = 53; 2445 2445 } ··· 2659 2659 FBINFO_HWACCEL_YPAN; 2660 2660 2661 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 2664 * these bits let the 101 powerbook 2665 2665 * wake up from sleep -- paulus ··· 2690 2690 if (M64_HAS(G3_PB_1024x768)) 2691 2691 /* G3 PowerBook with 1024x768 LCD */ 2692 2692 default_vmode = VMODE_1024_768_60; 2693 - else if (machine_is_compatible("iMac")) 2693 + else if (of_machine_is_compatible("iMac")) 2694 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 2696 /* iBook with 800x600 LCD */ 2697 2697 default_vmode = VMODE_800_600_60; 2698 2698 else ··· 3104 3104 } 3105 3105 3106 3106 dp = pci_device_to_OF_node(pdev); 3107 - if (node == dp->node) { 3107 + if (node == dp->phandle) { 3108 3108 struct fb_var_screeninfo *var = &default_var; 3109 3109 unsigned int N, P, Q, M, T, R; 3110 3110 u32 v_total, h_total;
+3 -3
drivers/video/aty/radeon_backlight.c
··· 175 175 176 176 #ifdef CONFIG_PMAC_BACKLIGHT 177 177 pdata->negative = pdata->negative || 178 - machine_is_compatible("PowerBook4,3") || 179 - machine_is_compatible("PowerBook6,3") || 180 - machine_is_compatible("PowerBook6,5"); 178 + of_machine_is_compatible("PowerBook4,3") || 179 + of_machine_is_compatible("PowerBook6,3") || 180 + of_machine_is_compatible("PowerBook6,5"); 181 181 #endif 182 182 183 183 rinfo->info->bl_dev = bd;
+5 -2
fs/proc/proc_devtree.c
··· 10 10 #include <linux/seq_file.h> 11 11 #include <linux/stat.h> 12 12 #include <linux/string.h> 13 + #include <linux/of.h> 14 + #include <linux/module.h> 13 15 #include <asm/prom.h> 14 16 #include <asm/uaccess.h> 15 17 #include "internal.h" 16 18 17 - #ifndef HAVE_ARCH_DEVTREE_FIXUPS 18 19 static inline void set_node_proc_entry(struct device_node *np, 19 20 struct proc_dir_entry *de) 20 21 { 21 - } 22 + #ifdef HAVE_ARCH_DEVTREE_FIXUPS 23 + np->pde = de; 22 24 #endif 25 + } 23 26 24 27 static struct proc_dir_entry *proc_device_tree; 25 28
+44 -18
include/linux/of.h
··· 19 19 #include <linux/bitops.h> 20 20 #include <linux/kref.h> 21 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 28 typedef u32 phandle; 24 29 typedef u32 ihandle; ··· 44 39 struct device_node { 45 40 const char *name; 46 41 const char *type; 47 - phandle node; 48 - #if !defined(CONFIG_SPARC) 49 - phandle linux_phandle; 50 - #endif 42 + phandle phandle; 51 43 char *full_name; 52 44 53 45 struct property *properties; ··· 65 63 #endif 66 64 }; 67 65 66 + /* Pointer for first entry in chain of all nodes. */ 67 + extern struct device_node *allnodes; 68 + extern struct device_node *of_chosen; 69 + extern rwlock_t devtree_lock; 70 + 68 71 static inline int of_node_check_flag(struct device_node *n, unsigned long flag) 69 72 { 70 73 return test_bit(flag, &n->_flags); ··· 78 71 static inline void of_node_set_flag(struct device_node *n, unsigned long flag) 79 72 { 80 73 set_bit(flag, &n->_flags); 81 - } 82 - 83 - static inline void 84 - set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de) 85 - { 86 - dn->pde = de; 87 74 } 88 75 89 76 extern struct device_node *of_find_all_nodes(struct device_node *prev); ··· 102 101 */ 103 102 104 103 /* Helper to read a big number; size is in cells (not bytes) */ 105 - static inline u64 of_read_number(const u32 *cell, int size) 104 + static inline u64 of_read_number(const __be32 *cell, int size) 106 105 { 107 106 u64 r = 0; 108 107 while (size--) 109 - r = (r << 32) | *(cell++); 108 + r = (r << 32) | be32_to_cpu(*(cell++)); 110 109 return r; 111 110 } 112 111 113 112 /* Like of_read_number, but we want an unsigned long result */ 114 - #ifdef CONFIG_PPC32 115 - static inline unsigned long of_read_ulong(const u32 *cell, int size) 113 + static inline unsigned long of_read_ulong(const __be32 *cell, int size) 116 114 { 117 - return cell[size-1]; 115 + /* toss away upper bits if unsigned long is smaller than u64 */ 116 + return of_read_number(cell, size); 118 117 } 119 - #else 120 - #define of_read_ulong(cell, size) of_read_number(cell, size) 121 - #endif 122 118 123 119 #include <asm/prom.h> 120 + 121 + /* Default #address and #size cells. Allow arch asm/prom.h to override */ 122 + #if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT) 123 + #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 124 + #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 125 + #endif 126 + 127 + /* Default string compare functions, Allow arch asm/prom.h to override */ 128 + #if !defined(of_compat_cmp) 129 + #define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l)) 130 + #define of_prop_cmp(s1, s2) strcmp((s1), (s2)) 131 + #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) 132 + #endif 124 133 125 134 /* flag descriptions */ 126 135 #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ ··· 198 187 const char *list_name, const char *cells_name, int index, 199 188 struct device_node **out_node, const void **out_args); 200 189 190 + extern int of_machine_is_compatible(const char *compat); 191 + 192 + extern int prom_add_property(struct device_node* np, struct property* prop); 193 + extern int prom_remove_property(struct device_node *np, struct property *prop); 194 + extern int prom_update_property(struct device_node *np, 195 + struct property *newprop, 196 + struct property *oldprop); 197 + 198 + #if defined(CONFIG_OF_DYNAMIC) 199 + /* For updating the device tree at runtime */ 200 + extern void of_attach_node(struct device_node *); 201 + extern void of_detach_node(struct device_node *); 202 + #endif 203 + 204 + #endif /* CONFIG_OF */ 201 205 #endif /* _LINUX_OF_H */
+46 -29
include/linux/of_fdt.h
··· 42 42 * ends when size is 0 43 43 */ 44 44 struct boot_param_header { 45 - u32 magic; /* magic word OF_DT_HEADER */ 46 - u32 totalsize; /* total size of DT block */ 47 - u32 off_dt_struct; /* offset to structure */ 48 - u32 off_dt_strings; /* offset to strings */ 49 - u32 off_mem_rsvmap; /* offset to memory reserve map */ 50 - u32 version; /* format version */ 51 - u32 last_comp_version; /* last compatible version */ 45 + __be32 magic; /* magic word OF_DT_HEADER */ 46 + __be32 totalsize; /* total size of DT block */ 47 + __be32 off_dt_struct; /* offset to structure */ 48 + __be32 off_dt_strings; /* offset to strings */ 49 + __be32 off_mem_rsvmap; /* offset to memory reserve map */ 50 + __be32 version; /* format version */ 51 + __be32 last_comp_version; /* last compatible version */ 52 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 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 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 65 /* For scanning the flat device-tree at boot time */ 61 - extern int __init of_scan_flat_dt(int (*it)(unsigned long node, 62 - const char *uname, int depth, 63 - void *data), 64 - void *data); 65 - extern void __init *of_get_flat_dt_prop(unsigned long node, const char *name, 66 - unsigned long *size); 67 - extern int __init of_flat_dt_is_compatible(unsigned long node, 68 - const char *name); 69 - extern unsigned long __init of_get_flat_dt_root(void); 66 + extern char *find_flat_dt_string(u32 offset); 67 + extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname, 68 + int depth, void *data), 69 + void *data); 70 + extern void *of_get_flat_dt_prop(unsigned long node, const char *name, 71 + unsigned long *size); 72 + extern int of_flat_dt_is_compatible(unsigned long node, const char *name); 73 + extern unsigned long 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 98 /* Other Prototypes */ 72 - extern void finish_device_tree(void); 73 99 extern void unflatten_device_tree(void); 74 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 102 #endif /* __ASSEMBLY__ */ 86 103 #endif /* _LINUX_OF_FDT_H */
+1 -1
sound/aoa/fabrics/layout.c
··· 768 768 "required property %s not present\n", propname); 769 769 return -ENODEV; 770 770 } 771 - if (*ref != codec->node->linux_phandle) { 771 + if (*ref != codec->node->phandle) { 772 772 printk(KERN_INFO "snd-aoa-fabric-layout: " 773 773 "%s doesn't match!\n", propname); 774 774 return -ENODEV;
+12 -12
sound/ppc/awacs.c
··· 751 751 752 752 static void snd_pmac_awacs_resume(struct snd_pmac *chip) 753 753 { 754 - if (machine_is_compatible("PowerBook3,1") 755 - || machine_is_compatible("PowerBook3,2")) { 754 + if (of_machine_is_compatible("PowerBook3,1") 755 + || of_machine_is_compatible("PowerBook3,2")) { 756 756 msleep(100); 757 757 snd_pmac_awacs_write_reg(chip, 1, 758 758 chip->awacs_reg[1] & ~MASK_PAROUT); ··· 780 780 } 781 781 #endif /* CONFIG_PM */ 782 782 783 - #define IS_PM7500 (machine_is_compatible("AAPL,7500") \ 784 - || machine_is_compatible("AAPL,8500") \ 785 - || machine_is_compatible("AAPL,9500")) 786 - #define IS_PM5500 (machine_is_compatible("AAPL,e411")) 787 - #define IS_BEIGE (machine_is_compatible("AAPL,Gossamer")) 788 - #define IS_IMAC1 (machine_is_compatible("PowerMac2,1")) 789 - #define IS_IMAC2 (machine_is_compatible("PowerMac2,2") \ 790 - || machine_is_compatible("PowerMac4,1")) 791 - #define IS_G4AGP (machine_is_compatible("PowerMac3,1")) 792 - #define IS_LOMBARD (machine_is_compatible("PowerBook1,1")) 783 + #define IS_PM7500 (of_machine_is_compatible("AAPL,7500") \ 784 + || of_machine_is_compatible("AAPL,8500") \ 785 + || of_machine_is_compatible("AAPL,9500")) 786 + #define IS_PM5500 (of_machine_is_compatible("AAPL,e411")) 787 + #define IS_BEIGE (of_machine_is_compatible("AAPL,Gossamer")) 788 + #define IS_IMAC1 (of_machine_is_compatible("PowerMac2,1")) 789 + #define IS_IMAC2 (of_machine_is_compatible("PowerMac2,2") \ 790 + || of_machine_is_compatible("PowerMac4,1")) 791 + #define IS_G4AGP (of_machine_is_compatible("PowerMac3,1")) 792 + #define IS_LOMBARD (of_machine_is_compatible("PowerBook1,1")) 793 793 794 794 static int imac1, imac2; 795 795
+2 -2
sound/ppc/burgundy.c
··· 582 582 static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify) 583 583 { 584 584 if (chip->auto_mute) { 585 - int imac = machine_is_compatible("iMac"); 585 + int imac = of_machine_is_compatible("iMac"); 586 586 int reg, oreg; 587 587 reg = oreg = snd_pmac_burgundy_rcb(chip, 588 588 MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); ··· 620 620 */ 621 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 624 int i, err; 625 625 626 626 /* Checks to see the chip is alive and kicking */
+9 -9
sound/ppc/pmac.c
··· 922 922 } 923 923 924 924 /* it seems the Pismo & iBook can't byte-swap in hardware. */ 925 - if (machine_is_compatible("PowerBook3,1") || 926 - machine_is_compatible("PowerBook2,1")) 925 + if (of_machine_is_compatible("PowerBook3,1") || 926 + of_machine_is_compatible("PowerBook2,1")) 927 927 chip->can_byte_swap = 0 ; 928 928 929 - if (machine_is_compatible("PowerBook2,1")) 929 + if (of_machine_is_compatible("PowerBook2,1")) 930 930 chip->can_duplex = 0; 931 931 } 932 932 ··· 959 959 chip->control_mask = MASK_IEPC | MASK_IEE | 0x11; /* default */ 960 960 961 961 /* check machine type */ 962 - if (machine_is_compatible("AAPL,3400/2400") 963 - || machine_is_compatible("AAPL,3500")) 962 + if (of_machine_is_compatible("AAPL,3400/2400") 963 + || of_machine_is_compatible("AAPL,3500")) 964 964 chip->is_pbook_3400 = 1; 965 - else if (machine_is_compatible("PowerBook1,1") 966 - || machine_is_compatible("AAPL,PowerBook1998")) 965 + else if (of_machine_is_compatible("PowerBook1,1") 966 + || of_machine_is_compatible("AAPL,PowerBook1998")) 967 967 chip->is_pbook_G3 = 1; 968 968 chip->node = of_find_node_by_name(NULL, "awacs"); 969 969 sound = of_node_get(chip->node); ··· 1033 1033 } 1034 1034 if (of_device_is_compatible(sound, "tumbler")) { 1035 1035 chip->model = PMAC_TUMBLER; 1036 - chip->can_capture = machine_is_compatible("PowerMac4,2") 1037 - || machine_is_compatible("PowerBook4,1"); 1036 + chip->can_capture = of_machine_is_compatible("PowerMac4,2") 1037 + || of_machine_is_compatible("PowerBook4,1"); 1038 1038 chip->can_duplex = 0; 1039 1039 // chip->can_byte_swap = 0; /* FIXME: check this */ 1040 1040 chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
+1 -1
sound/soc/fsl/efika-audio-fabric.c
··· 55 55 struct platform_device *pdev; 56 56 int rc; 57 57 58 - if (!machine_is_compatible("bplan,efika")) 58 + if (!of_machine_is_compatible("bplan,efika")) 59 59 return -ENODEV; 60 60 61 61 card.platform = &mpc5200_audio_dma_platform;
+1 -1
sound/soc/fsl/pcm030-audio-fabric.c
··· 55 55 struct platform_device *pdev; 56 56 int rc; 57 57 58 - if (!machine_is_compatible("phytec,pcm030")) 58 + if (!of_machine_is_compatible("phytec,pcm030")) 59 59 return -ENODEV; 60 60 61 61 card.platform = &mpc5200_audio_dma_platform;