From: Andrzej Hajda <a.hajda@samsung.com>
To: linux-kernel@vger.kernel.org (open list)
Cc: Andrzej Hajda <a.hajda@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mike Turquette <mturquette@linaro.org>,
Russell King <linux@arm.linux.org.uk>,
Linus Walleij <linus.walleij@linaro.org>,
Alexandre Courbot <gnurou@gmail.com>,
Thierry Reding <thierry.reding@gmail.com>,
Inki Dae <inki.dae@samsung.com>,
Kishon Vijay Abraham I <kishon@ti.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Grant Likely <grant.likely@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
linux-arm-kernel@lists.infradead.org (moderated list:ARM/CLKDEV
SUPPORT), linux-gpio@vger.kernel.org (open list:GPIO SUBSYSTEM),
dri-devel@lists.freedesktop.org (open list:DRM PANEL DRIVERS),
linux-samsung-soc@vger.kernel.org (moderated list:ARM/S5P EXYNOS
AR...),
devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND...),
boris.brezillon@free-electrons.com
Subject: [RFC 12/15] drm/exynos/dpi: use common of_graph functions
Date: Wed, 10 Dec 2014 16:48:30 +0100 [thread overview]
Message-ID: <1418226513-14105-13-git-send-email-a.hajda@samsung.com> (raw)
In-Reply-To: <1418226513-14105-1-git-send-email-a.hajda@samsung.com>
The patch removes private of_graph functions and uses common ones.
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
drivers/gpu/drm/exynos/exynos_drm_dpi.c | 117 +++++++-------------------------
1 file changed, 24 insertions(+), 93 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dpi.c b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
index 37678cf..91a29e1 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dpi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
@@ -14,6 +14,7 @@
#include <drm/drm_crtc_helper.h>
#include <drm/drm_panel.h>
+#include <linux/of_graph.h>
#include <linux/regulator/consumer.h>
#include <video/of_videomode.h>
@@ -21,6 +22,15 @@
#include "exynos_drm_drv.h"
+/* possible of_graph port nodes used by device */
+enum {
+ FIMD_PORT_IN0,
+ FIMD_PORT_IN1,
+ FIMD_PORT_IN2,
+ FIMD_PORT_RGB,
+ FIMD_PORT_WRB,
+};
+
struct exynos_dpi {
struct exynos_drm_display display;
struct device *dev;
@@ -171,102 +181,12 @@ static struct exynos_drm_display_ops exynos_dpi_display_ops = {
.dpms = exynos_dpi_dpms
};
-/* of_* functions will be removed after merge of of_graph patches */
-static struct device_node *
-of_get_child_by_name_reg(struct device_node *parent, const char *name, u32 reg)
-{
- struct device_node *np;
-
- for_each_child_of_node(parent, np) {
- u32 r;
-
- if (!np->name || of_node_cmp(np->name, name))
- continue;
-
- if (of_property_read_u32(np, "reg", &r) < 0)
- r = 0;
-
- if (reg == r)
- break;
- }
-
- return np;
-}
-
-static struct device_node *of_graph_get_port_by_reg(struct device_node *parent,
- u32 reg)
-{
- struct device_node *ports, *port;
-
- ports = of_get_child_by_name(parent, "ports");
- if (ports)
- parent = ports;
-
- port = of_get_child_by_name_reg(parent, "port", reg);
-
- of_node_put(ports);
-
- return port;
-}
-
-static struct device_node *
-of_graph_get_endpoint_by_reg(struct device_node *port, u32 reg)
-{
- return of_get_child_by_name_reg(port, "endpoint", reg);
-}
-
-static struct device_node *
-of_graph_get_remote_port_parent(const struct device_node *node)
-{
- struct device_node *np;
- unsigned int depth;
-
- np = of_parse_phandle(node, "remote-endpoint", 0);
-
- /* Walk 3 levels up only if there is 'ports' node. */
- for (depth = 3; depth && np; depth--) {
- np = of_get_next_parent(np);
- if (depth == 2 && of_node_cmp(np->name, "ports"))
- break;
- }
- return np;
-}
-
-enum {
- FIMD_PORT_IN0,
- FIMD_PORT_IN1,
- FIMD_PORT_IN2,
- FIMD_PORT_RGB,
- FIMD_PORT_WRB,
-};
-
-static struct device_node *exynos_dpi_of_find_panel_node(struct device *dev)
-{
- struct device_node *np, *ep;
-
- np = of_graph_get_port_by_reg(dev->of_node, FIMD_PORT_RGB);
- if (!np)
- return NULL;
-
- ep = of_graph_get_endpoint_by_reg(np, 0);
- of_node_put(np);
- if (!ep)
- return NULL;
-
- np = of_graph_get_remote_port_parent(ep);
- of_node_put(ep);
-
- return np;
-}
-
static int exynos_dpi_parse_dt(struct exynos_dpi *ctx)
{
struct device *dev = ctx->dev;
struct device_node *dn = dev->of_node;
struct device_node *np;
- ctx->panel_node = exynos_dpi_of_find_panel_node(dev);
-
np = of_get_child_by_name(dn, "display-timings");
if (np) {
struct videomode *vm;
@@ -289,10 +209,21 @@ static int exynos_dpi_parse_dt(struct exynos_dpi *ctx)
return 0;
}
- if (!ctx->panel_node)
- return -EINVAL;
+ np = NULL;
+ while ((np = of_graph_get_next_endpoint(dev->of_node, np))) {
+ struct of_endpoint ep;
- return 0;
+ of_graph_parse_endpoint(np, &ep);
+ if (ep.port != FIMD_PORT_RGB)
+ continue;
+
+ ctx->panel_node = of_graph_get_remote_port_parent(np);
+ of_node_put(np);
+
+ return ctx->panel_node ? 0 : -EINVAL;
+ }
+
+ return -EINVAL;
}
struct exynos_drm_display *exynos_dpi_probe(struct device *dev)
--
1.9.1
next prev parent reply other threads:[~2014-12-10 15:49 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-10 15:48 [RFC 00/15] Resource tracking/allocation framework Andrzej Hajda
2014-12-10 15:48 ` [RFC 01/15] drivers/base: add track framework Andrzej Hajda
2014-12-12 16:36 ` Mark Brown
2014-12-12 23:12 ` AH
2014-12-15 12:55 ` Mark Brown
2014-12-15 14:00 ` Andrzej Hajda
2014-12-10 15:48 ` [RFC 02/15] drivers/base: add restrack framework Andrzej Hajda
2014-12-12 16:52 ` Mark Brown
2014-12-15 8:28 ` Andrzej Hajda
2014-12-15 11:38 ` Mark Brown
2014-12-10 15:48 ` [RFC 03/15] drm/panel: add restrack support Andrzej Hajda
2014-12-10 15:48 ` [RFC 04/15] regulator: " Andrzej Hajda
2014-12-10 16:07 ` Mark Brown
2014-12-11 10:49 ` Andrzej Hajda
2014-12-11 12:58 ` Mark Brown
2014-12-11 13:43 ` Russell King - ARM Linux
2014-12-12 8:22 ` Andrzej Hajda
2014-12-10 15:48 ` [RFC 05/15] gpio: move DT parsing code to separate functions Andrzej Hajda
2015-01-13 6:17 ` Linus Walleij
2014-12-10 15:48 ` [RFC 06/15] gpio: add restrack support Andrzej Hajda
2014-12-10 15:48 ` [RFC 07/15] clk: add DT parsing function Andrzej Hajda
2015-01-13 19:24 ` Mike Turquette
2014-12-10 15:48 ` [RFC 08/15] clk: add restrack support Andrzej Hajda
2015-01-13 19:25 ` Mike Turquette
2014-12-10 15:48 ` [RFC 09/15] phy: " Andrzej Hajda
2014-12-10 15:48 ` [RFC 10/15] drm/exynos/dsi: simplify hotplug code Andrzej Hajda
2014-12-10 15:48 ` [RFC 11/15] drm/exynos/dsi: convert to restrack API Andrzej Hajda
2014-12-10 15:48 ` Andrzej Hajda [this message]
2014-12-10 15:48 ` [RFC 13/15] drm/exynos/dpi: " Andrzej Hajda
2014-12-10 15:48 ` [RFC 14/15] drm/panel/ld9040: do not power off panel on removal Andrzej Hajda
2014-12-10 15:48 ` [RFC 15/15] drm/panel/ld9040: convert to restrack API Andrzej Hajda
2014-12-10 16:16 ` [RFC 00/15] Resource tracking/allocation framework Russell King - ARM Linux
[not found] ` <CA+tnuKYSDZ0mtzQ_g1QjovJwG01OgPjSXuozEBXQsEZv_2o-=w@mail.gmail.com>
2014-12-10 17:39 ` Russell King - ARM Linux
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=1418226513-14105-13-git-send-email-a.hajda@samsung.com \
--to=a.hajda@samsung.com \
--cc=boris.brezillon@free-electrons.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gnurou@gmail.com \
--cc=grant.likely@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=inki.dae@samsung.com \
--cc=kishon@ti.com \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=m.szyprowski@samsung.com \
--cc=mturquette@linaro.org \
--cc=robh+dt@kernel.org \
--cc=thierry.reding@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®