From: Maxime Ripard <maxime@cerno.tech>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Chen-Yu Tsai <wens@csie.org>, Maxime Ripard <maxime@cerno.tech>,
Jernej Skrabec <jernej.skrabec@siol.net>,
Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>,
Daniel Vetter <daniel.vetter@intel.com>,
David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 4/7] drm/sun4i: tcon: Refactor the LVDS and panel probing
Date: Fri, 19 Feb 2021 14:59:31 +0100 [thread overview]
Message-ID: <20210219135934.618684-5-maxime@cerno.tech> (raw)
In-Reply-To: <20210219135934.618684-1-maxime@cerno.tech>
The current code to parse the DT, deal with the older device trees, and
register either the RGB or LVDS output has so far grown organically into
the bind function and has become quite hard to extend properly.
Let's move it into a single function that grabs all the resources it needs
and registers the proper panel output.
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
drivers/gpu/drm/sun4i/sun4i_tcon.c | 127 +++++++++++++----------------
1 file changed, 58 insertions(+), 69 deletions(-)
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index 1e643bc7e786..32757175f86b 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -885,6 +885,63 @@ static int sun4i_tcon_init_regmap(struct device *dev,
return 0;
}
+static int sun4i_tcon_register_panel(struct drm_device *drm,
+ struct sun4i_tcon *tcon)
+{
+ struct device_node *companion;
+ struct device_node *remote;
+ struct device *dev = tcon->dev;
+ int ret;
+
+ /*
+ * If we have an LVDS panel connected to the TCON, we should
+ * just probe the LVDS connector. Otherwise, let's just register
+ * an RGB panel.
+ */
+ remote = of_graph_get_remote_node(dev->of_node, 1, 0);
+ if (!tcon->quirks->supports_lvds ||
+ !of_device_is_compatible(remote, "panel-lvds"))
+ return sun4i_rgb_init(drm, tcon);
+
+ /*
+ * This can only be made optional since we've had DT
+ * nodes without the LVDS reset properties.
+ *
+ * If the property is missing, just disable LVDS, and
+ * print a warning.
+ */
+ tcon->lvds_rst = devm_reset_control_get_optional(dev, "lvds");
+ if (IS_ERR(tcon->lvds_rst)) {
+ dev_err(dev, "Couldn't get our reset line\n");
+ return PTR_ERR(tcon->lvds_rst);
+ } else if (!tcon->lvds_rst) {
+ dev_warn(dev, "Missing LVDS reset property, please upgrade your DT\n");
+ return -ENODEV;
+ }
+
+ reset_control_reset(tcon->lvds_rst);
+
+ /*
+ * This can only be made optional since we've had DT
+ * nodes without the LVDS clocks properties.
+ *
+ * If the property is missing, just disable LVDS, and
+ * print a warning.
+ */
+ if (tcon->quirks->has_lvds_alt) {
+ tcon->lvds_pll = devm_clk_get_optional(dev, "lvds-alt");
+ if (IS_ERR(tcon->lvds_pll)) {
+ dev_err(dev, "Couldn't get the LVDS PLL\n");
+ return PTR_ERR(tcon->lvds_pll);
+ } else if (!tcon->lvds_pll) {
+ dev_warn(dev, "Missing LVDS PLL clock, please upgrade your DT\n");
+ return -ENODEV;
+ }
+ }
+
+ return sun4i_lvds_init(drm, tcon);
+}
+
/*
* On SoCs with the old display pipeline design (Display Engine 1.0),
* the TCON is always tied to just one backend. Hence we can traverse
@@ -1132,10 +1189,8 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master,
struct drm_device *drm = data;
struct sun4i_drv *drv = drm->dev_private;
struct sunxi_engine *engine;
- struct device_node *remote;
struct sun4i_tcon *tcon;
struct reset_control *edp_rstc;
- bool has_lvds_rst, has_lvds_alt, can_lvds;
int ret;
engine = sun4i_tcon_find_engine(drv, dev->of_node);
@@ -1180,58 +1235,6 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master,
return ret;
}
- if (tcon->quirks->supports_lvds) {
- /*
- * This can only be made optional since we've had DT
- * nodes without the LVDS reset properties.
- *
- * If the property is missing, just disable LVDS, and
- * print a warning.
- */
- tcon->lvds_rst = devm_reset_control_get_optional(dev, "lvds");
- if (IS_ERR(tcon->lvds_rst)) {
- dev_err(dev, "Couldn't get our reset line\n");
- return PTR_ERR(tcon->lvds_rst);
- } else if (tcon->lvds_rst) {
- has_lvds_rst = true;
- reset_control_reset(tcon->lvds_rst);
- } else {
- has_lvds_rst = false;
- }
-
- /*
- * This can only be made optional since we've had DT
- * nodes without the LVDS reset properties.
- *
- * If the property is missing, just disable LVDS, and
- * print a warning.
- */
- if (tcon->quirks->has_lvds_alt) {
- tcon->lvds_pll = devm_clk_get(dev, "lvds-alt");
- if (IS_ERR(tcon->lvds_pll)) {
- if (PTR_ERR(tcon->lvds_pll) == -ENOENT) {
- has_lvds_alt = false;
- } else {
- dev_err(dev, "Couldn't get the LVDS PLL\n");
- return PTR_ERR(tcon->lvds_pll);
- }
- } else {
- has_lvds_alt = true;
- }
- }
-
- if (!has_lvds_rst ||
- (tcon->quirks->has_lvds_alt && !has_lvds_alt)) {
- dev_warn(dev, "Missing LVDS properties, Please upgrade your DT\n");
- dev_warn(dev, "LVDS output disabled\n");
- can_lvds = false;
- } else {
- can_lvds = true;
- }
- } else {
- can_lvds = false;
- }
-
ret = sun4i_tcon_init_clocks(dev, tcon);
if (ret) {
dev_err(dev, "Couldn't init our TCON clocks\n");
@@ -1266,21 +1269,7 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master,
}
if (tcon->quirks->has_channel_0) {
- /*
- * If we have an LVDS panel connected to the TCON, we should
- * just probe the LVDS connector. Otherwise, just probe RGB as
- * we used to.
- */
- remote = of_graph_get_remote_node(dev->of_node, 1, 0);
- if (of_device_is_compatible(remote, "panel-lvds"))
- if (can_lvds)
- ret = sun4i_lvds_init(drm, tcon);
- else
- ret = -EINVAL;
- else
- ret = sun4i_rgb_init(drm, tcon);
- of_node_put(remote);
-
+ ret = sun4i_tcon_register_panel(drm, tcon);
if (ret < 0)
goto err_free_dotclock;
}
--
2.29.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-02-19 14:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-19 13:59 [PATCH v4 0/7] drm/sun4i: Add support for dual-link LVDS on the A20 Maxime Ripard
2021-02-19 13:59 ` [PATCH v4 1/7] of: Make of_graph_get_port_by_id take a const device_node Maxime Ripard
2021-02-19 13:59 ` [PATCH v4 2/7] drm/of: Change the prototype of drm_of_lvds_get_dual_link_pixel_order Maxime Ripard
2021-02-19 13:59 ` [PATCH v4 3/7] dt-bindings: display: sun4i: Add LVDS Dual-Link property Maxime Ripard
2021-02-19 13:59 ` Maxime Ripard [this message]
2021-02-19 13:59 ` [PATCH v4 5/7] drm/sun4i: tcon: Support the LVDS Dual-Link Maxime Ripard
2021-02-19 13:59 ` [PATCH v4 6/7] drm/sun4i: tcon: Enable the A20 dual-link output Maxime Ripard
2021-02-19 13:59 ` [PATCH v4 7/7] [DO NOT MERGE] ARM: dts: sun7i: Enable LVDS Dual-Link on the Cubieboard Maxime Ripard
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=20210219135934.618684-5-maxime@cerno.tech \
--to=maxime@cerno.tech \
--cc=airlied@linux.ie \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=frowand.list@gmail.com \
--cc=jernej.skrabec@siol.net \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=robh+dt@kernel.org \
--cc=wens@csie.org \
/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