Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2146734rwd; Wed, 17 May 2023 06:27:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5jqPJRwvWDBa2orqSdlWy0y0yTTi9KUEDusqFkWUDMV503x+Fl5cmKecVSeQRgR9/1IuRa X-Received: by 2002:a05:6a20:7349:b0:104:2d89:8f5d with SMTP id v9-20020a056a20734900b001042d898f5dmr25453455pzc.10.1684330042062; Wed, 17 May 2023 06:27:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684330042; cv=none; d=google.com; s=arc-20160816; b=cw/o71gtTdwalCZOaCvVOjVAEaPZmmrWDe2ZVJvxI0uDNRl7vfPN6/HkCtYt/Gmza0 9MemwdQs1tJH2MeXCdp1/uU639Acd3qyY4qUklF0bFHJ7JMzFqubMCXsqnbKiruZgpFp b6IECLxayL/OCLq1c4BJ0bsinQ9GVnqhq5vsAfy/c9+Y9WpbyYdVOymyzTwT0weS9vru uzm73u3rIeTY2fzc+WMqJ1RHPVStX2ez1c2PL9q1x2d+vuvWIvz4i6f1PvTxEnwXfcSn zRZ2aSCPfB+Z9yPzhUzk3pezEpCV/viWxI/ZIgDUphXThL5PdEvnRCnmLaabuUCGHJLu iDxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=pht+iYdDqCU6SsYdyqD2dF3DX3Qy13QORms11nSeyIM=; b=Uk54mg7wjvUCrfjcyPSKup+WuxY5JTtE0PFvjzhRabtTMDLhaVAoYRltXA+jNASX8J cFGEkedED2TR8M6D7quKyfG9HD/F/zGk6B6TaurI96c57XEdh0iZnR/lWenCkiGryg90 dCLWpB2a47pxRnGCzadC2GGBwOgYbi0xemsp6bOvI0cHJW2qm/Ci164BWrwjn4s6cxQy lGstmbd8jcMhEuQPoadMmuTuyUIRL3kj2VedCQG7GvuSe8oZ4Y26esrSJ1qM4j13bRX/ gVrzXEuZgVGebL2CRBwM4a4xKfvrBPg3zoYYmy2WpbqNgU/7fAYzTJc3gSA25ZzUoiV1 AlYw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v202-20020a6361d3000000b0052c4296d8casi20231148pgb.325.2023.05.17.06.27.07; Wed, 17 May 2023 06:27:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229529AbjEQNBw convert rfc822-to-8bit (ORCPT + 99 others); Wed, 17 May 2023 09:01:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231796AbjEQNBs (ORCPT ); Wed, 17 May 2023 09:01:48 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36539AA for ; Wed, 17 May 2023 06:01:45 -0700 (PDT) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pzGmd-00020O-ER; Wed, 17 May 2023 15:01:35 +0200 Message-ID: Subject: Re: [PATCH V6 6/6] drm: bridge: samsung-dsim: Support non-burst mode From: Lucas Stach To: Adam Ford , dri-devel@lists.freedesktop.org Cc: Marek Vasut , Neil Armstrong , Jernej Skrabec , Robert Foss , Jonas Karlman , aford@beaconembedded.com, Frieder Schrempf , linux-kernel@vger.kernel.org, Laurent Pinchart , Andrzej Hajda , Chen-Yu Tsai , Marek Szyprowski , Jagan Teki Date: Wed, 17 May 2023 15:01:33 +0200 In-Reply-To: <20230515235713.232939-7-aford173@gmail.com> References: <20230515235713.232939-1-aford173@gmail.com> <20230515235713.232939-7-aford173@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 Am Montag, dem 15.05.2023 um 18:57 -0500 schrieb Adam Ford: > 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.  > Same as with the earlier patch, this needs to be documented in the DT binding by moving "samsung,burst-clock-frequency" to be a optional property. Regards, Lucas > 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 > --- > drivers/gpu/drm/bridge/samsung-dsim.c | 27 +++++++++++++++++++++------ > 1 file changed, 21 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c > index 3944b7cfbbdf..03b21d13f067 100644 > --- a/drivers/gpu/drm/bridge/samsung-dsim.c > +++ b/drivers/gpu/drm/bridge/samsung-dsim.c > @@ -655,16 +655,28 @@ static unsigned long samsung_dsim_set_pll(struct samsung_dsim *dsi, > > dsi->hs_clock = fout; > > + dsi->hs_clock = fout; > + > return fout; > } > > 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; > @@ -935,7 +947,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; > @@ -1785,10 +1797,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_info(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);