All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hyungwon Hwang <human.hwang@samsung.com>
To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	inki.dae@samsung.com, daniel@fooishbar.org
Cc: dh09.lee@samsung.com, sw0312.kim@samsung.com,
	Hyungwon Hwang <human.hwang@samsung.com>,
	cw00.choi@samsung.com
Subject: [PATCH v4 2/8] of: add helper for getting endpoint node of specific identifiers
Date: Tue, 07 Apr 2015 20:57:32 +0900	[thread overview]
Message-ID: <1428407858-25523-3-git-send-email-human.hwang@samsung.com> (raw)
In-Reply-To: <1428407858-25523-1-git-send-email-human.hwang@samsung.com>

When there are multiple ports or multiple endpoints in a port, they have to be
distinguished by the value of reg property. It is common. The drivers can get
the specific endpoint in the specific port via this function. Now the drivers
have to implement this code in themselves or have to force the order of dt nodes
to get the right node.

Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
Acked-by: Rob Herring <robh+dt@kernel.org>
---
Changes for v2:
- None

Changes for v3:
- None

Changes for v4:
- None
 drivers/of/base.c        | 33 +++++++++++++++++++++++++++++++++
 include/linux/of_graph.h |  8 ++++++++
 2 files changed, 41 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 8f165b1..37bc8e0 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2158,6 +2158,39 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 EXPORT_SYMBOL(of_graph_get_next_endpoint);

 /**
+ * of_graph_get_endpoint_by_regs() - get endpoint node of specific identifiers
+ * @parent: pointer to the parent device node
+ * @port_reg: identifier (value of reg property) of the parent port node
+ * @reg: identifier (value of reg property) of the endpoint node
+ *
+ * Return: An 'endpoint' node pointer which is identified by reg and at the same
+ * is the child of a port node identified by port_reg. reg and port_reg are
+ * ignored when they are -1.
+ */
+struct device_node *of_graph_get_endpoint_by_regs(
+	const struct device_node *parent, int port_reg, int reg)
+{
+	struct of_endpoint endpoint;
+	struct device_node *node, *prev_node = NULL;
+
+	while (1) {
+		node = of_graph_get_next_endpoint(parent, prev_node);
+		of_node_put(prev_node);
+		if (!node)
+			break;
+
+		of_graph_parse_endpoint(node, &endpoint);
+		if (((port_reg == -1) || (endpoint.port == port_reg)) &&
+			((reg == -1) || (endpoint.id == reg)))
+			return node;
+
+		prev_node = node;
+	}
+
+	return NULL;
+}
+
+/**
  * of_graph_get_remote_port_parent() - get remote port's parent node
  * @node: pointer to a local endpoint device_node
  *
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index befef42..e859eb7 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -31,6 +31,8 @@ int of_graph_parse_endpoint(const struct device_node *node,
 				struct of_endpoint *endpoint);
 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 					struct device_node *previous);
+struct device_node *of_graph_get_endpoint_by_regs(
+		const struct device_node *parent, int port_reg, int reg);
 struct device_node *of_graph_get_remote_port_parent(
 					const struct device_node *node);
 struct device_node *of_graph_get_remote_port(const struct device_node *node);
@@ -49,6 +51,12 @@ static inline struct device_node *of_graph_get_next_endpoint(
 	return NULL;
 }

+struct device_node *of_graph_get_endpoint_by_regs(
+		const struct device_node *parent, int port_reg, int reg)
+{
+	return NULL;
+}
+
 static inline struct device_node *of_graph_get_remote_port_parent(
 					const struct device_node *node)
 {
--
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-04-07 11:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 11:57 [PATCH v4 0/8] Add drivers for Exynos5433 display Hyungwon Hwang
2015-04-07 11:57 ` [PATCH v4 1/8] drm/exynos: add Exynos5433 decon driver Hyungwon Hwang
2015-04-07 11:57 ` Hyungwon Hwang [this message]
     [not found] ` <1428407858-25523-1-git-send-email-human.hwang-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-04-07 11:57   ` [PATCH v4 3/8] drm/exynos: mic: add MIC driver Hyungwon Hwang
2015-04-07 11:57   ` [PATCH v4 4/8] drm/exynos: dsi: rename pll_clk to sclk_clk Hyungwon Hwang
2015-04-07 13:03     ` Inki Dae
2015-04-07 11:57 ` [PATCH v4 5/8] drm/exynos: dsi: generalize register setting and clock control Hyungwon Hwang
2015-04-07 13:08   ` Inki Dae
2015-04-07 11:57 ` [PATCH v4 6/8] drm/exynos: dsi: add support for Exynos5433 Hyungwon Hwang
2015-04-07 13:11   ` Inki Dae
2015-04-07 11:57 ` [PATCH v4 7/8] drm/exynos: dsi: add support for MIC driver as a bridge Hyungwon Hwang
2015-04-07 11:57 ` [PATCH v4 8/8] drm/exynos: dsi: do not set TE GPIO direction by input Hyungwon Hwang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428407858-25523-3-git-send-email-human.hwang@samsung.com \
    --to=human.hwang@samsung.com \
    --cc=cw00.choi@samsung.com \
    --cc=daniel@fooishbar.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dh09.lee@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=sw0312.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.