From patchwork Fri Jan 26 13:20:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10185719 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 12EE9603ED for ; Fri, 26 Jan 2018 13:20:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00C6E2851E for ; Fri, 26 Jan 2018 13:20:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E964E28EE5; Fri, 26 Jan 2018 13:20:54 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C1EE28B75 for ; Fri, 26 Jan 2018 13:20:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7CF746E247; Fri, 26 Jan 2018 13:20:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x243.google.com (mail-lf0-x243.google.com [IPv6:2a00:1450:4010:c07::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id E043D6E247 for ; Fri, 26 Jan 2018 13:20:51 +0000 (UTC) Received: by mail-lf0-x243.google.com with SMTP id q17so649744lfa.9 for ; Fri, 26 Jan 2018 05:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZkcZ3Hz9axvmxaEvTJhtt3GYiNfBHdF5l5Hj42qYwyc=; b=frJYlJMjqgpPxcmnVrwYcDqRc1AixVyRcJjDumeUoUxjNVTEkEZAHpXtJr6En5k5k6 CoQtg6GHG59UeyxoyfhxiwWD6GnMO6UmskIeudScU0X3xIH8UTXhEUw35vxd3B2K+rBw 894blbDdBgKUQ5CmiAINnHix6ek6vu6rCvSyg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZkcZ3Hz9axvmxaEvTJhtt3GYiNfBHdF5l5Hj42qYwyc=; b=FzJutuHpeGeFBtpT1y3f1tYjMFxjhisdnJY8SLnMrpbQW39q+AbZhP0pb0Vk4+TIuH R0VnrqMCXWsiLDFnfosxcd94C9zYSI3F+77hEE4iEnK2AnLxoh48GyNPNqPjTzfojcNR 8b+/TApc4949izr4BjB7DzFzOg8Gx7kZaK56QRSxdEj8q+yzb+fjoglrvPEGwOTSKEve aG+g5g/BLenHm13Y2s2sI+YFRtHNuIRU7BNtklNSE6nbr5nCN7j6G6XdxU0gdyYyCIv3 i3Ug8n3ar04p5HRnFGGDFz4eDLWjOt4qREa51ZOoHdxgw7NXOt6XcA8P1Pg9KSOD0fGX xLMA== X-Gm-Message-State: AKwxytfQtk8bSyrW13tlLUhBx9H7tw7TwH+uGqh6suebTYrccOI7EJtO owzl04UuXAij+1eQVBjMWEnUBX2/3NY= X-Google-Smtp-Source: AH8x224L+Fwp5a08nNiWPhpOnTqoNYMumEo/sR2UDXbfFWbMvgfDxNcEqLCT66FAmCL8Ro/8JTkvwQ== X-Received: by 10.46.29.138 with SMTP id w10mr1712425lje.120.1516972850029; Fri, 26 Jan 2018 05:20:50 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id h15sm937704ljh.77.2018.01.26.05.20.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jan 2018 05:20:49 -0800 (PST) From: Linus Walleij To: Daniel Vetter , Jani Nikula , Sean Paul , Eric Anholt Subject: [PATCH 4/4] drm/pl111: Support multiple endpoints on the CLCD Date: Fri, 26 Jan 2018 14:20:33 +0100 Message-Id: <20180126132033.19744-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180126132033.19744-1-linus.walleij@linaro.org> References: <20180126132033.19744-1-linus.walleij@linaro.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The Versatile PL110 implementations use multiple endpoints: from the PL111 port, the lines are routed through a PLD, and from there forked so the same lines go to a VGA DAC and an external TFT panel connector. This is discrete wireing so there is no way to turn of one output, i.e. this is really two endpoints, not two ports. We model this with multiple endpoints, so we need to loop over the available endpoints, check for panel or bridge on each and accumulate the result before continuing. The code already will give the panel preference over the bridge, if present, so the output will be sent to the panel if both a panel and a bridge is present on two endpoints of the same port. If they all return -EPROBE_DEFER we return -EPROBE_DEFER as well. If just one endpoint is present on the port, the behaviour is the same as before. Signed-off-by: Linus Walleij --- drivers/gpu/drm/pl111/pl111_drv.c | 62 +++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/pl111/pl111_drv.c b/drivers/gpu/drm/pl111/pl111_drv.c index f1f1b87b0e44..7e9f5efe3274 100644 --- a/drivers/gpu/drm/pl111/pl111_drv.c +++ b/drivers/gpu/drm/pl111/pl111_drv.c @@ -58,6 +58,8 @@ #include #include #include +#include +#include #include #include @@ -84,9 +86,13 @@ static int pl111_modeset_init(struct drm_device *dev) { struct drm_mode_config *mode_config; struct pl111_drm_dev_private *priv = dev->dev_private; - struct drm_panel *panel; - struct drm_bridge *bridge; + struct device_node *np = dev->dev->of_node; + struct device_node *remote; + struct drm_panel *panel = NULL; + struct drm_bridge *bridge = NULL; + bool defer = false; int ret = 0; + int i; drm_mode_config_init(dev); mode_config = &dev->mode_config; @@ -96,10 +102,54 @@ static int pl111_modeset_init(struct drm_device *dev) mode_config->min_height = 1; mode_config->max_height = 768; - ret = drm_of_find_panel_or_bridge(dev->dev->of_node, - 0, 0, &panel, &bridge); - if (ret && ret != -ENODEV) - return ret; + i = 0; + for_each_endpoint_of_node(np, remote) { + struct drm_panel *tmp_panel; + struct drm_bridge *tmp_bridge; + + dev_dbg(dev->dev, "checking endpoint %d\n", i); + + ret = drm_of_find_panel_or_bridge(dev->dev->of_node, + 0, i, + &tmp_panel, + &tmp_bridge); + if (ret) { + if (ret == -EPROBE_DEFER) { + /* + * Something deferred, but that is often just + * another way of saying -ENODEV, but let's + * cast a vote for later deferral. + */ + defer = true; + } else if (ret != -ENODEV) { + /* Continue, maybe something else is working */ + dev_err(dev->dev, + "endpoint %d returns %d\n", i, ret); + } + } + + if (tmp_panel) { + dev_info(dev->dev, + "found panel on endpoint %d\n", i); + panel = tmp_panel; + } + if (tmp_bridge) { + dev_info(dev->dev, + "found bridge on endpoint %d\n", i); + bridge = tmp_bridge; + } + + i++; + } + + /* + * If we can't find neither panel nor bridge on any of the + * endpoints, and any of them retured -EPROBE_DEFER, then + * let's defer this driver too. + */ + if ((!panel && !bridge) && defer) + return -EPROBE_DEFER; + if (panel) { bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_Unknown);