Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1698784rwd; Thu, 18 May 2023 16:15:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ63ig2wnmLrqQLGOFPXbd6YXUU4kZlQY7ZorngOtOPXjrky5Tc/qIEnz25M90q2+BI3ICqq X-Received: by 2002:a17:902:ea04:b0:1ad:e2b6:d2a0 with SMTP id s4-20020a170902ea0400b001ade2b6d2a0mr4617644plg.11.1684451749486; Thu, 18 May 2023 16:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684451749; cv=none; d=google.com; s=arc-20160816; b=w97Qqco4aJTQwN9bI+wUzdoehoQIlb6o2gxk0MwQBeGzRjTt44gRNa6FFjkQpBrHhL KZM4f3nFmq8t3BCG3Q/GEtCpVkIynoiIRe//MNeG9IZbttmZSDTDskBAoN4RTkuwjyy6 BUniF6hTyIjYqC+yiUMXWT3NuYrC04lmtnmFlzW2oYH/VD+84Tk2zcCF1vTG/h63KQk3 eJ4EMcen/OFolCuPYiy/1Z6uN6lehPkl/W4Z2twoQwIYdsjpgRIDA5YTmG7k125N6TK/ pFtQBBStepy7LxsusiHlUFSEPScNWN1kMD124Qga2uLBZVE9WKONWbgre5gXNcwFXSaB SLsA== 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=ecbFuD3QxPryZIrTro3PTU8NirrT9CMhiKMvVewbmus=; b=tOsoUIcy3ewWMlbdp1xVroi19FX/JAKMAcsdwWzu0I/26jqczpkJWGmvodZTDFe3iz L9NnpQCRqu7W23aRFuP26TLmcfm1MrwNEn59eJUxOaM7rX1ftXN5tOroPxhhe25eZBei I3/BuSPzQSbcWwhH9wLIHIKkKUKnKiy3DizjurcX7gXy8eblqUI5oUsDR7g+2ODAPRW6 tOg9TgJE5jnx2iPxdChxgTvmzl8i7pEQ6zmS4a/n8/vmPGJbKuGvyQDRAvYI/oxuPYDG 1bazyGd+8Hpixm4orNfKrjn+R29z2K5qNETBDr8lkBbxjjhe2bJ/vMN1ZOYMmEY8vRVe lybA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=DRlxu1K3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a635110000000b0050beec2c6cdsi2482547pgb.238.2023.05.18.16.15.37; Thu, 18 May 2023 16:15:49 -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=@gmail.com header.s=20221208 header.b=DRlxu1K3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230451AbjERXHH (ORCPT + 99 others); Thu, 18 May 2023 19:07:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231189AbjERXGw (ORCPT ); Thu, 18 May 2023 19:06:52 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB18EE66 for ; Thu, 18 May 2023 16:06:48 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3354760df57so654335ab.0 for ; Thu, 18 May 2023 16:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684451208; x=1687043208; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ecbFuD3QxPryZIrTro3PTU8NirrT9CMhiKMvVewbmus=; b=DRlxu1K3ekyZ0+ZqWmJVHzlHiDTU/lo4ajzaQcfzIQ9w1xTidojcidM1YQuCK2BO3F tqm+ZiwKQY+HABU4Gtw4HBJqm1lPIhMSRQVWSSfHI0TfIILXKQfiTma7bcZcKU4cpe1T b/THWyOPH0DhPnmIn4G7LUBvawe7uAdL0LPUXnLKqFZaCVLBIJSV2og0thMmAsYuxC2P 3Hyyq5OWSb23+2Sl5QlQpW9fo4ESjElOEK1y0WYt26MJIW1+/sdM+FwA6K7xozxPAY3D RqhIyb5DLxH8L94aYNtw9AiqseUpIkFPBmnUqaFcRAM9cna6safTrKkf3sUlV4SoOoj1 JdOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684451208; x=1687043208; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ecbFuD3QxPryZIrTro3PTU8NirrT9CMhiKMvVewbmus=; b=D/5pUz0AaWkMIXG8sH0yHoaWxKaIE4lfFZMWghWd2anPacxoWGLzxKeOQ/WEaYGv2o 3O7P8qGKbe//q6d0cmCeIMHqezNK8utiJpmiNuUIL3fw8Kzv1L7p/LXf6sw1m3SwMktx A1ncOjzWXlAfe0JdS/7YFZm8BhyJdtIJiSEUQBUZKjfaAOBQZmjf2XoB9QJwAb+Pz/pT S6RpHevYUEZcTV343eh2U2NunpA/Cb2m3slw3fSV3IBPE15P8LaRhmXopHYR4Z9tU58T akvdSTtLixOxyqvgRmSElxNv/OX1b7QyEiTZOLx+muqJTb+Vxq/GTgb0mQTo+Sn8+1iJ ucHQ== X-Gm-Message-State: AC+VfDzUvXRZxXykQ7vbu4S7wpaQrxmQ7Nw/e8VfMGlrxttpTZtM5ZNz rFOV6WVkrv4D8k9NGKBJcWI= X-Received: by 2002:a92:ac11:0:b0:334:fa57:e670 with SMTP id r17-20020a92ac11000000b00334fa57e670mr4397461ilh.0.1684451207938; Thu, 18 May 2023 16:06:47 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:56b8:635c:4c7a:15b1]) by smtp.gmail.com with ESMTPSA id z12-20020a92cd0c000000b003317ebbc426sm635897iln.47.2023.05.18.16.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 16:06:47 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Cc: aford@beaconembedded.com, Adam Ford , Chen-Yu Tsai , Frieder Schrempf , Marek Szyprowski , Jagan Teki , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Inki Dae , linux-kernel@vger.kernel.org Subject: [PATCH V7 6/6] drm: bridge: samsung-dsim: Support non-burst mode Date: Thu, 18 May 2023 18:06:26 -0500 Message-Id: <20230518230626.404068-7-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518230626.404068-1-aford173@gmail.com> References: <20230518230626.404068-1-aford173@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 The high-speed clock is hard-coded to the burst-clock frequency specified in the device tree. However, when using devices like certain bridge chips without burst mode and varying resolutions and refresh rates, it may be necessary to set the high-speed clock dynamically based on the desired pixel clock for the connected device. This also removes the need to set a clock speed from the device tree for non-burst mode operation, since the pixel clock rate is the rate requested from the attached device like a bridge chip. This should have no impact for people using burst-mode and setting the burst clock rate is still required for those users. If the burst clock is not present, change the error message to dev_info indicating the clock use the pixel clock. Signed-off-by: Adam Ford Tested-by: Chen-Yu Tsai Tested-by: Frieder Schrempf Reviewed-by: Frieder Schrempf Tested-by: Marek Szyprowski Reviewed-by: Jagan Teki Tested-by: Jagan Teki # imx8mm-icore --- drivers/gpu/drm/bridge/samsung-dsim.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index e67e501c9d49..9eda8ecc4151 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -660,11 +660,21 @@ static unsigned long samsung_dsim_set_pll(struct samsung_dsim *dsi, static int samsung_dsim_enable_clock(struct samsung_dsim *dsi) { - unsigned long hs_clk, byte_clk, esc_clk; + unsigned long hs_clk, byte_clk, esc_clk, pix_clk; unsigned long esc_div; u32 reg; + struct drm_display_mode *m = &dsi->mode; + int bpp = mipi_dsi_pixel_format_to_bpp(dsi->format); + + /* m->clock is in KHz */ + pix_clk = m->clock * 1000; + + /* Use burst_clk_rate if available, otherwise use the pix_clk */ + if (dsi->burst_clk_rate) + hs_clk = samsung_dsim_set_pll(dsi, dsi->burst_clk_rate); + else + hs_clk = samsung_dsim_set_pll(dsi, DIV_ROUND_UP(pix_clk * bpp, dsi->lanes)); - hs_clk = samsung_dsim_set_pll(dsi, dsi->burst_clk_rate); if (!hs_clk) { dev_err(dsi->dev, "failed to configure DSI PLL\n"); return -EFAULT; @@ -936,7 +946,7 @@ static void samsung_dsim_set_display_mode(struct samsung_dsim *dsi) u32 reg; if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO) { - int byte_clk_khz = dsi->burst_clk_rate / 1000 / 8; + int byte_clk_khz = dsi->hs_clock / 1000 / 8; int hfp = (m->hsync_start - m->hdisplay) * byte_clk_khz / m->clock; int hbp = (m->htotal - m->hsync_end) * byte_clk_khz / m->clock; int hsa = (m->hsync_end - m->hsync_start) * byte_clk_khz / m->clock; @@ -1786,10 +1796,13 @@ static int samsung_dsim_parse_dt(struct samsung_dsim *dsi) return PTR_ERR(pll_clk); } + /* If it doesn't exist, use pixel clock instead of failing */ ret = samsung_dsim_of_read_u32(node, "samsung,burst-clock-frequency", - &dsi->burst_clk_rate, 0); - if (ret < 0) - return ret; + &dsi->burst_clk_rate, 1); + if (ret < 0) { + dev_dbg(dev, "Using pixel clock for HS clock frequency\n"); + dsi->burst_clk_rate = 0; + } ret = samsung_dsim_of_read_u32(node, "samsung,esc-clock-frequency", &dsi->esc_clk_rate, 0); -- 2.39.2