Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1693766rwd; Thu, 18 May 2023 16:10:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5wklvQVch8AhDZm+I3tX+AMl5OEqU/SrEHhcBE+u+12t6u/jm3IxMuMx89tr3pXHqnLdKH X-Received: by 2002:a05:6a20:7485:b0:102:3f67:dbe1 with SMTP id p5-20020a056a20748500b001023f67dbe1mr117835pzd.4.1684451442204; Thu, 18 May 2023 16:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684451442; cv=none; d=google.com; s=arc-20160816; b=EY6IJHz8De0+mgRv82GH+tihNWY1521wn+fEgNCzUztfdml7314rxT5msR1p7CViGO LAZpg6XgjECfBjIY06Kb+3w5ex4BV5v2Gd12cWDJcw+t42Lx2O19EgcPE4clDM6jx7+r zNBr4bSvhVqaYUPlDDAWErZ86XTeBOL/7b/lPfY+nSvmMhNbMFkeztcCLhCIb6lfI9TE SN+XQyuE2QmVZZpJcwjUNToc0zWC1vt4WnkDMWBiKGz5bkupeRf/ZTuJPRerKsI6/PFT OaT9ttaMn+PlGcRgjcedcbTUFVhicNkKKQEPsGSwcglvdttfeN8iZenerCDSXaahYE4p BB0g== 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=TkgUBoTxrN0CEnRT74Chghq2miOefeDr1PRbCfEvqtc=; b=NbjUhifV9vWV40ZFh1jPJFKIjffIZnTQE3jTD1ZJm5ytwlvIY7uhf9m9nKK80r4+Xk VrSpAHUpEJ4SAwVa7Zd56U3mQcc9p/wOCmgHVRwL4FkNlLPSNCB5H4gBB83aNgmv1O4k nnGhr957hirOOLcQx5orwAGQ513y3HEvQ0ikepzQ9woKzaRZMA4y4WmT9QCMdo6Ovqmv JOg2mmN8qpku100DlJWgK/qyaClq3XvFQHqZZwPaxUgm8RM/eVo6hhCJnlWwOA/D0y1G GIuI47iirdJXpaXv0nX3ILpfgR/kinmJFze5pEZ3kv2dqrkirPT2sCLeel9JSwMsfH07 yzAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="gHVZ/8UL"; 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 z20-20020a63b914000000b0052872c32995si2534364pge.724.2023.05.18.16.10.27; Thu, 18 May 2023 16:10:42 -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="gHVZ/8UL"; 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 S229947AbjERXGz (ORCPT + 99 others); Thu, 18 May 2023 19:06:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231187AbjERXGu (ORCPT ); Thu, 18 May 2023 19:06:50 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FFE710C3 for ; Thu, 18 May 2023 16:06:42 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-3313fe59a61so6485425ab.0 for ; Thu, 18 May 2023 16:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684451201; x=1687043201; 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=TkgUBoTxrN0CEnRT74Chghq2miOefeDr1PRbCfEvqtc=; b=gHVZ/8ULZ6U5cF2PnE8kNQVwQpZh15ZUzFYh8Z5miIW1egbnujmJOhVkNr/mUP3P3R bHPCdWsqb0iSjdLY98Wjh/W6gRbhsXnwz8nEGIuslQk9xDpAzIn+Wdwyr4ZjIg2Ov07E QoBcaD7xNjq7cy6ViyhGVus1gnNN2cAf2wed8I0cTMCDeMskCe3eEYyARp7bm5u1Hq7w QPwe5l6wMT77i9O08vUeEYaBlQqwmgVNA9cJzAUOJa2GtHMcXfRm/8s5j6v2Z9hA//in 7DDxP0vMSspN2GWQfAfhf+VomirgRTf3tyf56L3LbvYWu7bcODAInT0X6WH3fys7zedE exRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684451201; x=1687043201; 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=TkgUBoTxrN0CEnRT74Chghq2miOefeDr1PRbCfEvqtc=; b=L1PkISoJ9RdYTF+YocQwtKXTnyH0o+VxcDzUunsfDTnYtCao7aO/pNglIs5r+GyDj5 WuN7qH3NMzYjAt7RWWVyDrRL4yppitAdsjp/Y21F+0ixdXX1SS3OaY723XjfgnfxSpd1 N/zy2HfTVdt/PVWRDDjTu4ep1m+vgZ3afgrzKkON0HRX8ShuviEnn9PiaZSLvkcE1uAZ 9rtx8yOjLIaSfPZ6C6Q1YhFVti+I57xLAsA9cBmAsMWuBIMfLOIocJti8nBRJ9UTPZ70 QshdpFSiTI3t7I4LtUAEvpWLFo4aJFgzOaAQYglpZjrHZboMHT0sN4KsdHU5S0ffo2GU QJWA== X-Gm-Message-State: AC+VfDwFzITIGP3q9kPRLwtscQgRm4lhzrnwB4GRSrpLZTjrMYHGOi1h PaUNRUEhliYBdLBeIIW93Lv1L48Pu+E= X-Received: by 2002:a92:c811:0:b0:32c:dc61:8e84 with SMTP id v17-20020a92c811000000b0032cdc618e84mr5665825iln.4.1684451201277; Thu, 18 May 2023 16:06:41 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:56b8:635c:4c7a:15b1]) by smtp.gmail.com with ESMTPSA id z12-20020a92cd0c000000b003317ebbc426sm635897iln.47.2023.05.18.16.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 16:06:40 -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 , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Inki Dae , linux-kernel@vger.kernel.org Subject: [PATCH V7 2/6] drm: bridge: samsung-dsim: Fix PMS Calculator on imx8m[mnp] Date: Thu, 18 May 2023 18:06:22 -0500 Message-Id: <20230518230626.404068-3-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518230626.404068-1-aford173@gmail.com> References: <20230518230626.404068-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 2be3b58624c3..bf4b33d2de76 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, + .min_freq = 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, + .min_freq = 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, + .min_freq = 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, + .min_freq = 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, + .min_freq = 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, + .min_freq = 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->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 ba5484de2b30..a1a5b2b89a7a 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