aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/of.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/of.h')
-rw-r--r--include/linux/of.h71
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
26typedef u32 phandle; 28typedef u32 phandle;
27typedef u32 ihandle; 29typedef 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. */
69extern struct device_node *allnodes; 71extern struct device_node *allnodes;
70extern struct device_node *of_chosen; 72extern struct device_node *of_chosen;
73extern struct device_node *of_aliases;
71extern rwlock_t devtree_lock; 74extern rwlock_t devtree_lock;
72 75
73static inline bool of_have_populated_dt(void) 76static 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);
205extern int of_property_read_u64(const struct device_node *np,
206 const char *propname, u64 *out_value);
202 207
203extern int of_property_read_string(struct device_node *np, 208extern 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);
211extern int of_property_read_string_index(struct device_node *np,
212 const char *propname,
213 int index, const char **output);
214extern int of_property_count_strings(struct device_node *np,
215 const char *propname);
206extern int of_device_is_compatible(const struct device_node *device, 216extern int of_device_is_compatible(const struct device_node *device,
207 const char *); 217 const char *);
208extern int of_device_is_available(const struct device_node *device); 218extern int of_device_is_available(const struct device_node *device);
209extern const void *of_get_property(const struct device_node *node, 219extern 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
212extern int of_n_addr_cells(struct device_node *np); 225extern int of_n_addr_cells(struct device_node *np);
213extern int of_n_size_cells(struct device_node *np); 226extern int of_n_size_cells(struct device_node *np);
214extern const struct of_device_id *of_match_node( 227extern 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
237extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align));
238extern int of_alias_get_id(struct device_node *np, const char *stem);
239
224extern int of_machine_is_compatible(const char *compat); 240extern int of_machine_is_compatible(const char *compat);
225 241
226extern int prom_add_property(struct device_node* np, struct property* prop); 242extern int prom_add_property(struct device_node* np, struct property* prop);
@@ -235,6 +251,7 @@ extern void of_attach_node(struct device_node *);
235extern void of_detach_node(struct device_node *); 251extern 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
240static inline bool of_have_populated_dt(void) 257static 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
265static inline int of_device_is_compatible(const struct device_node *device,
266 const char *name)
267{
268 return 0;
269}
270
271static inline struct property *of_find_property(const struct device_node *np,
272 const char *name,
273 int *lenp)
274{
275 return NULL;
276}
277
245static inline int of_property_read_u32_array(const struct device_node *np, 278static 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
292static 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
299static inline int of_property_count_strings(struct device_node *np,
300 const char *propname)
301{
302 return -ENOSYS;
303}
304
259static inline const void *of_get_property(const struct device_node *node, 305static 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
312static inline int of_property_read_u64(const struct device_node *np,
313 const char *propname, u64 *out_value)
314{
315 return -ENOSYS;
316}
317
318static 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
325static inline int of_alias_get_id(struct device_node *np, const char *stem)
326{
327 return -ENOSYS;
328}
329
330static 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
268static inline int of_property_read_u32(const struct device_node *np, 339static inline int of_property_read_u32(const struct device_node *np,