Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1851540rwd; Thu, 25 May 2023 20:15:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7DVPdd2e6n1n+6D2KdtIg2R6RO/N+HHLrYQGSYnSSPDdDQ4S7ES6FVbgZdsVcnu79mzAXD X-Received: by 2002:a05:6a21:790:b0:10f:8b61:197c with SMTP id mg16-20020a056a21079000b0010f8b61197cmr320243pzb.54.1685070951857; Thu, 25 May 2023 20:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685070951; cv=none; d=google.com; s=arc-20160816; b=Dp0Q581nZpuuK9QXQ7lkpHYFUHXkp8h6YsPKUt47fNm1BGhzJr5VY3G4Y4G/fNVNAn lWtsfN22rqQ0tba/lqMFdaC3IVuSE0zcHSFNGJTsZmCAQgfJyNKyjTj00XSvMG6njg8t PF4kUVWxbVSBZdM0tcCOt7+eKKmv1GRjSZBBDszbxG29/3NTx0yHJ8c2UYzhDs3YWWnV AH1Jfi58a7wPWY4FqaGJG2QWLimqrMCt+n2b6iArfV8Iz/hgI5OsSLicl9c9lmEcUbH/ QiLtmT2WOZ4S5+DXx23JJj9TVkxYxhQ0EpEXpjA7i5mQAP78DIOULr32LqG90X0dCVUw LkUw== 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=EZwQCaqcjy7RjxDAR2wRO2JGL84KcCiGYyuPBX57oTU=; b=fcKuYDGW62kTrQd0l5Xv/pdKVDAuOirSLg+2VnVTB2U8rv+1B9I3b5CvcUH9fI3R9d Pbq2TQllEKCFONAWS0PyXeyp/VpVZ/xT2dqIZxXAcrtJ/m7WcCkZ5qkdkpgC3nfCFba/ iY4sYJY+mHAxF54L9W+ouk6MEtH2Lv3Je4gcHcXMoHGYl/w0byHaFJTrbNA2LmIHo4LA +dvo1eEs3OGJ0/i1BIJ68d6sD4TF9vg1ueotKinQkbfhDWEN9CfmPZUI1k49SVfZy3Ke 9eG9Z5MxJadAjkWl4MPD8mOgoSzSgTx2xDabg7s6xwHQ2rZYKYV3NFDLIuQ7PU1w1qen IHJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=SL3yZ2bL; 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 u21-20020a627915000000b00643b2b72c8esi2923174pfc.317.2023.05.25.20.15.39; Thu, 25 May 2023 20:15:51 -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=SL3yZ2bL; 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 S234501AbjEZDGd (ORCPT + 99 others); Thu, 25 May 2023 23:06:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231691AbjEZDGS (ORCPT ); Thu, 25 May 2023 23:06:18 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20780E6; Thu, 25 May 2023 20:06:12 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-33af56dfe35so255505ab.2; Thu, 25 May 2023 20:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685070371; x=1687662371; 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=EZwQCaqcjy7RjxDAR2wRO2JGL84KcCiGYyuPBX57oTU=; b=SL3yZ2bL+Fcnjpm+QQGYOdSO63Z0kU0R9qvNv2zZm16wB/iEfKcSRxYXszttr0yr/+ yLChq/wv4fq8KpJPBrAuvAqPSIHnJO0n1xZLx84TNfTkmze8WUBCfXpGetoqFOMMTI2U Rp3sUocO/WAacUrvB0sMHMI+7yIxsQ8OMz/dbpi3yXmK3kVyLUKRtezLms1qYcvvpTnr ZlsUdUWb1O4IWwZ2RnU6Ef1fiP38KMmgwhmIb448kKOyjZGyA6L0FqwajT5rP+zW6xx/ 42WSZGPe8ciTPVJ1YPUqZyYJIscyY+cZlwvAeDG72/hrK9yHgm/e2sNntm47CBBo/je1 pNQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685070371; x=1687662371; 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=EZwQCaqcjy7RjxDAR2wRO2JGL84KcCiGYyuPBX57oTU=; b=SbKsjmP8t8ANAHrhMlB+iEmACxoEGnmn4I3BTvjRwkRte2pF+bdtnjAgOlIomCD0Z2 0TL1rdkTxsSNYY6Dg+A+/yCMYxa0nBQ7I6RIOwMhwjVHv0+rFU+r7+qNtNG+mEvK+8DR nRYAoEze10SW7uGkdMhz3mtJdM3XT+pYFZi0pzAyVSqTtZ3wJmz3C6HIBpAaw0XDRILy jK3eEl3/OcMrqHBEJ5iZbjYuwL8hVR8DTK0uU+TtDXYRspN55B9pz6hSvbU4eIgHO/xr yagRDzT7TkmjzFqAJ6I6MdeeBzIhtttusXJ0Gjy9G0wJ2GW6yQrE53SxrurH0PV4nE4Y DFDQ== X-Gm-Message-State: AC+VfDxv9MeFpdSy7ysJrxXjDKEjmKyvIbptUst5t877fuHH98G+NuT9 XEXojAfGpPEJr8lUl1/APaM= X-Received: by 2002:a6b:6510:0:b0:774:952a:1c09 with SMTP id z16-20020a6b6510000000b00774952a1c09mr69368iob.9.1685070371055; Thu, 25 May 2023 20:06:11 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:3dd9:3f6c:9922:6420]) by smtp.gmail.com with ESMTPSA id i2-20020a5e8502000000b007702f55116fsm363189ioj.38.2023.05.25.20.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 20:06:10 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Cc: aford@beaconembedded.com, Adam Ford , Lucas Stach , Chen-Yu Tsai , Frieder Schrempf , Marek Szyprowski , Jagan Teki , Inki Dae , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Marek Vasut , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V8 2/7] drm: bridge: samsung-dsim: Fix PMS Calculator on imx8m[mnp] Date: Thu, 25 May 2023 22:05:54 -0500 Message-Id: <20230526030559.326566-3-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230526030559.326566-1-aford173@gmail.com> References: <20230526030559.326566-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 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 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 | 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 a2d1eaf0ed1c..ead922c3ce9f 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -407,6 +407,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, + .min_freq = 500, }; static const struct samsung_dsim_driver_data exynos4_dsi_driver_data = { @@ -420,6 +423,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, + .min_freq = 500, }; static const struct samsung_dsim_driver_data exynos5_dsi_driver_data = { @@ -431,6 +437,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, + .min_freq = 500, }; static const struct samsung_dsim_driver_data exynos5433_dsi_driver_data = { @@ -443,6 +452,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, + .min_freq = 500, }; static const struct samsung_dsim_driver_data exynos5422_dsi_driver_data = { @@ -455,6 +467,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, + .min_freq = 500, }; static const struct samsung_dsim_driver_data imx8mm_dsi_driver_data = { @@ -471,6 +486,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, + .min_freq = 1050, }; static const struct samsung_dsim_driver_data * @@ -549,12 +567,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->min_freq * 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 6a37d1e079bf..2c20b9460c9a 100644 --- a/include/drm/bridge/samsung-dsim.h +++ b/include/drm/bridge/samsung-dsim.h @@ -54,11 +54,14 @@ struct samsung_dsim_driver_data { unsigned int has_freqband:1; unsigned int has_clklane_stop:1; unsigned int num_clks; + unsigned int min_freq; unsigned int max_freq; unsigned int wait_for_reset; unsigned int num_bits_resol; unsigned int pll_p_offset; const unsigned int *reg_values; + u16 m_min; + u16 m_max; }; struct samsung_dsim_host_ops { -- 2.39.2