Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6179669rwr; Mon, 1 May 2023 18:19:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6oqSIyDbdP0m1TvhdwuHHOjJwp1P8D6tFDH1+Ts0gJK/v2GHVfy4VHf05hLZurcx8tWNyM X-Received: by 2002:a05:6a00:1950:b0:628:1b3:d499 with SMTP id s16-20020a056a00195000b0062801b3d499mr23630386pfk.21.1682990354530; Mon, 01 May 2023 18:19:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682990354; cv=none; d=google.com; s=arc-20160816; b=bxWcB5knouuJBe5BVBU8+FDEJ3NL09C+B09nrUmR87hhPYiDYCbhRA9wc32EbCJgPI K+9S6Lwy0/n/84FixLFrnYlicePpUE05/wTPODIHedcMAbluN1cnDS3jUy+ekqJatlBt jz1gQxZX1uCEiPGNqk3LskLsGNMAx6uU7I89OdE77MUjIX+Up3hKtyfSKKkPyxYa1+gx i+5OYpEKYlnSucTQpzhgclNWapFBb1UpitqL9ns8/21oU05E27YeYovkk39JWreEDwnU 1eSxyRuIeT99PG4Ng/VXp3dRlXdNpw8aPNJjJHsc+qw6S9ps33+KbI7JSAvaSa+T8O54 e3Kg== 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=LILHGDPu6PO8q8DSVW+PJ0k8lNeferhINno8wB3FCRc=; b=xm/ZopRhlmRJjH0N82GbIxssRY561/f80N+jtiKLenoIvIOgMbROskB2c99v31kLF4 gEYpzd1iMCRafKXGjFc/2FoAo7+ZCUxQe1VnwcOmzbmG75dAiILvKNyTU7N46JoR9O/m aTKiRWIZiu9qLnOp2DD+iQcR36i83lYqMi+iBqvUEEmnn0tyyaf2qPgGtcpwCtlfXCOT u4iNChlBKUxLF+LrqKkfQbDNV7S6UrrRJERJ62lf5lig82ve/LVxN9QXouPS8jKTCKua ior9SAr+Min+MhMJgAxQUtpMlFx09Y2X0j/ug0XR3cIkTXXr12IZfI+55lkJzoJmxNFG M5lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ODN1m4Vv; 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 g14-20020a62520e000000b00640f213b6fesi16104772pfb.240.2023.05.01.18.19.03; Mon, 01 May 2023 18:19:14 -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=ODN1m4Vv; 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 S230008AbjEBBIc (ORCPT + 99 others); Mon, 1 May 2023 21:08:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233338AbjEBBIT (ORCPT ); Mon, 1 May 2023 21:08:19 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C75D40D0 for ; Mon, 1 May 2023 18:08:18 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-3310e9368eeso5471105ab.0 for ; Mon, 01 May 2023 18:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682989698; x=1685581698; 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=LILHGDPu6PO8q8DSVW+PJ0k8lNeferhINno8wB3FCRc=; b=ODN1m4Vvr99jSc5D+ktc9kqN9l0wREObKD2jZ82mb/T09ybjsKvdPnQKZgSEPzg+Wr cOWG1i4r7WnsFgctCGcr1iSXJoKN9/VP2RBn16nAyUywLVzHJ20PenJI0V2ZTzbcFRQh 9fi3c5cuq/hK6u0xwonLVbDTkZiKPJJzzOdkD+Hssd0ATZR1083DUs6YZwlPZuT8OhpC bWf+ZBz1Rcx3WHiF+XNgKiaW7jH5x+wBZbvEkAvoPQNXVGUaRnh4rbjF4H+llZ/7fYkT 7BXa3Mcywh2PLAhyHhiVQmY+994phYiq7SoEWAQjoInFTpomEIJZrBW6byMPnRXdRL1m uUzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682989698; x=1685581698; 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=LILHGDPu6PO8q8DSVW+PJ0k8lNeferhINno8wB3FCRc=; b=dFMlpsq8DLWtaTvJhbNcdhCxGh9r05n+pOeqUdMlibRmbH1PjkfZU15SCFNjNqyjnJ E6W6J0MHdts3XFswjVcDKRS0fVbTXkvL0z74XevBsQ+E14boKulE+yV6dwSrG01dGT+b 7fkSEleOyFJogPRbdJE0YC9zJe7uKUigUSgMKcB1KWu6JJBPx4ilJhovqY99mP915IFC YqqfoexEV0zwEMhbQsq6xw7N1eCT+c5QRq7LIL7TVjZLWsFVViU7QpDxONCZesd6Ev4r 7mc2vi7CDmfVcTD6aD06H7fO9S0GgmYBJtl3F6DZ3X/U/8CYrGO783upzllgvr5PjWPT 40hg== X-Gm-Message-State: AC+VfDx28+vXZ2+tzMJh1+1bVsgL2ndr7VPkogzAIe4b51rdsk6Oo10s aj43CjB2R9ZzZ2u0aoa4IA4= X-Received: by 2002:a92:c94c:0:b0:329:3f00:79e1 with SMTP id i12-20020a92c94c000000b003293f0079e1mr9698503ilq.18.1682989697613; Mon, 01 May 2023 18:08:17 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:8257:a536:d7fc:1919]) by smtp.gmail.com with ESMTPSA id f16-20020a056638329000b0040fb5d5429fsm4836329jav.131.2023.05.01.18.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 18:08:17 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Cc: marex@denx.de, aford@beaconembedded.com, Adam Ford , Chen-Yu Tsai , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Inki Dae , Jagan Teki , Marek Szyprowski , linux-kernel@vger.kernel.org Subject: [PATCH V3 6/7] drm: bridge: samsung-dsim: Support non-burst mode Date: Mon, 1 May 2023 20:07:58 -0500 Message-Id: <20230502010759.17282-7-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230502010759.17282-1-aford173@gmail.com> References: <20230502010759.17282-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 an HDMI bridge chip. This should have no impact for people using burst-mode and setting the burst clock rate is still required for those users. Signed-off-by: Adam Ford Tested-by: Chen-Yu Tsai --- drivers/gpu/drm/bridge/samsung-dsim.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index 99642230a54a..53099461cdc2 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -657,11 +657,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; @@ -1800,10 +1810,11 @@ 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); if (ret < 0) - return ret; + dsi->burst_clk_rate = 0; ret = samsung_dsim_of_read_u32(node, "samsung,esc-clock-frequency", &dsi->esc_clk_rate); -- 2.39.2