Hi,
This is a second attempt at supporting the LVDS dual-link output on the Allwinner A20.
Let me know what you think, Maxime
Changes from v1: - Reworked the DT bindings - Refactored a bit the panel registration in the tcon code.
Maxime Ripard (4): drm/of: Change the prototype of drm_of_lvds_get_dual_link_pixel_order drm/sun4i: tcon: Refactor the LVDS and panel probing drm/sun4i: tcon: Support the LVDS Dual-Link on the A20 [DO NOT MERGE] ARM: dts: sun7i: Enable LVDS Dual-Link on the Cubieboard
arch/arm/boot/dts/sun7i-a20-cubieboard2.dts | 69 ++++++++- drivers/gpu/drm/drm_of.c | 98 ++++++------ drivers/gpu/drm/rcar-du/rcar_lvds.c | 8 +- drivers/gpu/drm/sun4i/sun4i_tcon.c | 175 ++++++++++++--------- drivers/gpu/drm/sun4i/sun4i_tcon.h | 4 +- include/drm/drm_of.h | 16 +- 6 files changed, 242 insertions(+), 128 deletions(-)
base-commit: d113dbba9a18f9ac71edb1a66ae552c9407355f4
The drm_of_lvds_get_dual_link_pixel_order() function took so far the device_node of the two ports used together to make up a dual-link LVDS output.
This assumes that a binding would use an entire port for the LVDS output. However, some bindings have used endpoints instead and thus we need to operate at the endpoint level. Change slightly the arguments to allow that.
Signed-off-by: Maxime Ripard maxime@cerno.tech --- drivers/gpu/drm/drm_of.c | 98 +++++++++++++++--------------- drivers/gpu/drm/rcar-du/rcar_lvds.c | 8 +-- include/drm/drm_of.h | 16 +++-- 3 files changed, 63 insertions(+), 59 deletions(-)
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index b50b44e76279..2dcb49b0401b 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -291,50 +291,34 @@ static int drm_of_lvds_get_port_pixels_type(struct device_node *port_node) (odd_pixels ? DRM_OF_LVDS_ODD : 0); }
-static int drm_of_lvds_get_remote_pixels_type( - const struct device_node *port_node) +static int drm_of_lvds_get_remote_pixels_type(const struct device_node *endpoint) { - struct device_node *endpoint = NULL; - int pixels_type = -EPIPE; + struct device_node *remote_port; + int pixels_type;
- for_each_child_of_node(port_node, endpoint) { - struct device_node *remote_port; - int current_pt; - - if (!of_node_name_eq(endpoint, "endpoint")) - continue; - - remote_port = of_graph_get_remote_port(endpoint); - if (!remote_port) { - of_node_put(remote_port); - return -EPIPE; - } - - current_pt = drm_of_lvds_get_port_pixels_type(remote_port); + remote_port = of_graph_get_remote_port(endpoint); + if (!remote_port) { of_node_put(remote_port); - if (pixels_type < 0) - pixels_type = current_pt; - - /* - * Sanity check, ensure that all remote endpoints have the same - * pixel type. We may lift this restriction later if we need to - * support multiple sinks with different dual-link - * configurations by passing the endpoints explicitly to - * drm_of_lvds_get_dual_link_pixel_order(). - */ - if (!current_pt || pixels_type != current_pt) { - of_node_put(remote_port); - return -EINVAL; - } + return -EPIPE; }
+ pixels_type = drm_of_lvds_get_port_pixels_type(remote_port); + of_node_put(remote_port); + + if (pixels_type < 0) + pixels_type = -EPIPE; + return pixels_type; }
/** * drm_of_lvds_get_dual_link_pixel_order - Get LVDS dual-link pixel order - * @port1: First DT port node of the Dual-link LVDS source - * @port2: Second DT port node of the Dual-link LVDS source + * @dev1: First DT device node of the Dual-Link LVDS source + * @port1_id: ID of the first DT port node of the Dual-Link LVDS source + * @endpoint1_id: ID of the first DT port node of the Dual-Link LVDS source + * @dev2: First DT device node of the Dual-Link LVDS source + * @port2_id: ID of the first DT port node of the Dual-Link LVDS source + * @endpoint2_id: ID of the first DT port node of the Dual-Link LVDS source * * An LVDS dual-link connection is made of two links, with even pixels * transitting on one link, and odd pixels on the other link. This function @@ -348,32 +332,48 @@ static int drm_of_lvds_get_remote_pixels_type( * * If either port is not connected, this function returns -EPIPE. * - * @port1 and @port2 are typically DT sibling nodes, but may have different - * parents when, for instance, two separate LVDS encoders carry the even and odd - * pixels. + * @port1_id and @port2_id are typically DT sibling nodes, but may have + * different parents when, for instance, two separate LVDS encoders carry the + * even and odd pixels. + * + * If @port1_id, @port2_id, @endpoint1_id or @endpoint2_id are set to -1, their + * value is going to be ignored. * * Return: - * * DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS - @port1 carries even pixels and @port2 - * carries odd pixels - * * DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS - @port1 carries odd pixels and @port2 - * carries even pixels - * * -EINVAL - @port1 and @port2 are not connected to a dual-link LVDS sink, or - * the sink configuration is invalid - * * -EPIPE - when @port1 or @port2 are not connected + * * DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS - @endpoint1_id carries even pixels and + * @endpoint2_id carries odd pixels + * * DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS - @endpoint1_id carries odd pixels and + * @endpoint2_id carries even pixels + * * -EINVAL - @endpoint1_id and @endpoint2_id are not connected to a dual-link + * LVDS sink, or the sink configuration is invalid + * * -EPIPE - when @endpoint1_id or @endpoint2_id are not connected */ -int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1, - const struct device_node *port2) +int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *dev1, + int port1_id, + int endpoint1_id, + const struct device_node *dev2, + int port2_id, + int endpoint2_id) { + struct device_node *endpoint1, *endpoint2; int remote_p1_pt, remote_p2_pt;
- if (!port1 || !port2) + if (!dev1 || !dev2) + return -EINVAL; + + endpoint1 = of_graph_get_endpoint_by_regs(dev1, port1_id, endpoint1_id); + if (!endpoint1) + return -EINVAL; + + endpoint2 = of_graph_get_endpoint_by_regs(dev2, port2_id, endpoint2_id); + if (!endpoint2) return -EINVAL;
- remote_p1_pt = drm_of_lvds_get_remote_pixels_type(port1); + remote_p1_pt = drm_of_lvds_get_remote_pixels_type(endpoint1); if (remote_p1_pt < 0) return remote_p1_pt;
- remote_p2_pt = drm_of_lvds_get_remote_pixels_type(port2); + remote_p2_pt = drm_of_lvds_get_remote_pixels_type(endpoint2); if (remote_p2_pt < 0) return remote_p2_pt;
diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c index ab0d49618cf9..02d8c4ce820e 100644 --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c @@ -715,7 +715,6 @@ static int rcar_lvds_parse_dt_companion(struct rcar_lvds *lvds) { const struct of_device_id *match; struct device_node *companion; - struct device_node *port0, *port1; struct rcar_lvds *companion_lvds; struct device *dev = lvds->dev; int dual_link; @@ -743,11 +742,8 @@ static int rcar_lvds_parse_dt_companion(struct rcar_lvds *lvds) * connected to, if they are marked as expecting even pixels and * odd pixels than we need to enable vertical stripe output. */ - port0 = of_graph_get_port_by_id(dev->of_node, 1); - port1 = of_graph_get_port_by_id(companion, 1); - dual_link = drm_of_lvds_get_dual_link_pixel_order(port0, port1); - of_node_put(port0); - of_node_put(port1); + dual_link = drm_of_lvds_get_dual_link_pixel_order(dev->of_node, 1, -1, + companion, 1, -1);
switch (dual_link) { case DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS: diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h index b9b093add92e..7bb1f6603beb 100644 --- a/include/drm/drm_of.h +++ b/include/drm/drm_of.h @@ -47,8 +47,12 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, int port, int endpoint, struct drm_panel **panel, struct drm_bridge **bridge); -int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1, - const struct device_node *port2); +int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *dev1, + int port1_id, + int endpoint1_id, + const struct device_node *dev2, + int port2_id, + int endpoint2_id); #else static inline uint32_t drm_of_crtc_port_mask(struct drm_device *dev, struct device_node *port) @@ -93,8 +97,12 @@ static inline int drm_of_find_panel_or_bridge(const struct device_node *np, }
static inline int -drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1, - const struct device_node *port2) +drm_of_lvds_get_dual_link_pixel_order(const struct device_node *dev1, + int port1_id, + int endpoint1_id, + const struct device_node *dev2, + int port2_id, + int endpoint2_id) { return -EINVAL; }
Hi Maxime,
Thank you for the patch.
On Thu, Jul 30, 2020 at 11:35:01AM +0200, Maxime Ripard wrote:
The drm_of_lvds_get_dual_link_pixel_order() function took so far the device_node of the two ports used together to make up a dual-link LVDS output.
This assumes that a binding would use an entire port for the LVDS output. However, some bindings have used endpoints instead and thus we need to operate at the endpoint level. Change slightly the arguments to allow that.
Is this still needed ? Unless I'm mistaken, the Allwinner platform now uses two TCON instances for the two links, so there are two ports.
Signed-off-by: Maxime Ripard maxime@cerno.tech
drivers/gpu/drm/drm_of.c | 98 +++++++++++++++--------------- drivers/gpu/drm/rcar-du/rcar_lvds.c | 8 +-- include/drm/drm_of.h | 16 +++-- 3 files changed, 63 insertions(+), 59 deletions(-)
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index b50b44e76279..2dcb49b0401b 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -291,50 +291,34 @@ static int drm_of_lvds_get_port_pixels_type(struct device_node *port_node) (odd_pixels ? DRM_OF_LVDS_ODD : 0); }
-static int drm_of_lvds_get_remote_pixels_type(
const struct device_node *port_node)
+static int drm_of_lvds_get_remote_pixels_type(const struct device_node *endpoint) {
- struct device_node *endpoint = NULL;
- int pixels_type = -EPIPE;
- struct device_node *remote_port;
- int pixels_type;
- for_each_child_of_node(port_node, endpoint) {
struct device_node *remote_port;
int current_pt;
if (!of_node_name_eq(endpoint, "endpoint"))
continue;
remote_port = of_graph_get_remote_port(endpoint);
if (!remote_port) {
of_node_put(remote_port);
return -EPIPE;
}
current_pt = drm_of_lvds_get_port_pixels_type(remote_port);
- remote_port = of_graph_get_remote_port(endpoint);
- if (!remote_port) { of_node_put(remote_port);
if (pixels_type < 0)
pixels_type = current_pt;
/*
* Sanity check, ensure that all remote endpoints have the same
* pixel type. We may lift this restriction later if we need to
* support multiple sinks with different dual-link
* configurations by passing the endpoints explicitly to
* drm_of_lvds_get_dual_link_pixel_order().
*/
if (!current_pt || pixels_type != current_pt) {
of_node_put(remote_port);
return -EINVAL;
}
return -EPIPE;
}
pixels_type = drm_of_lvds_get_port_pixels_type(remote_port);
of_node_put(remote_port);
if (pixels_type < 0)
pixels_type = -EPIPE;
return pixels_type;
}
/**
- drm_of_lvds_get_dual_link_pixel_order - Get LVDS dual-link pixel order
- @port1: First DT port node of the Dual-link LVDS source
- @port2: Second DT port node of the Dual-link LVDS source
- @dev1: First DT device node of the Dual-Link LVDS source
- @port1_id: ID of the first DT port node of the Dual-Link LVDS source
- @endpoint1_id: ID of the first DT port node of the Dual-Link LVDS source
- @dev2: First DT device node of the Dual-Link LVDS source
- @port2_id: ID of the first DT port node of the Dual-Link LVDS source
- @endpoint2_id: ID of the first DT port node of the Dual-Link LVDS source
- An LVDS dual-link connection is made of two links, with even pixels
- transitting on one link, and odd pixels on the other link. This function
@@ -348,32 +332,48 @@ static int drm_of_lvds_get_remote_pixels_type(
- If either port is not connected, this function returns -EPIPE.
- @port1 and @port2 are typically DT sibling nodes, but may have different
- parents when, for instance, two separate LVDS encoders carry the even and odd
- pixels.
- @port1_id and @port2_id are typically DT sibling nodes, but may have
- different parents when, for instance, two separate LVDS encoders carry the
- even and odd pixels.
- If @port1_id, @port2_id, @endpoint1_id or @endpoint2_id are set to -1, their
- value is going to be ignored.
- Return:
- DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS - @port1 carries even pixels and @port2
- carries odd pixels
- DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS - @port1 carries odd pixels and @port2
- carries even pixels
- -EINVAL - @port1 and @port2 are not connected to a dual-link LVDS sink, or
- the sink configuration is invalid
- -EPIPE - when @port1 or @port2 are not connected
- DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS - @endpoint1_id carries even pixels and
- @endpoint2_id carries odd pixels
- DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS - @endpoint1_id carries odd pixels and
- @endpoint2_id carries even pixels
- -EINVAL - @endpoint1_id and @endpoint2_id are not connected to a dual-link
- LVDS sink, or the sink configuration is invalid
*/
- -EPIPE - when @endpoint1_id or @endpoint2_id are not connected
-int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
const struct device_node *port2)
+int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *dev1,
int port1_id,
int endpoint1_id,
const struct device_node *dev2,
int port2_id,
int endpoint2_id)
{
- struct device_node *endpoint1, *endpoint2; int remote_p1_pt, remote_p2_pt;
- if (!port1 || !port2)
- if (!dev1 || !dev2)
return -EINVAL;
- endpoint1 = of_graph_get_endpoint_by_regs(dev1, port1_id, endpoint1_id);
- if (!endpoint1)
return -EINVAL;
- endpoint2 = of_graph_get_endpoint_by_regs(dev2, port2_id, endpoint2_id);
- if (!endpoint2) return -EINVAL;
- remote_p1_pt = drm_of_lvds_get_remote_pixels_type(port1);
- remote_p1_pt = drm_of_lvds_get_remote_pixels_type(endpoint1); if (remote_p1_pt < 0) return remote_p1_pt;
- remote_p2_pt = drm_of_lvds_get_remote_pixels_type(port2);
- remote_p2_pt = drm_of_lvds_get_remote_pixels_type(endpoint2); if (remote_p2_pt < 0) return remote_p2_pt;
diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c index ab0d49618cf9..02d8c4ce820e 100644 --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c @@ -715,7 +715,6 @@ static int rcar_lvds_parse_dt_companion(struct rcar_lvds *lvds) { const struct of_device_id *match; struct device_node *companion;
- struct device_node *port0, *port1; struct rcar_lvds *companion_lvds; struct device *dev = lvds->dev; int dual_link;
@@ -743,11 +742,8 @@ static int rcar_lvds_parse_dt_companion(struct rcar_lvds *lvds) * connected to, if they are marked as expecting even pixels and * odd pixels than we need to enable vertical stripe output. */
- port0 = of_graph_get_port_by_id(dev->of_node, 1);
- port1 = of_graph_get_port_by_id(companion, 1);
- dual_link = drm_of_lvds_get_dual_link_pixel_order(port0, port1);
- of_node_put(port0);
- of_node_put(port1);
dual_link = drm_of_lvds_get_dual_link_pixel_order(dev->of_node, 1, -1,
companion, 1, -1);
switch (dual_link) { case DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS:
diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h index b9b093add92e..7bb1f6603beb 100644 --- a/include/drm/drm_of.h +++ b/include/drm/drm_of.h @@ -47,8 +47,12 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, int port, int endpoint, struct drm_panel **panel, struct drm_bridge **bridge); -int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
const struct device_node *port2);
+int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *dev1,
int port1_id,
int endpoint1_id,
const struct device_node *dev2,
int port2_id,
int endpoint2_id);
#else static inline uint32_t drm_of_crtc_port_mask(struct drm_device *dev, struct device_node *port) @@ -93,8 +97,12 @@ static inline int drm_of_find_panel_or_bridge(const struct device_node *np, }
static inline int -drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
const struct device_node *port2)
+drm_of_lvds_get_dual_link_pixel_order(const struct device_node *dev1,
int port1_id,
int endpoint1_id,
const struct device_node *dev2,
int port2_id,
int endpoint2_id)
{ return -EINVAL; }
Hi Laurent,
On Mon, Aug 31, 2020 at 11:28:52PM +0300, Laurent Pinchart wrote:
Hi Maxime,
Thank you for the patch.
On Thu, Jul 30, 2020 at 11:35:01AM +0200, Maxime Ripard wrote:
The drm_of_lvds_get_dual_link_pixel_order() function took so far the device_node of the two ports used together to make up a dual-link LVDS output.
This assumes that a binding would use an entire port for the LVDS output. However, some bindings have used endpoints instead and thus we need to operate at the endpoint level. Change slightly the arguments to allow that.
Is this still needed ? Unless I'm mistaken, the Allwinner platform now uses two TCON instances for the two links, so there are two ports.
Yes, and no.
The two TCONs indeed have each a port of their own, so we do have two ports indeed. However, what we don't have is a port entirely dedicated to the LVDS output.
Our binding uses a single port for all its output (RGB, LVDS or TV/HDMI controllers) with different endpoints.
Maxime
Hi Maxime,
On Tue, Sep 01, 2020 at 03:23:40PM +0200, Maxime Ripard wrote:
On Mon, Aug 31, 2020 at 11:28:52PM +0300, Laurent Pinchart wrote:
On Thu, Jul 30, 2020 at 11:35:01AM +0200, Maxime Ripard wrote:
The drm_of_lvds_get_dual_link_pixel_order() function took so far the device_node of the two ports used together to make up a dual-link LVDS output.
This assumes that a binding would use an entire port for the LVDS output. However, some bindings have used endpoints instead and thus we need to operate at the endpoint level. Change slightly the arguments to allow that.
Is this still needed ? Unless I'm mistaken, the Allwinner platform now uses two TCON instances for the two links, so there are two ports.
Yes, and no.
The two TCONs indeed have each a port of their own, so we do have two ports indeed. However, what we don't have is a port entirely dedicated to the LVDS output.
Our binding uses a single port for all its output (RGB, LVDS or TV/HDMI controllers) with different endpoints.
Good point. Then let's keep this patch :-) We can't fix existing bindings, but for the future, let's model separate display outputs as ports, not endpoints.
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.
Signed-off-by: Maxime Ripard maxime@cerno.tech --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 139 +++++++++++++++--------------- 1 file changed, 70 insertions(+), 69 deletions(-)
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 2a5a9903c4c6..d03ad75f9900 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -875,6 +875,75 @@ 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; + bool has_lvds_alt; + bool has_lvds_rst; + 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) { + 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"); + 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 @@ -1122,10 +1191,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); @@ -1170,58 +1237,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"); @@ -1256,21 +1271,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; }
On Thu, Jul 30, 2020 at 5:35 PM Maxime Ripard maxime@cerno.tech wrote:
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.
Signed-off-by: Maxime Ripard maxime@cerno.tech
Reviewed-by: Chen-Yu Tsai wens@csie.org
drivers/gpu/drm/sun4i/sun4i_tcon.c | 139 +++++++++++++++--------------- 1 file changed, 70 insertions(+), 69 deletions(-)
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 2a5a9903c4c6..d03ad75f9900 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -875,6 +875,75 @@ 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;
bool has_lvds_alt;
bool has_lvds_rst;
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);
Slightly related: IIRC there are a few LVDS panels supported in panel-simple so they don't use the panel-lvds compatible. Any idea how to deal with those?
Hi Chen-Yu,
Sorry for the delay
On Sat, Aug 29, 2020 at 02:43:53PM +0800, Chen-Yu Tsai wrote:
+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;
bool has_lvds_alt;
bool has_lvds_rst;
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);
Slightly related: IIRC there are a few LVDS panels supported in panel-simple so they don't use the panel-lvds compatible. Any idea how to deal with those?
I agree that this is an issue, I'm not entirely sure how to fix it. The proper fix would be to have multiple output ports, one for each output type, but given how our current binding looks like I'm not sure how we could retro-fit that without some horror-looking code.
Maybe we can add a property on the endpoint?
Maxime
On Mon, Oct 5, 2020 at 10:19 PM Maxime Ripard maxime@cerno.tech wrote:
Hi Chen-Yu,
Sorry for the delay
On Sat, Aug 29, 2020 at 02:43:53PM +0800, Chen-Yu Tsai wrote:
+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;
bool has_lvds_alt;
bool has_lvds_rst;
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);
Slightly related: IIRC there are a few LVDS panels supported in panel-simple so they don't use the panel-lvds compatible. Any idea how to deal with those?
I agree that this is an issue, I'm not entirely sure how to fix it. The proper fix would be to have multiple output ports, one for each output type, but given how our current binding looks like I'm not sure how we could retro-fit that without some horror-looking code.
Maybe we can add a property on the endpoint?
I guess that works. :)
Since the LCD and LVDS outputs use the same pins, it's not like we really would have multiple output ports.
ChenYu
Hi Maxime,
Thank you for the patch.
On Thu, Jul 30, 2020 at 11:35:02AM +0200, Maxime Ripard wrote:
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.
Signed-off-by: Maxime Ripard maxime@cerno.tech
drivers/gpu/drm/sun4i/sun4i_tcon.c | 139 +++++++++++++++--------------- 1 file changed, 70 insertions(+), 69 deletions(-)
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 2a5a9903c4c6..d03ad75f9900 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -875,6 +875,75 @@ 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;
- bool has_lvds_alt;
- bool has_lvds_rst;
- 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"))
This isn't very nice :-S Not a candidate for a fix in this patch, but something that should be addressed in the future. As Chen-Yu mentioned, there are LVDS panels supported by the panel-simple driver.
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) {
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.
Shouldn't this mention clock, not reset ?
*
* 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");
Would it make sense to move this to the has_lvds_rst = false and has_lvds_alt = false code sections about ? You could then print which property is missing.
Reviewed-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
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
@@ -1122,10 +1191,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);
@@ -1170,58 +1237,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");
@@ -1256,21 +1271,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);
if (ret < 0) goto err_free_dotclock; }ret = sun4i_tcon_register_panel(drm, tcon);
The A20 can use its second TCON as the secondary LVDS link in a dual-link setup, with the TCON0 being the main link. Extend a bit the parsing code to leverage the DRM dual-link code, register only the LVDS output on the primary TCON, and add the needed bits to setup the TCON properly.
Signed-off-by: Maxime Ripard maxime@cerno.tech --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 36 +++++++++++++++++++++++++++++++- drivers/gpu/drm/sun4i/sun4i_tcon.h | 4 +++- 2 files changed, 40 insertions(+)
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index d03ad75f9900..ed2abf6eb18b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -487,6 +487,9 @@ static void sun4i_tcon0_mode_set_lvds(struct sun4i_tcon *tcon, else reg |= SUN4I_TCON0_LVDS_IF_DATA_POL_NORMAL;
+ if (tcon->lvds_dual_link) + reg |= SUN4I_TCON0_LVDS_IF_DUAL_LINK; + if (sun4i_tcon_get_pixel_depth(encoder) == 24) reg |= SUN4I_TCON0_LVDS_IF_BITWIDTH_24BITS; else @@ -896,6 +899,16 @@ static int sun4i_tcon_register_panel(struct drm_device *drm, return sun4i_rgb_init(drm, tcon);
/* + * Only the TCON0 will be relevant for the LVDS output, so if + * our ID is something else, let's prevent our TCON from + * registering its own LVDS output + */ + if (tcon->id) { + dev_info(dev, "Secondary TCON, disabling panel output"); + return 0; + } + + /* * This can only be made optional since we've had DT * nodes without the LVDS reset properties. * @@ -941,6 +954,28 @@ static int sun4i_tcon_register_panel(struct drm_device *drm, return -ENODEV; }
+ /* + * If we don't have a second TCON, we will never be able to do + * dual-link LVDS, so we don't have much more to do. + */ + companion = of_parse_phandle(dev->of_node, "allwinner,lvds-companion", 0); + if (!companion) + return 0; + + /* + * Let's do a sanity check on the dual-link setup to make sure + * everything is properly described. + */ + ret = drm_of_lvds_get_dual_link_pixel_order(dev->of_node, 1, 0, + companion, 1, 0); + if (ret < 0) { + dev_err(dev, "Invalid Dual-Link Configuration.\n"); + return ret; + } + + dev_info(dev, "Primary TCON, enabling LVDS Dual-Link"); + tcon->lvds_dual_link = true; + return sun4i_lvds_init(drm, tcon); }
@@ -1500,6 +1535,7 @@ static const struct sun4i_tcon_quirks sun7i_a20_tcon0_quirks = { };
static const struct sun4i_tcon_quirks sun7i_a20_quirks = { + .supports_lvds = true, .has_channel_0 = true, .has_channel_1 = true, .dclk_min_div = 4, diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h index cfbf4e6c1679..51c4e09cdd13 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h @@ -98,6 +98,7 @@
#define SUN4I_TCON0_LVDS_IF_REG 0x84 #define SUN4I_TCON0_LVDS_IF_EN BIT(31) +#define SUN4I_TCON0_LVDS_IF_DUAL_LINK BIT(30) #define SUN4I_TCON0_LVDS_IF_BITWIDTH_MASK BIT(26) #define SUN4I_TCON0_LVDS_IF_BITWIDTH_18BITS (1 << 26) #define SUN4I_TCON0_LVDS_IF_BITWIDTH_24BITS (0 << 26) @@ -274,6 +275,9 @@ struct sun4i_tcon { /* Associated crtc */ struct sun4i_crtc *crtc;
+ /* Is the LVDS link a dual-channel link? */ + bool lvds_dual_link; + int id;
/* TCON list management */
On Thu, Jul 30, 2020 at 5:35 PM Maxime Ripard maxime@cerno.tech wrote:
The A20 can use its second TCON as the secondary LVDS link in a dual-link setup, with the TCON0 being the main link. Extend a bit the parsing code to leverage the DRM dual-link code, register only the LVDS output on the primary TCON, and add the needed bits to setup the TCON properly.
Signed-off-by: Maxime Ripard maxime@cerno.tech
drivers/gpu/drm/sun4i/sun4i_tcon.c | 36 +++++++++++++++++++++++++++++++- drivers/gpu/drm/sun4i/sun4i_tcon.h | 4 +++- 2 files changed, 40 insertions(+)
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index d03ad75f9900..ed2abf6eb18b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -487,6 +487,9 @@ static void sun4i_tcon0_mode_set_lvds(struct sun4i_tcon *tcon, else reg |= SUN4I_TCON0_LVDS_IF_DATA_POL_NORMAL;
if (tcon->lvds_dual_link)
reg |= SUN4I_TCON0_LVDS_IF_DUAL_LINK;
if (sun4i_tcon_get_pixel_depth(encoder) == 24) reg |= SUN4I_TCON0_LVDS_IF_BITWIDTH_24BITS; else
@@ -896,6 +899,16 @@ static int sun4i_tcon_register_panel(struct drm_device *drm, return sun4i_rgb_init(drm, tcon);
/*
* Only the TCON0 will be relevant for the LVDS output, so if
* our ID is something else, let's prevent our TCON from
* registering its own LVDS output
*/
if (tcon->id) {
dev_info(dev, "Secondary TCON, disabling panel output");
Nit: "disabling" is a bit misleading.
Just stating that it is used as a secondary link
return 0;
}
/* * This can only be made optional since we've had DT * nodes without the LVDS reset properties. *
@@ -941,6 +954,28 @@ static int sun4i_tcon_register_panel(struct drm_device *drm, return -ENODEV; }
/*
* If we don't have a second TCON, we will never be able to do
* dual-link LVDS, so we don't have much more to do.
*/
companion = of_parse_phandle(dev->of_node, "allwinner,lvds-companion", 0);
if (!companion)
return 0;
I assume you want
return sun4i_lvds_init(drm, tcon);
otherwise single-link LVDS would not work anymore?
ChenYu
/*
* Let's do a sanity check on the dual-link setup to make sure
* everything is properly described.
*/
ret = drm_of_lvds_get_dual_link_pixel_order(dev->of_node, 1, 0,
companion, 1, 0);
if (ret < 0) {
dev_err(dev, "Invalid Dual-Link Configuration.\n");
return ret;
}
dev_info(dev, "Primary TCON, enabling LVDS Dual-Link");
tcon->lvds_dual_link = true;
return sun4i_lvds_init(drm, tcon);
}
@@ -1500,6 +1535,7 @@ static const struct sun4i_tcon_quirks sun7i_a20_tcon0_quirks = { };
static const struct sun4i_tcon_quirks sun7i_a20_quirks = {
.supports_lvds = true, .has_channel_0 = true, .has_channel_1 = true, .dclk_min_div = 4,
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h index cfbf4e6c1679..51c4e09cdd13 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h @@ -98,6 +98,7 @@
#define SUN4I_TCON0_LVDS_IF_REG 0x84 #define SUN4I_TCON0_LVDS_IF_EN BIT(31) +#define SUN4I_TCON0_LVDS_IF_DUAL_LINK BIT(30) #define SUN4I_TCON0_LVDS_IF_BITWIDTH_MASK BIT(26) #define SUN4I_TCON0_LVDS_IF_BITWIDTH_18BITS (1 << 26) #define SUN4I_TCON0_LVDS_IF_BITWIDTH_24BITS (0 << 26) @@ -274,6 +275,9 @@ struct sun4i_tcon { /* Associated crtc */ struct sun4i_crtc *crtc;
/* Is the LVDS link a dual-channel link? */
bool lvds_dual_link;
int id; /* TCON list management */
-- git-series 0.9.1
Hi Maxime,
Thank you for the patch.
On Thu, Jul 30, 2020 at 11:35:03AM +0200, Maxime Ripard wrote:
The A20 can use its second TCON as the secondary LVDS link in a dual-link setup, with the TCON0 being the main link. Extend a bit the parsing code to leverage the DRM dual-link code, register only the LVDS output on the primary TCON, and add the needed bits to setup the TCON properly.
Signed-off-by: Maxime Ripard maxime@cerno.tech
drivers/gpu/drm/sun4i/sun4i_tcon.c | 36 +++++++++++++++++++++++++++++++- drivers/gpu/drm/sun4i/sun4i_tcon.h | 4 +++- 2 files changed, 40 insertions(+)
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index d03ad75f9900..ed2abf6eb18b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -487,6 +487,9 @@ static void sun4i_tcon0_mode_set_lvds(struct sun4i_tcon *tcon, else reg |= SUN4I_TCON0_LVDS_IF_DATA_POL_NORMAL;
- if (tcon->lvds_dual_link)
reg |= SUN4I_TCON0_LVDS_IF_DUAL_LINK;
- if (sun4i_tcon_get_pixel_depth(encoder) == 24) reg |= SUN4I_TCON0_LVDS_IF_BITWIDTH_24BITS; else
@@ -896,6 +899,16 @@ static int sun4i_tcon_register_panel(struct drm_device *drm, return sun4i_rgb_init(drm, tcon);
/*
* Only the TCON0 will be relevant for the LVDS output, so if
* our ID is something else, let's prevent our TCON from
* registering its own LVDS output
*/
- if (tcon->id) {
dev_info(dev, "Secondary TCON, disabling panel output");
This may worry the user unnecessarily. I'd make it a debug message, or drop it completely, and like reword it a bit as pointed out by Chen-Yu.
return 0;
- }
- /*
- This can only be made optional since we've had DT
- nodes without the LVDS reset properties.
@@ -941,6 +954,28 @@ static int sun4i_tcon_register_panel(struct drm_device *drm, return -ENODEV; }
- /*
* If we don't have a second TCON, we will never be able to do
* dual-link LVDS, so we don't have much more to do.
*/
- companion = of_parse_phandle(dev->of_node, "allwinner,lvds-companion", 0);
Should there be a patch to add this property to the DT bindings ?
- if (!companion)
return 0;
- /*
* Let's do a sanity check on the dual-link setup to make sure
* everything is properly described.
*/
- ret = drm_of_lvds_get_dual_link_pixel_order(dev->of_node, 1, 0,
companion, 1, 0);
- if (ret < 0) {
dev_err(dev, "Invalid Dual-Link Configuration.\n");
return ret;
- }
- dev_info(dev, "Primary TCON, enabling LVDS Dual-Link");
- tcon->lvds_dual_link = true;
- return sun4i_lvds_init(drm, tcon);
}
@@ -1500,6 +1535,7 @@ static const struct sun4i_tcon_quirks sun7i_a20_tcon0_quirks = { };
static const struct sun4i_tcon_quirks sun7i_a20_quirks = {
- .supports_lvds = true,
Should this be split to a separate patch, or at least mentioned in the commit message ?
.has_channel_0 = true, .has_channel_1 = true, .dclk_min_div = 4, diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h index cfbf4e6c1679..51c4e09cdd13 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h @@ -98,6 +98,7 @@
#define SUN4I_TCON0_LVDS_IF_REG 0x84 #define SUN4I_TCON0_LVDS_IF_EN BIT(31) +#define SUN4I_TCON0_LVDS_IF_DUAL_LINK BIT(30) #define SUN4I_TCON0_LVDS_IF_BITWIDTH_MASK BIT(26) #define SUN4I_TCON0_LVDS_IF_BITWIDTH_18BITS (1 << 26) #define SUN4I_TCON0_LVDS_IF_BITWIDTH_24BITS (0 << 26) @@ -274,6 +275,9 @@ struct sun4i_tcon { /* Associated crtc */ struct sun4i_crtc *crtc;
/* Is the LVDS link a dual-channel link? */
bool lvds_dual_link;
int id;
/* TCON list management */
For the sake of the example, let's enable an LVDS Dual-Link display on a Cubieboard.
Signed-off-by: Maxime Ripard maxime@cerno.tech --- arch/arm/boot/dts/sun7i-a20-cubieboard2.dts | 69 ++++++++++++++++++++++- 1 file changed, 69 insertions(+)
diff --git a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts index b8203e4ef21c..20278a27ec16 100644 --- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts +++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts @@ -85,6 +85,49 @@ gpios = <&pio 7 20 GPIO_ACTIVE_HIGH>; }; }; + + panel: panel { + compatible = "panel-lvds"; + width-mm = <153>; + height-mm = <90>; + data-mapping = "vesa-24"; + + panel-timing { + clock-frequency = <148500000>; + hfront-porch = <88>; + hactive = <1920>; + hback-porch = <148>; + hsync-len = <44>; + + vfront-porch = <4>; + vactive = <1080>; + vback-porch = <36>; + vsync-len = <5>; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dual-lvds-even-pixels; + + panel_input_0: endpoint { + remote-endpoint = <&tcon0_out_panel>; + }; + }; + + port@1 { + reg = <1>; + dual-lvds-odd-pixels; + + panel_input_1: endpoint { + remote-endpoint = <&tcon1_out_panel>; + }; + }; + }; + }; };
&ahci { @@ -218,6 +261,32 @@ status = "okay"; };
+&tcon0 { + pinctrl-names = "default"; + pinctrl-0 = <&lcd_lvds0_pins>; + allwinner,lvds-companion = <&tcon1>; + status = "okay"; +}; + +&tcon0_out { + tcon0_out_panel: endpoint@0 { + remote-endpoint = <&panel_input_0>; + }; +}; + +&tcon1 { + pinctrl-names = "default"; + pinctrl-0 = <&lcd_lvds1_pins>; + allwinner,lvds-companion = <&tcon0>; + status = "okay"; +}; + +&tcon1_out { + tcon1_out_panel: endpoint@0 { + remote-endpoint = <&panel_input_1>; + }; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pb_pins>;
dri-devel@lists.freedesktop.org