From patchwork Wed Sep 29 08:42:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12524921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30523C433F5 for ; Wed, 29 Sep 2021 08:46:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EEAA26128E for ; Wed, 29 Sep 2021 08:46:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EEAA26128E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KzpvaI6OLIRVedhmAv5mNc6Z5QPJ0fCct3APatDMLWM=; b=FoktD7bMSh4Cuy fZFGbhK9jBFr3glB16l/ocwQqnZBt9JCFpis5ulLWY5UNhf4+CW4AlWEEdyn6zdOycQg2TUD9pzp9 Qo/d/a7iUxXbxRSrtkAQ6pNJO3rfuwzxFz49kO+zXvCQayTdlvKd1JE8NzYeDU18RwWPzDUgKhViW RQ/sh7kn+GJKuJQOhBcsbJNwJVzTJpInjBkzBgvHKu6qk/2RUq3SdAHnkLSbSSQ1FE/auoW5Lrzwj 7qwidWJOim3UiyseL1MYWcUHh4yrZR140d49syNrI8wf63xaQ5YW1M0gY5qUFQP46sc02MPffOOzY yRsq3fDunLhfh0LaZYtQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVVC5-00ATkC-Ef; Wed, 29 Sep 2021 08:44:01 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVVB4-00ATQe-HE for linux-arm-kernel@lists.infradead.org; Wed, 29 Sep 2021 08:43:00 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 7D5DF3200F9F; Wed, 29 Sep 2021 04:42:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 29 Sep 2021 04:42:58 -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=FJFQ1azQRDRmA YHCJ8TvmTKHApO5RLnncYdEXMr5UsM=; b=NjOc4nS/f4GkCF7075NWSJTeQLKWf IUj2Kjz/aw/uAe+QWfRejRAo2OJoXrIFf7H0k8BdmhTEfxD9fGiXC7aXX3DhVXFl BfWJjvTfogNyJ/4asC3TaBH8iv7IOMnUXe9JVCQzD8rbwf7tYI3lkb2wo+G/K8f0 tF54hjnQZEq6pNsAVNERj8Bxw331zgCMFEI5odJtb9wDTI6kIt2uR9NTCoxVnz0n ZJmXw0zIsY98WxTb3+JMiXwU4jGEbE5Qdt/kgdxqrC0SgQBdPrMEgrEZsNa/sv7P 8BmKBXp55EKnyngvBPcmXmMf/oOMS5e4W11TbvTIzPSYYzNmRIAZFQIMg== 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= fm3; bh=FJFQ1azQRDRmAYHCJ8TvmTKHApO5RLnncYdEXMr5UsM=; b=ZxrawEVY fDyp/705XtU+DgFfkdjj98VVAzrt9ucLcsGDVLLR6XPD63dVXmfQ4/y+D9/CNrk7 YoUmq/4y8/9kOFtHujh7nNBLvBXGQtzuguFo0bRBXoKQXB/o/JVDVL60qf/tHuYm cjDeIlenvbgxxElXc2YWlp6auwNc4b2GANz2WMe24Szg/HThsJ8gB50LiRiRN8+G oaJGh8JPur65fmTvX/5+URUCselZ3mr+pNhGUgLNzuekIy/chBTfF7xspRMLMHwM lt8WDwdjXDwu1/U1SKaHltFzbAvI1ld4k7e3I5G+ZBAVsTZzKvrqhotQJbxVjGO9 kPmWk/pBsjtZOg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudekvddgtdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Sep 2021 04:42:56 -0400 (EDT) From: Maxime Ripard To: Rob Herring , Frank Rowand , Chen-Yu Tsai , Maxime Ripard , =?utf-8?q?Jernej_=C5=A0krabec?= , Daniel Vetter , David Airlie , Laurent Pinchart Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 5/7] drm/sun4i: tcon: Support the LVDS Dual-Link Date: Wed, 29 Sep 2021 10:42:32 +0200 Message-Id: <20210929084234.1271915-6-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210929084234.1271915-1-maxime@cerno.tech> References: <20210929084234.1271915-1-maxime@cerno.tech> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210929_014258_622976_CF53095E X-CRM114-Status: GOOD ( 20.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. Reviewed-by: Chen-Yu Tsai Signed-off-by: Maxime Ripard --- 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 e38e60faafd2..c7c94b7c6439 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 @@ -886,6 +890,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. @@ -922,6 +936,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 e624f6977eb8..7609a880a8a7 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) @@ -281,6 +282,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 */