From patchwork Fri May 12 14:56:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe CORNU X-Patchwork-Id: 9724383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9433E60382 for ; Fri, 12 May 2017 14:57:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8987D2877F for ; Fri, 12 May 2017 14:57:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D8CE28834; Fri, 12 May 2017 14:57:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F114F2877F for ; Fri, 12 May 2017 14:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MIne07tj7N2mM+UKB5Hb7TF/mJXKqytPgeHHu5V/SDc=; b=d/IYCIYF26sD2J VnCTIYlyuabtYMquv5E9u5rG8EbFObXc9JU55mDmSLD03OsB5djXiHDYNYpWP9yhiV9rozIXiD14n Ypp7J06T4lwFEkkBqZtFiCOO1cLc1b+9IPAieXSPgoScXXKbtDoAq6mBSkvy1RYZU0PBueqR+H/2I eqEyJGqFamQJi60yeqdFtyTGjG+z/oFMJRxXYu/9vgCYwTpbf91fqymoJ53GVlebJBBqjAEgRodJ1 JzwevX9KnlAC234kO+t0/Hc1YXJBTXGGn4KB7TSvIZ2mGQUMh6tqldTGPXFHpDJubzTjUXJJVu5zi +BqlHgD5FxrvlIKk1j1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d9C0v-0000gD-E1; Fri, 12 May 2017 14:57:53 +0000 Received: from mx07-00178001.pphosted.com ([62.209.51.94]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d9C0i-0000TR-3r for linux-arm-kernel@lists.infradead.org; Fri, 12 May 2017 14:57:42 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v4CEscvg010777; Fri, 12 May 2017 16:56:54 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-.pphosted.com with ESMTP id 2abjae1fv9-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 12 May 2017 16:56:54 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EF66B38; Fri, 12 May 2017 14:56:50 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas24.st.com [10.75.90.94]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C268E244F; Fri, 12 May 2017 14:56:50 +0000 (GMT) Received: from localhost (10.201.23.32) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.339.0; Fri, 12 May 2017 16:56:50 +0200 From: Philippe CORNU To: Alexandre Torgue , Thierry Reding , David Airlie , Maxime Coquelin , Russell King , Mark Rutland , Rob Herring , Arnd Bergmann , Benjamin Gaignard , Yannick Fertre Subject: [PATCH v1 1/3] drm/stm: ltdc: Add bridge support Date: Fri, 12 May 2017 16:56:27 +0200 Message-ID: <1494600989-13507-2-git-send-email-philippe.cornu@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494600989-13507-1-git-send-email-philippe.cornu@st.com> References: <1494600989-13507-1-git-send-email-philippe.cornu@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.32] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-12_08:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170512_075740_477011_3D7206B0 X-CRM114-Status: GOOD ( 15.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, kernel@stlinux.com, Philippe Cornu , Fabien Dessenne , dri-devel@lists.freedesktop.org, Mickael Reulier , Vincent Abriou , Gabriel Fernandez , Ludovic Barre Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add the bridge support, used by DSI host and HDMI/LVDS bridges. Signed-off-by: Philippe CORNU --- drivers/gpu/drm/stm/ltdc.c | 82 +++++++++++++++++++++++++++++++++++++++------- drivers/gpu/drm/stm/ltdc.h | 1 + 2 files changed, 72 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c index 7b2d63b..b0d1fba 100644 --- a/drivers/gpu/drm/stm/ltdc.c +++ b/drivers/gpu/drm/stm/ltdc.c @@ -858,6 +858,43 @@ static struct drm_encoder *ltdc_rgb_encoder_create(struct drm_device *ddev) return encoder; } +static const struct drm_encoder_funcs bridge_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; + +struct drm_encoder *bridge_encoder_create(struct drm_device *ddev, + struct drm_bridge *bridge) +{ + struct drm_encoder *encoder; + int ret; + + encoder = devm_kzalloc(ddev->dev, sizeof(*encoder), GFP_KERNEL); + if (!encoder) + return NULL; + + encoder->possible_crtcs = CRTC_MASK; + encoder->possible_clones = 0; /* No cloning support */ + + drm_encoder_init(ddev, encoder, &bridge_encoder_funcs, + DRM_MODE_ENCODER_TMDS, NULL); + + drm_encoder_helper_add(encoder, NULL); + + /* Link drm_bridge to encoder */ + bridge->encoder = encoder; + encoder->bridge = bridge; + + ret = drm_bridge_attach(encoder, bridge, NULL); + if (ret) { + drm_encoder_cleanup(encoder); + return NULL; + } + + DRM_DEBUG_DRIVER("Bridge encoder:%d created\n", encoder->base.id); + + return encoder; +} + /* * DRM_CONNECTOR */ @@ -967,12 +1004,12 @@ static int ltdc_get_caps(struct drm_device *ddev) return 0; } -static struct drm_panel *ltdc_get_panel(struct drm_device *ddev) +static int ltdc_parse_dt(struct drm_device *ddev) { + struct ltdc_device *ldev = ddev->dev_private; struct device *dev = ddev->dev; struct device_node *np = dev->of_node; struct device_node *entity, *port = NULL; - struct drm_panel *panel = NULL; DRM_DEBUG_DRIVER("\n"); @@ -987,19 +1024,36 @@ static struct drm_panel *ltdc_get_panel(struct drm_device *ddev) port = of_graph_get_remote_port_parent(entity); if (port) { + struct drm_bridge *bridge; + struct drm_panel *panel; + + bridge = of_drm_find_bridge(port); panel = of_drm_find_panel(port); - of_node_put(port); + if (!bridge && !panel) { + of_node_put(entity); + return -EPROBE_DEFER; + } + + if (bridge) { + if (!ldev->bridge) { + ldev->bridge = bridge; + DRM_INFO("remote bridge %s\n", + port->full_name); + } + } + if (panel) { - DRM_DEBUG_DRIVER("remote panel %s\n", + if (!ldev->panel) { + ldev->panel = panel; + DRM_INFO("remote panel %s\n", port->full_name); - } else { - DRM_DEBUG_DRIVER("panel missing\n"); - of_node_put(entity); + } } + of_node_put(port); } } - return panel; + return 0; } int ltdc_load(struct drm_device *ddev) @@ -1017,9 +1071,9 @@ int ltdc_load(struct drm_device *ddev) DRM_DEBUG_DRIVER("\n"); - ldev->panel = ltdc_get_panel(ddev); - if (!ldev->panel) - return -EPROBE_DEFER; + ret = ltdc_parse_dt(ddev); + if (ret) + return ret; rstc = of_reset_control_get(np, NULL); @@ -1077,6 +1131,12 @@ int ltdc_load(struct drm_device *ddev) DRM_INFO("ltdc hw version 0x%08x - ready\n", ldev->caps.hw_version); + if (ldev->bridge) { + encoder = bridge_encoder_create(ddev, ldev->bridge); + if (!encoder) + return -EINVAL; + } + if (ldev->panel) { encoder = ltdc_rgb_encoder_create(ddev); if (!encoder) { diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h index 5427ef4..0083cad 100644 --- a/drivers/gpu/drm/stm/ltdc.h +++ b/drivers/gpu/drm/stm/ltdc.h @@ -25,6 +25,7 @@ struct ltdc_device { void __iomem *regs; struct clk *pixel_clk; /* lcd pixel clock */ struct drm_panel *panel; + struct drm_bridge *bridge; struct spinlock lock; /* protecting irq status register */ struct ltdc_caps caps; u32 clut[256]; /* color look up table */