-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is minimal infrastructure needed for devicetree work. It uses an a sample "skeleton" devicetree - embedded in kernel image - to print the board, manufacturer by parsing the top-level "compatible" string. As of now we don't need any additional "board" specific "machine_desc". TODO: support interpreting the command line as boot-loader passed dtb Signed-off-by: Vineet Gupta <vgupta@synopsys.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: devicetree-discuss@lists.ozlabs.org Cc: Rob Herring <rob.herring@calxeda.com> Cc: James Hogan <james.hogan@imgtec.com> Reviewed-by: Rob Herring <rob.herring@calxeda.com> Reviewed-by: James Hogan <james.hogan@imgtec.com>
- Loading branch information
Vineet Gupta
committed
Feb 15, 2013
1 parent
ee36d17
commit 999159a
Showing
11 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Built-in dtb | ||
builtindtb-y := skeleton | ||
|
||
ifneq ($(CONFIG_ARC_BUILTIN_DTB_NAME),"") | ||
builtindtb-y := $(patsubst "%",%,$(CONFIG_ARC_BUILTIN_DTB_NAME)) | ||
endif | ||
|
||
obj-y += $(builtindtb-y).dtb.o | ||
targets += $(builtindtb-y).dtb | ||
|
||
dtbs: $(addprefix $(obj)/, $(builtindtb-y).dtb) | ||
|
||
clean-files := *.dtb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com) | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
/dts-v1/; | ||
|
||
/include/ "skeleton.dtsi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com) | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
/* | ||
* Skeleton device tree; the bare minimum needed to boot; just include and | ||
* add a compatible value. | ||
*/ | ||
|
||
/ { | ||
compatible = "snps,arc"; | ||
#address-cells = <1>; | ||
#size-cells = <1>; | ||
chosen { }; | ||
aliases { }; | ||
memory { device_type = "memory"; reg = <0 0>; }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com) | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
#ifndef _ASM_ARC_PROM_H_ | ||
#define _ASM_ARC_PROM_H_ | ||
|
||
#define HAVE_ARCH_DEVTREE_FIXUPS | ||
extern int __init setup_machine_fdt(void *dt); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,6 @@ | |
|
||
extern char _int_vec_base_lds[]; | ||
extern char __arc_dccm_base[]; | ||
extern char __dtb_start[]; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com) | ||
* | ||
* Based on reduced version of METAG | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
|
||
#include <linux/init.h> | ||
#include <linux/reboot.h> | ||
#include <linux/memblock.h> | ||
#include <linux/of.h> | ||
#include <linux/of_fdt.h> | ||
#include <asm/prom.h> | ||
|
||
/* called from unflatten_device_tree() to bootstrap devicetree itself */ | ||
void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) | ||
{ | ||
return __va(memblock_alloc(size, align)); | ||
} | ||
|
||
/** | ||
* setup_machine_fdt - Machine setup when an dtb was passed to the kernel | ||
* @dt: virtual address pointer to dt blob | ||
* | ||
* If a dtb was passed to the kernel, then use it to choose the correct | ||
* machine_desc and to setup the system. | ||
*/ | ||
int __init setup_machine_fdt(void *dt) | ||
{ | ||
struct boot_param_header *devtree = dt; | ||
unsigned long dt_root; | ||
char *model, *compat; | ||
char manufacturer[16]; | ||
|
||
/* check device tree validity */ | ||
if (be32_to_cpu(devtree->magic) != OF_DT_HEADER) | ||
return 1; | ||
|
||
/* Search the mdescs for the 'best' compatible value match */ | ||
initial_boot_params = devtree; | ||
dt_root = of_get_flat_dt_root(); | ||
|
||
/* compat = "<manufacturer>,<model>" */ | ||
compat = of_get_flat_dt_prop(dt_root, "compatible", NULL); | ||
if (!compat) | ||
compat = "<unknown>"; | ||
|
||
model = strchr(compat, ','); | ||
if (model) | ||
model++; | ||
|
||
strlcpy(manufacturer, compat, model ? model - compat : strlen(compat)); | ||
|
||
pr_info("Board \"%s\" from %s (Manufacturer)\n", model, manufacturer); | ||
|
||
/* Retrieve various information from the /chosen node */ | ||
of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters