blob: 79886ade070f2e791274c92814bc04bfbcff4947 [file] [log] [blame]
Stephen Rothwell76c1ce72007-05-01 16:19:07 +10001#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 Slaby1977f032007-10-18 23:40:25 -070019#include <linux/bitops.h>
Grant Likely283029d2008-01-09 06:20:40 +110020#include <linux/mod_devicetable.h>
Stephen Rothwell76c1ce72007-05-01 16:19:07 +100021
Stephen Rothwell76c1ce72007-05-01 16:19:07 +100022#include <asm/prom.h>
23
24/* flag descriptions */
25#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
26#define OF_DETACHED 2 /* node has been detached from the device tree */
27
28#define OF_BAD_ADDR ((u64)-1)
29
30extern struct device_node *of_find_node_by_name(struct device_node *from,
31 const char *name);
32#define for_each_node_by_name(dn, name) \
33 for (dn = of_find_node_by_name(NULL, name); dn; \
34 dn = of_find_node_by_name(dn, name))
35extern struct device_node *of_find_node_by_type(struct device_node *from,
36 const char *type);
37#define for_each_node_by_type(dn, type) \
38 for (dn = of_find_node_by_type(NULL, type); dn; \
39 dn = of_find_node_by_type(dn, type))
40extern struct device_node *of_find_compatible_node(struct device_node *from,
41 const char *type, const char *compat);
42#define for_each_compatible_node(dn, type, compatible) \
43 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
44 dn = of_find_compatible_node(dn, type, compatible))
Grant Likely283029d2008-01-09 06:20:40 +110045extern struct device_node *of_find_matching_node(struct device_node *from,
46 const struct of_device_id *matches);
47#define for_each_matching_node(dn, matches) \
48 for (dn = of_find_matching_node(NULL, matches); dn; \
49 dn = of_find_matching_node(dn, matches))
Stephen Rothwell76c1ce72007-05-01 16:19:07 +100050extern struct device_node *of_find_node_by_path(const char *path);
51extern struct device_node *of_find_node_by_phandle(phandle handle);
52extern struct device_node *of_get_parent(const struct device_node *node);
Michael Ellermanf4eb0102007-10-26 16:54:31 +100053extern struct device_node *of_get_next_parent(struct device_node *node);
Stephen Rothwell76c1ce72007-05-01 16:19:07 +100054extern struct device_node *of_get_next_child(const struct device_node *node,
55 struct device_node *prev);
Michael Ellermanaabc08d2007-11-26 19:03:45 +110056#define for_each_child_of_node(parent, child) \
57 for (child = of_get_next_child(parent, NULL); child != NULL; \
58 child = of_get_next_child(parent, child))
59
Stephen Rothwell76c1ce72007-05-01 16:19:07 +100060extern struct property *of_find_property(const struct device_node *np,
61 const char *name,
62 int *lenp);
63extern int of_device_is_compatible(const struct device_node *device,
64 const char *);
Josh Boyer834d97d2008-03-27 00:33:14 +110065extern int of_device_is_available(const struct device_node *device);
Stephen Rothwell76c1ce72007-05-01 16:19:07 +100066extern const void *of_get_property(const struct device_node *node,
67 const char *name,
68 int *lenp);
Stephen Rothwell76c1ce72007-05-01 16:19:07 +100069extern int of_n_addr_cells(struct device_node *np);
70extern int of_n_size_cells(struct device_node *np);
Grant Likely283029d2008-01-09 06:20:40 +110071extern const struct of_device_id *of_match_node(
72 const struct of_device_id *matches, const struct device_node *node);
Grant Likely3f07af42008-07-25 22:25:13 -040073extern int of_modalias_node(struct device_node *node, char *modalias, int len);
Stephen Rothwell76c1ce72007-05-01 16:19:07 +100074
75#endif /* _LINUX_OF_H */