From nobody Thu Apr 16 12:28:38 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 A1F6137106D for ; Fri, 27 Feb 2026 20:48:54 +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=1772225337; cv=none; b=Ytg71GLk46O4t0jIQeg/IeNFtxHjp1XqvrAh9hi+VQBs0EOSg02KQS4lfJCfHrYKcn3mqJANFFBx8JHJcCGgo+0kO1vEqSywjuZn5vdp6ED7w+RbkBrjh4y0q35zbbPl9+iAzTRn8keFMkyyevu9NqnXxt6frC7dAVMsHG5rTqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772225337; c=relaxed/simple; bh=433OBg1+YhSGQUkUR4/HWbY+HhNN+rC6S+NSviwRYKA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M+kFZW1UrIo8j60XO1KFRpzmqZcPA+sI3gOQEZ/MX36ysMIA48sRdeFCvBn4l1H/jGHrrcsjhVr8OJvBq9Tsc2HVbvS/JvYysNwLvBO1FlJRqRmXQUGV4V4rHrg7q0z/YmRcvn3vdDvDw0SgDYJuAeHej95Nr+HqG3fcsh2XXu4= 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=fnkPYyXm; 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="fnkPYyXm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1772225332; bh=433OBg1+YhSGQUkUR4/HWbY+HhNN+rC6S+NSviwRYKA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fnkPYyXmoPbrn1PvNVWYLCew2XoscpGzvLQB2U+kVJISmi+ygn6ZSbNlnWW+grB9h BNA05bXkglNq8muXn/K37Cq/VpyLPmDrj/xIvWExp/3kGlA3YKGLlKyQ/LNyz5OXYm q7Qj84JE7JmeV/sokp70rB6KrgQD3Rge85/H5kMk3GtOVBIsqtKNSuzlClKJLIEJBJ OuyD2ofdPsBFKQsfngaIa76f3Y8DgiOeZqhM5EMcY/9O7pjOgTF2n8lNZDuhmhdKAi 1+jvZtMDhDvyCCpei0j7HnTF8seZbidaR7LYK18XX9NL6B4wiPR4EzyVsFpniIaA2q 9r1AsDAbQd8Xg== Received: from localhost (unknown [86.123.23.225]) (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 954A617E0E91; Fri, 27 Feb 2026 21:48:52 +0100 (CET) From: Cristian Ciocaltea Date: Fri, 27 Feb 2026 22:48:45 +0200 Subject: [PATCH 1/6] phy: rockchip: samsung-hdptx: Fix rate recalculation for high bpc 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: <20260227-hdptx-clk-fixes-v1-1-f998f2762d0f@collabora.com> References: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> In-Reply-To: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> To: Vinod Koul , Neil Armstrong , Heiko Stuebner , Algea Cao , Dmitry Baryshkov Cc: kernel@collabora.com, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 The PHY PLL can been programmed by an external component, e.g. the bootloader, just before the recalc_rate() callback is invoked during devm_clk_hw_register() in the probe path. Therefore rk_hdptx_phy_clk_recalc_rate() finds the PLL enabled and attempts to compute the clock rate, while making use of the bpc value from the HDMI PHY configuration, which always defaults to 8 because phy_configure() was not run at that point. As a consequence, the (re)calculated rate is incorrect when the actual bpc was higher than 8. Do not rely on any of the hdmi_cfg members when computing the clock rate and, instead, read the required input data (i.e. bpc), directly from the hardware registers. Fixes: 3481fc04d969 ("phy: rockchip: samsung-hdptx: Compute clk rate from P= LL config") Signed-off-by: Cristian Ciocaltea Tested-by: Thomas Niederpr=C3=BCm --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index 2d973bc37f07..7fb1c22318bb 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -2168,7 +2168,7 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(st= ruct rk_hdptx_phy *hdptx) struct lcpll_config lcpll_hw; struct ropll_config ropll_hw; u64 fout, sdm; - u32 mode, val; + u32 mode, bpc, val; int ret, i; =20 ret =3D regmap_read(hdptx->regmap, CMN_REG(0008), &mode); @@ -2266,6 +2266,7 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(st= ruct rk_hdptx_phy *hdptx) if (ret) return 0; ropll_hw.pms_sdiv =3D ((val & PLL_PCG_POSTDIV_SEL_MASK) >> 4) + 1; + bpc =3D (FIELD_GET(PLL_PCG_CLK_SEL_MASK, val) << 1) + 8; =20 fout =3D PLL_REF_CLK * ropll_hw.pms_mdiv; if (ropll_hw.sdm_en) { @@ -2280,7 +2281,7 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(st= ruct rk_hdptx_phy *hdptx) fout =3D fout + sdm; } =20 - return div_u64(fout * 2, ropll_hw.pms_sdiv * 10); + return div_u64(fout * 2 * 8, ropll_hw.pms_sdiv * 10 * bpc); } =20 static unsigned long rk_hdptx_phy_clk_recalc_rate(struct clk_hw *hw, @@ -2288,19 +2289,13 @@ static unsigned long rk_hdptx_phy_clk_recalc_rate(s= truct clk_hw *hw, { struct rk_hdptx_phy *hdptx =3D to_rk_hdptx_phy(hw); u32 status; - u64 rate; int ret; =20 ret =3D regmap_read(hdptx->grf, GRF_HDPTX_CON0, &status); if (ret || !(status & HDPTX_I_PLL_EN)) return 0; =20 - rate =3D rk_hdptx_phy_clk_calc_rate_from_pll_cfg(hdptx); - - if (hdptx->hdmi_cfg.mode =3D=3D PHY_HDMI_MODE_FRL) - return rate; - - return DIV_ROUND_CLOSEST_ULL(rate * 8, hdptx->hdmi_cfg.bpc); + return rk_hdptx_phy_clk_calc_rate_from_pll_cfg(hdptx); } =20 static int rk_hdptx_phy_clk_determine_rate(struct clk_hw *hw, --=20 2.52.0 From nobody Thu Apr 16 12:28:38 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 6B2BE38BF77 for ; Fri, 27 Feb 2026 20:48:55 +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=1772225338; cv=none; b=u3eJs3mMBD/E46gBKj2lZhGN+0uLVjIMPbHRvEhBkkOylSzKeTNSXIdMV9Wq9uPW/iOI2qvoRL9OrvcZlk7A+pYYwPOSyszakEBljsG8wK/fc6aGB/gLWOQ7S2n+njdI+yypM7UpPcXtFP2+pAiay0U6x1dTxZV0UG4SileO3TU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772225338; c=relaxed/simple; bh=Y2Geq+AGRbgf8SUPSZ0VVd9oVwBJPeFTxHsLrwSzLao=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d4kfpyU5rRLwWV2Oeb0OeRzh/1mTeDlqu8jhkQayRiGLisM/kcrTaDyWoqnmFJvd1mIO0PrYBKCS4/IzEqOLIK0gkNqh8oFmUdnUyfroflrwpAR4mrDSid0sQOJAlReF9W5gEZFtA2tngLTtd/8UhI2lFsOz/qkQwZZGKbblpZ4= 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=kRptXLG9; 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="kRptXLG9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1772225333; bh=Y2Geq+AGRbgf8SUPSZ0VVd9oVwBJPeFTxHsLrwSzLao=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kRptXLG9UUJkqt3NNGuAq1Z7TPIAg2UMb6/3gR9PupHNZ2satj6/+fNyRc3ilCSTB Wa/8exhDuGNrtr/by1XRDecoUl8mkJ3RalsAdpjXY+lqUwhGKQyjksf5pfODLG2cX5 9Qb6UtALA4N8WiU1dZU8qlwYIIgKRs81/VPQtfvlEOzRa4DkBv13ashkJFVBrnj/vw LJrmhOI3THf7G3wDArZLPZnIozh1J2LMr18hSWbB9Jmtz3zQFyA4ABLMeIXDZkIuBb widhuOHqSYOSfA1q4R1HECWADK/cWpAm2YxMbcNQ9rSscHuWhLtYS2Aflh9HDrOhU4 VwjXn81JbK+sA== Received: from localhost (unknown [86.123.23.225]) (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 67DB517E0EAF; Fri, 27 Feb 2026 21:48:53 +0100 (CET) From: Cristian Ciocaltea Date: Fri, 27 Feb 2026 22:48:46 +0200 Subject: [PATCH 2/6] phy: rockchip: samsung-hdptx: Handle uncommitted PHY config changes 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: <20260227-hdptx-clk-fixes-v1-2-f998f2762d0f@collabora.com> References: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> In-Reply-To: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> To: Vinod Koul , Neil Armstrong , Heiko Stuebner , Algea Cao , Dmitry Baryshkov Cc: kernel@collabora.com, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 Any changes to the PHY link rate and/or color depth done via the HDMI PHY configuration API are not immediately programmed into the hardware, but are delayed until the PHY usage count gets incremented from 0 to 1, that is when it is powered on or when the PLL clock exposed through the CCF API is prepared, whichever comes first. Since the clock might remain in prepared state after subsequent PHY config changes, the programming can also be triggered via clk_ops.set_rate(). However, from the clock consumer perspective (i.e. VOP2 display controller), the (pixel) clock rate doesn't vary with bpc, as that is handled internally by the PHY and reflected in the TDMS character rate only. As a consequence, changing the bpc while preserving the modeline may lead to out-of-sync issues between CCF and HDMI PHY config state, because the .set_rate() callback is not invoked when clock rate remains constant. This may also happen when the PHY PLL has been pre-programmed by an external entity, e.g. the bootloader, which is actually a regression introduced by the recent FRL patches. Introduce a pll_config_dirty flag to keep track of uncommitted PHY config changes and use it in clk_ops.determine_rate() to invalidate the current clock rate (as known by CCF) and, consequently, ensure those changes are programmed into hardware via clk_ops.set_rate(). Moreover, proceed with a similar fix in phy_ops.power_on() callback, to handle the scenario where the CCF API is not used due to operating in FRL mode, while the clock is still in a prepared state and thus preventing rk_hdptx_phy_consumer_get() to apply the updated PHY configuration. Fixes: de5dba833118 ("phy: rockchip: samsung-hdptx: Add HDMI 2.1 FRL suppor= t") Fixes: 9d0ec51d7c22 ("phy: rockchip: samsung-hdptx: Add high color depth ma= nagement") Signed-off-by: Cristian Ciocaltea Tested-by: Thomas Niederpr=C3=BCm --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 86 ++++++++++++-------= ---- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index 7fb1c22318bb..14d266c8df5c 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -413,6 +413,7 @@ struct rk_hdptx_phy { =20 /* clk provider */ struct clk_hw hw; + bool pll_config_dirty; bool restrict_rate_change; =20 atomic_t usage_count; @@ -1260,13 +1261,19 @@ static int rk_hdptx_tmds_ropll_cmn_config(struct rk= _hdptx_phy *hdptx) =20 static int rk_hdptx_pll_cmn_config(struct rk_hdptx_phy *hdptx) { + int ret; + if (hdptx->hdmi_cfg.rate <=3D HDMI20_MAX_RATE) - return rk_hdptx_tmds_ropll_cmn_config(hdptx); + ret =3D rk_hdptx_tmds_ropll_cmn_config(hdptx); + else if (hdptx->hdmi_cfg.rate =3D=3D FRL_8G4L_RATE) + ret =3D rk_hdptx_frl_lcpll_ropll_cmn_config(hdptx); + else + ret =3D rk_hdptx_frl_lcpll_cmn_config(hdptx); =20 - if (hdptx->hdmi_cfg.rate =3D=3D FRL_8G4L_RATE) - return rk_hdptx_frl_lcpll_ropll_cmn_config(hdptx); + if (!ret) + hdptx->pll_config_dirty =3D false; =20 - return rk_hdptx_frl_lcpll_cmn_config(hdptx); + return ret; } =20 static int rk_hdptx_frl_lcpll_mode_config(struct rk_hdptx_phy *hdptx) @@ -1347,25 +1354,17 @@ static int rk_hdptx_phy_consumer_get(struct rk_hdpt= x_phy *hdptx) return 0; =20 ret =3D regmap_read(hdptx->grf, GRF_HDPTX_STATUS, &status); - if (ret) - goto dec_usage; - - if (status & HDPTX_O_PLL_LOCK_DONE) - dev_warn(hdptx->dev, "PLL locked by unknown consumer!\n"); + if (ret) { + atomic_dec(&hdptx->usage_count); + return ret; + } =20 - if (mode =3D=3D PHY_MODE_DP) { + if (mode =3D=3D PHY_MODE_DP) rk_hdptx_dp_reset(hdptx); - } else { - ret =3D rk_hdptx_pll_cmn_config(hdptx); - if (ret) - goto dec_usage; - } + else + rk_hdptx_pll_cmn_config(hdptx); =20 return 0; - -dec_usage: - atomic_dec(&hdptx->usage_count); - return ret; } =20 static int rk_hdptx_phy_consumer_put(struct rk_hdptx_phy *hdptx, bool forc= e) @@ -1700,16 +1699,20 @@ static int rk_hdptx_phy_power_on(struct phy *phy) if (ret) rk_hdptx_phy_consumer_put(hdptx, true); } else { - regmap_write(hdptx->grf, GRF_HDPTX_CON0, - HDPTX_MODE_SEL << 16 | FIELD_PREP(HDPTX_MODE_SEL, 0x0)); + if (hdptx->pll_config_dirty) + ret =3D rk_hdptx_pll_cmn_config(hdptx); =20 - if (hdptx->hdmi_cfg.mode =3D=3D PHY_HDMI_MODE_FRL) - ret =3D rk_hdptx_frl_lcpll_mode_config(hdptx); - else - ret =3D rk_hdptx_tmds_ropll_mode_config(hdptx); + if (!ret) { + regmap_write(hdptx->grf, GRF_HDPTX_CON0, + HDPTX_MODE_SEL << 16 | FIELD_PREP(HDPTX_MODE_SEL, 0x0)); =20 - if (ret) + if (hdptx->hdmi_cfg.mode =3D=3D PHY_HDMI_MODE_FRL) + ret =3D rk_hdptx_frl_lcpll_mode_config(hdptx); + else + ret =3D rk_hdptx_tmds_ropll_mode_config(hdptx); + } else { rk_hdptx_phy_consumer_put(hdptx, true); + } } =20 return ret; @@ -2081,7 +2084,10 @@ static int rk_hdptx_phy_configure(struct phy *phy, u= nion phy_configure_opts *opt dev_err(hdptx->dev, "invalid hdmi params for phy configure\n"); } else { hdptx->restrict_rate_change =3D true; - dev_dbg(hdptx->dev, "%s rate=3D%llu bpc=3D%u\n", __func__, + hdptx->pll_config_dirty =3D true; + + dev_dbg(hdptx->dev, "%s %s rate=3D%llu bpc=3D%u\n", __func__, + hdptx->hdmi_cfg.mode ? "FRL" : "TMDS", hdptx->hdmi_cfg.rate, hdptx->hdmi_cfg.bpc); } =20 @@ -2303,8 +2309,19 @@ static int rk_hdptx_phy_clk_determine_rate(struct cl= k_hw *hw, { struct rk_hdptx_phy *hdptx =3D to_rk_hdptx_phy(hw); =20 - if (hdptx->hdmi_cfg.mode =3D=3D PHY_HDMI_MODE_FRL) - return hdptx->hdmi_cfg.rate; + /* + * Invalidate current clock rate to ensure rk_hdptx_phy_clk_set_rate() + * will be invoked to commit PLL configuration. + */ + if (hdptx->pll_config_dirty) { + req->rate =3D 0; + return 0; + } + + if (hdptx->hdmi_cfg.mode =3D=3D PHY_HDMI_MODE_FRL) { + req->rate =3D hdptx->hdmi_cfg.rate; + return 0; + } =20 /* * FIXME: Temporarily allow altering TMDS char rate via CCF. @@ -2336,17 +2353,6 @@ static int rk_hdptx_phy_clk_set_rate(struct clk_hw *= hw, unsigned long rate, unsigned long parent_rate) { struct rk_hdptx_phy *hdptx =3D to_rk_hdptx_phy(hw); - unsigned long long link_rate =3D rate; - - if (hdptx->hdmi_cfg.mode !=3D PHY_HDMI_MODE_FRL) - link_rate =3D DIV_ROUND_CLOSEST_ULL(rate * hdptx->hdmi_cfg.bpc, 8); - - /* Revert any unlikely link rate change since determine_rate() */ - if (hdptx->hdmi_cfg.rate !=3D link_rate) { - dev_warn(hdptx->dev, "Reverting unexpected rate change from %llu to %llu= \n", - link_rate, hdptx->hdmi_cfg.rate); - hdptx->hdmi_cfg.rate =3D link_rate; - } =20 /* * The link rate would be normally programmed in HW during --=20 2.52.0 From nobody Thu Apr 16 12:28:38 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 113D838A714 for ; Fri, 27 Feb 2026 20:48:55 +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=1772225339; cv=none; b=VVM5HfulsncML0xQshoAiv0mZBBdWw8p3ZSvKqhry2ESVjNtN2Q9sTqd/OlbpGgwdVIq6JGNvaVxbfkR+A26VgkXH3j3N3jsR0ojxE9guULEEv+/p53Bo0vfy5wctcdESP+ylzdlT5YW0ynTaHzveTAIffp/8oBugVIMFcyM1sE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772225339; c=relaxed/simple; bh=l4Su0pklR2T7HnDbslEWlVekgDffWEurFlItFSCNEBU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ld+/2Beh/nhZrzNRJUYlBOLM9unUYYkOcDdOlkIA7SWM1yBaFTvVWv1rfT+uLrALQlUrjH+ArI+FkCX/4xkujb1297fSp2S/Qgs9JIXyppCSxkgH6iBZAh9yiANOlTm0MlRcX+z2nPUtmkE3L5H3GeHfM8T7LRe8OfQ1r8ZrRis= 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=Lr76XhgT; 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="Lr76XhgT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1772225334; bh=l4Su0pklR2T7HnDbslEWlVekgDffWEurFlItFSCNEBU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Lr76XhgT3pF22ZlPP7xtJKrksTgBCAOAvyQRjFushgXOO8GTQByozohUp4P8//dlS TK8rjDL+z+2MvfKWE7ZF45rptLv3RNRnDSkFKSuM0JPWmtekEvBRx76/GuVjrhnnTE 4mRkHMiS14gsWnEbaETtfzw/vAYJvcYQ5tB/QVAf3nbCyOb/EsQ+bXR0HcTZIOTBds J+14uE+23WhFsxQOysRYl1n/y9E5RDFNPj+wNq2Sy9+8fNwgybc2YCcT2tzShFDQxD efPFG8nF/6pQ4Qg3urnSZORpaKa2ryHZNG5uw05E40iTS98fDYDLGTb7AVYMhkn2Wh dI/KkSAwrct0w== Received: from localhost (unknown [86.123.23.225]) (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 3F16817E0F33; Fri, 27 Feb 2026 21:48:54 +0100 (CET) From: Cristian Ciocaltea Date: Fri, 27 Feb 2026 22:48:47 +0200 Subject: [PATCH 3/6] phy: rockchip: samsung-hdptx: Drop TMDS rate setup workaround 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: <20260227-hdptx-clk-fixes-v1-3-f998f2762d0f@collabora.com> References: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> In-Reply-To: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> To: Vinod Koul , Neil Armstrong , Heiko Stuebner , Algea Cao , Dmitry Baryshkov Cc: kernel@collabora.com, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 Since commit ba9c2fe18c17 ("drm/rockchip: dw_hdmi_qp: Switch to phy_configure()") the TMDS rate setup doesn't rely anymore on the unconventional usage of the bus width, instead it is managed exclusively through the HDMI PHY configuration API. Drop the now obsolete workaround to retrieve the TMDS character rate via phy_get_bus_width() during power_on(). While at it, get rid of the extra call to rk_hdptx_phy_consumer_put() by moving the statement at the end of the function. Signed-off-by: Cristian Ciocaltea Tested-by: Thomas Niederpr=C3=BCm --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 26 ++++++-------------= ---- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index 14d266c8df5c..b56360b5df78 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -1655,22 +1655,6 @@ static int rk_hdptx_phy_power_on(struct phy *phy) enum phy_mode mode =3D phy_get_mode(phy); int ret, lane; =20 - if (mode !=3D PHY_MODE_DP) { - if (!hdptx->hdmi_cfg.rate && hdptx->hdmi_cfg.mode !=3D PHY_HDMI_MODE_FRL= ) { - /* - * FIXME: Temporary workaround to setup TMDS char rate - * from the RK DW HDMI QP bridge driver. - * Will be removed as soon the switch to the HDMI PHY - * configuration API has been completed on both ends. - */ - hdptx->hdmi_cfg.rate =3D phy_get_bus_width(hdptx->phy) & 0xfffffff; - hdptx->hdmi_cfg.rate *=3D 100; - } - - dev_dbg(hdptx->dev, "%s rate=3D%llu bpc=3D%u\n", __func__, - hdptx->hdmi_cfg.rate, hdptx->hdmi_cfg.bpc); - } - ret =3D rk_hdptx_phy_consumer_get(hdptx); if (ret) return ret; @@ -1696,9 +1680,10 @@ static int rk_hdptx_phy_power_on(struct phy *phy) rk_hdptx_dp_pll_init(hdptx); =20 ret =3D rk_hdptx_dp_aux_init(hdptx); - if (ret) - rk_hdptx_phy_consumer_put(hdptx, true); } else { + dev_dbg(hdptx->dev, "%s rate=3D%llu bpc=3D%u\n", __func__, + hdptx->hdmi_cfg.rate, hdptx->hdmi_cfg.bpc); + if (hdptx->pll_config_dirty) ret =3D rk_hdptx_pll_cmn_config(hdptx); =20 @@ -1710,11 +1695,12 @@ static int rk_hdptx_phy_power_on(struct phy *phy) ret =3D rk_hdptx_frl_lcpll_mode_config(hdptx); else ret =3D rk_hdptx_tmds_ropll_mode_config(hdptx); - } else { - rk_hdptx_phy_consumer_put(hdptx, true); } } =20 + if (ret) + rk_hdptx_phy_consumer_put(hdptx, true); + return ret; } =20 --=20 2.52.0 From nobody Thu Apr 16 12:28:38 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 E8ECD478842 for ; Fri, 27 Feb 2026 20:48:56 +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=1772225339; cv=none; b=OoYdY8NK3xZkfBRSqbjXUD+GBvqboG16ethoMkumUPLWf4H619GCcg2UZKsnG8Nf2yc3uKdHGVuQtPabykT+NtZUR18LOULtJpO2VXB8HDA38H/p/IyGtXzcQ9cVYSRaZXBaj4k+fRxaU4SNAcNA6BUIadRl6ZRvx8BmxawwWIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772225339; c=relaxed/simple; bh=jAV1rL/dLM95YP1sZnfa/b90+uXslqsIMfLbW9A3ld4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AqWMzvMU0Bn6ZrvXP8He2ixN6Au6DmV8GypScFmRScA8LfiYVbKRxonpIlZeqJFsg1oYa7MPG+1lMnoVM+f4zEWaLZJGdKbwvYAFb+AYGVchtzqinutu5JVxksfbTyUeYggEuQ/km6fuviBn8x4dOKyh+/gvbbWB2FZYyhG9ytM= 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=g0nLWeX5; 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="g0nLWeX5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1772225335; bh=jAV1rL/dLM95YP1sZnfa/b90+uXslqsIMfLbW9A3ld4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=g0nLWeX5eCO2JrJCAx/PrNGwvGj0sU0A38oCfihWu6JalsrLXTjp+v1bZ2HjoxM1u Y4fvkcr1riHVLCaTNv8dc1HAOOUSZ1T7RmNiUvMNcg36PVfBXImZr4V+c7jAGai/tB jd6Ry/jCWIZ7qDHD9FruxapFXPnr5ztb8F0lsdCyPRj8ZxXDboErkgKYKpI3AY6r60 rK/8n0XS0b4ecj1nYrVbaaLxaLpe03Cq+DzZpm5QVJu3P8kHK1n3V8PQlbiKpFK19r WzaMyityV8CKPvjCzAmql/ufYAxWRTbC5I4FiDDgnCuyxU7Pbk36y0PYK3B7sjR4da LnygPPAeg5UbA== Received: from localhost (unknown [86.123.23.225]) (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 1397E17E1004; Fri, 27 Feb 2026 21:48:55 +0100 (CET) From: Cristian Ciocaltea Date: Fri, 27 Feb 2026 22:48:48 +0200 Subject: [PATCH 4/6] phy: rockchip: samsung-hdptx: Drop restrict_rate_change handling 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: <20260227-hdptx-clk-fixes-v1-4-f998f2762d0f@collabora.com> References: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> In-Reply-To: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> To: Vinod Koul , Neil Armstrong , Heiko Stuebner , Algea Cao , Dmitry Baryshkov Cc: kernel@collabora.com, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 Since commit 6efbd0f46dd8 ("phy: rockchip: samsung-hdptx: Restrict altering TMDS char rate via CCF"), adjusting the rate via the Common Clock Framework API has been disallowed. To avoid breaking existing users until switching to the PHY config API, it introduced a temporary exception to the rule, controlled via the 'restrict_rate_change' flag. As the API transition completed, remove the now deprecated exception logic. Signed-off-by: Cristian Ciocaltea Tested-by: Thomas Niederpr=C3=BCm --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 42 +++++--------------= ---- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index b56360b5df78..e5c8bc95a416 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -414,7 +414,6 @@ struct rk_hdptx_phy { /* clk provider */ struct clk_hw hw; bool pll_config_dirty; - bool restrict_rate_change; =20 atomic_t usage_count; =20 @@ -2069,7 +2068,6 @@ static int rk_hdptx_phy_configure(struct phy *phy, un= ion phy_configure_opts *opt if (ret) { dev_err(hdptx->dev, "invalid hdmi params for phy configure\n"); } else { - hdptx->restrict_rate_change =3D true; hdptx->pll_config_dirty =3D true; =20 dev_dbg(hdptx->dev, "%s %s rate=3D%llu bpc=3D%u\n", __func__, @@ -2296,41 +2294,17 @@ static int rk_hdptx_phy_clk_determine_rate(struct c= lk_hw *hw, struct rk_hdptx_phy *hdptx =3D to_rk_hdptx_phy(hw); =20 /* - * Invalidate current clock rate to ensure rk_hdptx_phy_clk_set_rate() - * will be invoked to commit PLL configuration. + * For uncommitted PLL configuration, invalidate the current clock rate + * to ensure rk_hdptx_phy_clk_set_rate() will be always invoked. + * Otherwise, restrict the rate according to the PHY link setup. */ - if (hdptx->pll_config_dirty) { + if (hdptx->pll_config_dirty) req->rate =3D 0; - return 0; - } - - if (hdptx->hdmi_cfg.mode =3D=3D PHY_HDMI_MODE_FRL) { + else if (hdptx->hdmi_cfg.mode =3D=3D PHY_HDMI_MODE_FRL) req->rate =3D hdptx->hdmi_cfg.rate; - return 0; - } - - /* - * FIXME: Temporarily allow altering TMDS char rate via CCF. - * To be dropped as soon as the RK DW HDMI QP bridge driver - * switches to make use of phy_configure(). - */ - if (!hdptx->restrict_rate_change && req->rate !=3D hdptx->hdmi_cfg.rate) { - struct phy_configure_opts_hdmi hdmi =3D { - .tmds_char_rate =3D req->rate, - }; - - int ret =3D rk_hdptx_phy_verify_hdmi_config(hdptx, &hdmi, &hdptx->hdmi_c= fg); - - if (ret) - return ret; - } - - /* - * The TMDS char rate shall be adjusted via phy_configure() only, - * hence ensure rk_hdptx_phy_clk_set_rate() won't be invoked with - * a different rate argument. - */ - req->rate =3D DIV_ROUND_CLOSEST_ULL(hdptx->hdmi_cfg.rate * 8, hdptx->hdmi= _cfg.bpc); + else + req->rate =3D DIV_ROUND_CLOSEST_ULL(hdptx->hdmi_cfg.rate * 8, + hdptx->hdmi_cfg.bpc); =20 return 0; } --=20 2.52.0 From nobody Thu Apr 16 12:28:38 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 EC736478855 for ; Fri, 27 Feb 2026 20:48:57 +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=1772225342; cv=none; b=o7oqXuqqIWFB8E9ZsRh+/3LThhC9GdGebdHFD/3kGkt0Ok0lkvyVmxm1o5oqNAlzhoy1mQa2X+6+jbKTS2k5RF+NGEotmvNppRwVXHQm28/Ul4sZ58qwIjYYfajhuMCftPjIpXxCOjGz2NWJbouxL0z5fLNfz/l+kF9r2kqa+Bg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772225342; c=relaxed/simple; bh=6VdwbDzh9c5THmToHLBg9iEmO9d1dcL9v7l56XWwBcI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JXncL3e0d6zYMENaD50GzahzUkvlv/IyNxUyHeKcEyLtQVJ1OobPIWopHlhCqOpYBKOEroXGkGQSHdzHznXAwnkkVVg0dLfYEZvlrZQH30GlRwvveS/KcrbaLrFUA4aZSa1enM9A8WXCymUc3GoB+WTBYH1d2lO9YlvFKLDKbXQ= 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=g+J95y9g; 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="g+J95y9g" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1772225336; bh=6VdwbDzh9c5THmToHLBg9iEmO9d1dcL9v7l56XWwBcI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=g+J95y9gDuFntS6xe2QP3zXvHCoZCtEY4JT7Y4BXVVFYSihpXkEuqtfWFQKfju30z fXMHZ+QK256ZT3ftf0RfsDD5byNI/KzlkBhxcMDzYBLgxCX6gQTle2v5PZokciXRr3 D8kU2cM0xNytVd9P/tFwMSaCahlhiGNlCkzblISQQsRg/nyiczwTm3+IVNtf3cg6cd EU2apc2MfOoG3WpAkawqhyHWbmhQkr/OJF8uPIpy5W6sxNE0oMIPXq6u1myVHyIHTb x9RbHNIEA8JyU/mDJJWsUrEWITGJTGTWXK+fwGinTbMoAy8U65v9BOwLcRKBgLXPU7 jZmlUoxyEBpqw== Received: from localhost (unknown [86.123.23.225]) (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 D581217E1005; Fri, 27 Feb 2026 21:48:55 +0100 (CET) From: Cristian Ciocaltea Date: Fri, 27 Feb 2026 22:48:49 +0200 Subject: [PATCH 5/6] phy: rockchip: samsung-hdptx: Simplify GRF access with FIELD_PREP_WM16() 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: <20260227-hdptx-clk-fixes-v1-5-f998f2762d0f@collabora.com> References: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> In-Reply-To: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> To: Vinod Koul , Neil Armstrong , Heiko Stuebner , Algea Cao , Dmitry Baryshkov Cc: kernel@collabora.com, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 The 16 most significant bits of the general-purpose register (GRF) are used as a write-enable mask for the remaining 16 bits. Make use of the recently introduced FIELD_PREP_WM16() macro to avoid open-coding the bit shift operations and improve code readability. Signed-off-by: Cristian Ciocaltea Tested-by: Thomas Niederpr=C3=BCm --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 52 +++++++++++--------= ---- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index e5c8bc95a416..baa6916331be 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2021-2022 Rockchip Electronics Co., Ltd. - * Copyright (c) 2024 Collabora Ltd. + * Copyright (c) 2024-2026 Collabora Ltd. * * Author: Algea Cao * Author: Cristian Ciocaltea @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -949,7 +950,9 @@ static void rk_hdptx_pre_power_up(struct rk_hdptx_phy *= hdptx) reset_control_assert(hdptx->rsts[RST_CMN].rstc); reset_control_assert(hdptx->rsts[RST_INIT].rstc); =20 - val =3D (HDPTX_I_PLL_EN | HDPTX_I_BIAS_EN | HDPTX_I_BGR_EN) << 16; + val =3D (FIELD_PREP_WM16(HDPTX_I_PLL_EN, 0) | + FIELD_PREP_WM16(HDPTX_I_BIAS_EN, 0) | + FIELD_PREP_WM16(HDPTX_I_BGR_EN, 0)); regmap_write(hdptx->grf, GRF_HDPTX_CON0, val); } =20 @@ -960,8 +963,8 @@ static int rk_hdptx_post_enable_lane(struct rk_hdptx_ph= y *hdptx) =20 reset_control_deassert(hdptx->rsts[RST_LANE].rstc); =20 - val =3D (HDPTX_I_BIAS_EN | HDPTX_I_BGR_EN) << 16 | - HDPTX_I_BIAS_EN | HDPTX_I_BGR_EN; + val =3D (FIELD_PREP_WM16(HDPTX_I_BIAS_EN, 1) | + FIELD_PREP_WM16(HDPTX_I_BGR_EN, 1)); regmap_write(hdptx->grf, GRF_HDPTX_CON0, val); =20 /* 3 lanes FRL mode */ @@ -990,16 +993,15 @@ static int rk_hdptx_post_enable_pll(struct rk_hdptx_p= hy *hdptx) u32 val; int ret; =20 - val =3D (HDPTX_I_BIAS_EN | HDPTX_I_BGR_EN) << 16 | - HDPTX_I_BIAS_EN | HDPTX_I_BGR_EN; + val =3D (FIELD_PREP_WM16(HDPTX_I_BIAS_EN, 1) | + FIELD_PREP_WM16(HDPTX_I_BGR_EN, 1)); regmap_write(hdptx->grf, GRF_HDPTX_CON0, val); =20 usleep_range(10, 15); reset_control_deassert(hdptx->rsts[RST_INIT].rstc); =20 usleep_range(10, 15); - val =3D HDPTX_I_PLL_EN << 16 | HDPTX_I_PLL_EN; - regmap_write(hdptx->grf, GRF_HDPTX_CON0, val); + regmap_write(hdptx->grf, GRF_HDPTX_CON0, FIELD_PREP_WM16(HDPTX_I_PLL_EN, = 1)); =20 usleep_range(10, 15); reset_control_deassert(hdptx->rsts[RST_CMN].rstc); @@ -1037,7 +1039,9 @@ static void rk_hdptx_phy_disable(struct rk_hdptx_phy = *hdptx) reset_control_assert(hdptx->rsts[RST_CMN].rstc); reset_control_assert(hdptx->rsts[RST_INIT].rstc); =20 - val =3D (HDPTX_I_PLL_EN | HDPTX_I_BIAS_EN | HDPTX_I_BGR_EN) << 16; + val =3D (FIELD_PREP_WM16(HDPTX_I_PLL_EN, 0) | + FIELD_PREP_WM16(HDPTX_I_BIAS_EN, 0) | + FIELD_PREP_WM16(HDPTX_I_BGR_EN, 0)); regmap_write(hdptx->grf, GRF_HDPTX_CON0, val); } =20 @@ -1135,7 +1139,7 @@ static int rk_hdptx_frl_lcpll_cmn_config(struct rk_hd= ptx_phy *hdptx) =20 rk_hdptx_pre_power_up(hdptx); =20 - regmap_write(hdptx->grf, GRF_HDPTX_CON0, LC_REF_CLK_SEL << 16); + regmap_write(hdptx->grf, GRF_HDPTX_CON0, FIELD_PREP_WM16(LC_REF_CLK_SEL, = 0)); =20 rk_hdptx_multi_reg_write(hdptx, rk_hdptx_common_cmn_init_seq); rk_hdptx_multi_reg_write(hdptx, rk_hdptx_frl_lcpll_cmn_init_seq); @@ -1178,8 +1182,7 @@ static int rk_hdptx_frl_lcpll_ropll_cmn_config(struct= rk_hdptx_phy *hdptx) rk_hdptx_pre_power_up(hdptx); =20 /* ROPLL input reference clock from LCPLL (cascade mode) */ - regmap_write(hdptx->grf, GRF_HDPTX_CON0, - (LC_REF_CLK_SEL << 16) | LC_REF_CLK_SEL); + regmap_write(hdptx->grf, GRF_HDPTX_CON0, FIELD_PREP_WM16(LC_REF_CLK_SEL, = 1)); =20 rk_hdptx_multi_reg_write(hdptx, rk_hdptx_common_cmn_init_seq); rk_hdptx_multi_reg_write(hdptx, rk_hdptx_frl_lcpll_ropll_cmn_init_seq); @@ -1218,7 +1221,7 @@ static int rk_hdptx_tmds_ropll_cmn_config(struct rk_h= dptx_phy *hdptx) =20 rk_hdptx_pre_power_up(hdptx); =20 - regmap_write(hdptx->grf, GRF_HDPTX_CON0, LC_REF_CLK_SEL << 16); + regmap_write(hdptx->grf, GRF_HDPTX_CON0, FIELD_PREP_WM16(LC_REF_CLK_SEL, = 0)); =20 rk_hdptx_multi_reg_write(hdptx, rk_hdptx_common_cmn_init_seq); rk_hdptx_multi_reg_write(hdptx, rk_hdptx_tmds_cmn_init_seq); @@ -1336,11 +1339,9 @@ static void rk_hdptx_dp_reset(struct rk_hdptx_phy *h= dptx) FIELD_PREP(LN_TX_DRV_EI_EN_MASK, 0)); =20 regmap_write(hdptx->grf, GRF_HDPTX_CON0, - HDPTX_I_PLL_EN << 16 | FIELD_PREP(HDPTX_I_PLL_EN, 0x0)); - regmap_write(hdptx->grf, GRF_HDPTX_CON0, - HDPTX_I_BIAS_EN << 16 | FIELD_PREP(HDPTX_I_BIAS_EN, 0x0)); - regmap_write(hdptx->grf, GRF_HDPTX_CON0, - HDPTX_I_BGR_EN << 16 | FIELD_PREP(HDPTX_I_BGR_EN, 0x0)); + FIELD_PREP_WM16(HDPTX_I_PLL_EN, 0) | + FIELD_PREP_WM16(HDPTX_I_BIAS_EN, 0) | + FIELD_PREP_WM16(HDPTX_I_BGR_EN, 0)); } =20 static int rk_hdptx_phy_consumer_get(struct rk_hdptx_phy *hdptx) @@ -1611,9 +1612,8 @@ static int rk_hdptx_dp_aux_init(struct rk_hdptx_phy *= hdptx) FIELD_PREP(OVRD_SB_VREG_EN_MASK, 0x1)); =20 regmap_write(hdptx->grf, GRF_HDPTX_CON0, - HDPTX_I_BGR_EN << 16 | FIELD_PREP(HDPTX_I_BGR_EN, 0x1)); - regmap_write(hdptx->grf, GRF_HDPTX_CON0, - HDPTX_I_BIAS_EN << 16 | FIELD_PREP(HDPTX_I_BIAS_EN, 0x1)); + FIELD_PREP_WM16(HDPTX_I_BGR_EN, 1) | + FIELD_PREP_WM16(HDPTX_I_BIAS_EN, 1)); usleep_range(20, 25); =20 reset_control_deassert(hdptx->rsts[RST_INIT].rstc); @@ -1660,7 +1660,7 @@ static int rk_hdptx_phy_power_on(struct phy *phy) =20 if (mode =3D=3D PHY_MODE_DP) { regmap_write(hdptx->grf, GRF_HDPTX_CON0, - HDPTX_MODE_SEL << 16 | FIELD_PREP(HDPTX_MODE_SEL, 0x1)); + FIELD_PREP_WM16(HDPTX_MODE_SEL, 1)); =20 for (lane =3D 0; lane < 4; lane++) { regmap_update_bits(hdptx->regmap, LANE_REG(031e) + 0x400 * lane, @@ -1688,7 +1688,7 @@ static int rk_hdptx_phy_power_on(struct phy *phy) =20 if (!ret) { regmap_write(hdptx->grf, GRF_HDPTX_CON0, - HDPTX_MODE_SEL << 16 | FIELD_PREP(HDPTX_MODE_SEL, 0x0)); + FIELD_PREP_WM16(HDPTX_MODE_SEL, 0)); =20 if (hdptx->hdmi_cfg.mode =3D=3D PHY_HDMI_MODE_FRL) ret =3D rk_hdptx_frl_lcpll_mode_config(hdptx); @@ -1823,8 +1823,7 @@ static int rk_hdptx_phy_set_rate(struct rk_hdptx_phy = *hdptx, u32 bw, status; int ret; =20 - regmap_write(hdptx->grf, GRF_HDPTX_CON0, - HDPTX_I_PLL_EN << 16 | FIELD_PREP(HDPTX_I_PLL_EN, 0x0)); + regmap_write(hdptx->grf, GRF_HDPTX_CON0, FIELD_PREP_WM16(HDPTX_I_PLL_EN, = 0)); =20 switch (dp->link_rate) { case 1620: @@ -1880,8 +1879,7 @@ static int rk_hdptx_phy_set_rate(struct rk_hdptx_phy = *hdptx, regmap_update_bits(hdptx->regmap, CMN_REG(0095), DP_TX_LINK_BW_MASK, FIELD_PREP(DP_TX_LINK_BW_MASK, bw)); =20 - regmap_write(hdptx->grf, GRF_HDPTX_CON0, - HDPTX_I_PLL_EN << 16 | FIELD_PREP(HDPTX_I_PLL_EN, 0x1)); + regmap_write(hdptx->grf, GRF_HDPTX_CON0, FIELD_PREP_WM16(HDPTX_I_PLL_EN, = 1)); =20 ret =3D regmap_read_poll_timeout(hdptx->grf, GRF_HDPTX_STATUS, status, FIELD_GET(HDPTX_O_PLL_LOCK_DONE, status), --=20 2.52.0 From nobody Thu Apr 16 12:28:38 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 C36DB478863 for ; Fri, 27 Feb 2026 20:48:58 +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=1772225341; cv=none; b=aQP8ftj/4Rllr6CSiSEx+ZhtI9CNuyGKxKQ/ruQ+ZWyIccI+j5sM6k8Kc8mItVdsqo3Oz71PVUciV1Y/akZd1wufVLU5yX4XnJewt2wWWLa4XPsleymZw0P4W1Is4pD1oCtg/Cc++WtXJ8tS/25Q+p0pza4p972szfnacRPnRr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772225341; c=relaxed/simple; bh=/sK6i9vVoJoj489C/nqwbfyHVN9JnqcxydzdEsQFnNM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h/4lMLPmKiZ0byeWR9/yzTJ9Q4utZGEDQZ+AWW5p+TgBqhqeckzlVXmnFLqcwOubSPsyB9uJc0CSrOIXuPPr9/0sxZ6tXQklUayO2M75HMeJmp+79XnTXymmN6tICtUDIRQYhZzioDmXwPPYpJCAESWNXC6CUrGRH8i1Ye2/8Sk= 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=bIOaJhXe; 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="bIOaJhXe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1772225336; bh=/sK6i9vVoJoj489C/nqwbfyHVN9JnqcxydzdEsQFnNM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bIOaJhXeoTV33St7mSU68XlnDmEHBpbH1ToVFoNE9jFThwIWZa7UZ/CfoA6IxFGXY 474SVBIuZTqJ6EemCNODH+VoxOHO1X0IgLOFyw1uG720MO6ruqEmm02rVThASZVPPs i2F6yZ69YHDZCSBP+Bcq/PoLOdx21UT0IpRLaU/R8yVHDaVLrjsxZOa36CKfrYQgGL enJYd9C3VjeLhucHoh/Ont5TtLh/LblK2mqzarAIvfhdZGtQMRW+/26YJiKowKSNgz LVMV8gR3QzfGa+CynDk6flnBDUkLT2X8s8w0xueVyblgmlrjk4cnkHitsZwaFV4UcH QAzQQ/tVOC+ww== Received: from localhost (unknown [86.123.23.225]) (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 B7B0B17E107E; Fri, 27 Feb 2026 21:48:56 +0100 (CET) From: Cristian Ciocaltea Date: Fri, 27 Feb 2026 22:48:50 +0200 Subject: [PATCH 6/6] phy: rockchip: samsung-hdptx: Consistently use bitfield macros 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: <20260227-hdptx-clk-fixes-v1-6-f998f2762d0f@collabora.com> References: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> In-Reply-To: <20260227-hdptx-clk-fixes-v1-0-f998f2762d0f@collabora.com> To: Vinod Koul , Neil Armstrong , Heiko Stuebner , Algea Cao , Dmitry Baryshkov Cc: kernel@collabora.com, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 Make the code more robust and improve readability by using the available bitfield macros (e.g. FIELD_PREP, FIELD_GET) whenever possible, instead of open coding the related bit operations. Signed-off-by: Cristian Ciocaltea Tested-by: Thomas Niederpr=C3=BCm --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 22 ++++++++++++++++---= --- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index baa6916331be..3bde7fbb34b1 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -53,6 +53,12 @@ /* CMN_REG(001e) */ #define LCPLL_PI_EN_MASK BIT(5) #define LCPLL_100M_CLK_EN_MASK BIT(0) +/* CMN_REG(0022) */ +#define ANA_LCPLL_PMS_PDIV_MASK GENMASK(7, 4) +#define ANA_LCPLL_PMS_REFDIV_MASK GENMASK(3, 0) +/* CMN_REG(0023) */ +#define LCPLL_PMS_SDIV_RBR_MASK GENMASK(7, 4) +#define LCPLL_PMS_SDIV_HBR_MASK GENMASK(3, 0) /* CMN_REG(0025) */ #define LCPLL_PMS_IQDIV_RSTN_MASK BIT(4) /* CMN_REG(0028) */ @@ -1157,9 +1163,11 @@ static int rk_hdptx_frl_lcpll_cmn_config(struct rk_h= dptx_phy *hdptx) regmap_write(hdptx->regmap, CMN_REG(0020), cfg->pms_mdiv); regmap_write(hdptx->regmap, CMN_REG(0021), cfg->pms_mdiv_afc); regmap_write(hdptx->regmap, CMN_REG(0022), - (cfg->pms_pdiv << 4) | cfg->pms_refdiv); + FIELD_PREP(ANA_LCPLL_PMS_PDIV_MASK, cfg->pms_pdiv) | + FIELD_PREP(ANA_LCPLL_PMS_REFDIV_MASK, cfg->pms_refdiv)); regmap_write(hdptx->regmap, CMN_REG(0023), - (cfg->pms_sdiv << 4) | cfg->pms_sdiv); + FIELD_PREP(LCPLL_PMS_SDIV_RBR_MASK, cfg->pms_sdiv) | + FIELD_PREP(LCPLL_PMS_SDIV_HBR_MASK, cfg->pms_sdiv)); regmap_write(hdptx->regmap, CMN_REG(002a), cfg->sdm_deno); regmap_write(hdptx->regmap, CMN_REG(002b), cfg->sdm_num_sign); regmap_write(hdptx->regmap, CMN_REG(002c), cfg->sdm_num); @@ -1229,8 +1237,10 @@ static int rk_hdptx_tmds_ropll_cmn_config(struct rk_= hdptx_phy *hdptx) regmap_write(hdptx->regmap, CMN_REG(0051), cfg->pms_mdiv); regmap_write(hdptx->regmap, CMN_REG(0055), cfg->pms_mdiv_afc); regmap_write(hdptx->regmap, CMN_REG(0059), - (cfg->pms_pdiv << 4) | cfg->pms_refdiv); - regmap_write(hdptx->regmap, CMN_REG(005a), cfg->pms_sdiv << 4); + FIELD_PREP(ANA_ROPLL_PMS_PDIV_MASK, cfg->pms_pdiv) | + FIELD_PREP(ANA_ROPLL_PMS_REFDIV_MASK, cfg->pms_refdiv)); + regmap_write(hdptx->regmap, CMN_REG(005a), + FIELD_PREP(ROPLL_PMS_SDIV_RBR_MASK, cfg->pms_sdiv)); =20 regmap_update_bits(hdptx->regmap, CMN_REG(005e), ROPLL_SDM_EN_MASK, FIELD_PREP(ROPLL_SDM_EN_MASK, cfg->sdm_en)); @@ -2192,7 +2202,7 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(st= ruct rk_hdptx_phy *hdptx) ret =3D regmap_read(hdptx->regmap, CMN_REG(002D), &val); if (ret) return 0; - lcpll_hw.sdc_n =3D (val & LCPLL_SDC_N_MASK) >> 1; + lcpll_hw.sdc_n =3D FIELD_GET(LCPLL_SDC_N_MASK, val); =20 for (i =3D 0; i < ARRAY_SIZE(rk_hdptx_frl_lcpll_cfg); i++) { const struct lcpll_config *cfg =3D &rk_hdptx_frl_lcpll_cfg[i]; @@ -2253,7 +2263,7 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(st= ruct rk_hdptx_phy *hdptx) 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; + ropll_hw.pms_sdiv =3D FIELD_GET(PLL_PCG_POSTDIV_SEL_MASK, val) + 1; bpc =3D (FIELD_GET(PLL_PCG_CLK_SEL_MASK, val) << 1) + 8; =20 fout =3D PLL_REF_CLK * ropll_hw.pms_mdiv; --=20 2.52.0