diff options
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/Kconfig | 5 | ||||
-rw-r--r-- | drivers/of/Makefile | 1 | ||||
-rw-r--r-- | drivers/of/pdt.c | 54 |
3 files changed, 44 insertions, 16 deletions
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 6acbff389ab6..aa675ebd8eb3 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig | |||
@@ -4,7 +4,7 @@ config DTC | |||
4 | config OF | 4 | config OF |
5 | bool | 5 | bool |
6 | 6 | ||
7 | menu "Flattened Device Tree and Open Firmware support" | 7 | menu "Device Tree and Open Firmware support" |
8 | depends on OF | 8 | depends on OF |
9 | 9 | ||
10 | config PROC_DEVICETREE | 10 | config PROC_DEVICETREE |
@@ -19,6 +19,9 @@ config OF_FLATTREE | |||
19 | bool | 19 | bool |
20 | select DTC | 20 | select DTC |
21 | 21 | ||
22 | config OF_PROMTREE | ||
23 | bool | ||
24 | |||
22 | config OF_DYNAMIC | 25 | config OF_DYNAMIC |
23 | def_bool y | 26 | def_bool y |
24 | depends on PPC_OF | 27 | depends on PPC_OF |
diff --git a/drivers/of/Makefile b/drivers/of/Makefile index 0052c405463a..7888155bea08 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile | |||
@@ -1,5 +1,6 @@ | |||
1 | obj-y = base.o | 1 | obj-y = base.o |
2 | obj-$(CONFIG_OF_FLATTREE) += fdt.o | 2 | obj-$(CONFIG_OF_FLATTREE) += fdt.o |
3 | obj-$(CONFIG_OF_PROMTREE) += pdt.o | ||
3 | obj-$(CONFIG_OF_ADDRESS) += address.o | 4 | obj-$(CONFIG_OF_ADDRESS) += address.o |
4 | obj-$(CONFIG_OF_IRQ) += irq.o | 5 | obj-$(CONFIG_OF_IRQ) += irq.o |
5 | obj-$(CONFIG_OF_DEVICE) += device.o platform.o | 6 | obj-$(CONFIG_OF_DEVICE) += device.o platform.o |
diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c index c3c2d70b3f75..2fdb1b478d6f 100644 --- a/drivers/of/pdt.c +++ b/drivers/of/pdt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* prom_common.c: OF device tree support common code. | 1 | /* pdt.c: OF PROM device tree support code. |
2 | * | 2 | * |
3 | * Paul Mackerras August 1996. | 3 | * Paul Mackerras August 1996. |
4 | * Copyright (C) 1996-2005 Paul Mackerras. | 4 | * Copyright (C) 1996-2005 Paul Mackerras. |
@@ -7,6 +7,7 @@ | |||
7 | * {engebret|bergner}@us.ibm.com | 7 | * {engebret|bergner}@us.ibm.com |
8 | * | 8 | * |
9 | * Adapted for sparc by David S. Miller davem@davemloft.net | 9 | * Adapted for sparc by David S. Miller davem@davemloft.net |
10 | * Adapted for multiple architectures by Andres Salomon <dilinger@queued.net> | ||
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
@@ -20,13 +21,36 @@ | |||
20 | #include <linux/mutex.h> | 21 | #include <linux/mutex.h> |
21 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
22 | #include <linux/of.h> | 23 | #include <linux/of.h> |
24 | #include <linux/of_pdt.h> | ||
23 | #include <asm/prom.h> | 25 | #include <asm/prom.h> |
24 | #include <asm/oplib.h> | 26 | #include <asm/oplib.h> |
25 | #include <asm/leon.h> | ||
26 | 27 | ||
27 | void (*prom_build_more)(struct device_node *dp, struct device_node ***nextp); | 28 | void __initdata (*prom_build_more)(struct device_node *dp, |
29 | struct device_node ***nextp); | ||
28 | 30 | ||
29 | unsigned int prom_unique_id; | 31 | #if defined(CONFIG_SPARC) |
32 | unsigned int of_pdt_unique_id __initdata; | ||
33 | |||
34 | #define of_pdt_incr_unique_id(p) do { \ | ||
35 | (p)->unique_id = of_pdt_unique_id++; \ | ||
36 | } while (0) | ||
37 | |||
38 | static inline const char *of_pdt_node_name(struct device_node *dp) | ||
39 | { | ||
40 | return dp->path_component_name; | ||
41 | } | ||
42 | |||
43 | #else | ||
44 | |||
45 | static inline void of_pdt_incr_unique_id(void *p) { } | ||
46 | static inline void irq_trans_init(struct device_node *dp) { } | ||
47 | |||
48 | static inline const char *of_pdt_node_name(struct device_node *dp) | ||
49 | { | ||
50 | return dp->name; | ||
51 | } | ||
52 | |||
53 | #endif /* !CONFIG_SPARC */ | ||
30 | 54 | ||
31 | static struct property * __init build_one_prop(phandle node, char *prev, | 55 | static struct property * __init build_one_prop(phandle node, char *prev, |
32 | char *special_name, | 56 | char *special_name, |
@@ -43,7 +67,7 @@ static struct property * __init build_one_prop(phandle node, char *prev, | |||
43 | tmp = NULL; | 67 | tmp = NULL; |
44 | } else { | 68 | } else { |
45 | p = prom_early_alloc(sizeof(struct property) + 32); | 69 | p = prom_early_alloc(sizeof(struct property) + 32); |
46 | p->unique_id = prom_unique_id++; | 70 | of_pdt_incr_unique_id(p); |
47 | } | 71 | } |
48 | 72 | ||
49 | p->name = (char *) (p + 1); | 73 | p->name = (char *) (p + 1); |
@@ -124,7 +148,7 @@ static struct device_node * __init prom_create_node(phandle node, | |||
124 | return NULL; | 148 | return NULL; |
125 | 149 | ||
126 | dp = prom_early_alloc(sizeof(*dp)); | 150 | dp = prom_early_alloc(sizeof(*dp)); |
127 | dp->unique_id = prom_unique_id++; | 151 | of_pdt_incr_unique_id(dp); |
128 | dp->parent = parent; | 152 | dp->parent = parent; |
129 | 153 | ||
130 | kref_init(&dp->kref); | 154 | kref_init(&dp->kref); |
@@ -140,13 +164,13 @@ static struct device_node * __init prom_create_node(phandle node, | |||
140 | return dp; | 164 | return dp; |
141 | } | 165 | } |
142 | 166 | ||
143 | char * __init build_full_name(struct device_node *dp) | 167 | static char * __init build_full_name(struct device_node *dp) |
144 | { | 168 | { |
145 | int len, ourlen, plen; | 169 | int len, ourlen, plen; |
146 | char *n; | 170 | char *n; |
147 | 171 | ||
148 | plen = strlen(dp->parent->full_name); | 172 | plen = strlen(dp->parent->full_name); |
149 | ourlen = strlen(dp->path_component_name); | 173 | ourlen = strlen(of_pdt_node_name(dp)); |
150 | len = ourlen + plen + 2; | 174 | len = ourlen + plen + 2; |
151 | 175 | ||
152 | n = prom_early_alloc(len); | 176 | n = prom_early_alloc(len); |
@@ -155,7 +179,7 @@ char * __init build_full_name(struct device_node *dp) | |||
155 | strcpy(n + plen, "/"); | 179 | strcpy(n + plen, "/"); |
156 | plen++; | 180 | plen++; |
157 | } | 181 | } |
158 | strcpy(n + plen, dp->path_component_name); | 182 | strcpy(n + plen, of_pdt_node_name(dp)); |
159 | 183 | ||
160 | return n; | 184 | return n; |
161 | } | 185 | } |
@@ -182,7 +206,9 @@ static struct device_node * __init prom_build_tree(struct device_node *parent, | |||
182 | *(*nextp) = dp; | 206 | *(*nextp) = dp; |
183 | *nextp = &dp->allnext; | 207 | *nextp = &dp->allnext; |
184 | 208 | ||
209 | #if defined(CONFIG_SPARC) | ||
185 | dp->path_component_name = build_path_component(dp); | 210 | dp->path_component_name = build_path_component(dp); |
211 | #endif | ||
186 | dp->full_name = build_full_name(dp); | 212 | dp->full_name = build_full_name(dp); |
187 | 213 | ||
188 | dp->child = prom_build_tree(dp, prom_getchild(node), nextp); | 214 | dp->child = prom_build_tree(dp, prom_getchild(node), nextp); |
@@ -196,20 +222,18 @@ static struct device_node * __init prom_build_tree(struct device_node *parent, | |||
196 | return ret; | 222 | return ret; |
197 | } | 223 | } |
198 | 224 | ||
199 | void __init prom_build_devicetree(void) | 225 | void __init of_pdt_build_devicetree(phandle root_node) |
200 | { | 226 | { |
201 | struct device_node **nextp; | 227 | struct device_node **nextp; |
202 | 228 | ||
203 | allnodes = prom_create_node(prom_root_node, NULL); | 229 | allnodes = prom_create_node(root_node, NULL); |
230 | #if defined(CONFIG_SPARC) | ||
204 | allnodes->path_component_name = ""; | 231 | allnodes->path_component_name = ""; |
232 | #endif | ||
205 | allnodes->full_name = "/"; | 233 | allnodes->full_name = "/"; |
206 | 234 | ||
207 | nextp = &allnodes->allnext; | 235 | nextp = &allnodes->allnext; |
208 | allnodes->child = prom_build_tree(allnodes, | 236 | allnodes->child = prom_build_tree(allnodes, |
209 | prom_getchild(allnodes->phandle), | 237 | prom_getchild(allnodes->phandle), |
210 | &nextp); | 238 | &nextp); |
211 | of_console_init(); | ||
212 | |||
213 | printk("PROM: Built device tree with %u bytes of memory.\n", | ||
214 | prom_early_allocated); | ||
215 | } | 239 | } |