of: Introduce common early_init_dt_scan
authorRob Herring <rob.herring@calxeda.com>
Mon, 26 Aug 2013 14:47:40 +0000 (09:47 -0500)
committerRob Herring <rob.herring@calxeda.com>
Wed, 9 Oct 2013 16:38:07 +0000 (11:38 -0500)
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.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Grant Likely <grant.likely@linaro.org>
drivers/of/fdt.c
include/linux/of_fdt.h

index 51776166d2b0f04db2f910dc8c7d95b5aa27ac19..bfbfda5437682c54a79e76cbb3cbacbbe0f43bd7 100644 (file)
@@ -785,6 +785,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
  *
index 58c28a8cc257b0222596490f1274f6b1d7b68ac0..73e16511134ed0b8a1a56a8acf23361425524ab6 100644 (file)
@@ -116,6 +116,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 unflatten_and_copy_device_tree(void);