|
@@ -165,3 +165,64 @@ int v4l2_of_parse_endpoint(const struct device_node *node,
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(v4l2_of_parse_endpoint);
|
|
EXPORT_SYMBOL(v4l2_of_parse_endpoint);
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * v4l2_of_parse_link() - parse a link between two endpoints
|
|
|
|
+ * @node: pointer to the endpoint at the local end of the link
|
|
|
|
+ * @link: pointer to the V4L2 OF link data structure
|
|
|
|
+ *
|
|
|
|
+ * Fill the link structure with the local and remote nodes and port numbers.
|
|
|
|
+ * The local_node and remote_node fields are set to point to the local and
|
|
|
|
+ * remote port's parent nodes respectively (the port parent node being the
|
|
|
|
+ * parent node of the port node if that node isn't a 'ports' node, or the
|
|
|
|
+ * grand-parent node of the port node otherwise).
|
|
|
|
+ *
|
|
|
|
+ * A reference is taken to both the local and remote nodes, the caller must use
|
|
|
|
+ * v4l2_of_put_link() to drop the references when done with the link.
|
|
|
|
+ *
|
|
|
|
+ * Return: 0 on success, or -ENOLINK if the remote endpoint can't be found.
|
|
|
|
+ */
|
|
|
|
+int v4l2_of_parse_link(const struct device_node *node,
|
|
|
|
+ struct v4l2_of_link *link)
|
|
|
|
+{
|
|
|
|
+ struct device_node *np;
|
|
|
|
+
|
|
|
|
+ memset(link, 0, sizeof(*link));
|
|
|
|
+
|
|
|
|
+ np = of_get_parent(node);
|
|
|
|
+ of_property_read_u32(np, "reg", &link->local_port);
|
|
|
|
+ np = of_get_next_parent(np);
|
|
|
|
+ if (of_node_cmp(np->name, "ports") == 0)
|
|
|
|
+ np = of_get_next_parent(np);
|
|
|
|
+ link->local_node = np;
|
|
|
|
+
|
|
|
|
+ np = of_parse_phandle(node, "remote-endpoint", 0);
|
|
|
|
+ if (!np) {
|
|
|
|
+ of_node_put(link->local_node);
|
|
|
|
+ return -ENOLINK;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ np = of_get_parent(np);
|
|
|
|
+ of_property_read_u32(np, "reg", &link->remote_port);
|
|
|
|
+ np = of_get_next_parent(np);
|
|
|
|
+ if (of_node_cmp(np->name, "ports") == 0)
|
|
|
|
+ np = of_get_next_parent(np);
|
|
|
|
+ link->remote_node = np;
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(v4l2_of_parse_link);
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * v4l2_of_put_link() - drop references to nodes in a link
|
|
|
|
+ * @link: pointer to the V4L2 OF link data structure
|
|
|
|
+ *
|
|
|
|
+ * Drop references to the local and remote nodes in the link. This function must
|
|
|
|
+ * be called on every link parsed with v4l2_of_parse_link().
|
|
|
|
+ */
|
|
|
|
+void v4l2_of_put_link(struct v4l2_of_link *link)
|
|
|
|
+{
|
|
|
|
+ of_node_put(link->local_node);
|
|
|
|
+ of_node_put(link->remote_node);
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(v4l2_of_put_link);
|