Merge tag 'v4.4-rc7'
[firefly-linux-kernel-4.4.55.git] / include / linux / of_graph.h
index 56e0507a0d5881c4e55a68b7238ed19482b1331e..f8bcd0e21a26649fb70ad645d79b09ee00412283 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef __LINUX_OF_GRAPH_H
 #define __LINUX_OF_GRAPH_H
 
+#include <linux/types.h>
+
 /**
  * struct of_endpoint - the OF graph endpoint data structure
  * @port: identifier (value of reg property) of a port this endpoint belongs to
@@ -26,11 +28,25 @@ struct of_endpoint {
        const struct device_node *local_node;
 };
 
+/**
+ * for_each_endpoint_of_node - iterate over every endpoint in a device node
+ * @parent: parent device node containing ports and endpoints
+ * @child: loop variable pointing to the current endpoint node
+ *
+ * When breaking out of the loop, of_node_put(child) has to be called manually.
+ */
+#define for_each_endpoint_of_node(parent, child) \
+       for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \
+            child = of_graph_get_next_endpoint(parent, child))
+
 #ifdef CONFIG_OF
 int of_graph_parse_endpoint(const struct device_node *node,
                                struct of_endpoint *endpoint);
+struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
                                        struct device_node *previous);
+struct device_node *of_graph_get_endpoint_by_regs(
+               const struct device_node *parent, int port_reg, int reg);
 struct device_node *of_graph_get_remote_port_parent(
                                        const struct device_node *node);
 struct device_node *of_graph_get_remote_port(const struct device_node *node);
@@ -41,6 +57,13 @@ static inline int of_graph_parse_endpoint(const struct device_node *node,
 {
        return -ENOSYS;
 }
+
+static inline struct device_node *of_graph_get_port_by_id(
+                                       struct device_node *node, u32 id)
+{
+       return NULL;
+}
+
 static inline struct device_node *of_graph_get_next_endpoint(
                                        const struct device_node *parent,
                                        struct device_node *previous)
@@ -48,6 +71,12 @@ static inline struct device_node *of_graph_get_next_endpoint(
        return NULL;
 }
 
+static inline struct device_node *of_graph_get_endpoint_by_regs(
+               const struct device_node *parent, int port_reg, int reg)
+{
+       return NULL;
+}
+
 static inline struct device_node *of_graph_get_remote_port_parent(
                                        const struct device_node *node)
 {