From patchwork Sat Apr 15 10:40:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 674097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14FF5C77B71 for ; Sat, 15 Apr 2023 10:41:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229829AbjDOKlU (ORCPT ); Sat, 15 Apr 2023 06:41:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbjDOKlT (ORCPT ); Sat, 15 Apr 2023 06:41:19 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 315A94ED1; Sat, 15 Apr 2023 03:41:18 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-760bba6404cso20398539f.1; Sat, 15 Apr 2023 03:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681555277; x=1684147277; 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=56ZqII4Fb21fefI3ij/UQDEmcVSWwrH95gBjy3Mjo2c=; b=c8R4I6O7ggblq3O1pN0J/PavAtXqWA4bYUwa0MWOlSiv+6wVMfuKWJjDtC7rumJhcN 0wnseCj6TyzdfajLDnKts4AwioLf4PO6JyroWchUm/aq2GRk9J+Lg3+Xoc14CHqCaw+2 YW33BbG9KN3jggKvsgFWRlVK6qxRfaPAAb/BZ5zbH+Rk8Wlnp4UN9QUF9G9PbETTzSy4 29TtbhcGai+nhWmrd4BBMWnOBy59vNlI2foFoP9nU76fTp2lRKxj3WqSBo5tZ3oOp0q8 dQdHlgD28OO9t5wPpSbx45HEVfMBwSIq7B7r+qmyPSSWtXkh2BQ/+YEKhgdehA4QHEyp j1Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681555277; x=1684147277; 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=56ZqII4Fb21fefI3ij/UQDEmcVSWwrH95gBjy3Mjo2c=; b=kLu+s32quCEUPPtT9n/G5tU+rm8ZYFDUAysJBtR1FbXIMMLiWqwmn+lhuIVgPgoqad rulItJsanBOcERdWY7SkfRhtKGFNrEYiX1jYGhg887SIOmjz9+EInAK+CTBTPDn71H6Q jwlx9ZaLWTLIBg5H/QxZ8F4Yb2N6rte/KDhiZS5DuauyBi5RMqX9vWmOVa+pKiJXmxu8 X/n9QtXCoauPzc0vWERwOi+rK2nmMY5Ig2spq5LdDOk9zXkCJisBWHCeRFJrNZfxkPHJ 7Gd05doEtf9FTXRELfFolI3eOmqS2j3owwxICuhxJf6iGUnFlTN9q81+NQJtqWrcYKXv d39w== X-Gm-Message-State: AAQBX9eCP3FOQAevEEMBqtYXaYpL9ZXZJ4JHtqSD7LfAkjsZEtamah5c /WXbJmSJxYnrq0wgdhmD9CI= X-Google-Smtp-Source: AKy350YMpZS9K/4tuqfAqbcnOR5F8JMUeFciCZKRV1EEP8gaOTJNwxUsnA9p449Upwgys2q4gez8qA== X-Received: by 2002:a92:d80f:0:b0:329:5a6e:3a18 with SMTP id y15-20020a92d80f000000b003295a6e3a18mr5513977ilm.4.1681555277355; Sat, 15 Apr 2023 03:41:17 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:40bb:6fe6:ddbc:cc9a]) by smtp.gmail.com with ESMTPSA id bp11-20020a056638440b00b0040b38102b79sm246536jab.82.2023.04.15.03.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Apr 2023 03:41:16 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Cc: m.szyprowski@samsung.com, marex@denx.de, aford@beaconembedded.com, Adam Ford , Rob Herring , Krzysztof Kozlowski , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Inki Dae , Jagan Teki , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Frieder Schrempf , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] drm: bridge: samsung-dsim: Fix PMS Calculator on imx8m[mnp] Date: Sat, 15 Apr 2023 05:40:59 -0500 Message-Id: <20230415104104.5537-2-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230415104104.5537-1-aford173@gmail.com> References: <20230415104104.5537-1-aford173@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 also appears to be the case for the imx8mn and imx8mp. 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 --- 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 1ccbad4ea577..9fec32b44e05 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -406,6 +406,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, + .vco_min = 500, }; static const struct samsung_dsim_driver_data exynos4_dsi_driver_data = { @@ -419,6 +422,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, + .vco_min = 500, }; static const struct samsung_dsim_driver_data exynos5_dsi_driver_data = { @@ -430,6 +436,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, + .vco_min = 500, }; static const struct samsung_dsim_driver_data exynos5433_dsi_driver_data = { @@ -442,6 +451,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, + .vco_min = 500, }; static const struct samsung_dsim_driver_data exynos5422_dsi_driver_data = { @@ -454,6 +466,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, + .vco_min = 500, }; static const struct samsung_dsim_driver_data imx8mm_dsi_driver_data = { @@ -470,6 +485,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, + .vco_min = 1050, }; static const struct samsung_dsim_driver_data * @@ -548,12 +566,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->vco_min * 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..a088d84579bc 100644 --- a/include/drm/bridge/samsung-dsim.h +++ b/include/drm/bridge/samsung-dsim.h @@ -59,6 +59,9 @@ struct samsung_dsim_driver_data { unsigned int num_bits_resol; unsigned int pll_p_offset; const unsigned int *reg_values; + u16 m_min; + u16 m_max; + u64 vco_min; }; struct samsung_dsim_host_ops {