diff options
Diffstat (limited to 'include/linux/of.h')
-rw-r--r-- | include/linux/of.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index 9180dc5cb00b..4948552d60f5 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
@@ -17,11 +17,13 @@ | |||
17 | */ | 17 | */ |
18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
19 | #include <linux/bitops.h> | 19 | #include <linux/bitops.h> |
20 | #include <linux/errno.h> | ||
20 | #include <linux/kref.h> | 21 | #include <linux/kref.h> |
21 | #include <linux/mod_devicetable.h> | 22 | #include <linux/mod_devicetable.h> |
22 | #include <linux/spinlock.h> | 23 | #include <linux/spinlock.h> |
23 | 24 | ||
24 | #include <asm/byteorder.h> | 25 | #include <asm/byteorder.h> |
26 | #include <asm/errno.h> | ||
25 | 27 | ||
26 | typedef u32 phandle; | 28 | typedef u32 phandle; |
27 | typedef u32 ihandle; | 29 | typedef u32 ihandle; |
@@ -68,6 +70,7 @@ struct device_node { | |||
68 | /* Pointer for first entry in chain of all nodes. */ | 70 | /* Pointer for first entry in chain of all nodes. */ |
69 | extern struct device_node *allnodes; | 71 | extern struct device_node *allnodes; |
70 | extern struct device_node *of_chosen; | 72 | extern struct device_node *of_chosen; |
73 | extern struct device_node *of_aliases; | ||
71 | extern rwlock_t devtree_lock; | 74 | extern rwlock_t devtree_lock; |
72 | 75 | ||
73 | static inline bool of_have_populated_dt(void) | 76 | static inline bool of_have_populated_dt(void) |
@@ -199,16 +202,26 @@ extern int of_property_read_u32_array(const struct device_node *np, | |||
199 | const char *propname, | 202 | const char *propname, |
200 | u32 *out_values, | 203 | u32 *out_values, |
201 | size_t sz); | 204 | size_t sz); |
205 | extern int of_property_read_u64(const struct device_node *np, | ||
206 | const char *propname, u64 *out_value); | ||
202 | 207 | ||
203 | extern int of_property_read_string(struct device_node *np, | 208 | extern int of_property_read_string(struct device_node *np, |
204 | const char *propname, | 209 | const char *propname, |
205 | const char **out_string); | 210 | const char **out_string); |
211 | extern int of_property_read_string_index(struct device_node *np, | ||
212 | const char *propname, | ||
213 | int index, const char **output); | ||
214 | extern int of_property_count_strings(struct device_node *np, | ||
215 | const char *propname); | ||
206 | extern int of_device_is_compatible(const struct device_node *device, | 216 | extern int of_device_is_compatible(const struct device_node *device, |
207 | const char *); | 217 | const char *); |
208 | extern int of_device_is_available(const struct device_node *device); | 218 | extern int of_device_is_available(const struct device_node *device); |
209 | extern const void *of_get_property(const struct device_node *node, | 219 | extern const void *of_get_property(const struct device_node *node, |
210 | const char *name, | 220 | const char *name, |
211 | int *lenp); | 221 | int *lenp); |
222 | #define for_each_property(pp, properties) \ | ||
223 | for (pp = properties; pp != NULL; pp = pp->next) | ||
224 | |||
212 | extern int of_n_addr_cells(struct device_node *np); | 225 | extern int of_n_addr_cells(struct device_node *np); |
213 | extern int of_n_size_cells(struct device_node *np); | 226 | extern int of_n_size_cells(struct device_node *np); |
214 | extern const struct of_device_id *of_match_node( | 227 | extern const struct of_device_id *of_match_node( |
@@ -221,6 +234,9 @@ extern int of_parse_phandles_with_args(struct device_node *np, | |||
221 | const char *list_name, const char *cells_name, int index, | 234 | const char *list_name, const char *cells_name, int index, |
222 | struct device_node **out_node, const void **out_args); | 235 | struct device_node **out_node, const void **out_args); |
223 | 236 | ||
237 | extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)); | ||
238 | extern int of_alias_get_id(struct device_node *np, const char *stem); | ||
239 | |||
224 | extern int of_machine_is_compatible(const char *compat); | 240 | extern int of_machine_is_compatible(const char *compat); |
225 | 241 | ||
226 | extern int prom_add_property(struct device_node* np, struct property* prop); | 242 | extern int prom_add_property(struct device_node* np, struct property* prop); |
@@ -235,6 +251,7 @@ extern void of_attach_node(struct device_node *); | |||
235 | extern void of_detach_node(struct device_node *); | 251 | extern void of_detach_node(struct device_node *); |
236 | #endif | 252 | #endif |
237 | 253 | ||
254 | #define of_match_ptr(_ptr) (_ptr) | ||
238 | #else /* CONFIG_OF */ | 255 | #else /* CONFIG_OF */ |
239 | 256 | ||
240 | static inline bool of_have_populated_dt(void) | 257 | static inline bool of_have_populated_dt(void) |
@@ -242,6 +259,22 @@ static inline bool of_have_populated_dt(void) | |||
242 | return false; | 259 | return false; |
243 | } | 260 | } |
244 | 261 | ||
262 | #define for_each_child_of_node(parent, child) \ | ||
263 | while (0) | ||
264 | |||
265 | static inline int of_device_is_compatible(const struct device_node *device, | ||
266 | const char *name) | ||
267 | { | ||
268 | return 0; | ||
269 | } | ||
270 | |||
271 | static inline struct property *of_find_property(const struct device_node *np, | ||
272 | const char *name, | ||
273 | int *lenp) | ||
274 | { | ||
275 | return NULL; | ||
276 | } | ||
277 | |||
245 | static inline int of_property_read_u32_array(const struct device_node *np, | 278 | static inline int of_property_read_u32_array(const struct device_node *np, |
246 | const char *propname, | 279 | const char *propname, |
247 | u32 *out_values, size_t sz) | 280 | u32 *out_values, size_t sz) |
@@ -256,6 +289,19 @@ static inline int of_property_read_string(struct device_node *np, | |||
256 | return -ENOSYS; | 289 | return -ENOSYS; |
257 | } | 290 | } |
258 | 291 | ||
292 | static inline int of_property_read_string_index(struct device_node *np, | ||
293 | const char *propname, int index, | ||
294 | const char **out_string) | ||
295 | { | ||
296 | return -ENOSYS; | ||
297 | } | ||
298 | |||
299 | static inline int of_property_count_strings(struct device_node *np, | ||
300 | const char *propname) | ||
301 | { | ||
302 | return -ENOSYS; | ||
303 | } | ||
304 | |||
259 | static inline const void *of_get_property(const struct device_node *node, | 305 | static inline const void *of_get_property(const struct device_node *node, |
260 | const char *name, | 306 | const char *name, |
261 | int *lenp) | 307 | int *lenp) |
@@ -263,6 +309,31 @@ static inline const void *of_get_property(const struct device_node *node, | |||
263 | return NULL; | 309 | return NULL; |
264 | } | 310 | } |
265 | 311 | ||
312 | static inline int of_property_read_u64(const struct device_node *np, | ||
313 | const char *propname, u64 *out_value) | ||
314 | { | ||
315 | return -ENOSYS; | ||
316 | } | ||
317 | |||
318 | static inline struct device_node *of_parse_phandle(struct device_node *np, | ||
319 | const char *phandle_name, | ||
320 | int index) | ||
321 | { | ||
322 | return NULL; | ||
323 | } | ||
324 | |||
325 | static inline int of_alias_get_id(struct device_node *np, const char *stem) | ||
326 | { | ||
327 | return -ENOSYS; | ||
328 | } | ||
329 | |||
330 | static inline int of_machine_is_compatible(const char *compat) | ||
331 | { | ||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | #define of_match_ptr(_ptr) NULL | ||
336 | #define of_match_node(_matches, _node) NULL | ||
266 | #endif /* CONFIG_OF */ | 337 | #endif /* CONFIG_OF */ |
267 | 338 | ||
268 | static inline int of_property_read_u32(const struct device_node *np, | 339 | static inline int of_property_read_u32(const struct device_node *np, |