Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp899491rwl; Fri, 31 Mar 2023 04:11:06 -0700 (PDT) X-Google-Smtp-Source: AKy350bkIyUXEHDbVn5hQA7e4XILX/DRx9WupTmr2TiRp0Yccc95bIBhaemizgNjZS8wI8IKgF3H X-Received: by 2002:a05:6a20:748c:b0:cd:fc47:dd74 with SMTP id p12-20020a056a20748c00b000cdfc47dd74mr6193368pzd.4.1680261065688; Fri, 31 Mar 2023 04:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680261065; cv=none; d=google.com; s=arc-20160816; b=oeeEKv7x3vCUY1b5tELkVJ6YYMT8d+YMZQml2+/9I9rqDPqhC8GjwLerfTKK2U3Jsc FBUdBvSJg7R3nYpkxQgZRgAdCpffwifnPVn9yhx66EBiaJUacNGIPb1g+uYUJL+ri4XW OSf45K5nMu0nMeXjGQkOws69KgDpx+gG1hGdHLgX+7rvCPyEDqRFe/1WXVI4LCFT62n+ +pozzmW2b9ptd5kwQ/iXagb3jdLTugfe5siIp4fwHnQUky67Bb9CdptMAKoj7Zw+L5J8 xFrgmAYu1W5EF8IX9QvMD78oSTq7Rcq+b7rcqeoD3/FRXTT8sVkNmyISqqvDOgo/iATy fPCw== 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=MA7Dv2Qs3SnMl09WxFtijC9xKkxYGB+hhEONwk+AOpE=; b=cQV3dJpLh4dvtlmP6xK8LdroMl4yZjXHVbYuh9RMFAwCCtwQj0stVjUtQ8xvwpd9tr PVOtQUqpXM1urxB8LvqlxQz8wdefEvQmCPzl6vfcgMvmmRdh/0w5vsls4xY/QFF21t4g KY8hNtDBbOzWezFFt5x5JQJC/E3s4ZJ7wrjBCKm0uGDR5EBb8yAWDZCJNWfo0qQ2sHTK ce+i4QLZsWV0kkLXBk8M7TVwiOcRGr2DNHjOj0COhQBbgSrjmQbQ5LxK+R4Z5TgpUytY UYyGmZox91NhW+K3pGBYxznO2tSiiat1vEeJIaDrxcRdQqnP5JAhQrly/AwPHnb2KLdS NAvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crly.cz header.s=gm1 header.b=OkWk8cUH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v202-20020a6361d3000000b0050bcc130779si2067758pgb.28.2023.03.31.04.10.54; Fri, 31 Mar 2023 04:11:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@crly.cz header.s=gm1 header.b=OkWk8cUH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231621AbjCaLFg (ORCPT + 99 others); Fri, 31 Mar 2023 07:05:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232262AbjCaLFF (ORCPT ); Fri, 31 Mar 2023 07:05:05 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE56020C0F for ; Fri, 31 Mar 2023 04:03:22 -0700 (PDT) Received: (Authenticated sender: me@crly.cz) by mail.gandi.net (Postfix) with ESMTPSA id AA2F7C000B; Fri, 31 Mar 2023 11:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crly.cz; s=gm1; t=1680260580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MA7Dv2Qs3SnMl09WxFtijC9xKkxYGB+hhEONwk+AOpE=; b=OkWk8cUHf8T8iTP6TDIGKybBZFL7kC0usmc4QI5yJbhVu6kyvcZIbrsNgBG0GM9uIDdWlq ZyU9djQb2fU/Mqsk7fwMNTdu+qlqleXzEKz/YExzVO+ZOLRfKeCOA6M9I/nLzfhvCqfOHh uyZKWQhc4xFlkG9sl3snBvZFas0xTQl+o0kpmJ8tUF4bYPdALJVCZNokCiMvHQGcHXBn9I hJ8w0wc1+RaVoo1ctx8+bv8Nu72iosh0K9LmV5iqrB0VIX7qnBHorjNkYRO563up9mTAQ2 vfTPgaEAgoquUeQvL+3AM+TSKlZWZh+YOGssQdo9RswYH3Rmfdz23tsy66wlJQ== From: Roman Beranek To: Maxime Ripard , Chen-Yu Tsai , David Airlie , Daniel Vetter , Jernej Skrabec , Samuel Holland Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] drm: sun4i: calculate proper DCLK rate for DSI Date: Fri, 31 Mar 2023 13:02:45 +0200 Message-Id: <20230331110245.43527-4-me@crly.cz> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20230331110245.43527-1-me@crly.cz> References: <20230331110245.43527-1-me@crly.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In DSI mode, TCON0's data clock is required to run at 1/4 the per-lane bit rate. Signed-off-by: Roman Beranek --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 36 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index eec26b1faa4b..b263de7a8237 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -291,18 +291,6 @@ static int sun4i_tcon_get_clk_delay(const struct drm_display_mode *mode, return delay; } -static void sun4i_tcon0_mode_set_common(struct sun4i_tcon *tcon, - const struct drm_display_mode *mode) -{ - /* Configure the dot clock */ - clk_set_rate(tcon->dclk, mode->crtc_clock * 1000); - - /* Set the resolution */ - regmap_write(tcon->regs, SUN4I_TCON0_BASIC0_REG, - SUN4I_TCON0_BASIC0_X(mode->crtc_hdisplay) | - SUN4I_TCON0_BASIC0_Y(mode->crtc_vdisplay)); -} - static void sun4i_tcon0_mode_set_dithering(struct sun4i_tcon *tcon, const struct drm_connector *connector) { @@ -367,10 +355,18 @@ static void sun4i_tcon0_mode_set_cpu(struct sun4i_tcon *tcon, u32 block_space, start_delay; u32 tcon_div; + /* + * dclk is required to run at 1/4 the DSI per-lane bit rate. + */ tcon->dclk_min_div = SUN6I_DSI_TCON_DIV; tcon->dclk_max_div = SUN6I_DSI_TCON_DIV; + clk_set_rate(tcon->dclk, mode->crtc_clock * 1000 * (bpp / lanes) + / SUN6I_DSI_TCON_DIV); - sun4i_tcon0_mode_set_common(tcon, mode); + /* Set the resolution */ + regmap_write(tcon->regs, SUN4I_TCON0_BASIC0_REG, + SUN4I_TCON0_BASIC0_X(mode->crtc_hdisplay) | + SUN4I_TCON0_BASIC0_Y(mode->crtc_vdisplay)); /* Set dithering if needed */ sun4i_tcon0_mode_set_dithering(tcon, sun4i_tcon_get_connector(encoder)); @@ -438,7 +434,12 @@ static void sun4i_tcon0_mode_set_lvds(struct sun4i_tcon *tcon, tcon->dclk_min_div = 7; tcon->dclk_max_div = 7; - sun4i_tcon0_mode_set_common(tcon, mode); + clk_set_rate(tcon->dclk, mode->crtc_clock * 1000); + + /* Set the resolution */ + regmap_write(tcon->regs, SUN4I_TCON0_BASIC0_REG, + SUN4I_TCON0_BASIC0_X(mode->crtc_hdisplay) | + SUN4I_TCON0_BASIC0_Y(mode->crtc_vdisplay)); /* Set dithering if needed */ sun4i_tcon0_mode_set_dithering(tcon, sun4i_tcon_get_connector(encoder)); @@ -515,7 +516,12 @@ static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, tcon->dclk_min_div = tcon->quirks->dclk_min_div; tcon->dclk_max_div = 127; - sun4i_tcon0_mode_set_common(tcon, mode); + clk_set_rate(tcon->dclk, mode->crtc_clock * 1000); + + /* Set the resolution */ + regmap_write(tcon->regs, SUN4I_TCON0_BASIC0_REG, + SUN4I_TCON0_BASIC0_X(mode->crtc_hdisplay) | + SUN4I_TCON0_BASIC0_Y(mode->crtc_vdisplay)); /* Set dithering if needed */ sun4i_tcon0_mode_set_dithering(tcon, connector); -- 2.32.0 (Apple Git-132)