diff options
author | James Hogan <james.hogan@imgtec.com> | 2012-10-05 11:02:12 -0400 |
---|---|---|
committer | James Hogan <james.hogan@imgtec.com> | 2013-03-02 15:09:22 -0500 |
commit | 29dd78cf0b526d24063364a8c634b3e92514c1a2 (patch) | |
tree | 4dfa291da2d101242f5536be0146cba25e398838 /arch | |
parent | 262d96b0deb44ed58823447825d6efa5dddb4108 (diff) |
metag: Device tree
Add device tree files to arch/metag.
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/metag/boot/dts/Makefile | 16 | ||||
-rw-r--r-- | arch/metag/boot/dts/skeleton.dts | 10 | ||||
-rw-r--r-- | arch/metag/boot/dts/skeleton.dtsi | 14 | ||||
-rw-r--r-- | arch/metag/include/asm/prom.h | 23 | ||||
-rw-r--r-- | arch/metag/kernel/devtree.c | 97 |
5 files changed, 160 insertions, 0 deletions
diff --git a/arch/metag/boot/dts/Makefile b/arch/metag/boot/dts/Makefile new file mode 100644 index 000000000000..e0b5afd8bde8 --- /dev/null +++ b/arch/metag/boot/dts/Makefile | |||
@@ -0,0 +1,16 @@ | |||
1 | dtb-y += skeleton.dtb | ||
2 | |||
3 | # Built-in dtb | ||
4 | builtindtb-y := skeleton | ||
5 | |||
6 | ifneq ($(CONFIG_METAG_BUILTIN_DTB_NAME),"") | ||
7 | builtindtb-y := $(CONFIG_METAG_BUILTIN_DTB_NAME) | ||
8 | endif | ||
9 | obj-$(CONFIG_METAG_BUILTIN_DTB) += $(patsubst "%",%,$(builtindtb-y)).dtb.o | ||
10 | |||
11 | targets += dtbs | ||
12 | targets += $(dtb-y) | ||
13 | |||
14 | dtbs: $(addprefix $(obj)/, $(dtb-y)) | ||
15 | |||
16 | clean-files += *.dtb | ||
diff --git a/arch/metag/boot/dts/skeleton.dts b/arch/metag/boot/dts/skeleton.dts new file mode 100644 index 000000000000..7244d1f0d555 --- /dev/null +++ b/arch/metag/boot/dts/skeleton.dts | |||
@@ -0,0 +1,10 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Imagination Technologies Ltd. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | /dts-v1/; | ||
9 | |||
10 | /include/ "skeleton.dtsi" | ||
diff --git a/arch/metag/boot/dts/skeleton.dtsi b/arch/metag/boot/dts/skeleton.dtsi new file mode 100644 index 000000000000..78229eacced7 --- /dev/null +++ b/arch/metag/boot/dts/skeleton.dtsi | |||
@@ -0,0 +1,14 @@ | |||
1 | /* | ||
2 | * Skeleton device tree; the bare minimum needed to boot; just include and | ||
3 | * add a compatible value. The bootloader will typically populate the memory | ||
4 | * node. | ||
5 | */ | ||
6 | |||
7 | / { | ||
8 | compatible = "img,meta"; | ||
9 | #address-cells = <1>; | ||
10 | #size-cells = <1>; | ||
11 | chosen { }; | ||
12 | aliases { }; | ||
13 | memory { device_type = "memory"; reg = <0 0>; }; | ||
14 | }; | ||
diff --git a/arch/metag/include/asm/prom.h b/arch/metag/include/asm/prom.h new file mode 100644 index 000000000000..d881396c392c --- /dev/null +++ b/arch/metag/include/asm/prom.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | * arch/metag/include/asm/prom.h | ||
3 | * | ||
4 | * Copyright (C) 2012 Imagination Technologies Ltd. | ||
5 | * | ||
6 | * Based on ARM version: | ||
7 | * Copyright (C) 2009 Canonical Ltd. <jeremy.kerr@canonical.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | */ | ||
14 | #ifndef __ASM_METAG_PROM_H | ||
15 | #define __ASM_METAG_PROM_H | ||
16 | |||
17 | #include <asm/setup.h> | ||
18 | #define HAVE_ARCH_DEVTREE_FIXUPS | ||
19 | |||
20 | extern struct machine_desc *setup_machine_fdt(void *dt); | ||
21 | extern void metag_dt_memblock_reserve(void); | ||
22 | |||
23 | #endif /* __ASM_METAG_PROM_H */ | ||
diff --git a/arch/metag/kernel/devtree.c b/arch/metag/kernel/devtree.c new file mode 100644 index 000000000000..5b6b1d855492 --- /dev/null +++ b/arch/metag/kernel/devtree.c | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * linux/arch/metag/kernel/devtree.c | ||
3 | * | ||
4 | * Copyright (C) 2012 Imagination Technologies Ltd. | ||
5 | * | ||
6 | * Based on ARM version: | ||
7 | * Copyright (C) 2009 Canonical Ltd. <jeremy.kerr@canonical.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/init.h> | ||
15 | #include <linux/export.h> | ||
16 | #include <linux/types.h> | ||
17 | #include <linux/bootmem.h> | ||
18 | #include <linux/memblock.h> | ||
19 | #include <linux/of.h> | ||
20 | #include <linux/of_fdt.h> | ||
21 | |||
22 | #include <asm/setup.h> | ||
23 | #include <asm/page.h> | ||
24 | #include <asm/mach/arch.h> | ||
25 | |||
26 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) | ||
27 | { | ||
28 | pr_err("%s(%llx, %llx)\n", | ||
29 | __func__, base, size); | ||
30 | } | ||
31 | |||
32 | void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) | ||
33 | { | ||
34 | return alloc_bootmem_align(size, align); | ||
35 | } | ||
36 | |||
37 | /** | ||
38 | * setup_machine_fdt - Machine setup when an dtb was passed to the kernel | ||
39 | * @dt: virtual address pointer to dt blob | ||
40 | * | ||
41 | * If a dtb was passed to the kernel, then use it to choose the correct | ||
42 | * machine_desc and to setup the system. | ||
43 | */ | ||
44 | struct machine_desc * __init setup_machine_fdt(void *dt) | ||
45 | { | ||
46 | struct boot_param_header *devtree = dt; | ||
47 | struct machine_desc *mdesc, *mdesc_best = NULL; | ||
48 | unsigned int score, mdesc_score = ~1; | ||
49 | unsigned long dt_root; | ||
50 | const char *model; | ||
51 | |||
52 | /* check device tree validity */ | ||
53 | if (be32_to_cpu(devtree->magic) != OF_DT_HEADER) | ||
54 | return NULL; | ||
55 | |||
56 | /* Search the mdescs for the 'best' compatible value match */ | ||
57 | initial_boot_params = devtree; | ||
58 | dt_root = of_get_flat_dt_root(); | ||
59 | |||
60 | for_each_machine_desc(mdesc) { | ||
61 | score = of_flat_dt_match(dt_root, mdesc->dt_compat); | ||
62 | if (score > 0 && score < mdesc_score) { | ||
63 | mdesc_best = mdesc; | ||
64 | mdesc_score = score; | ||
65 | } | ||
66 | } | ||
67 | if (!mdesc_best) { | ||
68 | const char *prop; | ||
69 | long size; | ||
70 | |||
71 | pr_err("\nError: unrecognized/unsupported device tree compatible list:\n[ "); | ||
72 | |||
73 | prop = of_get_flat_dt_prop(dt_root, "compatible", &size); | ||
74 | if (prop) { | ||
75 | while (size > 0) { | ||
76 | printk("'%s' ", prop); | ||
77 | size -= strlen(prop) + 1; | ||
78 | prop += strlen(prop) + 1; | ||
79 | } | ||
80 | } | ||
81 | printk("]\n\n"); | ||
82 | |||
83 | dump_machine_table(); /* does not return */ | ||
84 | } | ||
85 | |||
86 | model = of_get_flat_dt_prop(dt_root, "model", NULL); | ||
87 | if (!model) | ||
88 | model = of_get_flat_dt_prop(dt_root, "compatible", NULL); | ||
89 | if (!model) | ||
90 | model = "<unknown>"; | ||
91 | pr_info("Machine: %s, model: %s\n", mdesc_best->name, model); | ||
92 | |||
93 | /* Retrieve various information from the /chosen node */ | ||
94 | of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); | ||
95 | |||
96 | return mdesc_best; | ||
97 | } | ||