diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-powerpc/of_device.h | 22 | ||||
-rw-r--r-- | include/asm-powerpc/of_platform.h | 38 | ||||
-rw-r--r-- | include/asm-powerpc/prom.h | 50 | ||||
-rw-r--r-- | include/asm-sparc/of_device.h | 49 | ||||
-rw-r--r-- | include/asm-sparc/of_platform.h | 32 | ||||
-rw-r--r-- | include/asm-sparc/prom.h | 62 | ||||
-rw-r--r-- | include/asm-sparc64/of_device.h | 50 | ||||
-rw-r--r-- | include/asm-sparc64/of_platform.h | 33 | ||||
-rw-r--r-- | include/asm-sparc64/prom.h | 62 | ||||
-rw-r--r-- | include/linux/of.h | 61 | ||||
-rw-r--r-- | include/linux/of_device.h | 26 | ||||
-rw-r--r-- | include/linux/of_platform.h | 57 |
12 files changed, 285 insertions, 257 deletions
diff --git a/include/asm-powerpc/of_device.h b/include/asm-powerpc/of_device.h index e9af49eb1aa8..ec2a8a2c737c 100644 --- a/include/asm-powerpc/of_device.h +++ b/include/asm-powerpc/of_device.h | |||
@@ -3,14 +3,12 @@ | |||
3 | #ifdef __KERNEL__ | 3 | #ifdef __KERNEL__ |
4 | 4 | ||
5 | #include <linux/device.h> | 5 | #include <linux/device.h> |
6 | #include <linux/mod_devicetable.h> | 6 | #include <linux/of.h> |
7 | #include <asm/prom.h> | ||
8 | |||
9 | 7 | ||
10 | /* | 8 | /* |
11 | * The of_device is a kind of "base class" that is a superset of | 9 | * The of_device is a kind of "base class" that is a superset of |
12 | * struct device for use by devices attached to an OF node and | 10 | * struct device for use by devices attached to an OF node and |
13 | * probed using OF properties | 11 | * probed using OF properties. |
14 | */ | 12 | */ |
15 | struct of_device | 13 | struct of_device |
16 | { | 14 | { |
@@ -18,24 +16,14 @@ struct of_device | |||
18 | u64 dma_mask; /* DMA mask */ | 16 | u64 dma_mask; /* DMA mask */ |
19 | struct device dev; /* Generic device interface */ | 17 | struct device dev; /* Generic device interface */ |
20 | }; | 18 | }; |
21 | #define to_of_device(d) container_of(d, struct of_device, dev) | ||
22 | |||
23 | extern const struct of_device_id *of_match_node( | ||
24 | const struct of_device_id *matches, const struct device_node *node); | ||
25 | extern const struct of_device_id *of_match_device( | ||
26 | const struct of_device_id *matches, const struct of_device *dev); | ||
27 | |||
28 | extern struct of_device *of_dev_get(struct of_device *dev); | ||
29 | extern void of_dev_put(struct of_device *dev); | ||
30 | |||
31 | extern int of_device_register(struct of_device *ofdev); | ||
32 | extern void of_device_unregister(struct of_device *ofdev); | ||
33 | extern void of_release_dev(struct device *dev); | ||
34 | 19 | ||
35 | extern ssize_t of_device_get_modalias(struct of_device *ofdev, | 20 | extern ssize_t of_device_get_modalias(struct of_device *ofdev, |
36 | char *str, ssize_t len); | 21 | char *str, ssize_t len); |
37 | extern int of_device_uevent(struct device *dev, | 22 | extern int of_device_uevent(struct device *dev, |
38 | char **envp, int num_envp, char *buffer, int buffer_size); | 23 | char **envp, int num_envp, char *buffer, int buffer_size); |
39 | 24 | ||
25 | /* This is just here during the transition */ | ||
26 | #include <linux/of_device.h> | ||
27 | |||
40 | #endif /* __KERNEL__ */ | 28 | #endif /* __KERNEL__ */ |
41 | #endif /* _ASM_POWERPC_OF_DEVICE_H */ | 29 | #endif /* _ASM_POWERPC_OF_DEVICE_H */ |
diff --git a/include/asm-powerpc/of_platform.h b/include/asm-powerpc/of_platform.h index 217eafb167e9..80e6fad28b4f 100644 --- a/include/asm-powerpc/of_platform.h +++ b/include/asm-powerpc/of_platform.h | |||
@@ -1,3 +1,5 @@ | |||
1 | #ifndef _ASM_POWERPC_OF_PLATFORM_H | ||
2 | #define _ASM_POWERPC_OF_PLATFORM_H | ||
1 | /* | 3 | /* |
2 | * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. | 4 | * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. |
3 | * <benh@kernel.crashing.org> | 5 | * <benh@kernel.crashing.org> |
@@ -9,37 +11,8 @@ | |||
9 | * | 11 | * |
10 | */ | 12 | */ |
11 | 13 | ||
12 | #include <asm/of_device.h> | 14 | /* This is just here during the transition */ |
13 | 15 | #include <linux/of_platform.h> | |
14 | /* | ||
15 | * The of_platform_bus_type is a bus type used by drivers that do not | ||
16 | * attach to a macio or similar bus but still use OF probing | ||
17 | * mechanism | ||
18 | */ | ||
19 | extern struct bus_type of_platform_bus_type; | ||
20 | |||
21 | /* | ||
22 | * An of_platform_driver driver is attached to a basic of_device on | ||
23 | * the "platform bus" (of_platform_bus_type) | ||
24 | */ | ||
25 | struct of_platform_driver | ||
26 | { | ||
27 | char *name; | ||
28 | struct of_device_id *match_table; | ||
29 | struct module *owner; | ||
30 | |||
31 | int (*probe)(struct of_device* dev, | ||
32 | const struct of_device_id *match); | ||
33 | int (*remove)(struct of_device* dev); | ||
34 | |||
35 | int (*suspend)(struct of_device* dev, pm_message_t state); | ||
36 | int (*resume)(struct of_device* dev); | ||
37 | int (*shutdown)(struct of_device* dev); | ||
38 | |||
39 | struct device_driver driver; | ||
40 | }; | ||
41 | #define to_of_platform_driver(drv) \ | ||
42 | container_of(drv,struct of_platform_driver, driver) | ||
43 | 16 | ||
44 | /* Platform drivers register/unregister */ | 17 | /* Platform drivers register/unregister */ |
45 | extern int of_register_platform_driver(struct of_platform_driver *drv); | 18 | extern int of_register_platform_driver(struct of_platform_driver *drv); |
@@ -56,5 +29,6 @@ extern int of_platform_bus_probe(struct device_node *root, | |||
56 | struct of_device_id *matches, | 29 | struct of_device_id *matches, |
57 | struct device *parent); | 30 | struct device *parent); |
58 | 31 | ||
59 | extern struct of_device *of_find_device_by_node(struct device_node *np); | ||
60 | extern struct of_device *of_find_device_by_phandle(phandle ph); | 32 | extern struct of_device *of_find_device_by_phandle(phandle ph); |
33 | |||
34 | #endif /* _ASM_POWERPC_OF_PLATFORM_H */ | ||
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h index 1632baa17dc6..6e391c9894ce 100644 --- a/include/asm-powerpc/prom.h +++ b/include/asm-powerpc/prom.h | |||
@@ -21,6 +21,13 @@ | |||
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 | |||
27 | #define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l)) | ||
28 | #define of_prop_cmp(s1, s2) strcmp((s1), (s2)) | ||
29 | #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) | ||
30 | |||
24 | /* Definitions used by the flattened device tree */ | 31 | /* Definitions used by the flattened device tree */ |
25 | #define OF_DT_HEADER 0xd00dfeed /* marker */ | 32 | #define OF_DT_HEADER 0xd00dfeed /* marker */ |
26 | #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ | 33 | #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ |
@@ -97,10 +104,6 @@ struct device_node { | |||
97 | 104 | ||
98 | extern struct device_node *of_chosen; | 105 | extern struct device_node *of_chosen; |
99 | 106 | ||
100 | /* flag descriptions */ | ||
101 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ | ||
102 | #define OF_DETACHED 2 /* node has been detached from the device tree */ | ||
103 | |||
104 | static inline int of_node_check_flag(struct device_node *n, unsigned long flag) | 107 | static inline int of_node_check_flag(struct device_node *n, unsigned long flag) |
105 | { | 108 | { |
106 | return test_bit(flag, &n->_flags); | 109 | return test_bit(flag, &n->_flags); |
@@ -120,31 +123,7 @@ static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_e | |||
120 | } | 123 | } |
121 | 124 | ||
122 | 125 | ||
123 | /* New style node lookup */ | ||
124 | extern struct device_node *of_find_node_by_name(struct device_node *from, | ||
125 | const char *name); | ||
126 | #define for_each_node_by_name(dn, name) \ | ||
127 | for (dn = of_find_node_by_name(NULL, name); dn; \ | ||
128 | dn = of_find_node_by_name(dn, name)) | ||
129 | extern struct device_node *of_find_node_by_type(struct device_node *from, | ||
130 | const char *type); | ||
131 | #define for_each_node_by_type(dn, type) \ | ||
132 | for (dn = of_find_node_by_type(NULL, type); dn; \ | ||
133 | dn = of_find_node_by_type(dn, type)) | ||
134 | extern struct device_node *of_find_compatible_node(struct device_node *from, | ||
135 | const char *type, const char *compat); | ||
136 | #define for_each_compatible_node(dn, type, compatible) \ | ||
137 | for (dn = of_find_compatible_node(NULL, type, compatible); dn; \ | ||
138 | dn = of_find_compatible_node(dn, type, compatible)) | ||
139 | extern struct device_node *of_find_node_by_path(const char *path); | ||
140 | extern struct device_node *of_find_node_by_phandle(phandle handle); | ||
141 | extern struct device_node *of_find_all_nodes(struct device_node *prev); | 126 | extern struct device_node *of_find_all_nodes(struct device_node *prev); |
142 | extern struct device_node *of_get_parent(const struct device_node *node); | ||
143 | extern struct device_node *of_get_next_child(const struct device_node *node, | ||
144 | struct device_node *prev); | ||
145 | extern struct property *of_find_property(const struct device_node *np, | ||
146 | const char *name, | ||
147 | int *lenp); | ||
148 | extern struct device_node *of_node_get(struct device_node *node); | 127 | extern struct device_node *of_node_get(struct device_node *node); |
149 | extern void of_node_put(struct device_node *node); | 128 | extern void of_node_put(struct device_node *node); |
150 | 129 | ||
@@ -166,17 +145,9 @@ extern void of_detach_node(const struct device_node *); | |||
166 | extern void finish_device_tree(void); | 145 | extern void finish_device_tree(void); |
167 | extern void unflatten_device_tree(void); | 146 | extern void unflatten_device_tree(void); |
168 | extern void early_init_devtree(void *); | 147 | extern void early_init_devtree(void *); |
169 | extern int of_device_is_compatible(const struct device_node *device, | ||
170 | const char *); | ||
171 | #define device_is_compatible(d, c) of_device_is_compatible((d), (c)) | 148 | #define device_is_compatible(d, c) of_device_is_compatible((d), (c)) |
172 | extern int machine_is_compatible(const char *compat); | 149 | extern int machine_is_compatible(const char *compat); |
173 | extern const void *of_get_property(const struct device_node *node, | ||
174 | const char *name, | ||
175 | int *lenp); | ||
176 | #define get_property(a, b, c) of_get_property((a), (b), (c)) | ||
177 | extern void print_properties(struct device_node *node); | 150 | extern void print_properties(struct device_node *node); |
178 | extern int of_n_addr_cells(struct device_node* np); | ||
179 | extern int of_n_size_cells(struct device_node* np); | ||
180 | extern int prom_n_intr_cells(struct device_node* np); | 151 | extern int prom_n_intr_cells(struct device_node* np); |
181 | extern void prom_get_irq_senses(unsigned char *senses, int off, int max); | 152 | extern void prom_get_irq_senses(unsigned char *senses, int off, int max); |
182 | extern int prom_add_property(struct device_node* np, struct property* prop); | 153 | extern int prom_add_property(struct device_node* np, struct property* prop); |
@@ -230,7 +201,6 @@ static inline unsigned long of_read_ulong(const u32 *cell, int size) | |||
230 | 201 | ||
231 | /* Translate an OF address block into a CPU physical address | 202 | /* Translate an OF address block into a CPU physical address |
232 | */ | 203 | */ |
233 | #define OF_BAD_ADDR ((u64)-1) | ||
234 | extern u64 of_translate_address(struct device_node *np, const u32 *addr); | 204 | extern u64 of_translate_address(struct device_node *np, const u32 *addr); |
235 | 205 | ||
236 | /* Extract an address from a device, returns the region size and | 206 | /* Extract an address from a device, returns the region size and |
@@ -357,5 +327,11 @@ extern int of_irq_to_resource(struct device_node *dev, int index, | |||
357 | */ | 327 | */ |
358 | extern void __iomem *of_iomap(struct device_node *device, int index); | 328 | extern void __iomem *of_iomap(struct device_node *device, int index); |
359 | 329 | ||
330 | /* | ||
331 | * NB: This is here while we transition from using asm/prom.h | ||
332 | * to linux/of.h | ||
333 | */ | ||
334 | #include <linux/of.h> | ||
335 | |||
360 | #endif /* __KERNEL__ */ | 336 | #endif /* __KERNEL__ */ |
361 | #endif /* _POWERPC_PROM_H */ | 337 | #endif /* _POWERPC_PROM_H */ |
diff --git a/include/asm-sparc/of_device.h b/include/asm-sparc/of_device.h index 7cb00c1b09c6..e5f5aedc2293 100644 --- a/include/asm-sparc/of_device.h +++ b/include/asm-sparc/of_device.h | |||
@@ -3,13 +3,9 @@ | |||
3 | #ifdef __KERNEL__ | 3 | #ifdef __KERNEL__ |
4 | 4 | ||
5 | #include <linux/device.h> | 5 | #include <linux/device.h> |
6 | #include <linux/of.h> | ||
6 | #include <linux/mod_devicetable.h> | 7 | #include <linux/mod_devicetable.h> |
7 | #include <asm/openprom.h> | 8 | #include <asm/openprom.h> |
8 | #include <asm/prom.h> | ||
9 | |||
10 | extern struct bus_type ebus_bus_type; | ||
11 | extern struct bus_type sbus_bus_type; | ||
12 | extern struct bus_type of_bus_type; | ||
13 | 9 | ||
14 | /* | 10 | /* |
15 | * The of_device is a kind of "base class" that is a superset of | 11 | * The of_device is a kind of "base class" that is a superset of |
@@ -30,50 +26,13 @@ struct of_device | |||
30 | int portid; | 26 | int portid; |
31 | int clock_freq; | 27 | int clock_freq; |
32 | }; | 28 | }; |
33 | #define to_of_device(d) container_of(d, struct of_device, dev) | ||
34 | 29 | ||
35 | extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); | 30 | extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); |
36 | extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); | 31 | extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); |
37 | 32 | ||
38 | extern struct of_device *of_find_device_by_node(struct device_node *); | 33 | /* These are just here during the transition */ |
39 | 34 | #include <linux/of_device.h> | |
40 | extern const struct of_device_id *of_match_device( | 35 | #include <linux/of_platform.h> |
41 | const struct of_device_id *matches, const struct of_device *dev); | ||
42 | |||
43 | extern struct of_device *of_dev_get(struct of_device *dev); | ||
44 | extern void of_dev_put(struct of_device *dev); | ||
45 | |||
46 | /* | ||
47 | * An of_platform_driver driver is attached to a basic of_device on | ||
48 | * the ISA, EBUS, and SBUS busses on sparc64. | ||
49 | */ | ||
50 | struct of_platform_driver | ||
51 | { | ||
52 | char *name; | ||
53 | struct of_device_id *match_table; | ||
54 | struct module *owner; | ||
55 | |||
56 | int (*probe)(struct of_device* dev, const struct of_device_id *match); | ||
57 | int (*remove)(struct of_device* dev); | ||
58 | |||
59 | int (*suspend)(struct of_device* dev, pm_message_t state); | ||
60 | int (*resume)(struct of_device* dev); | ||
61 | int (*shutdown)(struct of_device* dev); | ||
62 | |||
63 | struct device_driver driver; | ||
64 | }; | ||
65 | #define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver) | ||
66 | |||
67 | extern int of_register_driver(struct of_platform_driver *drv, | ||
68 | struct bus_type *bus); | ||
69 | extern void of_unregister_driver(struct of_platform_driver *drv); | ||
70 | extern int of_device_register(struct of_device *ofdev); | ||
71 | extern void of_device_unregister(struct of_device *ofdev); | ||
72 | extern struct of_device *of_platform_device_create(struct device_node *np, | ||
73 | const char *bus_id, | ||
74 | struct device *parent, | ||
75 | struct bus_type *bus); | ||
76 | extern void of_release_dev(struct device *dev); | ||
77 | 36 | ||
78 | #endif /* __KERNEL__ */ | 37 | #endif /* __KERNEL__ */ |
79 | #endif /* _ASM_SPARC_OF_DEVICE_H */ | 38 | #endif /* _ASM_SPARC_OF_DEVICE_H */ |
diff --git a/include/asm-sparc/of_platform.h b/include/asm-sparc/of_platform.h new file mode 100644 index 000000000000..64a230064ef2 --- /dev/null +++ b/include/asm-sparc/of_platform.h | |||
@@ -0,0 +1,32 @@ | |||
1 | #ifndef _ASM_SPARC_OF_PLATFORM_H | ||
2 | #define _ASM_SPARC_OF_PLATFORM_H | ||
3 | /* | ||
4 | * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. | ||
5 | * <benh@kernel.crashing.org> | ||
6 | * Modified for Sparc by merging parts of asm-sparc/of_device.h | ||
7 | * by Stephen Rothwell | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * as published by the Free Software Foundation; either version | ||
12 | * 2 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | /* This is just here during the transition */ | ||
17 | #include <linux/of_platform.h> | ||
18 | |||
19 | extern struct bus_type ebus_bus_type; | ||
20 | extern struct bus_type sbus_bus_type; | ||
21 | extern struct bus_type of_platform_bus_type; | ||
22 | #define of_bus_type of_platform_bus_type /* for compatibility */ | ||
23 | |||
24 | extern int of_register_driver(struct of_platform_driver *drv, | ||
25 | struct bus_type *bus); | ||
26 | extern void of_unregister_driver(struct of_platform_driver *drv); | ||
27 | extern struct of_device *of_platform_device_create(struct device_node *np, | ||
28 | const char *bus_id, | ||
29 | struct device *parent, | ||
30 | struct bus_type *bus); | ||
31 | |||
32 | #endif /* _ASM_SPARC_OF_PLATFORM_H */ | ||
diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index 9ea105ebe2ff..db9feb75bd86 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h | |||
@@ -2,7 +2,6 @@ | |||
2 | #define _SPARC_PROM_H | 2 | #define _SPARC_PROM_H |
3 | #ifdef __KERNEL__ | 3 | #ifdef __KERNEL__ |
4 | 4 | ||
5 | |||
6 | /* | 5 | /* |
7 | * Definitions for talking to the Open Firmware PROM on | 6 | * Definitions for talking to the Open Firmware PROM on |
8 | * Power Macintosh computers. | 7 | * Power Macintosh computers. |
@@ -17,11 +16,17 @@ | |||
17 | * as published by the Free Software Foundation; either version | 16 | * as published by the Free Software Foundation; either version |
18 | * 2 of the License, or (at your option) any later version. | 17 | * 2 of the License, or (at your option) any later version. |
19 | */ | 18 | */ |
20 | |||
21 | #include <linux/types.h> | 19 | #include <linux/types.h> |
22 | #include <linux/proc_fs.h> | 20 | #include <linux/proc_fs.h> |
23 | #include <asm/atomic.h> | 21 | #include <asm/atomic.h> |
24 | 22 | ||
23 | #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 | ||
24 | #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 | ||
25 | |||
26 | #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) | ||
27 | #define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) | ||
28 | #define of_node_cmp(s1, s2) strcmp((s1), (s2)) | ||
29 | |||
25 | typedef u32 phandle; | 30 | typedef u32 phandle; |
26 | typedef u32 ihandle; | 31 | typedef u32 ihandle; |
27 | 32 | ||
@@ -55,53 +60,30 @@ struct device_node { | |||
55 | unsigned int unique_id; | 60 | unsigned int unique_id; |
56 | }; | 61 | }; |
57 | 62 | ||
58 | /* flag descriptions */ | ||
59 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ | ||
60 | |||
61 | #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) | 63 | #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) |
62 | #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) | 64 | #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) |
63 | 65 | ||
64 | #define OF_BAD_ADDR ((u64)-1) | ||
65 | |||
66 | static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de) | ||
67 | { | ||
68 | dn->pde = de; | ||
69 | } | ||
70 | |||
71 | extern struct device_node *of_find_node_by_name(struct device_node *from, | ||
72 | const char *name); | ||
73 | #define for_each_node_by_name(dn, name) \ | ||
74 | for (dn = of_find_node_by_name(NULL, name); dn; \ | ||
75 | dn = of_find_node_by_name(dn, name)) | ||
76 | extern struct device_node *of_find_node_by_type(struct device_node *from, | ||
77 | const char *type); | ||
78 | #define for_each_node_by_type(dn, type) \ | ||
79 | for (dn = of_find_node_by_type(NULL, type); dn; \ | ||
80 | dn = of_find_node_by_type(dn, type)) | ||
81 | extern struct device_node *of_find_compatible_node(struct device_node *from, | ||
82 | const char *type, const char *compat); | ||
83 | extern struct device_node *of_find_node_by_path(const char *path); | ||
84 | extern struct device_node *of_find_node_by_phandle(phandle handle); | ||
85 | extern struct device_node *of_get_parent(const struct device_node *node); | ||
86 | extern struct device_node *of_get_next_child(const struct device_node *node, | ||
87 | struct device_node *prev); | ||
88 | extern struct property *of_find_property(const struct device_node *np, | ||
89 | const char *name, | ||
90 | int *lenp); | ||
91 | extern int of_device_is_compatible(const struct device_node *device, | ||
92 | const char *); | ||
93 | extern const void *of_get_property(const struct device_node *node, | ||
94 | const char *name, | ||
95 | int *lenp); | ||
96 | #define get_property(node,name,lenp) of_get_property(node,name,lenp) | ||
97 | extern int of_set_property(struct device_node *node, const char *name, void *val, int len); | 66 | extern int of_set_property(struct device_node *node, const char *name, void *val, int len); |
98 | extern int of_getintprop_default(struct device_node *np, | 67 | extern int of_getintprop_default(struct device_node *np, |
99 | const char *name, | 68 | const char *name, |
100 | int def); | 69 | int def); |
101 | extern int of_n_addr_cells(struct device_node *np); | ||
102 | extern int of_n_size_cells(struct device_node *np); | ||
103 | 70 | ||
104 | extern void prom_build_devicetree(void); | 71 | extern void prom_build_devicetree(void); |
105 | 72 | ||
73 | /* Dummy ref counting routines - to be implemented later */ | ||
74 | static inline struct device_node *of_node_get(struct device_node *node) | ||
75 | { | ||
76 | return node; | ||
77 | } | ||
78 | static inline void of_node_put(struct device_node *node) | ||
79 | { | ||
80 | } | ||
81 | |||
82 | /* | ||
83 | * NB: This is here while we transition from using asm/prom.h | ||
84 | * to linux/of.h | ||
85 | */ | ||
86 | #include <linux/of.h> | ||
87 | |||
106 | #endif /* __KERNEL__ */ | 88 | #endif /* __KERNEL__ */ |
107 | #endif /* _SPARC_PROM_H */ | 89 | #endif /* _SPARC_PROM_H */ |
diff --git a/include/asm-sparc64/of_device.h b/include/asm-sparc64/of_device.h index 60e9173c9acb..46d69b3223c5 100644 --- a/include/asm-sparc64/of_device.h +++ b/include/asm-sparc64/of_device.h | |||
@@ -3,14 +3,9 @@ | |||
3 | #ifdef __KERNEL__ | 3 | #ifdef __KERNEL__ |
4 | 4 | ||
5 | #include <linux/device.h> | 5 | #include <linux/device.h> |
6 | #include <linux/of.h> | ||
6 | #include <linux/mod_devicetable.h> | 7 | #include <linux/mod_devicetable.h> |
7 | #include <asm/openprom.h> | 8 | #include <asm/openprom.h> |
8 | #include <asm/prom.h> | ||
9 | |||
10 | extern struct bus_type isa_bus_type; | ||
11 | extern struct bus_type ebus_bus_type; | ||
12 | extern struct bus_type sbus_bus_type; | ||
13 | extern struct bus_type of_bus_type; | ||
14 | 9 | ||
15 | /* | 10 | /* |
16 | * The of_device is a kind of "base class" that is a superset of | 11 | * The of_device is a kind of "base class" that is a superset of |
@@ -31,50 +26,13 @@ struct of_device | |||
31 | int portid; | 26 | int portid; |
32 | int clock_freq; | 27 | int clock_freq; |
33 | }; | 28 | }; |
34 | #define to_of_device(d) container_of(d, struct of_device, dev) | ||
35 | 29 | ||
36 | extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); | 30 | extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); |
37 | extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); | 31 | extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); |
38 | 32 | ||
39 | extern struct of_device *of_find_device_by_node(struct device_node *); | 33 | /* These are just here during the transition */ |
40 | 34 | #include <linux/of_device.h> | |
41 | extern const struct of_device_id *of_match_device( | 35 | #include <linux/of_platform.h> |
42 | const struct of_device_id *matches, const struct of_device *dev); | ||
43 | |||
44 | extern struct of_device *of_dev_get(struct of_device *dev); | ||
45 | extern void of_dev_put(struct of_device *dev); | ||
46 | |||
47 | /* | ||
48 | * An of_platform_driver driver is attached to a basic of_device on | ||
49 | * the ISA, EBUS, and SBUS busses on sparc64. | ||
50 | */ | ||
51 | struct of_platform_driver | ||
52 | { | ||
53 | char *name; | ||
54 | struct of_device_id *match_table; | ||
55 | struct module *owner; | ||
56 | |||
57 | int (*probe)(struct of_device* dev, const struct of_device_id *match); | ||
58 | int (*remove)(struct of_device* dev); | ||
59 | |||
60 | int (*suspend)(struct of_device* dev, pm_message_t state); | ||
61 | int (*resume)(struct of_device* dev); | ||
62 | int (*shutdown)(struct of_device* dev); | ||
63 | |||
64 | struct device_driver driver; | ||
65 | }; | ||
66 | #define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver) | ||
67 | |||
68 | extern int of_register_driver(struct of_platform_driver *drv, | ||
69 | struct bus_type *bus); | ||
70 | extern void of_unregister_driver(struct of_platform_driver *drv); | ||
71 | extern int of_device_register(struct of_device *ofdev); | ||
72 | extern void of_device_unregister(struct of_device *ofdev); | ||
73 | extern struct of_device *of_platform_device_create(struct device_node *np, | ||
74 | const char *bus_id, | ||
75 | struct device *parent, | ||
76 | struct bus_type *bus); | ||
77 | extern void of_release_dev(struct device *dev); | ||
78 | 36 | ||
79 | #endif /* __KERNEL__ */ | 37 | #endif /* __KERNEL__ */ |
80 | #endif /* _ASM_SPARC64_OF_DEVICE_H */ | 38 | #endif /* _ASM_SPARC64_OF_DEVICE_H */ |
diff --git a/include/asm-sparc64/of_platform.h b/include/asm-sparc64/of_platform.h new file mode 100644 index 000000000000..f7c1f17c7d52 --- /dev/null +++ b/include/asm-sparc64/of_platform.h | |||
@@ -0,0 +1,33 @@ | |||
1 | #ifndef _ASM_SPARC64_OF_PLATFORM_H | ||
2 | #define _ASM_SPARC64_OF_PLATFORM_H | ||
3 | /* | ||
4 | * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. | ||
5 | * <benh@kernel.crashing.org> | ||
6 | * Modified for Sparc by merging parts of asm-sparc/of_device.h | ||
7 | * by Stephen Rothwell | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * as published by the Free Software Foundation; either version | ||
12 | * 2 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | /* This is just here during the transition */ | ||
17 | #include <linux/of_platform.h> | ||
18 | |||
19 | extern struct bus_type isa_bus_type; | ||
20 | extern struct bus_type ebus_bus_type; | ||
21 | extern struct bus_type sbus_bus_type; | ||
22 | extern struct bus_type of_platform_bus_type; | ||
23 | #define of_bus_type of_platform_bus_type /* for compatibility */ | ||
24 | |||
25 | extern int of_register_driver(struct of_platform_driver *drv, | ||
26 | struct bus_type *bus); | ||
27 | extern void of_unregister_driver(struct of_platform_driver *drv); | ||
28 | extern struct of_device *of_platform_device_create(struct device_node *np, | ||
29 | const char *bus_id, | ||
30 | struct device *parent, | ||
31 | struct bus_type *bus); | ||
32 | |||
33 | #endif /* _ASM_SPARC64_OF_PLATFORM_H */ | ||
diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h index b4df3042add0..2b9e0d795faf 100644 --- a/include/asm-sparc64/prom.h +++ b/include/asm-sparc64/prom.h | |||
@@ -2,7 +2,6 @@ | |||
2 | #define _SPARC64_PROM_H | 2 | #define _SPARC64_PROM_H |
3 | #ifdef __KERNEL__ | 3 | #ifdef __KERNEL__ |
4 | 4 | ||
5 | |||
6 | /* | 5 | /* |
7 | * Definitions for talking to the Open Firmware PROM on | 6 | * Definitions for talking to the Open Firmware PROM on |
8 | * Power Macintosh computers. | 7 | * Power Macintosh computers. |
@@ -17,11 +16,17 @@ | |||
17 | * as published by the Free Software Foundation; either version | 16 | * as published by the Free Software Foundation; either version |
18 | * 2 of the License, or (at your option) any later version. | 17 | * 2 of the License, or (at your option) any later version. |
19 | */ | 18 | */ |
20 | |||
21 | #include <linux/types.h> | 19 | #include <linux/types.h> |
22 | #include <linux/proc_fs.h> | 20 | #include <linux/proc_fs.h> |
23 | #include <asm/atomic.h> | 21 | #include <asm/atomic.h> |
24 | 22 | ||
23 | #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 | ||
24 | #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 | ||
25 | |||
26 | #define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l)) | ||
27 | #define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) | ||
28 | #define of_node_cmp(s1, s2) strcmp((s1), (s2)) | ||
29 | |||
25 | typedef u32 phandle; | 30 | typedef u32 phandle; |
26 | typedef u32 ihandle; | 31 | typedef u32 ihandle; |
27 | 32 | ||
@@ -63,54 +68,31 @@ struct of_irq_controller { | |||
63 | void *data; | 68 | void *data; |
64 | }; | 69 | }; |
65 | 70 | ||
66 | /* flag descriptions */ | ||
67 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ | ||
68 | |||
69 | #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) | 71 | #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) |
70 | #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) | 72 | #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) |
71 | 73 | ||
72 | #define OF_BAD_ADDR ((u64)-1) | ||
73 | |||
74 | static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de) | ||
75 | { | ||
76 | dn->pde = de; | ||
77 | } | ||
78 | |||
79 | extern struct device_node *of_find_node_by_name(struct device_node *from, | ||
80 | const char *name); | ||
81 | #define for_each_node_by_name(dn, name) \ | ||
82 | for (dn = of_find_node_by_name(NULL, name); dn; \ | ||
83 | dn = of_find_node_by_name(dn, name)) | ||
84 | extern struct device_node *of_find_node_by_type(struct device_node *from, | ||
85 | const char *type); | ||
86 | #define for_each_node_by_type(dn, type) \ | ||
87 | for (dn = of_find_node_by_type(NULL, type); dn; \ | ||
88 | dn = of_find_node_by_type(dn, type)) | ||
89 | extern struct device_node *of_find_compatible_node(struct device_node *from, | ||
90 | const char *type, const char *compat); | ||
91 | extern struct device_node *of_find_node_by_path(const char *path); | ||
92 | extern struct device_node *of_find_node_by_phandle(phandle handle); | ||
93 | extern struct device_node *of_find_node_by_cpuid(int cpuid); | 74 | extern struct device_node *of_find_node_by_cpuid(int cpuid); |
94 | extern struct device_node *of_get_parent(const struct device_node *node); | ||
95 | extern struct device_node *of_get_next_child(const struct device_node *node, | ||
96 | struct device_node *prev); | ||
97 | extern struct property *of_find_property(const struct device_node *np, | ||
98 | const char *name, | ||
99 | int *lenp); | ||
100 | extern int of_device_is_compatible(const struct device_node *device, | ||
101 | const char *); | ||
102 | extern const void *of_get_property(const struct device_node *node, | ||
103 | const char *name, | ||
104 | int *lenp); | ||
105 | #define get_property(node,name,lenp) of_get_property(node,name,lenp) | ||
106 | extern int of_set_property(struct device_node *node, const char *name, void *val, int len); | 75 | extern int of_set_property(struct device_node *node, const char *name, void *val, int len); |
107 | extern int of_getintprop_default(struct device_node *np, | 76 | extern int of_getintprop_default(struct device_node *np, |
108 | const char *name, | 77 | const char *name, |
109 | int def); | 78 | int def); |
110 | extern int of_n_addr_cells(struct device_node *np); | ||
111 | extern int of_n_size_cells(struct device_node *np); | ||
112 | 79 | ||
113 | extern void prom_build_devicetree(void); | 80 | extern void prom_build_devicetree(void); |
114 | 81 | ||
82 | /* Dummy ref counting routines - to be implemented later */ | ||
83 | static inline struct device_node *of_node_get(struct device_node *node) | ||
84 | { | ||
85 | return node; | ||
86 | } | ||
87 | static inline void of_node_put(struct device_node *node) | ||
88 | { | ||
89 | } | ||
90 | |||
91 | /* | ||
92 | * NB: This is here while we transition from using asm/prom.h | ||
93 | * to linux/of.h | ||
94 | */ | ||
95 | #include <linux/of.h> | ||
96 | |||
115 | #endif /* __KERNEL__ */ | 97 | #endif /* __KERNEL__ */ |
116 | #endif /* _SPARC64_PROM_H */ | 98 | #endif /* _SPARC64_PROM_H */ |
diff --git a/include/linux/of.h b/include/linux/of.h new file mode 100644 index 000000000000..47734ffd9745 --- /dev/null +++ b/include/linux/of.h | |||
@@ -0,0 +1,61 @@ | |||
1 | #ifndef _LINUX_OF_H | ||
2 | #define _LINUX_OF_H | ||
3 | /* | ||
4 | * Definitions for talking to the Open Firmware PROM on | ||
5 | * Power Macintosh and other computers. | ||
6 | * | ||
7 | * Copyright (C) 1996-2005 Paul Mackerras. | ||
8 | * | ||
9 | * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp. | ||
10 | * Updates for SPARC64 by David S. Miller | ||
11 | * Derived from PowerPC and Sparc prom.h files by Stephen Rothwell, IBM Corp. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version | ||
16 | * 2 of the License, or (at your option) any later version. | ||
17 | */ | ||
18 | #include <linux/types.h> | ||
19 | |||
20 | #include <asm/bitops.h> | ||
21 | #include <asm/prom.h> | ||
22 | |||
23 | /* flag descriptions */ | ||
24 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ | ||
25 | #define OF_DETACHED 2 /* node has been detached from the device tree */ | ||
26 | |||
27 | #define OF_BAD_ADDR ((u64)-1) | ||
28 | |||
29 | extern struct device_node *of_find_node_by_name(struct device_node *from, | ||
30 | const char *name); | ||
31 | #define for_each_node_by_name(dn, name) \ | ||
32 | for (dn = of_find_node_by_name(NULL, name); dn; \ | ||
33 | dn = of_find_node_by_name(dn, name)) | ||
34 | extern struct device_node *of_find_node_by_type(struct device_node *from, | ||
35 | const char *type); | ||
36 | #define for_each_node_by_type(dn, type) \ | ||
37 | for (dn = of_find_node_by_type(NULL, type); dn; \ | ||
38 | dn = of_find_node_by_type(dn, type)) | ||
39 | extern struct device_node *of_find_compatible_node(struct device_node *from, | ||
40 | const char *type, const char *compat); | ||
41 | #define for_each_compatible_node(dn, type, compatible) \ | ||
42 | for (dn = of_find_compatible_node(NULL, type, compatible); dn; \ | ||
43 | dn = of_find_compatible_node(dn, type, compatible)) | ||
44 | extern struct device_node *of_find_node_by_path(const char *path); | ||
45 | extern struct device_node *of_find_node_by_phandle(phandle handle); | ||
46 | extern struct device_node *of_get_parent(const struct device_node *node); | ||
47 | extern struct device_node *of_get_next_child(const struct device_node *node, | ||
48 | struct device_node *prev); | ||
49 | extern struct property *of_find_property(const struct device_node *np, | ||
50 | const char *name, | ||
51 | int *lenp); | ||
52 | extern int of_device_is_compatible(const struct device_node *device, | ||
53 | const char *); | ||
54 | extern const void *of_get_property(const struct device_node *node, | ||
55 | const char *name, | ||
56 | int *lenp); | ||
57 | #define get_property(a, b, c) of_get_property((a), (b), (c)) | ||
58 | extern int of_n_addr_cells(struct device_node *np); | ||
59 | extern int of_n_size_cells(struct device_node *np); | ||
60 | |||
61 | #endif /* _LINUX_OF_H */ | ||
diff --git a/include/linux/of_device.h b/include/linux/of_device.h new file mode 100644 index 000000000000..91bf84b9d144 --- /dev/null +++ b/include/linux/of_device.h | |||
@@ -0,0 +1,26 @@ | |||
1 | #ifndef _LINUX_OF_DEVICE_H | ||
2 | #define _LINUX_OF_DEVICE_H | ||
3 | #ifdef __KERNEL__ | ||
4 | |||
5 | #include <linux/device.h> | ||
6 | #include <linux/of.h> | ||
7 | #include <linux/mod_devicetable.h> | ||
8 | |||
9 | #include <asm/of_device.h> | ||
10 | |||
11 | #define to_of_device(d) container_of(d, struct of_device, dev) | ||
12 | |||
13 | extern const struct of_device_id *of_match_node( | ||
14 | const struct of_device_id *matches, const struct device_node *node); | ||
15 | extern const struct of_device_id *of_match_device( | ||
16 | const struct of_device_id *matches, const struct of_device *dev); | ||
17 | |||
18 | extern struct of_device *of_dev_get(struct of_device *dev); | ||
19 | extern void of_dev_put(struct of_device *dev); | ||
20 | |||
21 | extern int of_device_register(struct of_device *ofdev); | ||
22 | extern void of_device_unregister(struct of_device *ofdev); | ||
23 | extern void of_release_dev(struct device *dev); | ||
24 | |||
25 | #endif /* __KERNEL__ */ | ||
26 | #endif /* _LINUX_OF_DEVICE_H */ | ||
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h new file mode 100644 index 000000000000..5fd44e63fb26 --- /dev/null +++ b/include/linux/of_platform.h | |||
@@ -0,0 +1,57 @@ | |||
1 | #ifndef _LINUX_OF_PLATFORM_H | ||
2 | #define _LINUX_OF_PLATFORM_H | ||
3 | /* | ||
4 | * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. | ||
5 | * <benh@kernel.crashing.org> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/device.h> | ||
16 | #include <linux/mod_devicetable.h> | ||
17 | #include <linux/pm.h> | ||
18 | #include <linux/of_device.h> | ||
19 | |||
20 | /* | ||
21 | * The of_platform_bus_type is a bus type used by drivers that do not | ||
22 | * attach to a macio or similar bus but still use OF probing | ||
23 | * mechanism | ||
24 | */ | ||
25 | extern struct bus_type of_platform_bus_type; | ||
26 | |||
27 | /* | ||
28 | * An of_platform_driver driver is attached to a basic of_device on | ||
29 | * the "platform bus" (of_platform_bus_type) (or ISA, EBUS and SBUS | ||
30 | * busses on sparc). | ||
31 | */ | ||
32 | struct of_platform_driver | ||
33 | { | ||
34 | char *name; | ||
35 | struct of_device_id *match_table; | ||
36 | struct module *owner; | ||
37 | |||
38 | int (*probe)(struct of_device* dev, | ||
39 | const struct of_device_id *match); | ||
40 | int (*remove)(struct of_device* dev); | ||
41 | |||
42 | int (*suspend)(struct of_device* dev, pm_message_t state); | ||
43 | int (*resume)(struct of_device* dev); | ||
44 | int (*shutdown)(struct of_device* dev); | ||
45 | |||
46 | struct device_driver driver; | ||
47 | }; | ||
48 | #define to_of_platform_driver(drv) \ | ||
49 | container_of(drv,struct of_platform_driver, driver) | ||
50 | |||
51 | #include <asm/of_platform.h> | ||
52 | |||
53 | extern struct of_device *of_find_device_by_node(struct device_node *np); | ||
54 | |||
55 | extern int of_bus_type_init(struct bus_type *bus, const char *name); | ||
56 | |||
57 | #endif /* _LINUX_OF_PLATFORM_H */ | ||