2 * OF graph binding parsing helpers
4 * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
7 * Copyright (C) 2012 Renesas Electronics Corp.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
14 #ifndef __LINUX_OF_GRAPH_H
15 #define __LINUX_OF_GRAPH_H
17 #include <linux/types.h>
20 * struct of_endpoint - the OF graph endpoint data structure
21 * @port: identifier (value of reg property) of a port this endpoint belongs to
22 * @id: identifier (value of reg property) of this endpoint
23 * @local_node: pointer to device_node of this endpoint
28 const struct device_node *local_node;
32 * for_each_endpoint_of_node - iterate over every endpoint in a device node
33 * @parent: parent device node containing ports and endpoints
34 * @child: loop variable pointing to the current endpoint node
36 * When breaking out of the loop, of_node_put(child) has to be called manually.
38 #define for_each_endpoint_of_node(parent, child) \
39 for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \
40 child = of_graph_get_next_endpoint(parent, child))
43 int of_graph_parse_endpoint(const struct device_node *node,
44 struct of_endpoint *endpoint);
45 struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
46 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
47 struct device_node *previous);
48 struct device_node *of_graph_get_remote_port_parent(
49 const struct device_node *node);
50 struct device_node *of_graph_get_remote_port(const struct device_node *node);
53 static inline int of_graph_parse_endpoint(const struct device_node *node,
54 struct of_endpoint *endpoint)
59 static inline struct device_node *of_graph_get_port_by_id(
60 struct device_node *node, u32 id)
65 static inline struct device_node *of_graph_get_next_endpoint(
66 const struct device_node *parent,
67 struct device_node *previous)
72 static inline struct device_node *of_graph_get_remote_port_parent(
73 const struct device_node *node)
78 static inline struct device_node *of_graph_get_remote_port(
79 const struct device_node *node)
84 #endif /* CONFIG_OF */
86 #endif /* __LINUX_OF_GRAPH_H */