Merge branches 'acpi-video' and 'acpi-pmic'
[cascardo/linux.git] / include / linux / of.h
index 29f0adc..cf79be1 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/spinlock.h>
 #include <linux/topology.h>
 #include <linux/notifier.h>
+#include <linux/property.h>
 
 #include <asm/byteorder.h>
 #include <asm/errno.h>
@@ -49,6 +50,7 @@ struct device_node {
        const char *type;
        phandle phandle;
        const char *full_name;
+       struct fwnode_handle fwnode;
 
        struct  property *properties;
        struct  property *deadprops;    /* removed properties */
@@ -79,6 +81,7 @@ extern struct kobj_type of_node_ktype;
 static inline void of_node_init(struct device_node *node)
 {
        kobject_init(&node->kobj, &of_node_ktype);
+       node->fwnode.type = FWNODE_OF;
 }
 
 /* true when node is initialized */
@@ -114,6 +117,16 @@ extern struct device_node *of_aliases;
 extern struct device_node *of_stdout;
 extern raw_spinlock_t devtree_lock;
 
+static inline bool is_of_node(struct fwnode_handle *fwnode)
+{
+       return fwnode && fwnode->type == FWNODE_OF;
+}
+
+static inline struct device_node *of_node(struct fwnode_handle *fwnode)
+{
+       return fwnode ? container_of(fwnode, struct device_node, fwnode) : NULL;
+}
+
 static inline bool of_have_populated_dt(void)
 {
        return of_allnodes != NULL;
@@ -263,6 +276,10 @@ extern int of_property_read_u32_array(const struct device_node *np,
                                      size_t sz);
 extern int of_property_read_u64(const struct device_node *np,
                                const char *propname, u64 *out_value);
+extern int of_property_read_u64_array(const struct device_node *np,
+                                     const char *propname,
+                                     u64 *out_values,
+                                     size_t sz);
 
 extern int of_property_read_string(struct device_node *np,
                                   const char *propname,
@@ -355,6 +372,16 @@ bool of_console_check(struct device_node *dn, char *name, int index);
 
 #else /* CONFIG_OF */
 
+static inline bool is_of_node(struct fwnode_handle *fwnode)
+{
+       return false;
+}
+
+static inline struct device_node *of_node(struct fwnode_handle *fwnode)
+{
+       return NULL;
+}
+
 static inline const char* of_node_full_name(const struct device_node *np)
 {
        return "<no-node>";
@@ -477,6 +504,13 @@ static inline int of_property_read_u32_array(const struct device_node *np,
        return -ENOSYS;
 }
 
+static inline int of_property_read_u64_array(const struct device_node *np,
+                                            const char *propname,
+                                            u64 *out_values, size_t sz)
+{
+       return -ENOSYS;
+}
+
 static inline int of_property_read_string(struct device_node *np,
                                          const char *propname,
                                          const char **out_string)