Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp588398imm; Wed, 18 Jul 2018 07:25:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf+aKmM6Pdm/IrY5DcNazdYqdjKm+rkiIX4EefaF330uBQUVj9w6KaYrXs95+PDa9g2Rc3o X-Received: by 2002:a65:550d:: with SMTP id f13-v6mr6159337pgr.340.1531923933278; Wed, 18 Jul 2018 07:25:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531923933; cv=none; d=google.com; s=arc-20160816; b=yr468HUWFXoS8Omu9bpcuESIzImznmw4by160G99QyA3b7xLYjDsNhTQzflcBZaozo vjQMrUR/tdsyhhSvOs3OU2Ggc6u4dGv4tGFo0E1GbnKTwnH7dA17DUFxtpTAkuhtmVRU VBmBkF0yM1l6/dWWuLQiLY8I46t5ZbcP+pmVAIsF5BqInOLtYh0RijaNjPA6D3E9brsR 1swN/FV5TztAF82bzOMeGmMqXi56MbYuEGnRoyKpl869Qsel+e0KjI2BJTjvqfKh0Oo3 tSJWtEyPAS3lWzS5L4USyGplWbB+PVohb42HIL3PkMORb1VZEMGEfoZ4FWz5Dxufm7pe ntEg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=SWm6Cn33FgupTONdXRmpgdbkGUHOBHAWZIwWJ5SRXmc=; b=rtPpLGpM/iQiUeHEplAe/NeVjcT8fZCBHcvSQUtPSjXsk4XqWgpLw9+KiOpGkX+Lfl 4JA5uQ7kNjeXN0XVw4K0pWgI3wm3O79v5pNkud6/1pibey4L8PKl1OZtUtxi0UAhMcM8 9t4v3/lq8g7jeQiz+d2vmHElpdxqDyl7UfJzKE/lrSmHGUsq3rMi5odGcJkmFuPEbizp 4nK75mEJoJN9zsBqpfluojO1XtioVPxoF2wgbvRixILfEz6a/1F95UN4YPKwiFiFmZpR ZLXimw8q9AFWQQoALWzIlinRdaXRnwu6EYh22m22cA/Xy+in2zaYsm5n7c5z/25ips6q jn4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=ZjayEgwc; 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 a16-v6si3184490pff.43.2018.07.18.07.25.17; Wed, 18 Jul 2018 07:25:33 -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=ZjayEgwc; 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 S1730735AbeGRPCM (ORCPT + 99 others); Wed, 18 Jul 2018 11:02:12 -0400 Received: from mail.micronovasrl.com ([212.103.203.10]:44280 "EHLO mail.micronovasrl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729667AbeGRPCL (ORCPT ); Wed, 18 Jul 2018 11:02:11 -0400 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id 46E97B00779 for ; Wed, 18 Jul 2018 16:24:01 +0200 (CEST) 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:references:in-reply-to:x-mailer:message-id:date :date:subject:subject:to:from:from; s=dkim; t=1531923840; x= 1532787841; bh=WZ5goYWe8Oq6EHOATy0yRG0c44cv/dzKhK9vdPswsOg=; b=Z jayEgwc2+ZGbyEGrfgZwkfsCRwqwxFmsa9gzJjGdJoHffr/eiDelKnbT26WWgXCu 2QcClpUT04dAKYqDBH+DldpbbKe3V4FWYoacs4mqQA08Vg+J2DJJvwxSMh1/Tky/ zU2uhOiqA2byh7BQAH9rh3Yt3GWGVA6s2plB46Wc5Q= 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 Pcm9USi5H7Ti for ; Wed, 18 Jul 2018 16:24:00 +0200 (CEST) Received: from localhost.localdomain (62-11-51-166.dialup.tiscali.it [62.11.51.166]) by mail.micronovasrl.com (Postfix) with ESMTPSA id 7DF55B00049; Wed, 18 Jul 2018 16:23:59 +0200 (CEST) From: Giulio Benetti To: Paul Kocialkowski Cc: Giulio Benetti , Maxime Ripard , David Airlie , Chen-Yu Tsai , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR ALLWINNER A10), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Allwinner sunXi SoC support), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/sun4i: Handle DRM_BUS_FLAG_PIXDATA_*EDGE checking if panel is used. Date: Wed, 18 Jul 2018 16:23:57 +0200 Message-Id: <20180718142357.120998-1-giulio.benetti@micronovasrl.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180613081647.31183-1-paul.kocialkowski@bootlin.com> References: <20180613081647.31183-1-paul.kocialkowski@bootlin.com> 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. Check if panel is used. TCON can also handle VGA DAC, then panel could be empty. Signed-off-by: Giulio Benetti --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 8232b39e16ca..5c7d6ae53111 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 @@ -474,6 +475,33 @@ 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 (!IS_ERR(tcon->panel)) { + struct drm_panel *panel = tcon->panel; + struct drm_connector *connector = panel->connector; + struct drm_display_info display_info = connector->display_info; + + 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.17.1