aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/fdt.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-09 13:26:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-09 13:26:33 -0400
commit64c353864e3f7ccba0ade1bd6f562f9a3bc7e68d (patch)
treefdd4d4c0cc90ef920cd755b835f0acf1e6ef8fbf /drivers/of/fdt.c
parentd8cacd3a259bf522ea5e6c4c60eba67ba22f599c (diff)
parent10bcdfb8ba24760f715f0a700c3812747eddddf5 (diff)
Merge branch 'for-v3.12' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping
Pull DMA mapping update from Marek Szyprowski: "This contains an addition of Device Tree support for reserved memory regions (Contiguous Memory Allocator is one of the drivers for it) and changes required by the KVM extensions for PowerPC architectue" * 'for-v3.12' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping: ARM: init: add support for reserved memory defined by device tree drivers: of: add initialization code for dma reserved memory drivers: of: add function to scan fdt nodes given by path drivers: dma-contiguous: clean source code and prepare for device tree
Diffstat (limited to 'drivers/of/fdt.c')
-rw-r--r--drivers/of/fdt.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index b10ba00cc3e6..4fb06f3e7b3c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -545,6 +545,82 @@ int __init of_flat_dt_match(unsigned long node, const char *const *compat)
545 return of_fdt_match(initial_boot_params, node, compat); 545 return of_fdt_match(initial_boot_params, node, compat);
546} 546}
547 547
548struct fdt_scan_status {
549 const char *name;
550 int namelen;
551 int depth;
552 int found;
553 int (*iterator)(unsigned long node, const char *uname, int depth, void *data);
554 void *data;
555};
556
557/**
558 * fdt_scan_node_by_path - iterator for of_scan_flat_dt_by_path function
559 */
560static int __init fdt_scan_node_by_path(unsigned long node, const char *uname,
561 int depth, void *data)
562{
563 struct fdt_scan_status *st = data;
564
565 /*
566 * if scan at the requested fdt node has been completed,
567 * return -ENXIO to abort further scanning
568 */
569 if (depth <= st->depth)
570 return -ENXIO;
571
572 /* requested fdt node has been found, so call iterator function */
573 if (st->found)
574 return st->iterator(node, uname, depth, st->data);
575
576 /* check if scanning automata is entering next level of fdt nodes */
577 if (depth == st->depth + 1 &&
578 strncmp(st->name, uname, st->namelen) == 0 &&
579 uname[st->namelen] == 0) {
580 st->depth += 1;
581 if (st->name[st->namelen] == 0) {
582 st->found = 1;
583 } else {
584 const char *next = st->name + st->namelen + 1;
585 st->name = next;
586 st->namelen = strcspn(next, "/");
587 }
588 return 0;
589 }
590
591 /* scan next fdt node */
592 return 0;
593}
594
595/**
596 * of_scan_flat_dt_by_path - scan flattened tree blob and call callback on each
597 * child of the given path.
598 * @path: path to start searching for children
599 * @it: callback function
600 * @data: context data pointer
601 *
602 * This function is used to scan the flattened device-tree starting from the
603 * node given by path. It is used to extract information (like reserved
604 * memory), which is required on ealy boot before we can unflatten the tree.
605 */
606int __init of_scan_flat_dt_by_path(const char *path,
607 int (*it)(unsigned long node, const char *name, int depth, void *data),
608 void *data)
609{
610 struct fdt_scan_status st = {path, 0, -1, 0, it, data};
611 int ret = 0;
612
613 if (initial_boot_params)
614 ret = of_scan_flat_dt(fdt_scan_node_by_path, &st);
615
616 if (!st.found)
617 return -ENOENT;
618 else if (ret == -ENXIO) /* scan has been completed */
619 return 0;
620 else
621 return ret;
622}
623
548#ifdef CONFIG_BLK_DEV_INITRD 624#ifdef CONFIG_BLK_DEV_INITRD
549/** 625/**
550 * early_init_dt_check_for_initrd - Decode initrd location from flat tree 626 * early_init_dt_check_for_initrd - Decode initrd location from flat tree