Stephen Rothwell | 76c1ce7 | 2007-05-01 16:19:07 +1000 | [diff] [blame] | 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> |
Jiri Slaby | 1977f03 | 2007-10-18 23:40:25 -0700 | [diff] [blame] | 19 | #include <linux/bitops.h> |
Grant Likely | 283029d | 2008-01-09 06:20:40 +1100 | [diff] [blame] | 20 | #include <linux/mod_devicetable.h> |
Stephen Rothwell | 76c1ce7 | 2007-05-01 16:19:07 +1000 | [diff] [blame] | 21 | |
Grant Likely | 731581e | 2009-10-15 10:57:46 -0600 | [diff] [blame^] | 22 | typedef u32 phandle; |
| 23 | typedef u32 ihandle; |
| 24 | |
| 25 | struct property { |
| 26 | char *name; |
| 27 | int length; |
| 28 | void *value; |
| 29 | struct property *next; |
| 30 | unsigned long _flags; |
| 31 | unsigned int unique_id; |
| 32 | }; |
| 33 | |
Stephen Rothwell | 76c1ce7 | 2007-05-01 16:19:07 +1000 | [diff] [blame] | 34 | #include <asm/prom.h> |
| 35 | |
| 36 | /* flag descriptions */ |
| 37 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ |
| 38 | #define OF_DETACHED 2 /* node has been detached from the device tree */ |
| 39 | |
| 40 | #define OF_BAD_ADDR ((u64)-1) |
| 41 | |
| 42 | extern struct device_node *of_find_node_by_name(struct device_node *from, |
| 43 | const char *name); |
| 44 | #define for_each_node_by_name(dn, name) \ |
| 45 | for (dn = of_find_node_by_name(NULL, name); dn; \ |
| 46 | dn = of_find_node_by_name(dn, name)) |
| 47 | extern struct device_node *of_find_node_by_type(struct device_node *from, |
| 48 | const char *type); |
| 49 | #define for_each_node_by_type(dn, type) \ |
| 50 | for (dn = of_find_node_by_type(NULL, type); dn; \ |
| 51 | dn = of_find_node_by_type(dn, type)) |
| 52 | extern struct device_node *of_find_compatible_node(struct device_node *from, |
| 53 | const char *type, const char *compat); |
| 54 | #define for_each_compatible_node(dn, type, compatible) \ |
| 55 | for (dn = of_find_compatible_node(NULL, type, compatible); dn; \ |
| 56 | dn = of_find_compatible_node(dn, type, compatible)) |
Grant Likely | 283029d | 2008-01-09 06:20:40 +1100 | [diff] [blame] | 57 | extern struct device_node *of_find_matching_node(struct device_node *from, |
| 58 | const struct of_device_id *matches); |
| 59 | #define for_each_matching_node(dn, matches) \ |
| 60 | for (dn = of_find_matching_node(NULL, matches); dn; \ |
| 61 | dn = of_find_matching_node(dn, matches)) |
Stephen Rothwell | 76c1ce7 | 2007-05-01 16:19:07 +1000 | [diff] [blame] | 62 | extern struct device_node *of_find_node_by_path(const char *path); |
| 63 | extern struct device_node *of_find_node_by_phandle(phandle handle); |
| 64 | extern struct device_node *of_get_parent(const struct device_node *node); |
Michael Ellerman | f4eb010 | 2007-10-26 16:54:31 +1000 | [diff] [blame] | 65 | extern struct device_node *of_get_next_parent(struct device_node *node); |
Stephen Rothwell | 76c1ce7 | 2007-05-01 16:19:07 +1000 | [diff] [blame] | 66 | extern struct device_node *of_get_next_child(const struct device_node *node, |
| 67 | struct device_node *prev); |
Michael Ellerman | aabc08d | 2007-11-26 19:03:45 +1100 | [diff] [blame] | 68 | #define for_each_child_of_node(parent, child) \ |
| 69 | for (child = of_get_next_child(parent, NULL); child != NULL; \ |
| 70 | child = of_get_next_child(parent, child)) |
| 71 | |
Michael Ellerman | 1e291b14 | 2008-11-12 18:54:42 +0000 | [diff] [blame] | 72 | extern struct device_node *of_find_node_with_property( |
| 73 | struct device_node *from, const char *prop_name); |
| 74 | #define for_each_node_with_property(dn, prop_name) \ |
| 75 | for (dn = of_find_node_with_property(NULL, prop_name); dn; \ |
| 76 | dn = of_find_node_with_property(dn, prop_name)) |
| 77 | |
Stephen Rothwell | 76c1ce7 | 2007-05-01 16:19:07 +1000 | [diff] [blame] | 78 | extern struct property *of_find_property(const struct device_node *np, |
| 79 | const char *name, |
| 80 | int *lenp); |
| 81 | extern int of_device_is_compatible(const struct device_node *device, |
| 82 | const char *); |
Josh Boyer | 834d97d | 2008-03-27 00:33:14 +1100 | [diff] [blame] | 83 | extern int of_device_is_available(const struct device_node *device); |
Stephen Rothwell | 76c1ce7 | 2007-05-01 16:19:07 +1000 | [diff] [blame] | 84 | extern const void *of_get_property(const struct device_node *node, |
| 85 | const char *name, |
| 86 | int *lenp); |
Stephen Rothwell | 76c1ce7 | 2007-05-01 16:19:07 +1000 | [diff] [blame] | 87 | extern int of_n_addr_cells(struct device_node *np); |
| 88 | extern int of_n_size_cells(struct device_node *np); |
Grant Likely | 283029d | 2008-01-09 06:20:40 +1100 | [diff] [blame] | 89 | extern const struct of_device_id *of_match_node( |
| 90 | const struct of_device_id *matches, const struct device_node *node); |
Grant Likely | 3f07af4 | 2008-07-25 22:25:13 -0400 | [diff] [blame] | 91 | extern int of_modalias_node(struct device_node *node, char *modalias, int len); |
Grant Likely | 739649c | 2009-04-25 12:52:40 +0000 | [diff] [blame] | 92 | extern struct device_node *of_parse_phandle(struct device_node *np, |
| 93 | const char *phandle_name, |
| 94 | int index); |
Anton Vorontsov | 64b60e0 | 2008-10-10 04:43:17 +0000 | [diff] [blame] | 95 | extern int of_parse_phandles_with_args(struct device_node *np, |
| 96 | const char *list_name, const char *cells_name, int index, |
| 97 | struct device_node **out_node, const void **out_args); |
Stephen Rothwell | 76c1ce7 | 2007-05-01 16:19:07 +1000 | [diff] [blame] | 98 | |
| 99 | #endif /* _LINUX_OF_H */ |