Received: by 10.213.65.68 with SMTP id h4csp498193imn; Tue, 13 Mar 2018 10:56:55 -0700 (PDT) X-Google-Smtp-Source: AG47ELtgGqEv16OOFVKzdX7P90kxh53+Xqx5OWVFTwCU2OLQyRzNRl7Vvea4YYtIl1Wm+UcTDXaW X-Received: by 10.99.119.74 with SMTP id s71mr1154317pgc.321.1520963815112; Tue, 13 Mar 2018 10:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520963815; cv=none; d=google.com; s=arc-20160816; b=Kfp+hyVm30Q9RVVzY4Fi/JXqF5wQOZLxtBvMzU2oOgY4M0Mf9/xo9yOIjOfN1ymwGE NFNMHB7LU+mJ8hhAcH8IMDU4I/yKTY/BWp8W2vVMmd4i3hVjJkztyt/tE1jqPGuzvDzl XdMPlPU000eU3w4P5VpLPgspAW0NUePyuYAVJDQAVoQ3mA+2jyxGidtle08Surrtlps9 fTHqu5eAoFdTC9orhP6aeubH/NOekmiG6w35pysIyYSCBezSMhuKSS1nWutLbOrA6yEG lRw+9fWdcomExGjnwtKN7UIjzLlEwi2lpsTQGqYXEzvcLOjSrl1vJGd4uka1j0tRFEQo 5Xcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=zkWSPB8obYGP7cs0ZvwkF8LskQML2vnW0kqO3jFIgqE=; b=r1sVq7WdN1Lpfv63c3qPs2wi1zPD1Hl5nfGiLfG3gTFckN7ig2vkUUzW4N2lkd9idG cqWBmPtRGbmrRalXdYrA1VR2Ff86WfLEOgukNLUBaKETZMn1yQLEbUnRGLjw7ixczlLp wusZ5NrGMETMFIkMola0W1X71GcE5b+DVFv738ptAqq6reuIcr4cDz7Zs+PKMgsb2Y3J Ad/+tq2mI7rFif7pr5W/ODlY75wKK862CKC/Za+LJelFPaJO4VXUSsFCV+NEBHw3F++a /dbuGOcj7Ir6eA3q1mBftnHQ75H+ojNn1uN2ETEWhZIwtl+hXTu/vhoLutW+Ohj9fmqF ftfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=MnFXD8X9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16-v6si469872plk.608.2018.03.13.10.56.41; Tue, 13 Mar 2018 10:56:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=MnFXD8X9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752405AbeCMRzc (ORCPT + 99 others); Tue, 13 Mar 2018 13:55:32 -0400 Received: from mail.micronovasrl.com ([212.103.203.10]:43286 "EHLO mail.micronovasrl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751860AbeCMRz3 (ORCPT ); Tue, 13 Mar 2018 13:55:29 -0400 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id 0FC6BB00A1A for ; Tue, 13 Mar 2018 18:55:28 +0100 (CET) Authentication-Results: mail.micronovasrl.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=micronovasrl.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=micronovasrl.com; h=content-transfer-encoding:content-type:content-type :mime-version:x-mailer:message-id:date:date:subject:subject:to :from:from; s=dkim; t=1520963727; x=1521827728; bh=d31xLT7YoGOt6 0dsaXl7MJW+9T0wearNI45O9Wz5SFo=; b=MnFXD8X93rfDYQMo8d+09VCiLROom sgpAuM1herdm6Yyg4dp7j1PycyktJe6QaMSxQtwk6QbzN8XLhG+UCSMJcT5Vc2tX 0BdCRNDSRbYqqsRF6qPKghA+elSRxLHqxU5BZeBb6FLfM1BnpEOURZhjuYDkaaQe ogzXyD5mSHUXEk= X-Virus-Scanned: Debian amavisd-new at mail.micronovasrl.com X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 tagged_above=-10 required=4.5 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9] autolearn=unavailable autolearn_force=no Received: from mail.micronovasrl.com ([127.0.0.1]) by mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 5YLDQ3QkkAkt for ; Tue, 13 Mar 2018 18:55:27 +0100 (CET) Received: from localhost.localdomain (62-11-51-166.dialup.tiscali.it [62.11.51.166]) by mail.micronovasrl.com (Postfix) with ESMTPSA id 4D6F1B0033F; Tue, 13 Mar 2018 18:55:26 +0100 (CET) From: Giulio Benetti To: Maxime Ripard Cc: David Airlie , Chen-Yu Tsai , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Giulio Benetti Subject: [PATCH v2] drm/sun4i: Handle DRM_BUS_FLAG_PIXDATA_*EDGE Date: Tue, 13 Mar 2018 18:54:37 +0100 Message-Id: <1520963677-124239-1-git-send-email-giulio.benetti@micronovasrl.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Handle both positive and negative dclk polarity, according to bus_flags, taking care of this: On A20 and similar SoCs, the only way to achieve Positive Edge (Rising Edge), is setting dclk clock phase to 2/3(240°). By default TCON works in Negative Edge(Falling Edge), this is why phase is set to 0 in that case. Unfortunately there's no way to logically invert dclk through IO_POL register. The only acceptable way to work, triple checked with scope, is using clock phase set to 0° for Negative Edge and set to 240° for Positive Edge. On A33 and similar SoCs there would be a 90° phase option, but it divides also dclk by 2. This patch is a way to avoid quirks all around TCON and DOTCLOCK drivers for using A33 90° phase divided by 2 and consequently increase code complexity. Signed-off-by: Giulio Benetti --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 8ee87c2..3f1455d 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -345,6 +346,9 @@ static void sun4i_tcon0_mode_set_lvds(struct sun4i_tcon *tcon, static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, const struct drm_display_mode *mode) { + struct drm_panel *panel = tcon->panel; + struct drm_connector *connector = panel->connector; + struct drm_display_info display_info = connector->display_info; unsigned int bp, hsync, vsync; u8 clk_delay; u32 val = 0; @@ -400,6 +404,27 @@ static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, if (mode->flags & DRM_MODE_FLAG_PVSYNC) val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE; + /* + * On A20 and similar SoCs, the only way to achieve Positive Edge + * (Rising Edge), is setting dclk clock phase to 2/3(240°). + * By default TCON works in Negative Edge(Falling Edge), + * this is why phase is set to 0 in that case. + * Unfortunately there's no way to logically invert dclk through + * IO_POL register. + * The only acceptable way to work, triple checked with scope, + * is using clock phase set to 0° for Negative Edge and set to 240° + * for Positive Edge. + * On A33 and similar SoCs there would be a 90° phase option, + * but it divides also dclk by 2. + * Following code is a way to avoid quirks all around TCON + * and DOTCLOCK drivers. + */ + if (display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_POSEDGE) + clk_set_phase(tcon->dclk, 240); + + if (display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_NEGEDGE) + clk_set_phase(tcon->dclk, 0); + regmap_update_bits(tcon->regs, SUN4I_TCON0_IO_POL_REG, SUN4I_TCON0_IO_POL_HSYNC_POSITIVE | SUN4I_TCON0_IO_POL_VSYNC_POSITIVE, val); -- 2.7.4