From patchwork Tue Feb 6 09:35:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 126969 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2745442ljc; Tue, 6 Feb 2018 01:36:02 -0800 (PST) X-Google-Smtp-Source: AH8x226Zetxcr+WmEkejN4H+AISzGXetj+BCPJ/3MxNmQm0NHFKkvcOD+vCpn+QPE3x+bbL663pF X-Received: by 2002:a17:902:7441:: with SMTP id e1-v6mr1836436plt.204.1517909762372; Tue, 06 Feb 2018 01:36:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517909762; cv=none; d=google.com; s=arc-20160816; b=xsCrLaIaAw6LnIvhBuO1v6xzDG1N60fq2GqXIIAhDnOrwZxuxDTk+Wa7e8RNGaCf7y vqsjB8UyDyOF79wp9e4s7H2P6+9juyaQHbljLwI8qZmw9sGX8t0+GarCBJUQFm9sWh7U pm3enXWwPqRy5ySejBzg3eMvmMMWkRIT3CRSH6GYwVQO4H3kS3bAU7Rs09XxKSIpYJnh qUqBPtEGKwW24JDuPUUIWdBYFtJ7Nr0RB8MjGr5rvtlHI7nnq2edEZCpcShskjcvp7Jw cWmo7FNjHbi7BDTJ63nmOPoj/HIgSBq6Z4bYXcHc4T35m2xgoVn1KCCV6bKX+cuQk/lR cpQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=KQwHpbJGbJwqieLXriljZul1IAvjrvxCVb/DZsl3Eng=; b=FeU7X20ZKc037eTiYFeBnYu2tjxoEvAz3n8HZ+bmLi6um3rHWFhq/nmVfaxr2EFT2V eM/PTcSvGVUrc1y3m789eSEl5gWlEIguDss0zeTP4FPYwE7OFcs76HPuQAYUKMY08wXz JN0j+kjj2KGjuHHhcOm2oIBO/+yJp5nvjfZ+is55RRQhW5uNjotTSBWG7Bb+gbXTykL4 KHUE4lx2mRjMfB+teuisNCiI0psWn/M4+OZTzmj3DuhHGubaMgbtmi/RUDuxa/LQr6Sf jjMmTgdy0X1KKx+DRmKRKR130RPhvqGT4mm7/ytu4vnwa9HwBN4qSwWkEhUeDbo7iGu/ xAwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jy05onFO; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id y11si1065815pgv.625.2018.02.06.01.36.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2018 01:36:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jy05onFO; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 67A016E3D7; Tue, 6 Feb 2018 09:35:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 61CDD6E3D7 for ; Tue, 6 Feb 2018 09:35:56 +0000 (UTC) Received: by mail-lf0-x242.google.com with SMTP id v188so1733019lfa.11 for ; Tue, 06 Feb 2018 01:35:56 -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=G78Hhtf6Ya/TZC/+9D5XKSJ8jxZ2NyRWibBWPLE3bMQ=; b=jy05onFOpfseKgAi4J7vBhP0AKLYgDvnqeSzmy1OJH00cOs2M9mvCP+ngs5JH8IVlZ eTYZjOjkxC0gCxLQs4GCJBQ6fj5D7e2rbG21pS87r7hprhlL3uUyUO2lCNzpJY70p+UL 7oQiu5DKWFNEEtfXwYLOYKhtc0CXLHVOZwwOM= 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=G78Hhtf6Ya/TZC/+9D5XKSJ8jxZ2NyRWibBWPLE3bMQ=; b=PlkS06zLLyfM12yBUz0f3NwfSycmmquwQuz1WkAaxcud2pr3MC4j6M3adwrpplu5RP wcZPgiYilXSwI+gbL8RSi6UI1DxcVcaRvei8sAcoiYU7fwX82sGupp8Wi/eA5TmaVxQZ 6vU0+ZKhE7iF/CuhYPK/ME4GkabuiVaE0dbpdll2ZXbrLEg7qiWNKaVlzAeWylktTZhp Wp1lwrZqr+AnqBvx1fHO+8+ysbf1RtmmbUsKamLIFhEvcB6qhLuyaUUhIPHkr4Bt3o8S YZYRqz8xlq/sQE7J6dfleeiQf5sEfvOF7X84LQ8qZPfCC4tv8tQsGlZIBHL4UIFjIy0s yHAw== X-Gm-Message-State: APf1xPDakjhCen/aG+sI2UlUXkJc9ew+vLott+KPqjORMsHLvkdi+1PZ Ha9XPW+JZbVuqHM8jLUFe3qbFw== X-Received: by 10.46.17.91 with SMTP id f88mr1195674lje.54.1517909754602; Tue, 06 Feb 2018 01:35:54 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m129sm2253675lfg.75.2018.02.06.01.35.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2018 01:35:53 -0800 (PST) From: Linus Walleij To: Daniel Vetter , Jani Nikula , Sean Paul , Eric Anholt Subject: [PATCH 5/5 v3] drm/pl111: Support multiple endpoints on the CLCD Date: Tue, 6 Feb 2018 10:35:40 +0100 Message-Id: <20180206093540.8147-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180206093540.8147-1-linus.walleij@linaro.org> References: <20180206093540.8147-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" 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. Reviewed-by: Eric Anholt Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Collect Eric's Review tag. --- 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 e6fa897c740c..221f3af02fb4 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);