1c349dbc7Sjsg /* Public domain. */
2c349dbc7Sjsg
3c349dbc7Sjsg #ifndef _LINUX_OF_H
4c349dbc7Sjsg #define _LINUX_OF_H
5c349dbc7Sjsg
6c349dbc7Sjsg #ifdef __macppc__
7c349dbc7Sjsg static inline int
of_machine_is_compatible(const char * model)8c349dbc7Sjsg of_machine_is_compatible(const char *model)
9c349dbc7Sjsg {
10c349dbc7Sjsg extern char *hw_prod;
11c349dbc7Sjsg return (strcmp(model, hw_prod) == 0);
12c349dbc7Sjsg }
13c349dbc7Sjsg #endif
14c349dbc7Sjsg
15*667382c7Skettenis struct device_node {
16*667382c7Skettenis const char *full_name;
17*667382c7Skettenis };
18*667382c7Skettenis
19*667382c7Skettenis #define of_node dv_cfdata
20*667382c7Skettenis
21*667382c7Skettenis struct device_node *__of_get_compatible_child(void *, const char *);
22*667382c7Skettenis #define of_get_compatible_child(d, n) \
23*667382c7Skettenis __of_get_compatible_child(&(d), (n))
24*667382c7Skettenis
25*667382c7Skettenis struct device_node *__of_get_child_by_name(void *, const char *);
26*667382c7Skettenis #define of_get_child_by_name(d, n) \
27*667382c7Skettenis __of_get_child_by_name(&(d), (n))
28*667382c7Skettenis
29*667382c7Skettenis #define of_node_put(p)
30*667382c7Skettenis
31*667382c7Skettenis struct device_node *__of_devnode(void *);
32*667382c7Skettenis #define __of_node(arg) \
33*667382c7Skettenis __builtin_types_compatible_p(typeof(arg), struct device_node *) ? \
34*667382c7Skettenis (struct device_node *)arg : __of_devnode(&arg)
35*667382c7Skettenis
36*667382c7Skettenis int __of_property_present(struct device_node *, const char *);
37*667382c7Skettenis #define of_property_present(n, p) \
38*667382c7Skettenis __of_property_present(__of_node(n), (p))
39*667382c7Skettenis
40*667382c7Skettenis int __of_property_read_variable_u32_array(struct device_node *,
41*667382c7Skettenis const char *, uint32_t *, size_t, size_t);
42*667382c7Skettenis #define of_property_read_u32(n, p, o) \
43*667382c7Skettenis __of_property_read_variable_u32_array(__of_node(n), (p), (o), 1, 1)
44*667382c7Skettenis #define of_property_read_variable_u32_array(n, p, o, l, h) \
45*667382c7Skettenis __of_property_read_variable_u32_array(__of_node(n), (p), (o), (l), (h))
46*667382c7Skettenis
47*667382c7Skettenis int __of_property_read_variable_u64_array(struct device_node *,
48*667382c7Skettenis const char *, uint64_t *, size_t, size_t);
49*667382c7Skettenis #define of_property_read_u64(n, p, o) \
50*667382c7Skettenis __of_property_read_variable_u64_array(__of_node(n), (p), (o), 1, 1)
51*667382c7Skettenis
52*667382c7Skettenis int __of_property_match_string(struct device_node *,
53*667382c7Skettenis const char *, const char *);
54*667382c7Skettenis #define of_property_match_string(n, a, b) \
55*667382c7Skettenis __of_property_match_string(__of_node(n), (a), (b))
56*667382c7Skettenis
57*667382c7Skettenis struct device_node *__of_parse_phandle(struct device_node *,
58*667382c7Skettenis const char *, int);
59*667382c7Skettenis #define of_parse_phandle(n, a, b) \
60*667382c7Skettenis __of_parse_phandle(__of_node(n), (a), (b))
61*667382c7Skettenis
62*667382c7Skettenis struct of_phandle_args {
63*667382c7Skettenis struct device_node *np;
64*667382c7Skettenis int args_count;
65*667382c7Skettenis uint32_t args[5];
66*667382c7Skettenis };
67*667382c7Skettenis
68*667382c7Skettenis int __of_parse_phandle_with_args(struct device_node *,
69*667382c7Skettenis const char *, const char *, int, struct of_phandle_args *);
70*667382c7Skettenis #define of_parse_phandle_with_args(n, a, b, c, d) \
71*667382c7Skettenis __of_parse_phandle_with_args(__of_node(n), (a), (b), (c), (d))
72*667382c7Skettenis
73*667382c7Skettenis int of_device_is_available(struct device_node *);
74*667382c7Skettenis
75*667382c7Skettenis struct of_device_id {
76*667382c7Skettenis const char *compatible;
77*667382c7Skettenis const void *data;
78*667382c7Skettenis };
79*667382c7Skettenis
80*667382c7Skettenis struct device_node *__matching_node(struct device_node *,
81*667382c7Skettenis const struct of_device_id *);
82*667382c7Skettenis #define for_each_matching_node(a, b) \
83*667382c7Skettenis for (a = __matching_node(NULL, b); a; a = __matching_node(a, b))
84*667382c7Skettenis
85c349dbc7Sjsg #endif
86