From patchwork Fri Oct 20 12:54:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 116492 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp118165edb; Fri, 20 Oct 2017 05:56:23 -0700 (PDT) X-Received: by 10.84.160.200 with SMTP id v8mr4021188plg.55.1508504183222; Fri, 20 Oct 2017 05:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508504183; cv=none; d=google.com; s=arc-20160816; b=X+itOI11c5kzkiRJnorMwap6MZL04jeoOkF7PsVKeIMXWzoCI8frlEwhVC+yP/DvQU wTe+UL5+hgLmZF/fttxVSLUusOjhaQjJIXuQK+U51edRn/VDdoy0mn+Bz0JKGnkfvmMM fHHidIKIHgBxSBQcTvF4tUrgZj5wD9zqPqDLCwFxqYjywsfbsdC6+4lKRDSq+OWFQRfb 1KAIXMLriGv+hkg+l77TtEBPvIgSzUdJylXmX8cVj8jKaT5B/O/LguXyUl4s4OdlMs0/ 75N7MxUgrGhS+/npOXXYG4xgDvE5dejfCt4uNv70o+CMudlr4287AViQJc+nPVT+8T7s oDkQ== 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 :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:message-id:date:subject:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=M+maY9osFynwKkZRtXwtIPDx1AarzVRQ6yT/RK9c9lE=; b=T2g/LQ7XyW8awzwIf6NKs9g9hhv3HubAWChMF74s7RxL5SpHEDC3w0c9cD31XP78Yn UjL8o7I6+PD62G8MHFqcrNoAlKc982bOpNcTka//v4WMDtiXqewREiafPHOyR3pKZvGS Ogc7+SJRtVd/NJo3Ou7AHKZMlZW4WyQsIT+At0WIkuE1utQAinWkL13rsWhZ3GVdSs+j OcdWN82bU6z9zusdGio1gvwC65Q7pVWCYEvZiFvXQzW610AOvuqpx+eDV0eyAWKZsjrz lj2OF1kkrqydX5z6JwQ9y8HtVl66oV3FUAqjv62CbfmZRC3TlCu1rFzqYpEYIzrCI+8u 8Wnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TFdrBPrQ; 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 f3si557633plo.396.2017.10.20.05.56.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Oct 2017 05:56:23 -0700 (PDT) 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=TFdrBPrQ; 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 E3BF16EC4B; Fri, 20 Oct 2017 12:56:21 +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 C89AF6EC4B for ; Fri, 20 Oct 2017 12:56:20 +0000 (UTC) Received: by mail-lf0-x243.google.com with SMTP id p184so13076061lfe.12 for ; Fri, 20 Oct 2017 05:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=GHx9tUjBcVnqrri4y4LzaIfPnnW2oFav01j7rcA4mk8=; b=TFdrBPrQazhPN6QQmmLrFgG02zFGSC1MgTq/6QcYWPOR36nxWS8SWbUsBfuRbRGu/J r/BrR1yWe3gTMMBFs4RRqgFfqCOS2faLGcGo94gEuI2t4gE84I0VlZ6wjWOQ6ugp2PFz t0+A5oWO8kj28A3fGxxIyn9Ny8c/qyjydC27k= 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; bh=GHx9tUjBcVnqrri4y4LzaIfPnnW2oFav01j7rcA4mk8=; b=Hd58OMdZl+g1WbsfxWVhCHMBVFXCDcA543OdAfPrfDbnJNpTV4PfxtiKNMBERvyzC+ yHJS5xymj5NJmMPw6LdTNpBr7xOkXZP/744xSUCydjeWCQ/YDQ4Pz25dlbQNlwA1Y8EU UVahzGE7Ru3Q2CYOSzfSEMCrHWCDTIRyuWG5vZtKeup/9xvjAgE3tKS1811Zj7EZqsXL x5mkl6svoRJddXUI+0gms5PEXs5HCECq4eGSpQJkUQ6e7kYTd+fS8T1BmzYWPVEQADR9 nQBXgCloIQ+hRBmQDSlJyehRbuuhCyJcYQqRyIOx4yVxaq45ePIUG/rN6WJ7K/Nnzb5O fIGg== X-Gm-Message-State: AMCzsaXSYFBsdJH5iPhWux25AJhJIVGGbMjG8JjchCDEpSH/g3eECusv A5qxazsoafcXNXsJuu1YAe48TA== X-Google-Smtp-Source: ABhQp+Reo0tprzkuvxGVDyw+6sOqmLZYxO4Y1v+GpZ5Q0gAwywn5g1uD2PAYReNHC3FGvWApAtNf/Q== X-Received: by 10.46.4.29 with SMTP id 29mr2324128lje.82.1508504178995; Fri, 20 Oct 2017 05:56:18 -0700 (PDT) Received: from localhost.localdomain (c-5f7c71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.124.95]) by smtp.gmail.com with ESMTPSA id h3sm182906lfj.26.2017.10.20.05.56.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2017 05:56:17 -0700 (PDT) From: Linus Walleij To: Archit Taneja , Andrzej Hajda , Laurent Pinchart Subject: [PATCH v4] drm: bridge: Add THS8134A/B support to dumb VGA DAC Date: Fri, 20 Oct 2017 14:54:12 +0200 Message-Id: <20171020125412.25988-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.6 Cc: Laurent Pinchart , dri-devel@lists.freedesktop.org, Bartosz Golaszewski , Maxime Ripard , linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This extends the dumb VGA DAC bridge to handle the THS8134A and THS8134B VGA DACs in addition to those already handled. The THS8134A, THS8134B and as it turns out also THS8135 need to have data clocked out at the negative edge of the clock pulse, since they clock it into the DAC at the positive edge (so by then it needs to be stable) so we need some extra logic to flag this on the connector to the driver. The semantics of the flag DRM_BUS_FLAG_PIXDATA_NEGEDGE in clearly indicates that this flag tells when to *drive* the data, not when the receiver *reads* it, so the TI variants needs to be handled like this. Introduce a variant struct and contain the information there, and add a bit of helpful comments about how this works so people will get it right when adding new DACs or connectiong new display drivers to DACs. The fact that THS8135 might be working on some systems today is probably due to the fact that the display driver cannot configure when the data is clocked out and the electronics have simply been designed around it so it works anyways. The phenomenon is very real on the ARM reference designs using PL111 where the hardware can control which edge to push out the data. Cc: Laurent Pinchart Cc: Bartosz Golaszewski Cc: Maxime Ripard Signed-off-by: Linus Walleij --- ChangeLog v3->v4: - Actually have the code syntactically correct and compiling :( (Kconfig mistake.) (...) AS usr/initramfs_data.o AR usr/built-in.o CC drivers/gpu/drm/bridge/dumb-vga-dac.o AR drivers/gpu/drm/bridge/built-in.o AR drivers/gpu/drm/built-in.o AR drivers/gpu/built-in.o AR drivers/built-in.o (...) ChangeLog v2->v3: - Move const specifier. - Cut one line of code assigning bus flags. - Preserve the "ti,ths8135" compatible for elder device trees. ChangeLog v1->v2: - Alphabetize includes - Use a u32 with the bus polarity flags and just encode the polarity using the DRM define directly. - Rename vendor_data to vendor_info. - Simplify assignment of the flag as it is just a simple u32 now. - Probe all TI variants on the "ti,ths813x" wildcard for now, we only need to know that the device is in this family to set the clock edge flag right. --- drivers/gpu/drm/bridge/dumb-vga-dac.c | 53 +++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/dumb-vga-dac.c b/drivers/gpu/drm/bridge/dumb-vga-dac.c index 831a606c4706..92d1fe93a012 100644 --- a/drivers/gpu/drm/bridge/dumb-vga-dac.c +++ b/drivers/gpu/drm/bridge/dumb-vga-dac.c @@ -11,6 +11,7 @@ */ #include +#include #include #include @@ -19,9 +20,18 @@ #include #include +/** + * struct vga_dac_info - characteristics of the DAC + * @clk_edge_latch: this defines the clock edge latch for the variant + */ +struct vga_dac_info { + u32 clk_edge_latch; +}; + struct dumb_vga { struct drm_bridge bridge; struct drm_connector connector; + const struct vga_dac_info *variant; struct i2c_adapter *ddc; struct regulator *vdd; @@ -55,6 +65,7 @@ static int dumb_vga_get_modes(struct drm_connector *connector) } drm_mode_connector_update_edid_property(connector, edid); + connector->display_info.bus_flags |= vga->variant->clk_edge_latch; return drm_add_edid_modes(connector, edid); fallback: @@ -67,6 +78,8 @@ static int dumb_vga_get_modes(struct drm_connector *connector) /* And prefer a mode pretty much anyone can handle */ drm_set_preferred_mode(connector, 1024, 768); + connector->display_info.bus_flags |= vga->variant->clk_edge_latch; + return ret; } @@ -183,6 +196,7 @@ static int dumb_vga_probe(struct platform_device *pdev) if (!vga) return -ENOMEM; platform_set_drvdata(pdev, vga); + vga->variant = of_device_get_match_data(&pdev->dev); vga->vdd = devm_regulator_get_optional(&pdev->dev, "vdd"); if (IS_ERR(vga->vdd)) { @@ -226,10 +240,43 @@ static int dumb_vga_remove(struct platform_device *pdev) return 0; } +static const struct vga_dac_info default_dac_variant = { + /* + * These DACs read data on the negative edge. For example in the + * ADV7123 datasheet (revision D, page 8) there is a timing diagram + * making this clear. So consequently we need to latch the data + * on the positive edge. + */ + .clk_edge_latch = DRM_BUS_FLAG_PIXDATA_POSEDGE, +}; + +static const struct vga_dac_info ti_ths_dac_variant = { + /* + * The TI DACs read the data on the positive edge of the CLK, + * so consequently we need to latch the data on the negative + * edge. + */ + .clk_edge_latch = DRM_BUS_FLAG_PIXDATA_NEGEDGE, +}; + static const struct of_device_id dumb_vga_match[] = { - { .compatible = "dumb-vga-dac" }, - { .compatible = "adi,adv7123" }, - { .compatible = "ti,ths8135" }, + { + .compatible = "dumb-vga-dac", + .data = &default_dac_variant, + }, + { + .compatible = "adi,adv7123", + .data = &default_dac_variant, + }, + { + /* Some trees contain just this compatible and no "ti,ths813x" */ + .compatible = "ti,ths8135", + .data = &ti_ths_dac_variant, + }, + { + .compatible = "ti,ths813x", + .data = &ti_ths_dac_variant, + }, {}, }; MODULE_DEVICE_TABLE(of, dumb_vga_match);