Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp362497rwr; Thu, 27 Apr 2023 02:19:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5xhnPBXM5OQgSD2h1lM8k8lPWi1fYUMqOKpYTxOaI+spkg6WCOp2e0lJ8o7gSuP21W8Qly X-Received: by 2002:a05:6a21:78a3:b0:f1:1ab5:5076 with SMTP id bf35-20020a056a2178a300b000f11ab55076mr1075992pzc.2.1682587189247; Thu, 27 Apr 2023 02:19:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682587189; cv=none; d=google.com; s=arc-20160816; b=NKghrXdj7HON/A9rtT/PdaRCmMV/hlY0mEWVlaEZUpV6nvYK/LJcYz+rs7nOBd+DdB d8Ihd/+pcwF4e1O2uq9hg8DysnzbgUIfm9tnh4RUJcZaggsV3Sp2t+EZfPppy0DJjZ7X 1l8EhC24DHa17I7pDv5oUQZJuRbXuO7txEA59jettwhVqwHbVQ7AMq9KS3NnSLEIrFf5 aZtbtjW7Pmbk372YRhaIYNfbIp7m2ccj6Y48ddhFhDCRSA0ezaHLfSZJhG2IM1CZrtUD PgZwROgTeWU7NGRiRqDKF5AoJeEScJNha7vk6rNZogAF/tpp+qGR1v3VZu/r4Eh3wW8H MgmA== 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=RXbaBNxkiTTV4hInjji5NkCrdDSarnLLhwu9cO3OfTc=; b=nMXDvzBPs6T0whvbFeGrxOUYZ9/bGXWBbjvUEINlxV/iwbgiVqzhHLJWbSRb97nOTQ OEP+P4srxKEmgnD0SjEu19iSeYRXkP2kbVcpBsUbFbuNHwMF/vaCQcgH8A+ogpgdIco9 BysIQ1t+/+g0EqpgQ3CdCQGCjHRREYwsQjmEboSRZQ9Xm1AbqidBaGueRU27XXwCXeoi rKBYKNub2fIkuz9X9yiPiy4CxRKPnocerINDQyeBTjvn+DfOXLX+CbzLnobeb3V7jDAG w/o+0UXVv4d2xJfhD7GnaL+MH902SK9SEUER0Q9HynZdfcL50ngPrSWGA5KwctTU/iLN ybAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crly.cz header.s=gm1 header.b=dQ4NDlSI; 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; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=crly.cz Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a6-20020a634d06000000b0050fa328e128si17291546pgb.419.2023.04.27.02.19.35; Thu, 27 Apr 2023 02:19:49 -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=dQ4NDlSI; 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; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=crly.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243230AbjD0JRq (ORCPT + 99 others); Thu, 27 Apr 2023 05:17:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243320AbjD0JRZ (ORCPT ); Thu, 27 Apr 2023 05:17:25 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9E334EC1 for ; Thu, 27 Apr 2023 02:17:10 -0700 (PDT) Received: (Authenticated sender: me@crly.cz) by mail.gandi.net (Postfix) with ESMTPSA id CA9521BF20A; Thu, 27 Apr 2023 09:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crly.cz; s=gm1; t=1682587029; 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=RXbaBNxkiTTV4hInjji5NkCrdDSarnLLhwu9cO3OfTc=; b=dQ4NDlSI58cJBb7iv0QJQowSzJODauNypp2m+QipibmpGjXssSEAgumLdAxs/1KE/x+dyW iZQki3PXi9o87QJvuzqpiZr+gCbfZUC7VaVLjLPDf78HsWOwgcIwc3cgr/vBCoyFaYKpC/ a/RxZyyxDw8hNDyTvDrhMbfBWRoPBz4KRklb/EVp7vJBSA/wiyQT9LDhyDctFFLv8Sv4I8 a8xlWsQY8Y691V4qkX9dXYKccZUpOGcdDFM5/DYylarPGuEl/t5Vs4wIM1v8mmXwVrsX1e bAKFe20aDWyhi/eHbtziQRQ1EYAGc/mbPCy6qCEdMD4hBMfM7oK2D77UtOQycw== From: Roman Beranek To: Maxime Ripard , Chen-Yu Tsai , David Airlie , Daniel Vetter , Jernej Skrabec , Samuel Holland Cc: Roman Beranek , Frank Oltmanns , Icenowy Zheng , Ondrej Jirman , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 7/7] drm: sun4i: calculate proper DCLK rate for DSI Date: Thu, 27 Apr 2023 11:16:11 +0200 Message-Id: <20230427091611.99044-8-me@crly.cz> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20230427091611.99044-1-me@crly.cz> References: <20230427091611.99044-1-me@crly.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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.34.1