From patchwork Wed Jul 25 20:34:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10544653 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 CC4CC9093 for ; Wed, 25 Jul 2018 20:36:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC3FB2AB3D for ; Wed, 25 Jul 2018 20:36:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0CF92AB4D; Wed, 25 Jul 2018 20:36:16 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5973C2AB3D for ; Wed, 25 Jul 2018 20:36:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 73FF46E402; Wed, 25 Jul 2018 20:36:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yb0-x242.google.com (mail-yb0-x242.google.com [IPv6:2607:f8b0:4002:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id A84B96E402 for ; Wed, 25 Jul 2018 20:36:13 +0000 (UTC) Received: by mail-yb0-x242.google.com with SMTP id k124-v6so3512947ybk.6 for ; Wed, 25 Jul 2018 13:36:13 -0700 (PDT) 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; bh=fNeUTlJ4GhpcI96stLqkvrFGlBMidcc1UWinuiedkOM=; b=uJWZC33CSsF4FKOmuskbijtkFOu9oEMdwgJKkWJdWKUJImk4Bd8p6A6EhA09GSCq/w TnhVVW3UJLdfyoHrIOnNRcKobDX4aPd86JXuZgJ6lWj5eUlquvd4Sbmh3yVBEverjOrS QLc4TP58jVt6YryCqT1TXfFUrPtKxWtK4oocnr6A2wdjaBwx3hTnBYf5wiOyzdCe7q1Y UmiAkBie4CqHOebbMk0ZYQbOf2Jfe1JZFHViRFD1fnrR+DzCiThOdEdac2vm1yTevo0o R9fYZIg+1+ivgpwXoIBDpgMglfmf7/8la7GtLTk9VSBZEzpwZt7AivPi7Evu05WDqpGR sKEg== X-Gm-Message-State: AOUpUlG/r4LWVghDEL00V+V3hJ1nDVotvu9IzZEn938wNj2vu9JuIdLr ylS+a/UWX3XHej5pjhKY97s4fQ== X-Google-Smtp-Source: AAOMgpfVjnL+pED6r8ueR8oK+1+6VAYDKIVDDnesE4vDLzQPR3M1DqzI/bMoEevYJQCHRrYlns1+5A== X-Received: by 2002:a25:ddc1:: with SMTP id u184-v6mr11405709ybg.457.1532550972869; Wed, 25 Jul 2018 13:36:12 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id f137-v6sm14692568ywb.52.2018.07.25.13.36.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 13:36:12 -0700 (PDT) From: Sean Paul To: Subject: [PATCH 3/3] drm/msm: dsi: Handle dual-channel for 6G as well Date: Wed, 25 Jul 2018 16:34:45 -0400 Message-Id: <20180725203529.164928-3-seanpaul@chromium.org> X-Mailer: git-send-email 2.18.0.233.g985f88cf7e-goog In-Reply-To: <20180725203529.164928-1-seanpaul@chromium.org> References: <20180725203529.164928-1-seanpaul@chromium.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, Sibi Sankar , freedreno@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This fixes up a collision between introducing dual-channel support and the dsi refactors. This patch applies the same dual-channel considerations and pclk calculations to both v2 and 6G, with a bit of abstracting for good measure. Signed-off-by: Sean Paul --- drivers/gpu/drm/msm/dsi/dsi_host.c | 72 +++++++++++++++--------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index 319501dcc083..96fb5f635314 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -664,11 +664,9 @@ void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host) clk_disable_unprepare(msm_host->byte_clk); } -int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_dual_dsi) +static u32 dsi_get_pclk_rate(struct msm_dsi_host *msm_host, bool is_dual_dsi) { struct drm_display_mode *mode = msm_host->mode; - u8 lanes = msm_host->lanes; - u32 bpp = dsi_get_bpp(msm_host->format); u32 pclk_rate; pclk_rate = mode->clock * 1000; @@ -676,61 +674,61 @@ int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_dual_dsi) /* * For dual DSI mode, the current DRM mode has the complete width of the * panel. Since, the complete panel is driven by two DSI controllers, - * theclock rates have to be split between the two dsi controllers. + * the clock rates have to be split between the two dsi controllers. * Adjust the byte and pixel clock rates for each dsi host accordingly. */ if (is_dual_dsi) pclk_rate /= 2; - if (lanes > 0) { - msm_host->byte_clk_rate = (pclk_rate * bpp) / (8 * lanes); - } else { + return pclk_rate; +} + +static void dsi_calc_pclk(struct msm_dsi_host *msm_host, bool is_dual_dsi) +{ + u8 lanes = msm_host->lanes; + u32 bpp = dsi_get_bpp(msm_host->format); + u32 pclk_rate = dsi_get_pclk_rate(msm_host, is_dual_dsi); + u64 pclk_bpp = (u64)pclk_rate * bpp; + + if (lanes == 0) { pr_err("%s: forcing mdss_dsi lanes to 1\n", __func__); - msm_host->byte_clk_rate = (pclk_rate * bpp) / 8; + lanes = 1; } - DBG("pclk=%d, bclk=%d", pclk_rate, msm_host->byte_clk_rate); + do_div(pclk_bpp, (8 * lanes)); - msm_host->esc_clk_rate = clk_get_rate(msm_host->esc_clk); + msm_host->pixel_clk_rate = pclk_rate; + msm_host->byte_clk_rate = pclk_bpp; + + DBG("pclk=%d, bclk=%d", msm_host->pixel_clk_rate, + msm_host->byte_clk_rate); + +} + +int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_dual_dsi) +{ + if (!msm_host->mode) { + pr_err("%s: mode not set\n", __func__); + return -EINVAL; + } + dsi_calc_pclk(msm_host, is_dual_dsi); + msm_host->esc_clk_rate = clk_get_rate(msm_host->esc_clk); return 0; } int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_dual_dsi) { - struct drm_display_mode *mode = msm_host->mode; - u8 lanes = msm_host->lanes; u32 bpp = dsi_get_bpp(msm_host->format); - u32 pclk_rate; u64 pclk_bpp; unsigned int esc_mhz, esc_div; unsigned long byte_mhz; - pclk_rate = mode->clock * 1000; - - /* - * For dual DSI mode, the current DRM mode has the complete width of the - * panel. Since, the complete panel is driven by two DSI controllers, - * theclock rates have to be split between the two dsi controllers. - * Adjust the byte and pixel clock rates for each dsi host accordingly. - */ - if (is_dual_dsi) - pclk_rate /= 2; - - pclk_bpp = pclk_rate * bpp; - if (lanes > 0) { - do_div(pclk_bpp, (8 * lanes)); - } else { - pr_err("%s: forcing mdss_dsi lanes to 1\n", __func__); - do_div(pclk_bpp, 8); - } - msm_host->pixel_clk_rate = pclk_rate; - msm_host->byte_clk_rate = pclk_bpp; - - DBG("pclk=%d, bclk=%d", msm_host->pixel_clk_rate, - msm_host->byte_clk_rate); + dsi_calc_pclk(msm_host, is_dual_dsi); - msm_host->src_clk_rate = (pclk_rate * bpp) / 8; + pclk_bpp = (u64)dsi_get_pclk_rate(msm_host, is_dual_dsi) * bpp; + do_div(pclk_bpp, 8); + msm_host->src_clk_rate = pclk_bpp; /* * esc clock is byte clock followed by a 4 bit divider,