Philipp Zabel | fd9fdb7 | 2014-02-10 22:01:48 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
Mark Brown | 01218bf | 2015-03-26 09:47:55 -0700 | [diff] [blame] | 17 | #include <linux/types.h> |
| 18 | |
Philipp Zabel | f2a575f | 2014-02-14 11:53:56 +0100 | [diff] [blame] | 19 | /** |
| 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 |
| 24 | */ |
| 25 | struct of_endpoint { |
| 26 | unsigned int port; |
| 27 | unsigned int id; |
| 28 | const struct device_node *local_node; |
| 29 | }; |
| 30 | |
Philipp Zabel | ee89059 | 2014-04-14 17:53:25 +0200 | [diff] [blame] | 31 | /** |
| 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 |
| 35 | * |
| 36 | * When breaking out of the loop, of_node_put(child) has to be called manually. |
| 37 | */ |
| 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)) |
| 41 | |
Philipp Zabel | fd9fdb7 | 2014-02-10 22:01:48 +0100 | [diff] [blame] | 42 | #ifdef CONFIG_OF |
Philipp Zabel | f2a575f | 2014-02-14 11:53:56 +0100 | [diff] [blame] | 43 | int of_graph_parse_endpoint(const struct device_node *node, |
| 44 | struct of_endpoint *endpoint); |
Philipp Zabel | bfe446e | 2014-03-11 11:21:11 +0100 | [diff] [blame] | 45 | struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id); |
Philipp Zabel | fd9fdb7 | 2014-02-10 22:01:48 +0100 | [diff] [blame] | 46 | struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, |
| 47 | struct device_node *previous); |
Hyungwon Hwang | 8ccd0d0 | 2015-06-12 21:59:01 +0900 | [diff] [blame] | 48 | struct device_node *of_graph_get_endpoint_by_regs( |
| 49 | const struct device_node *parent, int port_reg, int reg); |
Philipp Zabel | fd9fdb7 | 2014-02-10 22:01:48 +0100 | [diff] [blame] | 50 | struct device_node *of_graph_get_remote_port_parent( |
| 51 | const struct device_node *node); |
| 52 | struct device_node *of_graph_get_remote_port(const struct device_node *node); |
| 53 | #else |
| 54 | |
Philipp Zabel | f2a575f | 2014-02-14 11:53:56 +0100 | [diff] [blame] | 55 | static inline int of_graph_parse_endpoint(const struct device_node *node, |
Philipp Zabel | 00fd961 | 2014-03-07 15:49:54 +0100 | [diff] [blame] | 56 | struct of_endpoint *endpoint) |
Philipp Zabel | f2a575f | 2014-02-14 11:53:56 +0100 | [diff] [blame] | 57 | { |
| 58 | return -ENOSYS; |
| 59 | } |
| 60 | |
Philipp Zabel | bfe446e | 2014-03-11 11:21:11 +0100 | [diff] [blame] | 61 | static inline struct device_node *of_graph_get_port_by_id( |
| 62 | struct device_node *node, u32 id) |
| 63 | { |
| 64 | return NULL; |
| 65 | } |
| 66 | |
Philipp Zabel | fd9fdb7 | 2014-02-10 22:01:48 +0100 | [diff] [blame] | 67 | static inline struct device_node *of_graph_get_next_endpoint( |
| 68 | const struct device_node *parent, |
| 69 | struct device_node *previous) |
| 70 | { |
| 71 | return NULL; |
| 72 | } |
| 73 | |
Inki Dae | ce0bdb8 | 2015-06-23 16:06:44 +0900 | [diff] [blame] | 74 | static inline struct device_node *of_graph_get_endpoint_by_regs( |
Hyungwon Hwang | 8ccd0d0 | 2015-06-12 21:59:01 +0900 | [diff] [blame] | 75 | const struct device_node *parent, int port_reg, int reg) |
| 76 | { |
| 77 | return NULL; |
| 78 | } |
| 79 | |
Philipp Zabel | fd9fdb7 | 2014-02-10 22:01:48 +0100 | [diff] [blame] | 80 | static inline struct device_node *of_graph_get_remote_port_parent( |
| 81 | const struct device_node *node) |
| 82 | { |
| 83 | return NULL; |
| 84 | } |
| 85 | |
| 86 | static inline struct device_node *of_graph_get_remote_port( |
| 87 | const struct device_node *node) |
| 88 | { |
| 89 | return NULL; |
| 90 | } |
| 91 | |
| 92 | #endif /* CONFIG_OF */ |
| 93 | |
| 94 | #endif /* __LINUX_OF_GRAPH_H */ |