blob: 3c1c95a39e0c17f011e6332ed3a6caa5d7d5401b [file] [log] [blame]
Philipp Zabelfd9fdb72014-02-10 22:01:48 +01001/*
2 * OF graph binding parsing helpers
3 *
4 * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
5 * Author: Sylwester Nawrocki <s.nawrocki@samsung.com>
6 *
7 * Copyright (C) 2012 Renesas Electronics Corp.
8 * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
9 *
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.
13 */
14#ifndef __LINUX_OF_GRAPH_H
15#define __LINUX_OF_GRAPH_H
16
Philipp Zabelf2a575f2014-02-14 11:53:56 +010017/**
18 * struct of_endpoint - the OF graph endpoint data structure
19 * @port: identifier (value of reg property) of a port this endpoint belongs to
20 * @id: identifier (value of reg property) of this endpoint
21 * @local_node: pointer to device_node of this endpoint
22 */
23struct of_endpoint {
24 unsigned int port;
25 unsigned int id;
26 const struct device_node *local_node;
27};
28
Philipp Zabelee890592014-04-14 17:53:25 +020029/**
30 * for_each_endpoint_of_node - iterate over every endpoint in a device node
31 * @parent: parent device node containing ports and endpoints
32 * @child: loop variable pointing to the current endpoint node
33 *
34 * When breaking out of the loop, of_node_put(child) has to be called manually.
35 */
36#define for_each_endpoint_of_node(parent, child) \
37 for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \
38 child = of_graph_get_next_endpoint(parent, child))
39
Philipp Zabelfd9fdb72014-02-10 22:01:48 +010040#ifdef CONFIG_OF
Philipp Zabelf2a575f2014-02-14 11:53:56 +010041int of_graph_parse_endpoint(const struct device_node *node,
42 struct of_endpoint *endpoint);
Philipp Zabelbfe446e2014-03-11 11:21:11 +010043struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
Philipp Zabelfd9fdb72014-02-10 22:01:48 +010044struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
45 struct device_node *previous);
46struct device_node *of_graph_get_remote_port_parent(
47 const struct device_node *node);
48struct device_node *of_graph_get_remote_port(const struct device_node *node);
49#else
50
Philipp Zabelf2a575f2014-02-14 11:53:56 +010051static inline int of_graph_parse_endpoint(const struct device_node *node,
Philipp Zabel00fd9612014-03-07 15:49:54 +010052 struct of_endpoint *endpoint)
Philipp Zabelf2a575f2014-02-14 11:53:56 +010053{
54 return -ENOSYS;
55}
56
Philipp Zabelbfe446e2014-03-11 11:21:11 +010057static inline struct device_node *of_graph_get_port_by_id(
58 struct device_node *node, u32 id)
59{
60 return NULL;
61}
62
Philipp Zabelfd9fdb72014-02-10 22:01:48 +010063static inline struct device_node *of_graph_get_next_endpoint(
64 const struct device_node *parent,
65 struct device_node *previous)
66{
67 return NULL;
68}
69
70static inline struct device_node *of_graph_get_remote_port_parent(
71 const struct device_node *node)
72{
73 return NULL;
74}
75
76static inline struct device_node *of_graph_get_remote_port(
77 const struct device_node *node)
78{
79 return NULL;
80}
81
82#endif /* CONFIG_OF */
83
84#endif /* __LINUX_OF_GRAPH_H */