Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp1655488rwe; Sat, 15 Apr 2023 03:42:16 -0700 (PDT) X-Google-Smtp-Source: AKy350bcIzzDbAkweCThrcEN0svI8ovBQHoD5tKO8VCpoDnsAYxJteQaIUb+35n+5Si4RKYFMOIo X-Received: by 2002:a17:902:d103:b0:1a6:6f38:60df with SMTP id w3-20020a170902d10300b001a66f3860dfmr4948768plw.41.1681555336612; Sat, 15 Apr 2023 03:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681555336; cv=none; d=google.com; s=arc-20160816; b=MlRC+BCBZJ3vOaA/nYsA2YW932bmEl47DKuMYsRUL/D/TLPzyFEvF9t+/Dv9iWCvL5 h0l3o9OreE8MLxd6lHSAUaLUJrZIBLn9N57XcFqgFm1mdjiip90pnsSBiZbqaXMCQq+O ezR9ovMhQRxld14GeJRnNTry1XWmfRpsnk5Wa0M72AFjl6rZhn59LE+z8Wyci+ov8p50 9UQ/tXD4obv8dZ9gBMeop0p9sT0zDmL1zk7ri1t04CJo76BuR+1PJLbv6VKAVLJo23x6 NGqi/8CLTsmEGUW5Fde0D2DpfqtMSdDfpQZbOq1YV/Hy1nga/Qiid3oyE9QIJO6X3YjI 25sA== 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=56ZqII4Fb21fefI3ij/UQDEmcVSWwrH95gBjy3Mjo2c=; b=dSOUCn9dmhkCbn0D5MYe1YJvnLT/omqx8c9Fhjhxkzk4Zh6TTNhZPYG/2jV8uAvcpc lowmGj6kx6a6ew79/egwGNsQ6KNKuk7OIbi5ivffllAumH07F89m6pm29wIFa0ZkE3vb SdcbrAJ+Ka4Ejf5FsBDuJFwPK4cUswjDo6a2kmYVYx3X7jj9VJA8GOOW9dtzI8atSp/n fe3rHdQG2mDrIHUZ+rmZRGFvw/jL3+PTcjwlhTsXvNaIkWAlHZYIsMYaIdZxcnKvtiCy U6Y4xbZEvSZ4igA2BcCu81BuhvbUP37TaPp8mNVzecwCtoLaQVA3iIPstVnMYIekdv1H xocg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=c8R4I6O7; 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 q7-20020a170902dac700b001a1f70cc7dbsi7547479plx.562.2023.04.15.03.42.05; Sat, 15 Apr 2023 03:42:16 -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=c8R4I6O7; 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 S229899AbjDOKlW (ORCPT + 99 others); Sat, 15 Apr 2023 06:41:22 -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-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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 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 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 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 { -- 2.39.2