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 5/7] drm/sun4i: tcon: Support the LVDS Dual-Link Date: Fri, 19 Feb 2021 14:59:32 +0100 [thread overview] Message-ID: <20210219135934.618684-6-maxime@cerno.tech> (raw) In-Reply-To: <20210219135934.618684-1-maxime@cerno.tech> The A20 and other SoC with two TCONs (A31, R40, etc.) 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. Reviewed-by: Chen-Yu Tsai <wens@csie.org> 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 32757175f86b..005c37831eb6 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -475,6 +475,10 @@ static void sun4i_tcon0_mode_set_lvds(struct sun4i_tcon *tcon, SUN4I_TCON0_BASIC2_V_BACKPORCH(bp)); reg = SUN4I_TCON0_LVDS_IF_CLK_SEL_TCON0; + + 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 @@ -903,6 +907,16 @@ static int sun4i_tcon_register_panel(struct drm_device *drm, !of_device_is_compatible(remote, "panel-lvds")) 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_dbg(dev, "TCON used as an LVDS secondary link."); + return 0; + } + /* * This can only be made optional since we've had DT * nodes without the LVDS reset properties. @@ -939,6 +953,28 @@ static int sun4i_tcon_register_panel(struct drm_device *drm, } } + /* + * 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, "link-companion", 0); + if (!companion) + return sun4i_lvds_init(drm, tcon); + + /* + * 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); } diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h index ee555318e3c2..f6a589828f94 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) @@ -280,6 +281,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 */ -- 2.29.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
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 5/7] drm/sun4i: tcon: Support the LVDS Dual-Link Date: Fri, 19 Feb 2021 14:59:32 +0100 [thread overview] Message-ID: <20210219135934.618684-6-maxime@cerno.tech> (raw) In-Reply-To: <20210219135934.618684-1-maxime@cerno.tech> The A20 and other SoC with two TCONs (A31, R40, etc.) 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. Reviewed-by: Chen-Yu Tsai <wens@csie.org> 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 32757175f86b..005c37831eb6 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -475,6 +475,10 @@ static void sun4i_tcon0_mode_set_lvds(struct sun4i_tcon *tcon, SUN4I_TCON0_BASIC2_V_BACKPORCH(bp)); reg = SUN4I_TCON0_LVDS_IF_CLK_SEL_TCON0; + + 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 @@ -903,6 +907,16 @@ static int sun4i_tcon_register_panel(struct drm_device *drm, !of_device_is_compatible(remote, "panel-lvds")) 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_dbg(dev, "TCON used as an LVDS secondary link."); + return 0; + } + /* * This can only be made optional since we've had DT * nodes without the LVDS reset properties. @@ -939,6 +953,28 @@ static int sun4i_tcon_register_panel(struct drm_device *drm, } } + /* + * 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, "link-companion", 0); + if (!companion) + return sun4i_lvds_init(drm, tcon); + + /* + * 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); } diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h index ee555318e3c2..f6a589828f94 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) @@ -280,6 +281,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 */ -- 2.29.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2021-02-19 14:02 UTC|newest] Thread overview: 16+ 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 ` 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 ` 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 ` 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 2021-02-19 13:59 ` [PATCH v4 4/7] drm/sun4i: tcon: Refactor the LVDS and panel probing Maxime Ripard 2021-02-19 13:59 ` 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 ` 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 2021-02-19 13:59 ` 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-6-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: linkBe 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.