Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5204922rwr; Sun, 23 Apr 2023 23:59:41 -0700 (PDT) X-Google-Smtp-Source: AKy350ao24MD9hEc5F4zI7NxpybXGREJ52SyCGlqhnDGY2KsjSRM6ZWwInOLSiJeFSFoRFrK0A5p X-Received: by 2002:a17:902:ec90:b0:19d:1bc1:ce22 with SMTP id x16-20020a170902ec9000b0019d1bc1ce22mr17542280plg.5.1682319580953; Sun, 23 Apr 2023 23:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682319580; cv=none; d=google.com; s=arc-20160816; b=nN7YNBPUvr7MM5H0zAI9pyRovraw4kynM4eNqH1iOwCqkNmMjex2uoccn2eG5puJUv OI2C5pxhG1Alqo0Y6FELuTL+398lPk6zVB6h4S25TmBSBn/LNgvwKZwdRtSP3ZvYVMFI sGBOTD36AcchdesepnJpxPLvqpptdpoiOMadGYQJgRGgsO5w5QEqO/FLAb4SVmvWK4h0 Wj8ItGDgTHtIAMQIH21t5isGXTQnDnlVmrYqgPmz9XGTChLwZiL/QGLuDj8266cJT5Xs EuWEv/f3LFKMVa5MUKml0kSBEA18cavDmwgC/AatOKeGqH/tNT+HmFo+ql+xeczc58k8 LC9A== 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=yfkXxkxahcXQynHppV4bEamZ2J9FM2Yh16lDkn3On5A=; b=f1yi1+M/kQyqsabzB+7Q6vbyXQFsfVMJYf4btceKhuAyEppiVmpqAHck2gqsZtLH1D OX+2JipS2a5fGm3BKOw0xEKOOG/DxhsnroVFQqLKqotB+XUWjAGlSbbxg7jhdphU2gvZ yMYimYWU1ZC0PDWfpqRvmhdfQ9fKFB8jX3OGW9Bxqx8Olc1sWoWWTZO8n2v0UAfu4IEH nFFw008Rt6XuyHUwwBb3f0kOoERPcQIEf/NtdKmsjC6xKyuF/KL2ltVl+6tKsM9YN0W8 nLaP+HSha+NMcKJs6MN0785NF53k+1EYk6PfstcBaLCZ1syOf82Dg4CIR9034L9F8bt5 PI6w== 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 h16-20020a170902f55000b0019f79ba4a01si11525431plf.443.2023.04.23.23.59.29; Sun, 23 Apr 2023 23:59: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; 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 S231191AbjDXGxr convert rfc822-to-8bit (ORCPT + 99 others); Mon, 24 Apr 2023 02:53:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231193AbjDXGxo (ORCPT ); Mon, 24 Apr 2023 02:53:44 -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 D4F652133 for ; Sun, 23 Apr 2023 23:53:36 -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 1pqq4Z-0005EU-Cb; Mon, 24 Apr 2023 08:53:15 +0200 Message-ID: <59b186dc70934320e9af6b2b916b5253fdaff444.camel@pengutronix.de> Subject: Re: [PATCH V2 2/6] drm: bridge: samsung-dsim: Fix PMS Calculator on imx8m[mnp] From: Lucas Stach To: Adam Ford , dri-devel@lists.freedesktop.org Cc: m.szyprowski@samsung.com, aford@beaconembedded.com, dario.binacchi@amarulasolutions.com, Inki Dae , Jagan Teki , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Marek Vasut , linux-kernel@vger.kernel.org Date: Mon, 24 Apr 2023 08:53:00 +0200 In-Reply-To: <20230423121232.1345909-3-aford173@gmail.com> References: <20230423121232.1345909-1-aford173@gmail.com> <20230423121232.1345909-3-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 Sonntag, dem 23.04.2023 um 07:12 -0500 schrieb Adam Ford: > According to Table 13-45 of the i.MX8M Mini Reference Manual, the min > and max values for M and the frequency range for the VCO_out > calculator were incorrect. This information was contradicted in other > parts of the mini, nano and plus manuals. After reaching out to my > NXP Rep, when confronting him about discrepencies in the Nano manual, > he responded with: > "Yes it is definitely wrong, the one that is part > of the NOTE in MIPI_DPHY_M_PLLPMS register table against PMS_P, > PMS_M and PMS_S is not correct. I will report this to Doc team, > the one customer should be take into account is the Table 13-40 > DPHY PLL Parameters and the Note above." > > These updated values also match what is used in the NXP downstream > kernel. > > To fix this, make new variables to hold the min and max values of m > and the minimum value of VCO_out, and update the PMS calculator to > use these new variables instead of using hard-coded values to keep > the backwards compatibility with other parts using this driver. > > Fixes: 4d562c70c4dc ("drm: bridge: samsung-dsim: Add i.MX8M Mini/Nano support") > Signed-off-by: Adam Ford Reviewed-by: Lucas Stach > --- > drivers/gpu/drm/bridge/samsung-dsim.c | 22 ++++++++++++++++++++-- > include/drm/bridge/samsung-dsim.h | 3 +++ > 2 files changed, 23 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c > index 2be3b58624c3..adb9c13c5f7f 100644 > --- a/drivers/gpu/drm/bridge/samsung-dsim.c > +++ b/drivers/gpu/drm/bridge/samsung-dsim.c > @@ -405,6 +405,9 @@ static const struct samsung_dsim_driver_data exynos3_dsi_driver_data = { > .num_bits_resol = 11, > .pll_p_offset = 13, > .reg_values = reg_values, > + .m_min = 41, > + .m_max = 125, > + .vco_min = 500, > }; > > static const struct samsung_dsim_driver_data exynos4_dsi_driver_data = { > @@ -418,6 +421,9 @@ static const struct samsung_dsim_driver_data exynos4_dsi_driver_data = { > .num_bits_resol = 11, > .pll_p_offset = 13, > .reg_values = reg_values, > + .m_min = 41, > + .m_max = 125, > + .vco_min = 500, > }; > > static const struct samsung_dsim_driver_data exynos5_dsi_driver_data = { > @@ -429,6 +435,9 @@ static const struct samsung_dsim_driver_data exynos5_dsi_driver_data = { > .num_bits_resol = 11, > .pll_p_offset = 13, > .reg_values = reg_values, > + .m_min = 41, > + .m_max = 125, > + .vco_min = 500, > }; > > static const struct samsung_dsim_driver_data exynos5433_dsi_driver_data = { > @@ -441,6 +450,9 @@ static const struct samsung_dsim_driver_data exynos5433_dsi_driver_data = { > .num_bits_resol = 12, > .pll_p_offset = 13, > .reg_values = exynos5433_reg_values, > + .m_min = 41, > + .m_max = 125, > + .vco_min = 500, > }; > > static const struct samsung_dsim_driver_data exynos5422_dsi_driver_data = { > @@ -453,6 +465,9 @@ static const struct samsung_dsim_driver_data exynos5422_dsi_driver_data = { > .num_bits_resol = 12, > .pll_p_offset = 13, > .reg_values = exynos5422_reg_values, > + .m_min = 41, > + .m_max = 125, > + .vco_min = 500, > }; > > static const struct samsung_dsim_driver_data imx8mm_dsi_driver_data = { > @@ -469,6 +484,9 @@ static const struct samsung_dsim_driver_data imx8mm_dsi_driver_data = { > */ > .pll_p_offset = 14, > .reg_values = imx8mm_dsim_reg_values, > + .m_min = 64, > + .m_max = 1023, > + .vco_min = 1050, > }; > > static const struct samsung_dsim_driver_data * > @@ -547,12 +565,12 @@ static unsigned long samsung_dsim_pll_find_pms(struct samsung_dsim *dsi, > tmp = (u64)fout * (_p << _s); > do_div(tmp, fin); > _m = tmp; > - if (_m < 41 || _m > 125) > + if (_m < driver_data->m_min || _m > driver_data->m_max) > continue; > > tmp = (u64)_m * fin; > do_div(tmp, _p); > - if (tmp < 500 * MHZ || > + if (tmp < driver_data->vco_min * MHZ || > tmp > driver_data->max_freq * MHZ) > continue; > > diff --git a/include/drm/bridge/samsung-dsim.h b/include/drm/bridge/samsung-dsim.h > index ba5484de2b30..a088d84579bc 100644 > --- a/include/drm/bridge/samsung-dsim.h > +++ b/include/drm/bridge/samsung-dsim.h > @@ -59,6 +59,9 @@ struct samsung_dsim_driver_data { > unsigned int num_bits_resol; > unsigned int pll_p_offset; > const unsigned int *reg_values; > + u16 m_min; > + u16 m_max; > + u64 vco_min; > }; > > struct samsung_dsim_host_ops {