Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2392968imu; Thu, 24 Jan 2019 12:00:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN5b9N5ZIYNNEPHsMJuGYD7C3ICX5luQTE/YAcksNpqxjs5JGG2fv18qpFUS5+910sLkDKp4 X-Received: by 2002:a63:151f:: with SMTP id v31mr7077567pgl.34.1548360041504; Thu, 24 Jan 2019 12:00:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548360041; cv=none; d=google.com; s=arc-20160816; b=pvcOvP1jWzALLamUhmoMjLjZceg1jZByn+cs4f8yMTTmedyhlCZQivrwg/JTbG9rCQ cDdH1vdunO0VmH/UO/U5laZbbHAgDW1BR6I4YVyySDCnoLBe/86n00C4Mweplylitsoy q6EwOrss/Egf76I7Pm/VOwJcxGtU5ZtiGoElhG9j8LCjOS+QNrYQJwA/Vxsw6BVHu9es NvcKWOtMBLhLXpJLKpLP5G3SzJ1+prS3iNlgPsUucyBvJV7DytfZnWK+vi0uTM+XoZRL ad6AVf5ea/YbLHAOFRs12uBOuHBR9RK03gJx2OuxlN4Yjk7kc+AC2s7Fo1I0nIQytP+r Gbiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=anHsrjMbLEFT68kAkE2t/9/N/A+LioJPwdjsAaUWV6M=; b=f1YxHFQJ4daMRSDsL0PkGiXOBU+XYQ6ywPCMjbTbH5uXCLfJg/RXrxG1BkMFyYb9eF DiaczqEiIqorRH2YFZjrML/2f9ix6uCf7ZlywWaic5I9rxD217dtZMu6JySMQxAK00qx 0qezx2HZ7FM5vsAY7kOpM4GvaLkkwA1sco4K90UWA8mdkyTeGzaGsVWAqwp4BW5pd/QR AGYd9M2+sWXhYl1IkaV0PSDn+15FkIrNbjAAFVbDmjdlzLNI2C1A4OMqZt9M+8ZdVMj9 SM6rShx4e/4zlj8U5igEw+lvA2DoWOydOXEdygZevD4WrrVA7SPKkzZbyu4Lb47R2h+V clgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Mr+1LHQb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j61si22973434plb.232.2019.01.24.12.00.26; Thu, 24 Jan 2019 12:00:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Mr+1LHQb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731884AbfAXT7l (ORCPT + 99 others); Thu, 24 Jan 2019 14:59:41 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44155 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729731AbfAXT7k (ORCPT ); Thu, 24 Jan 2019 14:59:40 -0500 Received: by mail-pg1-f193.google.com with SMTP id t13so3114644pgr.11 for ; Thu, 24 Jan 2019 11:59:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=anHsrjMbLEFT68kAkE2t/9/N/A+LioJPwdjsAaUWV6M=; b=Mr+1LHQbGiGFa9RRSZEvmtvsm2fe15PzViT5Ls9dOEOJBDRMewkDbH+rFr+ohoXcRW yuQgBYFuy7z0M6CXzdfYUqwUxIE0QEikvpvuRXGf/52K1ghAEpq9fnWC7JDdBTmAh0sB nnud8zcmJgemxCqCzVmw7LD/rm+zBvoWVSZ9c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=anHsrjMbLEFT68kAkE2t/9/N/A+LioJPwdjsAaUWV6M=; b=XzmmrFDR4zCQP++Peqbn+ixlT7grlxJOxcH4Ks4XTSxoMhWB0wM3ir4i0Z3ppdqxOd /Nt2met+TtZRPJgUVwLZRiMEgYfl+HftsrI1etuiu2P/OZ5S2PLuwup3Vq0zcY7MrIlg THAxS81C69WMcdEw2yAGgfaMhxfBRUcxkIxOfszaF6u279QuqKhgVf09Fg6qj+E12wDi AkHsqA+dWliFnTiZNQMSvz7o68wjy+xBcwVX6B5Lq8jxP8RcQsWCclOEqGe5hgNLIxTI RnF+EzHz/BC1zlQxxCesD5Af78YrI8QaC0A+44uBjHEv5P/UDyznJRFSA5TBVZ3Zz1ta 7yqQ== X-Gm-Message-State: AJcUukd/GBmJZC/WuFIm5zwzQ6bBX3R7YprIXfvTaw3W4n46HHCoRmVu 12xgLUuipBkgenSgSAAulRCxYg== X-Received: by 2002:a63:2109:: with SMTP id h9mr7134428pgh.277.1548359979766; Thu, 24 Jan 2019 11:59:39 -0800 (PST) Received: from localhost.localdomain ([115.97.179.75]) by smtp.gmail.com with ESMTPSA id x11sm61637003pfe.72.2019.01.24.11.59.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 11:59:39 -0800 (PST) From: Jagan Teki To: Maxime Ripard , David Airlie , Daniel Vetter , Chen-Yu Tsai , Michael Turquette , Rob Herring , Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, Michael Trimarchi , linux-amarula@amarulasolutions.com, linux-sunxi@googlegroups.com, Jagan Teki Subject: [PATCH v6 04/22] drm/sun4i: sun6i_mipi_dsi: Simplify drq to support all modes Date: Fri, 25 Jan 2019 01:28:42 +0530 Message-Id: <20190124195900.22620-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190124195900.22620-1-jagan@amarulasolutions.com> References: <20190124195900.22620-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allwinner MIPI DSI drq has enable mode and set bits. - for burst mode, drq need to set enable mode bit. - for non-burst video modes, drq need to set enable mode, set bits for those front proch greater than 20 and for rest drq is not used. This patch simplifies existing drq code by grouping into sun6i_dsi_get_drq and support all video modes. Signed-off-by: Jagan Teki --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 39 ++++++++++++++++---------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 0f02bcc997a5..16a86d35dc5a 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -354,6 +354,28 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi, SUN6I_DSI_INST_JUMP_CFG_NUM(1)); }; +static int sun6i_dsi_get_drq(struct sun6i_dsi *dsi, + struct drm_display_mode *mode) +{ + struct mipi_dsi_device *device = dsi->device; + + if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) + return SUN6I_DSI_TCON_DRQ_ENABLE_MODE; + + if ((mode->hsync_start - mode->hdisplay) > 20) { + /* Maaaaaagic */ + u16 drq = (mode->hsync_start - mode->hdisplay) - 20; + + drq *= mipi_dsi_pixel_format_to_bpp(device->format); + drq /= 32; + + return (SUN6I_DSI_TCON_DRQ_ENABLE_MODE | + SUN6I_DSI_TCON_DRQ_SET(drq)); + } + + return 0; +} + static u16 sun6i_dsi_setup_inst_delay(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { @@ -381,21 +403,8 @@ static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi, static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { - struct mipi_dsi_device *device = dsi->device; - u32 val = 0; - - if ((mode->hsync_end - mode->hdisplay) > 20) { - /* Maaaaaagic */ - u16 drq = (mode->hsync_end - mode->hdisplay) - 20; - - drq *= mipi_dsi_pixel_format_to_bpp(device->format); - drq /= 32; - - val = (SUN6I_DSI_TCON_DRQ_ENABLE_MODE | - SUN6I_DSI_TCON_DRQ_SET(drq)); - } - - regmap_write(dsi->regs, SUN6I_DSI_TCON_DRQ_REG, val); + regmap_write(dsi->regs, SUN6I_DSI_TCON_DRQ_REG, + sun6i_dsi_get_drq(dsi, mode)); } static void sun6i_dsi_setup_inst_loop(struct sun6i_dsi *dsi, -- 2.18.0.321.gffc6fa0e3