From patchwork Fri Feb 1 15:42:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10792973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71A3E159A for ; Fri, 1 Feb 2019 15:42:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 608873220B for ; Fri, 1 Feb 2019 15:42:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 542653237C; Fri, 1 Feb 2019 15:42:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA39B3220B for ; Fri, 1 Feb 2019 15:42:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726721AbfBAPms (ORCPT ); Fri, 1 Feb 2019 10:42:48 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34557 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726582AbfBAPms (ORCPT ); Fri, 1 Feb 2019 10:42:48 -0500 Received: by mail-lj1-f195.google.com with SMTP id u89-v6so6228517lje.1 for ; Fri, 01 Feb 2019 07:42:46 -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=cX9BCqEMHQCHAsrFYobLewx1bc2r/y4XH0JrehpkNwQ=; b=FwxziL6YDddDrG61jfPHgvFaJd87cBPOW3CRbYGHFBfDrM1oRDhq4vhEY1PJJ/UYyJ bkPn8082W9QCvBDVGV5vOfvJ5Er9NngoWGLfoyUd2Lp5VPWw2fWm8X0SORDRauRjEpsp YUDKEyrN0SHFzni0QlMzJilLjLpgN2FCd/v4s= 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=cX9BCqEMHQCHAsrFYobLewx1bc2r/y4XH0JrehpkNwQ=; b=q50xXsx3XiMdCdoDpOS1LUmXOLKjeQQY84tLX75tEISDF04q7qM27oSRr/qxsQhM58 BIXHhwLB34Cy+TfF6rYPSdyDFEJsQJiH6YUwCMmYcLN9JxMK7BJMVkiWWvfoJkBgGpS5 4rb4M9hGzV7H7n1xsapH7KI6kHjBNlW8YcVu7KwI46aiHVEXRhT3AIrZL9pefe72B8XV G7Y3jenvyq74eMP6sr0fdeTnq+zctyvguorMEmjSUjkcoQlPNaQ3v7Cum6j2xhZhZ5Cw irjRatn7hunbWnvYIXYYCVJBpfrRAApyt44LIPaSijYjm4YiURN7V46jk7TD79x9ZUE9 znLA== X-Gm-Message-State: AJcUuke6yoKwSNVMpkolhfOfgCwt9XxalpyyJOESjLxSxsnONwLH0jr0 ZdP/eb5cJ43AW35eUXUFDrKW0g== X-Google-Smtp-Source: ALg8bN6kVB2Bdfh3cgksQB9MNbY1YwvZ83JikXHWf0FItNqeYebHwStbdzp+0p0qdcqDmysVQ2dxag== X-Received: by 2002:a2e:4c0a:: with SMTP id z10-v6mr31858340lja.85.1549035765991; Fri, 01 Feb 2019 07:42:45 -0800 (PST) Received: from localhost.localdomain ([217.76.202.68]) by smtp.gmail.com with ESMTPSA id i13-v6sm1305712ljg.82.2019.02.01.07.42.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 07:42:45 -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 v7 01/23] drm/sun4i: sun6i_mipi_dsi: Compute burst mode loop N1 instruction delay Date: Fri, 1 Feb 2019 21:12:10 +0530 Message-Id: <20190201154232.10505-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190201154232.10505-1-jagan@amarulasolutions.com> References: <20190201154232.10505-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Loop N1 instruction delay varies between burst and non-burst video modes. 1) for burst mode panels it is computed based on the panel pixel clock along with horizontal sync and porch timings. 2) for non-burst mode panels, it is same as existing (50 - 1) Reference code is available in BSP (from linux-sunxi drivers/video/sunxi/disp2/disp/de/lowlevel_sun50iw1/de_dsi.c) dsi_dev[sel]->dsi_inst_loop_num.bits.loop_n1= (panel->lcd_ht-panel->lcd_x)*(150)/(panel->lcd_dclk_freq*8) - 50; => (((mode->htotal - mode->hdisplay) * 150) / ((mode->clock / 1000) * 8)) - 50; This patch add loop N1 computation for burst mode by simplifying existing code to support all possible modes. Signed-off-by: Jagan Teki Tested-by: Merlijn Wajer --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index e3b34a345546..a5fcee750bee 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -354,6 +354,24 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi, SUN6I_DSI_INST_JUMP_CFG_NUM(1)); }; +static u16 sun6i_dsi_setup_inst_delay(struct sun6i_dsi *dsi, + struct drm_display_mode *mode) +{ + struct mipi_dsi_device *device = dsi->device; + u32 hsync_porch, dclk; + u16 delay; + + hsync_porch = (mode->htotal - mode->hdisplay); + dclk = (mode->clock / 1000); + + if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) + delay = ((hsync_porch * 150) / (dclk * 8)) - 50; + else + delay = 50 - 1; + + return delay; +} + static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { @@ -383,7 +401,7 @@ static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi, static void sun6i_dsi_setup_inst_loop(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { - u16 delay = 50 - 1; + u16 delay = sun6i_dsi_setup_inst_delay(dsi, mode); regmap_write(dsi->regs, SUN6I_DSI_INST_LOOP_NUM_REG(0), SUN6I_DSI_INST_LOOP_NUM_N0(50 - 1) |