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.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h
index 29f0adc5f3e4..cf79be1441d2 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -23,6 +23,7 @@
23#include <linux/spinlock.h> 23#include <linux/spinlock.h>
24#include <linux/topology.h> 24#include <linux/topology.h>
25#include <linux/notifier.h> 25#include <linux/notifier.h>
26#include <linux/property.h>
26 27
27#include <asm/byteorder.h> 28#include <asm/byteorder.h>
28#include <asm/errno.h> 29#include <asm/errno.h>
@@ -49,6 +50,7 @@ struct device_node {
49 const char *type; 50 const char *type;
50 phandle phandle; 51 phandle phandle;
51 const char *full_name; 52 const char *full_name;
53 struct fwnode_handle fwnode;
52 54
53 struct property *properties; 55 struct property *properties;
54 struct property *deadprops; /* removed properties */ 56 struct property *deadprops; /* removed properties */
@@ -79,6 +81,7 @@ extern struct kobj_type of_node_ktype;
79static inline void of_node_init(struct device_node *node) 81static inline void of_node_init(struct device_node *node)
80{ 82{
81 kobject_init(&node->kobj, &of_node_ktype); 83 kobject_init(&node->kobj, &of_node_ktype);
84 node->fwnode.type = FWNODE_OF;
82} 85}
83 86
84/* true when node is initialized */ 87/* true when node is initialized */
@@ -114,6 +117,16 @@ extern struct device_node *of_aliases;
114extern struct device_node *of_stdout; 117extern struct device_node *of_stdout;
115extern raw_spinlock_t devtree_lock; 118extern raw_spinlock_t devtree_lock;
116 119
120static inline bool is_of_node(struct fwnode_handle *fwnode)
121{
122 return fwnode && fwnode->type == FWNODE_OF;
123}
124
125static inline struct device_node *of_node(struct fwnode_handle *fwnode)
126{
127 return fwnode ? container_of(fwnode, struct device_node, fwnode) : NULL;
128}
129
117static inline bool of_have_populated_dt(void) 130static inline bool of_have_populated_dt(void)
118{ 131{
119 return of_allnodes != NULL; 132 return of_allnodes != NULL;
@@ -263,6 +276,10 @@ extern int of_property_read_u32_array(const struct device_node *np,
263 size_t sz); 276 size_t sz);
264extern int of_property_read_u64(const struct device_node *np, 277extern int of_property_read_u64(const struct device_node *np,
265 const char *propname, u64 *out_value); 278 const char *propname, u64 *out_value);
279extern int of_property_read_u64_array(const struct device_node *np,
280 const char *propname,
281 u64 *out_values,
282 size_t sz);
266 283
267extern int of_property_read_string(struct device_node *np, 284extern int of_property_read_string(struct device_node *np,
268 const char *propname, 285 const char *propname,
@@ -355,6 +372,16 @@ bool of_console_check(struct device_node *dn, char *name, int index);
355 372
356#else /* CONFIG_OF */ 373#else /* CONFIG_OF */
357 374
375static inline bool is_of_node(struct fwnode_handle *fwnode)
376{
377 return false;
378}
379
380static inline struct device_node *of_node(struct fwnode_handle *fwnode)
381{
382 return NULL;
383}
384
358static inline const char* of_node_full_name(const struct device_node *np) 385static inline const char* of_node_full_name(const struct device_node *np)
359{ 386{
360 return "<no-node>"; 387 return "<no-node>";
@@ -477,6 +504,13 @@ static inline int of_property_read_u32_array(const struct device_node *np,
477 return -ENOSYS; 504 return -ENOSYS;
478} 505}
479 506
507static inline int of_property_read_u64_array(const struct device_node *np,
508 const char *propname,
509 u64 *out_values, size_t sz)
510{
511 return -ENOSYS;
512}
513
480static inline int of_property_read_string(struct device_node *np, 514static inline int of_property_read_string(struct device_node *np,
481 const char *propname, 515 const char *propname,
482 const char **out_string) 516 const char **out_string)