Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5035056rwe; Tue, 18 Apr 2023 00:45:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ZgYNd2e8m822UX2UXEhaOIBcEU+4wMEBSk0KOO7r2V5q4EkDkAn4LTy2mbRG4hy0X9ucAU X-Received: by 2002:a05:6a20:4429:b0:f0:6f7f:4f2b with SMTP id ce41-20020a056a20442900b000f06f7f4f2bmr3444911pzb.1.1681803928733; Tue, 18 Apr 2023 00:45:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681803928; cv=none; d=google.com; s=arc-20160816; b=cXEPXeLAJaY6+HikWAI3d6i/AoPYDh7W/YkIO+4OYIb4hsYVn6Mevi/fKca0OEDhvC rVvEPUOP7TYikk7U1F5MHxkGbZzq8GKRUQkN2JcWrxyRxvzvgB4t6V8zo1iGoRkys5Io NGaaBXVmrijJle+LdgrS4ttr4r5jl/niGnCmBZ2gWipwPnuBRjZrxTcVZDQ6KL2OVflJ JiZnj45kIRGmz1kwD2LEuKrwkB0oaOL6mvvdhgpluWwE0DN8wdmmO/iXfv30CKnbUCwQ wRGIe4Xo71L7bmLthefS9DUuauaHtTH31Ch9EkuyI7N3KnkrVzikp+tZZ7o0LuNWBSMa ZT2A== 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=oiKd2IuKA4YkpgpZ4duXzrqvD45gkt7pR/TQQdlWIOJEaV5x9G8Q73asTNFt3yjeWZ Pw2M+l0GWhGXZsMVJ8XoQnHvijAN8SQ6FDa+9Nxq+JqT+AMj/FEhXFo2ls84ATdx/ssK 9D9JgxyRNDUN2FXyTgg0R58wZT9LZevZ9Ao4+i5zVFAu7I552/2Sz5eQjlbxp8By+5mg SUtzlC64+ZWEzc6zQt8MP+8GOYn5zVsW3Frkn2MFsA6f5ZdYjvIpmgDjdSYe155zPkXv elxRsMltUEvB766J9peUZmFVnxnaL/RoaFdLi5qUflcF0vWk3WZzHXYJbCjT47kliPJ5 pgBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crly.cz header.s=gm1 header.b=GGo8ZSJu; 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 w22-20020a631616000000b0051b423d966csi13163340pgl.280.2023.04.18.00.45.17; Tue, 18 Apr 2023 00:45:28 -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=GGo8ZSJu; 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 S229889AbjDRHlr (ORCPT + 99 others); Tue, 18 Apr 2023 03:41:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231241AbjDRHln (ORCPT ); Tue, 18 Apr 2023 03:41:43 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C8256A6D for ; Tue, 18 Apr 2023 00:41:26 -0700 (PDT) Received: (Authenticated sender: me@crly.cz) by mail.gandi.net (Postfix) with ESMTPSA id 5CF37FF818; Tue, 18 Apr 2023 07:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crly.cz; s=gm1; t=1681803671; 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=GGo8ZSJuCFf8PhmINCprVl3K0jroP984sMuxT1hhoVj7KXeXwt5lwaC1xXSQSse5e7Z+GX iyk+LFcxnTdfDqW4I8lFY9cKpqr+Rqz7yvhi65RVghDQzTPb2NR9uxc59vLxsbNdWcpcx8 mB4ksq+3XoPnpGctNNIrIiRFjNH3miTpSwFtEzhbOr+pOW1Ny4NuPFXobAPdA4PxpJm88T eTUxZiSsIP5Wd7oeLV5lZ1E/IfYPnaQZcv7Dtfd48/+iaPLhUI8/TDSOW4SiR/r3I+SNxk 4DnOAslp97cT8Df/zkoGbLEGBa/Ghx8YH8/hC7+nO9CRJzBFXhgdGezTL0ajMQ== 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 v2 7/7] drm: sun4i: calculate proper DCLK rate for DSI Date: Tue, 18 Apr 2023 09:40:08 +0200 Message-Id: <20230418074008.69752-8-me@crly.cz> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20230418074008.69752-1-me@crly.cz> References: <20230418074008.69752-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, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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