From nobody Mon Feb 9 17:58:03 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DB5B2989B4 for ; Sun, 21 Dec 2025 10:47:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766314031; cv=none; b=bkhWtJz29cvVyjuZkgaIepI8vtpkvVv0z573lUb8BEU+AoPBPZptbOQG4e/tVybMP7wHdrxsPeU2nwYJB3nKPTvrzUIdvXd2QFHRtOyM9iMFtIYiPGJ9/+NsB8Y9Nz7D4AY5W2fB1w9LrDw0Bl6hrbSwt96kzdqhahBY8vPQYvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766314031; c=relaxed/simple; bh=kDXcyjHMjIrOytzsZ+Lma1zPlSuP3hSoSfDGQ8aV6Wk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gJ9Gh6bkHkKGrqH7J1wIOE5SqTVcfNgM0uNe6o9Egfy8adSEYEH7/FKh8hUR1wDuB0PrF3t5r0Kt155NnqOVpFUtM0fOgCHaIgzAXdjAgZXlibZYwEAJlhlQAzYlyNtQeP3+XgwAwWfctvSOKzW3DKa3K1Ncj7C0Y/W/1xGOjYI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=HqHfxUpI; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="HqHfxUpI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1766314027; bh=kDXcyjHMjIrOytzsZ+Lma1zPlSuP3hSoSfDGQ8aV6Wk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HqHfxUpIR/VQ4vr5TpYaGljM9/Kmxesu0pgHXvKkKBs67iyd8z9Nhvik4fih9OMGd EqfuLlG8bVMmqBJgj5OQHqk+f7MdrbR/7zTtV9x9P2vA9RhVKP6FtrKJl8GHkqXy0E tiWlkkpfjWGcvifPce9DNyFe1SUZwcNirnUiWq4RF29CoboNBLMtzkJ6kuYfoXeWBS 2AnuSBU12cS4PEKPDNtJ/ZBpsNKYN8MYckYP00osNv1Coja0U8jKkVWFIBT1srBb0J /lqXu3BY7LWQP4xULAvmIz6U29cui820iR9bt5axwpODL7zFJAvNtxi4TS1da+VjQB a5291X7IaQtQA== Received: from localhost (unknown [82.79.138.145]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 9D7DD17E0506; Sun, 21 Dec 2025 11:47:07 +0100 (CET) From: Cristian Ciocaltea Date: Sun, 21 Dec 2025 12:46:54 +0200 Subject: [PATCH v5 07/11] phy: rockchip: samsung-hdptx: Compute clk rate from PLL config Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251221-phy-hdptx-frl-v5-7-dac390a780be@collabora.com> References: <20251221-phy-hdptx-frl-v5-0-dac390a780be@collabora.com> In-Reply-To: <20251221-phy-hdptx-frl-v5-0-dac390a780be@collabora.com> To: Vinod Koul , Kishon Vijay Abraham I , Heiko Stuebner , Algea Cao , Dmitry Baryshkov , Neil Armstrong Cc: kernel@collabora.com, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org X-Mailer: b4 0.14.3 Improve ->recalc_rate() callback of hdptx_phy_clk_ops to calculate the initial clock rate based on the actual PHY PLL configuration as retrieved from the related hardware registers. Signed-off-by: Cristian Ciocaltea --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 91 +++++++++++++++++++= +++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index 42f0ac5a74b1..c2d2f2468ba2 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -1818,12 +1818,101 @@ static void rk_hdptx_phy_clk_unprepare(struct clk_= hw *hw) rk_hdptx_phy_consumer_put(hdptx, true); } =20 +#define PLL_REF_CLK 24000000ULL + +static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(struct rk_hdptx_phy *hd= ptx) +{ + struct ropll_config ropll_hw; + u64 fout, sdm; + u32 mode, val; + int ret; + + ret =3D regmap_read(hdptx->regmap, CMN_REG(0008), &mode); + if (ret) + return 0; + + if (mode & LCPLL_LCVCO_MODE_EN_MASK) + return 0; + + ret =3D regmap_read(hdptx->regmap, CMN_REG(0051), &val); + if (ret) + return 0; + ropll_hw.pms_mdiv =3D val; + + ret =3D regmap_read(hdptx->regmap, CMN_REG(005E), &val); + if (ret) + return 0; + ropll_hw.sdm_en =3D val & ROPLL_SDM_EN_MASK; + + ret =3D regmap_read(hdptx->regmap, CMN_REG(0064), &val); + if (ret) + return 0; + ropll_hw.sdm_num_sign =3D val & ROPLL_SDM_NUM_SIGN_RBR_MASK; + + ret =3D regmap_read(hdptx->regmap, CMN_REG(0065), &val); + if (ret) + return 0; + ropll_hw.sdm_num =3D val; + + ret =3D regmap_read(hdptx->regmap, CMN_REG(0060), &val); + if (ret) + return 0; + ropll_hw.sdm_deno =3D val; + + ret =3D regmap_read(hdptx->regmap, CMN_REG(0069), &val); + if (ret) + return 0; + ropll_hw.sdc_n =3D (val & ROPLL_SDC_N_RBR_MASK) + 3; + + ret =3D regmap_read(hdptx->regmap, CMN_REG(006c), &val); + if (ret) + return 0; + ropll_hw.sdc_num =3D val; + + ret =3D regmap_read(hdptx->regmap, CMN_REG(0070), &val); + if (ret) + return 0; + ropll_hw.sdc_deno =3D val; + + ret =3D regmap_read(hdptx->regmap, CMN_REG(0086), &val); + if (ret) + return 0; + ropll_hw.pms_sdiv =3D ((val & PLL_PCG_POSTDIV_SEL_MASK) >> 4) + 1; + + fout =3D PLL_REF_CLK * ropll_hw.pms_mdiv; + if (ropll_hw.sdm_en) { + sdm =3D div_u64(PLL_REF_CLK * ropll_hw.sdc_deno * + ropll_hw.pms_mdiv * ropll_hw.sdm_num, + 16 * ropll_hw.sdm_deno * + (ropll_hw.sdc_deno * ropll_hw.sdc_n - ropll_hw.sdc_num)); + + if (ropll_hw.sdm_num_sign) + fout =3D fout - sdm; + else + fout =3D fout + sdm; + } + + return div_u64(fout * 2, ropll_hw.pms_sdiv * 10); +} + static unsigned long rk_hdptx_phy_clk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { struct rk_hdptx_phy *hdptx =3D to_rk_hdptx_phy(hw); + u32 status; + u64 rate; + int ret; + + if (hdptx->hw_rate) + return hdptx->hw_rate; + + ret =3D regmap_read(hdptx->grf, GRF_HDPTX_CON0, &status); + if (ret || !(status & HDPTX_I_PLL_EN)) + return 0; + + rate =3D rk_hdptx_phy_clk_calc_rate_from_pll_cfg(hdptx); =20 - return hdptx->hw_rate; + return DIV_ROUND_CLOSEST_ULL(rate * 8, hdptx->hdmi_cfg.bpc); } =20 static long rk_hdptx_phy_clk_round_rate(struct clk_hw *hw, unsigned long r= ate, --=20 2.51.2