From patchwork Tue Oct 17 09:06:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 116039 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4637039qgn; Tue, 17 Oct 2017 02:07:18 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBQjZTPqQZQeBlM0d1C8J3NyuFTq/FVdeC064RB4Tk7s89vJo2+MM0a+6Yi3mmphq5yyYZb X-Received: by 10.99.114.92 with SMTP id c28mr10505634pgn.342.1508231238621; Tue, 17 Oct 2017 02:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508231238; cv=none; d=google.com; s=arc-20160816; b=pdNkyUBWUuNZHZQOAf07aTps4vP7Uy74WMcSVEVUMMKrHRu6v3n3u29vQr0G3YJmIT HBwd5tr0taZhOFpt1Gx2jB4gkO5AwVRITLtpohu7TRn6I4oP5lVVXgFfH43i5kNH5zTz Wyo/l4H0lQPI9PGV+w1vS9WfIqyJfhOwPiLRvKOOC7TgwZwECt+LNWz6mkEqj0AapZEf z6iYeuw8kesfQkXjLRjziHJmslWeKsKA1+DPGw5qok6vNPY0DQIEhl0uDKqggnQAZZOi g5/gOGbBHtsZmjsOqM7gKZPatGZNQ+XlzaR9QGIjnQB5fRWOxl34BjtQg13vOIU0G40e zbXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:references:in-reply-to :message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=Pp4oS9ezp6cKQoOVjvMrqdmiWYNB6MR7bG55CQSfGLo=; b=DDmwbZlX+YnRTQcTi+Qv2+t0CMmVbpsi79N9S1txPQD0QLTvjTuVVnBXWHc1C33dS4 M/6RUkCJD/imFvq4e6evCbKE0M12pAPYur7HvHFBuS+LDwjOWkVrnzgFnPy56gzgrvf4 BJ87FE6FK4RofalWA9MtD/Cklnmk202sf2xnuWZnPaETZpudcG20t4S8d8Gz/layX1Zb Oqw1Bi1GlDoxH+NpLLjwAi1feJNZ6+2RVsQEpW+OR5PC9s02tH22j95wTey9oj7mhLtX CZcDO0qN24YPyPGEZtZYD/n7c6KeWcjU0G2ENF2GNiJ+7xLQrzYWFHpvy5c/XZzskM31 Phfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id x1si5186510pgp.479.2017.10.17.02.07.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 02:07:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E2B966E618; Tue, 17 Oct 2017 09:06:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id 00F176E606 for ; Tue, 17 Oct 2017 09:06:41 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 6BB7920891; Tue, 17 Oct 2017 11:06:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 416F62088B; Tue, 17 Oct 2017 11:06:40 +0200 (CEST) From: Maxime Ripard To: Daniel Vetter , David Airlie , Chen-Yu Tsai , Maxime Ripard Subject: [PATCH 07/23] drm/sun4i: tcon: Move out the tcon0 common setup Date: Tue, 17 Oct 2017 11:06:14 +0200 Message-Id: <03df3b0c8a1823b39a2ae0b190722f3623e76894.1508231063.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: References: In-Reply-To: References: Cc: Mark Rutland , Thomas Petazzoni , plaes@plaes.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Quentin Schulz , Rob Herring , Mylene Josserand , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, icenowy@aosc.io X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Some channel0 setup has to be done, no matter what the output interface is (RGB, CPU, LVDS). Move that code into a common function in order to avoid duplication. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 7ecd4f7c8411..f69bcdf11cb8 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -158,15 +158,26 @@ static int sun4i_tcon_get_clk_delay(const struct drm_display_mode *mode, return delay; } -static void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon, - struct drm_display_mode *mode) +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_rgb(struct sun4i_tcon *tcon, + const struct drm_display_mode *mode) { unsigned int bp, hsync, vsync; u8 clk_delay; u32 val = 0; - /* Configure the dot clock */ - clk_set_rate(tcon->dclk, mode->crtc_clock * 1000); + sun4i_tcon0_mode_set_common(tcon, mode); /* Adjust clock delay */ clk_delay = sun4i_tcon_get_clk_delay(mode, 0); @@ -174,11 +185,6 @@ static void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon, SUN4I_TCON0_CTL_CLK_DELAY_MASK, SUN4I_TCON0_CTL_CLK_DELAY(clk_delay)); - /* 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)); - /* * This is called a backporch in the register documentation, * but it really is the back porch + hsync @@ -329,7 +335,7 @@ void sun4i_tcon_mode_set(struct sun4i_tcon *tcon, { switch (encoder->encoder_type) { case DRM_MODE_ENCODER_NONE: - sun4i_tcon0_mode_set(tcon, mode); + sun4i_tcon0_mode_set_rgb(tcon, mode); sun4i_tcon_set_mux(tcon, 0, encoder); break; case DRM_MODE_ENCODER_TVDAC: