aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/Kconfig3
-rw-r--r--arch/powerpc/kernel/prom.c41
-rw-r--r--arch/sparc/Kconfig3
-rw-r--r--arch/sparc/kernel/prom.c42
-rw-r--r--arch/sparc64/Kconfig3
-rw-r--r--arch/sparc64/kernel/prom.c42
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/of/Makefile1
-rw-r--r--drivers/of/base.c65
-rw-r--r--include/asm-powerpc/prom.h3
-rw-r--r--include/asm-sparc/prom.h3
-rw-r--r--include/asm-sparc64/prom.h3
12 files changed, 85 insertions, 125 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index d860b640a140..853c282da22e 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -92,6 +92,9 @@ config ARCH_MAY_HAVE_PC_FDC
92config PPC_OF 92config PPC_OF
93 def_bool y 93 def_bool y
94 94
95config OF
96 def_bool y
97
95config PPC_UDBG_16550 98config PPC_UDBG_16550
96 bool 99 bool
97 default n 100 default n
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 37ff99bd98b4..6c9419a4d70a 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -1056,35 +1056,6 @@ void __init early_init_devtree(void *params)
1056 DBG(" <- early_init_devtree()\n"); 1056 DBG(" <- early_init_devtree()\n");
1057} 1057}
1058 1058
1059int of_n_addr_cells(struct device_node* np)
1060{
1061 const int *ip;
1062 do {
1063 if (np->parent)
1064 np = np->parent;
1065 ip = of_get_property(np, "#address-cells", NULL);
1066 if (ip != NULL)
1067 return *ip;
1068 } while (np->parent);
1069 /* No #address-cells property for the root node, default to 1 */
1070 return 1;
1071}
1072EXPORT_SYMBOL(of_n_addr_cells);
1073
1074int of_n_size_cells(struct device_node* np)
1075{
1076 const int* ip;
1077 do {
1078 if (np->parent)
1079 np = np->parent;
1080 ip = of_get_property(np, "#size-cells", NULL);
1081 if (ip != NULL)
1082 return *ip;
1083 } while (np->parent);
1084 /* No #size-cells property for the root node, default to 1 */
1085 return 1;
1086}
1087EXPORT_SYMBOL(of_n_size_cells);
1088 1059
1089/** Checks if the given "compat" string matches one of the strings in 1060/** Checks if the given "compat" string matches one of the strings in
1090 * the device's "compatible" property 1061 * the device's "compatible" property
@@ -1563,18 +1534,6 @@ struct property *of_find_property(const struct device_node *np,
1563EXPORT_SYMBOL(of_find_property); 1534EXPORT_SYMBOL(of_find_property);
1564 1535
1565/* 1536/*
1566 * Find a property with a given name for a given node
1567 * and return the value.
1568 */
1569const void *of_get_property(const struct device_node *np, const char *name,
1570 int *lenp)
1571{
1572 struct property *pp = of_find_property(np,name,lenp);
1573 return pp ? pp->value : NULL;
1574}
1575EXPORT_SYMBOL(of_get_property);
1576
1577/*
1578 * Add a property to a node 1537 * Add a property to a node
1579 */ 1538 */
1580int prom_add_property(struct device_node* np, struct property* prop) 1539int prom_add_property(struct device_node* np, struct property* prop)
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 603d83ad65c8..9d327ec59759 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -24,6 +24,9 @@ config GENERIC_ISA_DMA
24config ARCH_NO_VIRT_TO_BUS 24config ARCH_NO_VIRT_TO_BUS
25 def_bool y 25 def_bool y
26 26
27config OF
28 def_bool y
29
27source "init/Kconfig" 30source "init/Kconfig"
28 31
29menu "General machine setup" 32menu "General machine setup"
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c
index eed140b3c739..ac3f3c29b174 100644
--- a/arch/sparc/kernel/prom.c
+++ b/arch/sparc/kernel/prom.c
@@ -168,18 +168,6 @@ struct property *of_find_property(const struct device_node *np,
168} 168}
169EXPORT_SYMBOL(of_find_property); 169EXPORT_SYMBOL(of_find_property);
170 170
171/*
172 * Find a property with a given name for a given node
173 * and return the value.
174 */
175const void *of_get_property(const struct device_node *np, const char *name,
176 int *lenp)
177{
178 struct property *pp = of_find_property(np,name,lenp);
179 return pp ? pp->value : NULL;
180}
181EXPORT_SYMBOL(of_get_property);
182
183int of_getintprop_default(struct device_node *np, const char *name, int def) 171int of_getintprop_default(struct device_node *np, const char *name, int def)
184{ 172{
185 struct property *prop; 173 struct property *prop;
@@ -193,36 +181,6 @@ int of_getintprop_default(struct device_node *np, const char *name, int def)
193} 181}
194EXPORT_SYMBOL(of_getintprop_default); 182EXPORT_SYMBOL(of_getintprop_default);
195 183
196int of_n_addr_cells(struct device_node *np)
197{
198 const int* ip;
199 do {
200 if (np->parent)
201 np = np->parent;
202 ip = of_get_property(np, "#address-cells", NULL);
203 if (ip != NULL)
204 return *ip;
205 } while (np->parent);
206 /* No #address-cells property for the root node, default to 2 */
207 return 2;
208}
209EXPORT_SYMBOL(of_n_addr_cells);
210
211int of_n_size_cells(struct device_node *np)
212{
213 const int* ip;
214 do {
215 if (np->parent)
216 np = np->parent;
217 ip = of_get_property(np, "#size-cells", NULL);
218 if (ip != NULL)
219 return *ip;
220 } while (np->parent);
221 /* No #size-cells property for the root node, default to 1 */
222 return 1;
223}
224EXPORT_SYMBOL(of_n_size_cells);
225
226int of_set_property(struct device_node *dp, const char *name, void *val, int len) 184int of_set_property(struct device_node *dp, const char *name, void *val, int len)
227{ 185{
228 struct property **prevp; 186 struct property **prevp;
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index df6ee71894d1..f1cc55677ff2 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -65,6 +65,9 @@ config AUDIT_ARCH
65config ARCH_NO_VIRT_TO_BUS 65config ARCH_NO_VIRT_TO_BUS
66 def_bool y 66 def_bool y
67 67
68config OF
69 def_bool y
70
68choice 71choice
69 prompt "Kernel page size" 72 prompt "Kernel page size"
70 default SPARC64_PAGE_SIZE_8KB 73 default SPARC64_PAGE_SIZE_8KB
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index 5d220302cd50..8f926d439c0f 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -173,18 +173,6 @@ struct property *of_find_property(const struct device_node *np,
173} 173}
174EXPORT_SYMBOL(of_find_property); 174EXPORT_SYMBOL(of_find_property);
175 175
176/*
177 * Find a property with a given name for a given node
178 * and return the value.
179 */
180const void *of_get_property(const struct device_node *np, const char *name,
181 int *lenp)
182{
183 struct property *pp = of_find_property(np,name,lenp);
184 return pp ? pp->value : NULL;
185}
186EXPORT_SYMBOL(of_get_property);
187
188int of_getintprop_default(struct device_node *np, const char *name, int def) 176int of_getintprop_default(struct device_node *np, const char *name, int def)
189{ 177{
190 struct property *prop; 178 struct property *prop;
@@ -198,36 +186,6 @@ int of_getintprop_default(struct device_node *np, const char *name, int def)
198} 186}
199EXPORT_SYMBOL(of_getintprop_default); 187EXPORT_SYMBOL(of_getintprop_default);
200 188
201int of_n_addr_cells(struct device_node *np)
202{
203 const int* ip;
204 do {
205 if (np->parent)
206 np = np->parent;
207 ip = of_get_property(np, "#address-cells", NULL);
208 if (ip != NULL)
209 return *ip;
210 } while (np->parent);
211 /* No #address-cells property for the root node, default to 2 */
212 return 2;
213}
214EXPORT_SYMBOL(of_n_addr_cells);
215
216int of_n_size_cells(struct device_node *np)
217{
218 const int* ip;
219 do {
220 if (np->parent)
221 np = np->parent;
222 ip = of_get_property(np, "#size-cells", NULL);
223 if (ip != NULL)
224 return *ip;
225 } while (np->parent);
226 /* No #size-cells property for the root node, default to 1 */
227 return 1;
228}
229EXPORT_SYMBOL(of_n_size_cells);
230
231int of_set_property(struct device_node *dp, const char *name, void *val, int len) 189int of_set_property(struct device_node *dp, const char *name, void *val, int len)
232{ 190{
233 struct property **prevp; 191 struct property **prevp;
diff --git a/drivers/Makefile b/drivers/Makefile
index 0ea8e3237c0d..a9e4c5f922a0 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -86,3 +86,4 @@ obj-$(CONFIG_GENERIC_TIME) += clocksource/
86obj-$(CONFIG_DMA_ENGINE) += dma/ 86obj-$(CONFIG_DMA_ENGINE) += dma/
87obj-$(CONFIG_HID) += hid/ 87obj-$(CONFIG_HID) += hid/
88obj-$(CONFIG_PPC_PS3) += ps3/ 88obj-$(CONFIG_PPC_PS3) += ps3/
89obj-$(CONFIG_OF) += of/
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
new file mode 100644
index 000000000000..cddbe840e30a
--- /dev/null
+++ b/drivers/of/Makefile
@@ -0,0 +1 @@
obj-y = base.o
diff --git a/drivers/of/base.c b/drivers/of/base.c
new file mode 100644
index 000000000000..723d80d704e0
--- /dev/null
+++ b/drivers/of/base.c
@@ -0,0 +1,65 @@
1/*
2 * Procedures for creating, accessing and interpreting the device tree.
3 *
4 * Paul Mackerras August 1996.
5 * Copyright (C) 1996-2005 Paul Mackerras.
6 *
7 * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
8 * {engebret|bergner}@us.ibm.com
9 *
10 * Adapted for sparc and sparc64 by David S. Miller davem@davemloft.net
11 *
12 * Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19#include <linux/module.h>
20#include <linux/of.h>
21
22int of_n_addr_cells(struct device_node *np)
23{
24 const int *ip;
25
26 do {
27 if (np->parent)
28 np = np->parent;
29 ip = of_get_property(np, "#address-cells", NULL);
30 if (ip)
31 return *ip;
32 } while (np->parent);
33 /* No #address-cells property for the root node */
34 return OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
35}
36EXPORT_SYMBOL(of_n_addr_cells);
37
38int of_n_size_cells(struct device_node *np)
39{
40 const int *ip;
41
42 do {
43 if (np->parent)
44 np = np->parent;
45 ip = of_get_property(np, "#size-cells", NULL);
46 if (ip)
47 return *ip;
48 } while (np->parent);
49 /* No #size-cells property for the root node */
50 return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
51}
52EXPORT_SYMBOL(of_n_size_cells);
53
54/*
55 * Find a property with a given name for a given node
56 * and return the value.
57 */
58const void *of_get_property(const struct device_node *np, const char *name,
59 int *lenp)
60{
61 struct property *pp = of_find_property(np, name, lenp);
62
63 return pp ? pp->value : NULL;
64}
65EXPORT_SYMBOL(of_get_property);
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index 1134aeab2327..9fe0152ae245 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -21,6 +21,9 @@
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <asm/atomic.h> 22#include <asm/atomic.h>
23 23
24#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
25#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
26
24/* Definitions used by the flattened device tree */ 27/* Definitions used by the flattened device tree */
25#define OF_DT_HEADER 0xd00dfeed /* marker */ 28#define OF_DT_HEADER 0xd00dfeed /* marker */
26#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ 29#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */
diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h
index d67af08abb43..a8a121f6332b 100644
--- a/include/asm-sparc/prom.h
+++ b/include/asm-sparc/prom.h
@@ -20,6 +20,9 @@
20#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
21#include <asm/atomic.h> 21#include <asm/atomic.h>
22 22
23#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2
24#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
25
23typedef u32 phandle; 26typedef u32 phandle;
24typedef u32 ihandle; 27typedef u32 ihandle;
25 28
diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h
index 9905ed057d93..c98d1545ee8d 100644
--- a/include/asm-sparc64/prom.h
+++ b/include/asm-sparc64/prom.h
@@ -20,6 +20,9 @@
20#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
21#include <asm/atomic.h> 21#include <asm/atomic.h>
22 22
23#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2
24#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
25
23typedef u32 phandle; 26typedef u32 phandle;
24typedef u32 ihandle; 27typedef u32 ihandle;
25 28