Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1644788rwr; Fri, 5 May 2023 18:25:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ660jpe6VnSATLxNtlwF0zGUeijhchHQaNUkucsGqRqpNayhCR8JhFTXjxVcafQow70T5A2 X-Received: by 2002:a05:6a20:4413:b0:f2:4d44:3560 with SMTP id ce19-20020a056a20441300b000f24d443560mr4071021pzb.19.1683336318335; Fri, 05 May 2023 18:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683336318; cv=none; d=google.com; s=arc-20160816; b=imoXgsMfa8olDfmvFdsH6n8l9c8qmRq6EjINuKeZiAdSw1GIMyri9PhhmUYbcYTOGo S/NCPfXC8f80k8Ht1Y3B2kY+EcgHj+b1PqrQRsqxPcUBPPQkVCtrewbMp4KFuTbWXBaD PoucREQ/opeAUx8Mh/fMjW5Kpx6xhIhVCZscV+sMyEFyuOZ1jlbr6biwDoWHTU+QSwmw dCDhNFrFjmQA/+xVfbT8MvKLmR9qTI3BNLopYeC7bS5mwaSKDE1SDm+Jyhg6Ug0AmibW LxH6Yhp/SDw6St4Hwdiq3EaOsFd6oB5LbpLFNH/9i3QqKr1brO+hD8a/0h4si6M0jMGW TJoQ== 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=KhmHVm3biAYbsxZZFqn6S1mZ25+9+Btd76fwE2r61yM=; b=BykQRYIo51qv6pe0uDZALaT6UN0Hl6RkefUwcLDzCSAQPC6sya9HGhD39dzs+y/3Uc yFXnn0V01Xf2EPab5h93hOtAEqDQYTWeIX75nksqReuDebBrmCFBKhhHdFvGgPGsdySa 3Lq+GBpSaRdi8mk/1cqWQVBRB/OKpqKplsywLK6SP3ZIaMkWBvOfxKGAERYdrFuvF2qe h/Jlr6Me9yQMk+XoUXytIfVOWOweRa6lZhZ4NiI0Qd7IyNpXsZmhQNW+KkQCY3BIKdKe U7qIcHLobID1WjoYOCjKTN+FZOnOe9DofjNWv8Q1eWxjYaIVH01LI1tjVOQIzeIR9jiL QVlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=IesZ3n1A; 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 i11-20020a639d0b000000b005185d7599b1si3034765pgd.44.2023.05.05.18.25.05; Fri, 05 May 2023 18:25:18 -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=IesZ3n1A; 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 S230039AbjEFBJx (ORCPT + 99 others); Fri, 5 May 2023 21:09:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229954AbjEFBJq (ORCPT ); Fri, 5 May 2023 21:09:46 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B79AA1992 for ; Fri, 5 May 2023 18:09:45 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-763da065494so56762739f.0 for ; Fri, 05 May 2023 18:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683335385; x=1685927385; 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=KhmHVm3biAYbsxZZFqn6S1mZ25+9+Btd76fwE2r61yM=; b=IesZ3n1AOwj1IfCp5kLr6vAC8shx70AS1fWg5oLyOe5/OmMjTCAwAWHMgh+PvYQWxg 58epP43jgMS9aVJ4Eo+WXD95Q1RkZq0GJIfhu1bRn9isUcdx06O30kCizd/YCF3g8WEs 8WzBo8bFJkwB2KNrc6MKp1MPTKjB6VyG5k4BCuM/PjVU5uCIezyqrs8irTiIdzPA4ND2 dy32Hk2vLcO/ydnayQ4ZZWjHvNcfGQd8fD8ZWbkx4qVn/a4Xf3GXxyTMKlFDApE137Cq oonJJxXzrT6iaGJ/0vLxIg8TMgk2f6SHf2oaXnTnWQmObeOopq+8TLsRQbdTHFeAyWUe DFJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683335385; x=1685927385; 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=KhmHVm3biAYbsxZZFqn6S1mZ25+9+Btd76fwE2r61yM=; b=PQU8P8D6kuYzz5ZoNxi3bvPMlF/DwBRQ/BALbHpXuykE6DQwf2Gpwm/ulsDkCWIgnA p6jXclEskBS0NjQO+m/ZPn4JDm25Jvtc/VUG6jbQ9rwrEfFJK8yq5koK3YRsK66upTZ5 7a693K3EXz5QLGtxv6SJqDW3rWdeim7vg1fvapfgg9spkcFNKWUI3fdlaLYSNXNKvnyK NuoVGAGUrEakOonvxuYj7viVlIInmd3WddTG3TrQyxMxnzW0ifdHSedrdqKLUTBaJZuI 9jvNC3ZhFGF/fUXOh4k/jgbncDYV/5Z+kMA4bxSkECe48B87dYupdJsdhJEboIkOHSjg IHKQ== X-Gm-Message-State: AC+VfDxabk891e0z1DOGJxwnBODvMdJIS8CNJkmfirh+Sw87Ik2OV+13 vuUKz/7R4upsPfJ0Jg2Lll0= X-Received: by 2002:a6b:4010:0:b0:760:eeac:e1dd with SMTP id k16-20020a6b4010000000b00760eeace1ddmr1693109ioa.18.1683335384972; Fri, 05 May 2023 18:09:44 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:34a2:3894:45cc:c002]) by smtp.gmail.com with ESMTPSA id r11-20020a5e950b000000b00760ed929d0bsm335735ioj.2.2023.05.05.18.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 18:09:44 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Cc: aford@beaconembedded.com, Adam Ford , Lucas Stach , Chen-Yu Tsai , Frieder Schrempf , 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 V4 2/6] drm: bridge: samsung-dsim: Fix PMS Calculator on imx8m[mnp] Date: Fri, 5 May 2023 20:09:29 -0500 Message-Id: <20230506010933.170939-3-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230506010933.170939-1-aford173@gmail.com> References: <20230506010933.170939-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 --- 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