From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC8E4C4363A for ; Mon, 5 Oct 2020 15:16:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C5FE207BC for ; Mon, 5 Oct 2020 15:16:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726780AbgJEPPy (ORCPT ); Mon, 5 Oct 2020 11:15:54 -0400 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:43927 "EHLO new1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726754AbgJEPPx (ORCPT ); Mon, 5 Oct 2020 11:15:53 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 896F858016F; Mon, 5 Oct 2020 11:15:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 05 Oct 2020 11:15:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=M6TxlEDbt/kDk MimJa7ybEwCUY45Z+gACtOYuOtwq/s=; b=rdQD7n/fiHZTuQO5WB+A4I6dZJgZ5 jTjpc6T2nCRY78jVvi7gRVI9XYR27KgzocxxYKXg6f7A7ioptB7viw1G04fSVlLn YG4MmeNc1alBxjiyZ1loM/eKzpyxFaXKE5eRYHcX0L0bhxJ5tIkbEZhJe9JpFtQ5 RLbvJwBPW20HYlT3z4cLlSp5CP8Jdo8yPIss0XqCK4ymXmGblzHvISNrpCpe1TP7 16vl6V9091ctu9OGbel5HYtDDqDM6V0Wn0hXw33TywFc9Nex8EooSCrhtFQlYfru NtFsmbn/khvrs/hwxRE/Xcrj7CvlGmJYW9sa36Hhn5PDAX7kwZauEJweQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=M6TxlEDbt/kDkMimJa7ybEwCUY45Z+gACtOYuOtwq/s=; b=Xxau1wSS fgFYOu65IFeXBZYthNZ/H2P6jg48s453rixVv01/xUQUeMl9l8Vu7tCqGm7codmV YbzEZITthpHWfu9zZVcI+xBNSDlB3g6SFGlUY4RbCoQep5pXQ2kt0rqti8Z3jfl2 Slrj1ScsFTggv7jjcNExznvXSuOYjm77/C2H/3Jk0DTKuDSomTeQclE+uqqPJKEK t7oS0SVAmuc2m1NmBxEfWV0EKrx1HWIua8QxxI55QbIkX25zUxbjxZUKMhMKIKO/ XLmWTsmk3fTQ2QLGJMYQqVV7FlsAoTahLMDs5OClZIo7MxZyMerlkQIHM0jBKV8V FLXpIKfJFCVeTQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrgedvgdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucfkphepledtrdekledrieekrdejieenucevlhhushhtvghrufhiiigvpedvnecurf grrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 26481328005D; Mon, 5 Oct 2020 11:15:52 -0400 (EDT) From: Maxime Ripard To: Chen-Yu Tsai , Maxime Ripard , dri-devel@lists.freedesktop.org Cc: Maarten Lankhorst , Thomas Zimmermann , Daniel Vetter , David Airlie , devicetree@vger.kernel.org, Mark Rutland , Rob Herring , Frank Rowand , Laurent Pinchart , linux-arm-kernel@lists.infradead.org Subject: [PATCH RESEND v3 4/6] drm/sun4i: tcon: Support the LVDS Dual-Link Date: Mon, 5 Oct 2020 17:15:42 +0200 Message-Id: <8e63e9092f0fa4690a3fe6d21edd613b1f9c6874.1601910923.git-series.maxime@cerno.tech> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 35 +++++++++++++++++++++++++++++++- drivers/gpu/drm/sun4i/sun4i_tcon.h | 4 ++++- 2 files changed, 39 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 8a21cf7a6bc1..f497d866e835 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 @@ -894,6 +897,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_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. * @@ -929,6 +942,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, "allwinner,lvds-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 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