Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6178421rwr; Mon, 1 May 2023 18:17:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4FQdHQIu4oZnHDiZtJK1iNa4xGwHq+Qo2c/qm0q0Hh9AkbzCST4gqWJQ9HJXEJYbqW+bUZ X-Received: by 2002:a17:902:d482:b0:1a9:a672:12b8 with SMTP id c2-20020a170902d48200b001a9a67212b8mr17430663plg.68.1682990263747; Mon, 01 May 2023 18:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682990263; cv=none; d=google.com; s=arc-20160816; b=HHWe/g4fKRtJQ/kJ13t4tMC54Zj6+SF8LDXlwyjvWzK02B1DIqEhwskaMjB6JpKph3 UzqA1Pj4VkBhCqbbUnSpXfdOGhxQRz8aKwg4KFOc7l9R7R1mIYjFuDUfRcjyh4saYPFF lSPc95PzZDJh0kRtZtSQ07AvmLFDTJf92usFWhPqsQMPX+buRCMFSP02AsCJJPOevLpJ yVlcZ1ffKy7laTe0vuIgF+D1f2aH0gaWip/zhNh3p5UlcC/HMYChVEMMqyoV/za/6KO4 JU0o82JHZhC3lwpb0IRosspWRAlvKNDi8SPXPucaICdE+R/REl9GrE9bP/0JRt7+Dk1q 9aHg== 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=xTXYxsRf77C4yLC2TKlqpFtoqraoDJZ2y+9E11ns+dE=; b=tuNhVTEUWXdWgKahDchJP0GCu10llUgd+/Eil1ndtdgO9P3HpdDTWyM8mJA0TnCwXi Ja32t3fHX6QbnTOYJFNaiXLYjH74EL4szdb4KrHjYrLFlXZO8NjY/C4cyng4aOzQUjLT GCg6eve2iuXBdl78AAZtjp8JK7go1VcYufd1iQNcSF3IGZjhsUxKhGVDk7b9AbBXq45L WJ8PBpEyzPY0lF0ASXMEICdaSblzRw3yzhz1Soo0t/M+iSDa4vLxWl6kDLulOhMt/vW9 wYUfvKngNonhp6dFHvnjqPcgD0h9Tz6apBOmSmycDKbAEhfpRM9UhIymdHTNJxKwV5kz II4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=cFhQRnU8; 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 e12-20020a170902784c00b001a27afc07d9si24611794pln.146.2023.05.01.18.17.31; Mon, 01 May 2023 18:17:43 -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=cFhQRnU8; 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 S233379AbjEBBIY (ORCPT + 99 others); Mon, 1 May 2023 21:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233309AbjEBBIM (ORCPT ); Mon, 1 May 2023 21:08:12 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B449A3583 for ; Mon, 1 May 2023 18:08:11 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-760ecf3424bso58170039f.2 for ; Mon, 01 May 2023 18:08:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682989691; x=1685581691; 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=xTXYxsRf77C4yLC2TKlqpFtoqraoDJZ2y+9E11ns+dE=; b=cFhQRnU8n0BA92q9rOduE3LmlIvUj6IxLohDQN/6oLV+i6eMngwWWgJhESb5BmSCK6 4kYKlZOhCWfDxDHikb9H4ZCRP9bETlG8vXBFgumusBgO5xqlclzWxRG/U880g0ViS5Rf QppSwynxGVndxjuWsmj9JMvvcMSkVRilhqeeGa+aSvNk+3pUhTRyDLvlbelNgbc4IB8l YKuAkt80SnWr368EwfNdaesL8GaQ2wDZLS9oNF2FZHS/zCdDUG4PKmQK1NfV63XmMfrZ mupkewzJQ+q6V3olGdVvte/m9weUe6IaayF6TmCxss2HUXUuYPVFoQWyni8NGgb19WFv iLHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682989691; x=1685581691; 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=xTXYxsRf77C4yLC2TKlqpFtoqraoDJZ2y+9E11ns+dE=; b=R136RYXtBGD8URUbnx3R6UmEanmO8E3Eh6yFdp6YxHUrOJ48Rg2JORrmhcrfwfMXfo RjK9xiB4JM1J/X4xdVZOayvrMWmha5Llq0Mp0o/zPh+rMQThoPFBUmIHXDKuB1M+MkNB A82xyYW3QejrPZDmXnQR899b7wI6lxyqH/t0SFfsaC8NN8iExuR6wurcuKQNS0s0Su6L HoxlYsUhmcRdv7NRi+AWA3IViVWB//BYML/GQR1yu2xB5vbIdbC5YUaTc5QnkB47Xq8L a652KpDIWw4gIniuKkCTe67WqMUKbTraOstUIrwR0v2oDHJokWbGpPwIwtiIUKrw0Xe+ IpAw== X-Gm-Message-State: AC+VfDww+7DbPjRxc7lWUByqlqSRnsNdBc5eduQL9+ORghLg2zXWFY0g YuBbAeaHdHauJ3zf94t723A= X-Received: by 2002:a6b:3c07:0:b0:762:920c:4c91 with SMTP id k7-20020a6b3c07000000b00762920c4c91mr10015904iob.14.1682989690878; Mon, 01 May 2023 18:08:10 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:8257:a536:d7fc:1919]) by smtp.gmail.com with ESMTPSA id f16-20020a056638329000b0040fb5d5429fsm4836329jav.131.2023.05.01.18.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 18:08:10 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Cc: marex@denx.de, aford@beaconembedded.com, Adam Ford , Lucas Stach , Chen-Yu Tsai , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Inki Dae , Jagan Teki , Marek Szyprowski , Frieder Schrempf , linux-kernel@vger.kernel.org Subject: [PATCH V3 2/7] drm: bridge: samsung-dsim: Fix PMS Calculator on imx8m[mnp] Date: Mon, 1 May 2023 20:07:54 -0500 Message-Id: <20230502010759.17282-3-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230502010759.17282-1-aford173@gmail.com> References: <20230502010759.17282-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 --- 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