diff options
author | Rob Herring <rob.herring@calxeda.com> | 2013-08-26 09:47:40 -0500 |
---|---|---|
committer | Ishan Mittal <imittal@nvidia.com> | 2014-04-30 11:39:08 +0530 |
commit | d03e873944e99287cdafdecbe36301cb0ea02dfb (patch) | |
tree | c0b46b1eb5b551f05e5f5ae5371949eb79f14c42 | |
parent | 76e5fa6dc2390085700ddff550d27a38c9111ec6 (diff) |
of: Introduce common early_init_dt_scan
Most architectures scan the all the same items early in the FDT and none
are really architecture specific. Create a common early_init_dt_scan to
unify the early scan of root, memory, and chosen nodes in the flattened
DT.
(cherry picked from commit 0288ffcbfdf9b8656e7320c24caa1e4c1d498287)
Change-Id: I56ce372cc740ab11a8828d11bf8e508069bdac88
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Grant Likely <grant.likely@linaro.org>
-rw-r--r-- | drivers/of/fdt.c | 26 | ||||
-rw-r--r-- | include/linux/of_fdt.h | 2 |
2 files changed, 28 insertions, 0 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 028b5be967e4..75ccce3a69fb 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -712,6 +712,32 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) } #endif +bool __init early_init_dt_scan(void *params) +{ + if (!params) + return false; + + /* Setup flat device-tree pointer */ + initial_boot_params = params; + + /* check device tree validity */ + if (be32_to_cpu(initial_boot_params->magic) != OF_DT_HEADER) { + initial_boot_params = NULL; + return false; + } + + /* Retrieve various information from the /chosen node */ + of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); + + /* Initialize {size,address}-cells info */ + of_scan_flat_dt(early_init_dt_scan_root, NULL); + + /* Setup memory, calling early_init_dt_add_memory_arch */ + of_scan_flat_dt(early_init_dt_scan_memory, NULL); + + return true; +} + /** * unflatten_device_tree - create tree of device_nodes from flat blob * diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 4a17939b95cc..6b2bf7e9e7d4 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -113,6 +113,8 @@ extern void early_init_dt_setup_initrd_arch(u64 start, u64 end); extern int early_init_dt_scan_root(unsigned long node, const char *uname, int depth, void *data); +extern bool early_init_dt_scan(void *params); + /* Other Prototypes */ extern void unflatten_device_tree(void); extern void early_init_devtree(void *); |