Skip to content

Commit 0288ffc

Browse files
author
Rob Herring
committed
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. Signed-off-by: Rob Herring <rob.herring@calxeda.com> Acked-by: Grant Likely <grant.likely@linaro.org>
1 parent 08854f4 commit 0288ffc

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎drivers/of/fdt.c‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,32 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align)
785785
}
786786
#endif
787787

788+
bool __init early_init_dt_scan(void *params)
789+
{
790+
if (!params)
791+
return false;
792+
793+
/* Setup flat device-tree pointer */
794+
initial_boot_params = params;
795+
796+
/* check device tree validity */
797+
if (be32_to_cpu(initial_boot_params->magic) != OF_DT_HEADER) {
798+
initial_boot_params = NULL;
799+
return false;
800+
}
801+
802+
/* Retrieve various information from the /chosen node */
803+
of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
804+
805+
/* Initialize {size,address}-cells info */
806+
of_scan_flat_dt(early_init_dt_scan_root, NULL);
807+
808+
/* Setup memory, calling early_init_dt_add_memory_arch */
809+
of_scan_flat_dt(early_init_dt_scan_memory, NULL);
810+
811+
return true;
812+
}
813+
788814
/**
789815
* unflatten_device_tree - create tree of device_nodes from flat blob
790816
*

‎include/linux/of_fdt.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ extern void early_init_dt_setup_initrd_arch(u64 start, u64 end);
116116
extern int early_init_dt_scan_root(unsigned long node, const char *uname,
117117
int depth, void *data);
118118

119+
extern bool early_init_dt_scan(void *params);
120+
119121
/* Other Prototypes */
120122
extern void unflatten_device_tree(void);
121123
extern void unflatten_and_copy_device_tree(void);

0 commit comments

Comments
 (0)