From patchwork Fri May 19 15:20:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe CORNU X-Patchwork-Id: 9737431 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 2A7F7601A1 for ; Fri, 19 May 2017 15:22:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B6CF284E3 for ; Fri, 19 May 2017 15:22:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E06328474; Fri, 19 May 2017 15:22:36 +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 6023A28474 for ; Fri, 19 May 2017 15:22:35 +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=ZE2IZboPSp0VBPGy2aToCFdSoNK4TlUMrD9vMI4hjZE=; b=i5CjGAoHtzBPNz DHxxQYbq2yPAB9VpnQnx+ob8SX2aA6oVzQmqZVNB6rxx1TV6GllRnngyfMIr71qr3uKT5M9N/ELQ2 vufcQCOYGDTxVHttJxJ4wLc6NqWVdD6tpo4DJksF57eEtMhIY17OvJKji3sPU0fE8zMLNuy5eeiGK g8nUlE8GIeskqu7EwofZAbEOdOkYPUrqZLWwsRtIl3V5lTU1GCqioJQPcz6BEG0pm21AlrCaGBIyp B1limnLsfaDSCIRkvVpImhtFIk7LTh2SR+1e/Nf7G5/PQdHMSyw226PCctVokQguXr8fX7p9xAayi fQ6wb/QetDOmEXfrTvtQ==; 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 1dBjje-0007to-6z; Fri, 19 May 2017 15:22:34 +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 1dBjiZ-0006dD-1k for linux-arm-kernel@lists.infradead.org; Fri, 19 May 2017 15:21:30 +0000 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v4JF98Ig028643; Fri, 19 May 2017 17:20:35 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-.pphosted.com with ESMTP id 2ahet5nsy9-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 19 May 2017 17:20:35 +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 1A7FF3A; Fri, 19 May 2017 15:20:35 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E95502443; Fri, 19 May 2017 15:20:34 +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, 19 May 2017 17:20:34 +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 , Neil Armstrong , Archit Taneja , Eric Anholt , Chris Zhong Subject: [PATCH v2 1/5] drm/stm: ltdc: Add bridge support Date: Fri, 19 May 2017 17:20:14 +0200 Message-ID: <1495207218-11372-2-git-send-email-philippe.cornu@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495207218-11372-1-git-send-email-philippe.cornu@st.com> References: <1495207218-11372-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-19_09:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170519_082127_494651_11B631A4 X-CRM114-Status: GOOD ( 16.03 ) 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, 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 Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/stm/ltdc.c | 74 ++++++++++++++++++++++++++++++++++------------ drivers/gpu/drm/stm/ltdc.h | 1 + 2 files changed, 56 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c index 7b2d63b..809e420 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,13 @@ 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; + struct device_node *entity; + int ret; DRM_DEBUG_DRIVER("\n"); @@ -985,21 +1023,13 @@ static struct drm_panel *ltdc_get_panel(struct drm_device *ddev) if (!of_device_is_available(entity)) continue; - port = of_graph_get_remote_port_parent(entity); - if (port) { - panel = of_drm_find_panel(port); - of_node_put(port); - if (panel) { - DRM_DEBUG_DRIVER("remote panel %s\n", - port->full_name); - } else { - DRM_DEBUG_DRIVER("panel missing\n"); - of_node_put(entity); - } - } + ret = drm_of_find_panel_or_bridge(np, 0, 0, + &ldev->panel, &ldev->bridge); + if (ret) + return ret; } - return panel; + return 0; } int ltdc_load(struct drm_device *ddev) @@ -1017,9 +1047,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 +1107,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 */