Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1078432pxu; Wed, 6 Jan 2021 11:39:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1PMqbWGTvu+adPhpes7Uqg5kByG9Q+MKhQyx4j3VuPEkysBv4k3DdGeQwTKBi5C0lC5hH X-Received: by 2002:a05:6402:2041:: with SMTP id bc1mr4904473edb.369.1609961965887; Wed, 06 Jan 2021 11:39:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609961965; cv=none; d=google.com; s=arc-20160816; b=CIYE8Iv8NMkONJt0Xt1odJV3BxKdcHPdTrPNAMRMAHYgvuqASNkI2UQMAy13+E1t5U WV9ZUORJMM+m7/xZlxJRfr24cMGBxZ1jlYpoNV3mZcajQblm+FKH24zvPlWX7DYXTS14 6uHDMWUEcdkfQYzR+5j3bCHtlT1NdAidtI6BwwI+2LQNRDOJEQRQVej0ShSEStaLidBQ 29u8guD355NAYT9lP14vz9j/Kx6ZVf1tFDs5PJwwX6zaYfHAFqNC7LuzwXZN5ReTZ3zk yUvvnixpFRF94iK7brz1jg0DI1+V9RbjKIDFs6TBNBRTQxgoul/WQp6VHlxOB3enKvBt aTEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4KB7nQE2HfQNE9MLWN0xXYo5db7LaXQEjErlNoR7iiw=; b=HY9rHrmxbytqseUBQHp+HpyT6U8dEVqqPWCEvNNN7qaJFf/GHvwZOwnoGksiDnQmNS L018fWugKSyTxbNo2FlpBO0D9CuQz3uSGpcmoCa8qR+R7VuCrRRgkRdgzJ5D1QGyr0+W kYqs8kf/oOfP08bH5QChz4YsHO+OLNINFMjhyDevfD13UO1f0/HotxBfMJuV1ubxuTRr iiUe58CWwibd2jE9ByqTfksOwPVP9WL1QpurBWZxAJz6cXuEBF2WbA/BwlK7WZqOUTBv 9t5Se4/cf7uSnUnL5OQsB/TvGT0MLlTN0YZT0F+O+NxOLj3ovbNagijQGmdEKc7O87RE +QNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=bApMn1yP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b4si1224319ejv.71.2021.01.06.11.39.02; Wed, 06 Jan 2021 11:39:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=bApMn1yP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727271AbhAFThB (ORCPT + 99 others); Wed, 6 Jan 2021 14:37:01 -0500 Received: from mail.micronovasrl.com ([212.103.203.10]:59238 "EHLO mail.micronovasrl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbhAFThB (ORCPT ); Wed, 6 Jan 2021 14:37:01 -0500 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id D1720B045F1 for ; Wed, 6 Jan 2021 20:28:05 +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:references:in-reply-to:x-mailer:message-id:date :date:subject:subject:to:from:from; s=dkim; t=1609961285; x= 1610825286; bh=ve6PpitMBRMOaeoWwDbFW/+W2p3l0jAVa8GJuKa7cPU=; b=b ApMn1yPa/M9MRkOLZrYDeqI1D0qJ0zs/K4MEj3eASbCXv0hzGbkCmnpvv8YwCnR8 JzC1hi8ZRaDlTORuM0lkNBNqCmhWUSZS9kyG7GZfXdl1uUWzvuovJGZ3srZqxp9i a2JYntIWh2BNlRNSOruxcDm1PQ3Rrk8EohRME9GkRs= 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 qiewOOqfVPTa for ; Wed, 6 Jan 2021 20:28:05 +0100 (CET) Received: from ubuntu.localdomain (146-241-198-163.dyn.eolo.it [146.241.198.163]) by mail.micronovasrl.com (Postfix) with ESMTPSA id D3D2DB04586; Wed, 6 Jan 2021 20:28:02 +0100 (CET) From: Giulio Benetti To: Maxime Ripard Cc: Marjan Pascolo , wens@csie.org, daniel@ffwll.ch, airlied@linux.ie, treding@nvidia.com, Jernej Skrabec , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Giulio Benetti Subject: [PATCH 2/2] drm/sun4i: tcon: improve DCLK polarity handling Date: Wed, 6 Jan 2021 20:28:00 +0100 Message-Id: <20210106192800.164052-3-giulio.benetti@micronovasrl.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210106192800.164052-1-giulio.benetti@micronovasrl.com> References: <20210106192800.164052-1-giulio.benetti@micronovasrl.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It turned out(Maxime suggestion) that bit 26 of SUN4I_TCON0_IO_POL_REG is dedicated to invert DCLK polarity and this makes thing really easier than before. So let's handle DCLK polarity by adding SUN4I_TCON0_IO_POL_DCLK_POSITIVE as bit 26 and activating according to bus_flags the same way is done for all the other signals. Cc: Maxime Ripard Signed-off-by: Giulio Benetti --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 20 +------------------- drivers/gpu/drm/sun4i/sun4i_tcon.h | 1 + 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 52598bb0fb0b..30171ccd87e5 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -569,26 +569,8 @@ static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, if (info->bus_flags & DRM_BUS_FLAG_DE_LOW) val |= SUN4I_TCON0_IO_POL_DE_NEGATIVE; - /* - * 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 (info->bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE) - clk_set_phase(tcon->dclk, 0); - - if (info->bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE) - clk_set_phase(tcon->dclk, 240); + val |= SUN4I_TCON0_IO_POL_DCLK_POSITIVE; regmap_update_bits(tcon->regs, SUN4I_TCON0_IO_POL_REG, SUN4I_TCON0_IO_POL_HSYNC_POSITIVE | diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h index cfbf4e6c1679..0ce71d10a31b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h @@ -113,6 +113,7 @@ #define SUN4I_TCON0_IO_POL_REG 0x88 #define SUN4I_TCON0_IO_POL_DCLK_PHASE(phase) ((phase & 3) << 28) #define SUN4I_TCON0_IO_POL_DE_NEGATIVE BIT(27) +#define SUN4I_TCON0_IO_POL_DCLK_POSITIVE BIT(26) #define SUN4I_TCON0_IO_POL_HSYNC_POSITIVE BIT(25) #define SUN4I_TCON0_IO_POL_VSYNC_POSITIVE BIT(24) -- 2.25.1