Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * OF graph binding parsing helpers
0004  *
0005  * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
0006  * Author: Sylwester Nawrocki <s.nawrocki@samsung.com>
0007  *
0008  * Copyright (C) 2012 Renesas Electronics Corp.
0009  * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
0010  */
0011 #ifndef __LINUX_OF_GRAPH_H
0012 #define __LINUX_OF_GRAPH_H
0013 
0014 #include <linux/types.h>
0015 #include <linux/errno.h>
0016 
0017 /**
0018  * struct of_endpoint - the OF graph endpoint data structure
0019  * @port: identifier (value of reg property) of a port this endpoint belongs to
0020  * @id: identifier (value of reg property) of this endpoint
0021  * @local_node: pointer to device_node of this endpoint
0022  */
0023 struct of_endpoint {
0024     unsigned int port;
0025     unsigned int id;
0026     const struct device_node *local_node;
0027 };
0028 
0029 /**
0030  * for_each_endpoint_of_node - iterate over every endpoint in a device node
0031  * @parent: parent device node containing ports and endpoints
0032  * @child: loop variable pointing to the current endpoint node
0033  *
0034  * When breaking out of the loop, of_node_put(child) has to be called manually.
0035  */
0036 #define for_each_endpoint_of_node(parent, child) \
0037     for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \
0038          child = of_graph_get_next_endpoint(parent, child))
0039 
0040 #ifdef CONFIG_OF
0041 bool of_graph_is_present(const struct device_node *node);
0042 int of_graph_parse_endpoint(const struct device_node *node,
0043                 struct of_endpoint *endpoint);
0044 int of_graph_get_endpoint_count(const struct device_node *np);
0045 struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
0046 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
0047                     struct device_node *previous);
0048 struct device_node *of_graph_get_endpoint_by_regs(
0049         const struct device_node *parent, int port_reg, int reg);
0050 struct device_node *of_graph_get_remote_endpoint(
0051                     const struct device_node *node);
0052 struct device_node *of_graph_get_port_parent(struct device_node *node);
0053 struct device_node *of_graph_get_remote_port_parent(
0054                     const struct device_node *node);
0055 struct device_node *of_graph_get_remote_port(const struct device_node *node);
0056 struct device_node *of_graph_get_remote_node(const struct device_node *node,
0057                          u32 port, u32 endpoint);
0058 #else
0059 
0060 static inline bool of_graph_is_present(const struct device_node *node)
0061 {
0062     return false;
0063 }
0064 
0065 static inline int of_graph_parse_endpoint(const struct device_node *node,
0066                     struct of_endpoint *endpoint)
0067 {
0068     return -ENOSYS;
0069 }
0070 
0071 static inline int of_graph_get_endpoint_count(const struct device_node *np)
0072 {
0073     return 0;
0074 }
0075 
0076 static inline struct device_node *of_graph_get_port_by_id(
0077                     struct device_node *node, u32 id)
0078 {
0079     return NULL;
0080 }
0081 
0082 static inline struct device_node *of_graph_get_next_endpoint(
0083                     const struct device_node *parent,
0084                     struct device_node *previous)
0085 {
0086     return NULL;
0087 }
0088 
0089 static inline struct device_node *of_graph_get_endpoint_by_regs(
0090         const struct device_node *parent, int port_reg, int reg)
0091 {
0092     return NULL;
0093 }
0094 
0095 static inline struct device_node *of_graph_get_remote_endpoint(
0096                     const struct device_node *node)
0097 {
0098     return NULL;
0099 }
0100 
0101 static inline struct device_node *of_graph_get_port_parent(
0102     struct device_node *node)
0103 {
0104     return NULL;
0105 }
0106 
0107 static inline struct device_node *of_graph_get_remote_port_parent(
0108                     const struct device_node *node)
0109 {
0110     return NULL;
0111 }
0112 
0113 static inline struct device_node *of_graph_get_remote_port(
0114                     const struct device_node *node)
0115 {
0116     return NULL;
0117 }
0118 static inline struct device_node *of_graph_get_remote_node(
0119                     const struct device_node *node,
0120                     u32 port, u32 endpoint)
0121 {
0122     return NULL;
0123 }
0124 
0125 #endif /* CONFIG_OF */
0126 
0127 #endif /* __LINUX_OF_GRAPH_H */