From patchwork Tue May 2 01:07:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 89218 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp283491vqo; Mon, 1 May 2023 18:16:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4hxztmvhTzRyYExbhb92yEFooxsvYuMd40MzRiYn2CZJWhVQ6N5r3C88RQzFqZFxZ31uEI X-Received: by 2002:a05:6a00:1913:b0:63d:3d2b:a7ee with SMTP id y19-20020a056a00191300b0063d3d2ba7eemr23080076pfi.18.1682990205748; Mon, 01 May 2023 18:16:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682990205; cv=none; d=google.com; s=arc-20160816; b=OxC2WGmemVdFJlxuCR/wetH41ehXv0NqyTZVTtxsfMaFmAYJpjPx4B3pGg2mYiCXXY MfSdJlfbv+TXqlMok3QXjOQXcAs6W1AbdxIBpGfxhE7iNtnjZB/SeiRrwQd6JaLZtY4l KWALLMAJApODAP2S1ecSzzljOhGV8X7Rf851frmR53fPhqeHDiCgEqfC+vMGbKAfYZVp H2/kofMYPxEV0EY1LcdONxccMCXeTvVkNoO3YWgJpBCbR0B+s8ndDGl46a98HF6KDsSq i4j3cbLRVus1EFWL3y5KO05sKc2mIWmjQKC4ag1Ljrt9wWiUQZn+3+vLa2tRn+ZRJc6L +UrQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g14-20020a62520e000000b00640f213b6fesi16104772pfb.240.2023.05.01.18.16.31; Mon, 01 May 2023 18:16:45 -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 S233382AbjEBBIZ (ORCPT + 99 others); Mon, 1 May 2023 21:08:25 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764743138000177424?= X-GMAIL-MSGID: =?utf-8?q?1764743138000177424?= 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 {