From patchwork Tue May 2 01:07:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 89224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp290528vqo; Mon, 1 May 2023 18:34:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7IcMJIFsHjzqXjMtuwpPr3iSQJp/CK0BZjy0AiyTzVmo1Z4sd+/STzW1c/G8q9KBS4skhr X-Received: by 2002:a17:902:ec84:b0:1ab:515:27c3 with SMTP id x4-20020a170902ec8400b001ab051527c3mr2582873plg.47.1682991280269; Mon, 01 May 2023 18:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682991280; cv=none; d=google.com; s=arc-20160816; b=t9Afv5g0UgUJbTMRqwzULNOZxQ8HSJ3e073Ag8GJN8NnHYpgS6mMsRpOdviAdk2ksg LrQrrTMsy7FR5pwF/Hrkffknh4G8ON69zgqTRnls66s0CyEkSKynL+U8yjq4+dXfidj+ c+k1ibcZEMEvn+RxFNgaK1KHXT3Anr49lkzHE2+d2/J6bDxn3YweGinl6lFmO+3bY+ll JBVzGiNlsRuR4Qt6kwmt2XYzXf6xzb+Xk7K8OSFTksVhMyE+Vd8pyQUqJpOxh9P6/uJW jUacG6Crkrg7ws5peujX0w91iRBh8k6G+7ievmUw+yIxD6FGaYB9bZNttKcatgPX7Ono Oieg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n17-20020a170903111100b0019e2bd0fea8si29722895plh.143.2023.05.01.18.34.25; Mon, 01 May 2023 18:34:40 -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 S232627AbjEBBIc (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764744264902808271?= X-GMAIL-MSGID: =?utf-8?q?1764744264902808271?= 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 Tested-by: Frieder Schrempf Reviewed-by: Frieder Schrempf --- 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);