From nobody Fri Jul 24 04:54:30 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 BAB233A1A54 for ; Thu, 23 Jul 2026 19:41: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=1784835723; cv=none; b=DC95xHhnHzx37Ae47Opqr143w9kxhnji6eYWswek5r5dsBlRAJ+pOEso19kuX3U3u4dIh+z3PbT2DYQL7w4zIy1PeacsDXjJb5nhhnqmnK4eUIig+kldl/uBYKNlfkFMSnRg2gM/2bjBNmfOG6kFEh+linkoKgrxWLTfp01HGhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784835723; c=relaxed/simple; bh=DpuLUtdDhJa4UJFDwUavVl/FHq+zvMTjYuiEWd+fonE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S4cYbkaz8ou1nze+Xyls7xjzu3qVc//7yjiaivPbA8KSFIkuVbHE6SOs8V4GNo3c0HH0TDWkVN2r2nB+WL0b6p/481ybb/+kjeUpHzmcIvWfnWjLujbH80CD7qlqr+aZpBx2XbryNKcVqqXrZJP6uKheoEMfEEh25N/Yt6dMRrY= 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=U1XHmCkz; 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="U1XHmCkz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1784835707; bh=DpuLUtdDhJa4UJFDwUavVl/FHq+zvMTjYuiEWd+fonE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=U1XHmCkz4cvsqu3dYxUAgG7ZVgz3RN4agEuSlJ7aobMqGqR1cS6FS/0aDcsQGkUHq WttgcQMuCKwsHx0+9pdNxQ9qRzobuMAVX7h3YC9O2fk/AHhC5hm8yJZ9zrHO0BqmLk gI3nQEWmZCdFHMCQxM6HbCYxdNyve9IBG5t5cMZ21ffp4rM0ufb5Z0+U3fpCL9M9WU o3S1a8ArR+Oqot1zebeJl1mpKIq25mnxCUKk0a44b0BwDQPuZDXN76YE7b6SOvcTRD 8BPpL5tm9zi7PLsWCQ48SPm34zVg4KMq30zgggcftPIZzsA9J6arEsXorRTV6oK+e2 uuJfOtRfFpWHQ== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 2C44517E0A45; Thu, 23 Jul 2026 21:41:47 +0200 (CEST) From: Cristian Ciocaltea Date: Thu, 23 Jul 2026 22:41:44 +0300 Subject: [PATCH v5 01/10] 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: <20260723-hdptx-clk-fixes-v5-1-8e786067865f@collabora.com> References: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@collabora.com> In-Reply-To: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@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, =?utf-8?q?Thomas_Niederpr=C3=BCm?= , Simon Wright , Diederik de Haas , Andy Yan , Dmitry Baryshkov X-Mailer: b4 0.15.2 The PHY PLL can be 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") Tested-by: Thomas Niederpr=C3=BCm Tested-by: Simon Wright Tested-by: Diederik de Haas # NanoPC-T6 LTS Reviewed-by: Andy Yan Reviewed-by: Dmitry Baryshkov Signed-off-by: Cristian Ciocaltea --- 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..710603afff86 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_ROUND_CLOSEST_ULL(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.55.0 From nobody Fri Jul 24 04:54:30 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 2029B3DD500 for ; Thu, 23 Jul 2026 19:41:51 +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=1784835715; cv=none; b=hdp+xxD5uDjyvCoAB0hpltmOotp4LTbD5rYIFxG8FFsbbZh69GPVILahtwtu/5wvc8dOA/uxwgIuQZeMec2ztQ/4rnmrAVJUBHgOpGOikNtVpb4BznU2zMPrwu3rcLugbjHN29pGzFQ+TxNPPkMw9zFWJXoDfMJFdJUdCx3pLBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784835715; c=relaxed/simple; bh=LY0yMgZJBPQvaHgbjl3dveOux4Be0xwL6G2Zen77Log=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QivpEDGT9bth5fnZ3nz3kbo4ykJF3U7iJjSgi38YV2/0w3T6r+kmORSjzQ/XBph9Qz4e0z86p0RFLpQqlFSMGYguWvVLwTzW5DmLDpg7MMRmla2b7hOQK9+LtN+ZgJstrxweQvAksd29ZMGpa6dX2oZVUN7JXBDEryfiyV2oCno= 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=K8MC9VW5; 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="K8MC9VW5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1784835708; bh=LY0yMgZJBPQvaHgbjl3dveOux4Be0xwL6G2Zen77Log=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K8MC9VW5GsaRRF1DRBmLNZqNCtvqHgPVk8eDSIb1mIa/SbNtOrx/afZgJlPhL1YiX 8dnaa/ctKcSP98bAG2S2s1uDleDhkphD/FCZUXSUapKvTL+4PgTV+dl9VqOxdZvsHr 5Bve6LF14dRH05F7t12eCaS4wpxuNJz8iJ+aifuufqXk4pnMjP5ksKEIdhnDJaduEI SXUUXJGbv9LBaiftIs73qmXMx1Wmj2OSsZZFbvfROKYUlYdNZU94eLC7t5YXEPO1Bt jdM4I4yIoNZAh+MIE9GWHLFuHn6rJaSux6WAOEnIZunRKCWqRyp41QbcCa/uaIqd5I wCnytMFhNtdug== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id ED92517E0C7E; Thu, 23 Jul 2026 21:41:47 +0200 (CEST) From: Cristian Ciocaltea Date: Thu, 23 Jul 2026 22:41:45 +0300 Subject: [PATCH v5 02/10] phy: rockchip: samsung-hdptx: Prevent divide-by-zero when computing clk rate 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: <20260723-hdptx-clk-fixes-v5-2-8e786067865f@collabora.com> References: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@collabora.com> In-Reply-To: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@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, Sashiko , Diederik de Haas , Dmitry Baryshkov , Andy Yan X-Mailer: b4 0.15.2 Calculating 'sdm' fraction in rk_hdptx_phy_clk_calc_rate_from_pll_cfg() could trigger a divide-by-zero, as it uses div_u64() with a denominator read directly from hardware: the values ropll_hw.sdm_deno, ropll_hw.sdc_deno, ropll_hw.sdc_n, and ropll_hw.sdc_num are populated from PLL registers which, in theory, could be left by the bootloader uninitialized/misconfigured. Provide the necessary sanitization to avoid trusting the hardware state. Reported-by: Sashiko Closes: https://sashiko.dev/#/patchset/20260611-hdptx-clk-fixes-v3-0-67b1b0= c00e16@collabora.com?part=3D1 Fixes: 3481fc04d969 ("phy: rockchip: samsung-hdptx: Compute clk rate from P= LL config") Tested-by: Diederik de Haas # NanoPC-T6 LTS Reviewed-by: Dmitry Baryshkov Reviewed-by: Andy Yan Signed-off-by: Cristian Ciocaltea --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index 710603afff86..44e99343f249 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -2270,10 +2270,15 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(= struct rk_hdptx_phy *hdptx) =20 fout =3D PLL_REF_CLK * ropll_hw.pms_mdiv; if (ropll_hw.sdm_en) { + val =3D 16U * ropll_hw.sdm_deno * + (ropll_hw.sdc_deno * ropll_hw.sdc_n - ropll_hw.sdc_num); + if (!val) { + dev_dbg(hdptx->dev, "Invalid ROPLL hw state: deno =3D=3D 0\n"); + return 0; + } + 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)); + ropll_hw.pms_mdiv * ropll_hw.sdm_num, val); =20 if (ropll_hw.sdm_num_sign) fout =3D fout - sdm; --=20 2.55.0 From nobody Fri Jul 24 04:54:30 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 3BAE53D1ABD for ; Thu, 23 Jul 2026 19:41:52 +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=1784835719; cv=none; b=KHMJIrCxECRPNx6nCYF6If2ZEsyalip62aK47cRW24KDqy1WTrSRI5ro+xNcX5xfELyQkZOZmNaoxarP5hmemv3fU89uThr6agy09M/V6cCB3wIKd4/Tl6g0AxmcjrL4Ld8wLVBkY7lgZ35GMEQH32zeSSnuMfhnUMdLq10XonA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784835719; c=relaxed/simple; bh=3wiA+YdhNokfHpUT/YTfeE6P2ehlPZVLJt7TZ79Hbic=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qRDG3qskmGmBMAOQ6YZedxbcc/kCgc4L99HqPVFk1iQr4e7xrFxn1wzvI756NQdhN7mxqCvJzL90YusUZO7kNHQDqjz2yBPSpUIi68t6eak6sairKwnKN5ueZkEHBECN3nTtMGWySPbK4qqXx9JV9200v2lyFIPtVoMSSRgpfLk= 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=Qm1IYy2T; 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="Qm1IYy2T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1784835708; bh=3wiA+YdhNokfHpUT/YTfeE6P2ehlPZVLJt7TZ79Hbic=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Qm1IYy2TtPqOyjF109D4Iw36QfsgGfXb1gZA/RsciOb2Coce0le/kCY5R1eAEsMQ7 UuplZPRkZRHUILOhZ7dFyCED8HEsA6/UCFxBhv4epPQcp+bcuyNa4usjUitE5NxM7F Q6YTEKfDS9Rhu16RkyaxYwHHEZWBAeqBqfrkDMEl6UCexIxVhWoPAuHQfY3LNAwyOj FtkdbUuAjHtRXy9mwCyLm/T/sCqPfhH3mbS1BIgIv/U9WWo53MuDZXb86urEu/NfxH VwbY3WwYVnbLVZQKZe6xfFaxfkrkaasROvlCnWDgDdgnjXPs5b6HnlhOCApS9oR7UC 1/XJgEElJijYQ== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id B2FAD17E0CA6; Thu, 23 Jul 2026 21:41:48 +0200 (CEST) From: Cristian Ciocaltea Date: Thu, 23 Jul 2026 22:41:46 +0300 Subject: [PATCH v5 03/10] phy: rockchip: samsung-hdptx: Guard against clk rate integer underflow 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: <20260723-hdptx-clk-fixes-v5-3-8e786067865f@collabora.com> References: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@collabora.com> In-Reply-To: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@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, Sashiko X-Mailer: b4 0.15.2 The 'fout' subtraction in rk_hdptx_phy_clk_calc_rate_from_pll_cfg() could result in an integer underflow, if the hardware registers are misconfigured or contain uninitialized values, such that the computed sigma-delta modulator offset sdm exceeds the base frequency fout. This might lead to an absurdly high clock rate being returned to the Common Clock Framework, with unpredictable effects on downstream clk consumers. Provide the necessary sanitization to avoid trusting the hardware state. Reported-by: Sashiko Closes: https://lore.kernel.org/all/20260611235702.0E9691F000E9@smtp.kernel= .org/ Fixes: 3481fc04d969 ("phy: rockchip: samsung-hdptx: Compute clk rate from P= LL config") Signed-off-by: Cristian Ciocaltea --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index 44e99343f249..fcf04e9814cc 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -2280,10 +2280,16 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(= struct rk_hdptx_phy *hdptx) sdm =3D div_u64(PLL_REF_CLK * ropll_hw.sdc_deno * ropll_hw.pms_mdiv * ropll_hw.sdm_num, val); =20 - if (ropll_hw.sdm_num_sign) + if (ropll_hw.sdm_num_sign) { + if (sdm > fout) { + dev_dbg(hdptx->dev, "Invalid ROPLL hw state: sdm > fout\n"); + return 0; + } + fout =3D fout - sdm; - else + } else { fout =3D fout + sdm; + } } =20 return DIV_ROUND_CLOSEST_ULL(fout * 2 * 8, ropll_hw.pms_sdiv * 10 * bpc); --=20 2.55.0 From nobody Fri Jul 24 04:54:30 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 BAD643B4439 for ; Thu, 23 Jul 2026 19:41: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=1784835726; cv=none; b=dlWohLrz7gme5UCpj3Dc4bMas/aO+s7iLFTZ4qcUtMIXYbDJx9unNUq0uafqQvK/8JD0QuG95HwE5sl0NvQfF8mvgD8fVkkLWpCU2GXUixN1QfmnNdKFldP3y15OmQVlJaIwC0en8ecQjyYegNO22NKdnRt+sMYmVoKfTXbC+pY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784835726; c=relaxed/simple; bh=5sGfimKm9sYIHnBzOCtycoKCwoNHkaa8YO7d2RCED3U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b/vsgArumBb5DZhTPtXJIonYZMX3lylf4sXElId1+ZoAbZA5rrb5OAOiUiLm+ZF5X7hJ6fIn7O6Ed2HP12s/6J7JXTMyhqgjT1Privmc+IOr6qPc2frVnKnBIpjGsHsvkjr62JNFH/xsteph0huyveNjVhA7h0p1KAY9C99zDNQ= 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=NKmedy4P; 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="NKmedy4P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1784835709; bh=5sGfimKm9sYIHnBzOCtycoKCwoNHkaa8YO7d2RCED3U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NKmedy4PE1wOgOX+OoAsyHTHhRCmr3jdrQf0+qzUqm4Ssu6jBfRHzsyZF3avsd+2D xI6bLapWTaFlxqoNz1zozgJ+wBY5pYgO3GKhfyD+VrHzvrxbaDD3c4/mqXwbohPEYx f5g3Wzaw4jnyBtHZKlE9zGng3TnmZwfsbUQ8rCmzRo1PVLM5+ZwWPa7yrBLkkkkYCe rPVC+qoOox/B2p2WcOlhnOe6/hH/Z7Bs7+pJ7g/uyQRnUtdqUt5UTBxjOXog8/63Hl x/x3pzig1OxQlS4jNR6LcS04/HLQzfNFFpaW4Bqr9myxWF26lNSeHmEj9iTVAPqW9B +Z68TnPa6Uq3A== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 7A55A17E0DC1; Thu, 23 Jul 2026 21:41:49 +0200 (CEST) From: Cristian Ciocaltea Date: Thu, 23 Jul 2026 22:41:47 +0300 Subject: [PATCH v5 04/10] phy: rockchip: samsung-hdptx: Fix rate recalculation for 3.2GHz FRL 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: <20260723-hdptx-clk-fixes-v5-4-8e786067865f@collabora.com> References: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@collabora.com> In-Reply-To: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@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, Sashiko , Diederik de Haas , Dmitry Baryshkov , Andy Yan X-Mailer: b4 0.15.2 rk_hdptx_phy_clk_calc_rate_from_pll_cfg() is currently unable to handle cascade mode for the 3.2GHz FRL operating mode, as it relies solely on LCPLL_LCVCO_MODE_EN_MASK to determinate the rate from the rk_hdptx_frl_lcpll_cfg array. Since there is no entry for this particular rate, the function returns 0. This is the only rate which requires LC_REF_CLK_SEL to be set in GRF_HDPTX_CON0, hence extend the FRL matching accordingly. Reported-by: Sashiko Closes: https://sashiko.dev/#/patchset/20260611-hdptx-clk-fixes-v3-0-67b1b0= c00e16@collabora.com?part=3D1 Fixes: de5dba833118 ("phy: rockchip: samsung-hdptx: Add HDMI 2.1 FRL suppor= t") Tested-by: Diederik de Haas # NanoPC-T6 LTS Reviewed-by: Dmitry Baryshkov Reviewed-by: Andy Yan Signed-off-by: Cristian Ciocaltea --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 33 ++++++++++++++++---= ---- 1 file changed, 24 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 fcf04e9814cc..3a1a43ec2552 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -2206,16 +2206,31 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(= struct rk_hdptx_phy *hdptx) return 0; lcpll_hw.sdc_n =3D (val & LCPLL_SDC_N_MASK) >> 1; =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]; + ret =3D regmap_read(hdptx->grf, GRF_HDPTX_CON0, &val); + if (ret) + return 0; =20 - if (cfg->pms_mdiv =3D=3D lcpll_hw.pms_mdiv && - cfg->pms_sdiv =3D=3D lcpll_hw.pms_sdiv && - cfg->sdm_num_sign =3D=3D lcpll_hw.sdm_num_sign && - cfg->sdm_num =3D=3D lcpll_hw.sdm_num && - cfg->sdm_deno =3D=3D lcpll_hw.sdm_deno && - cfg->sdc_n =3D=3D lcpll_hw.sdc_n) - return cfg->rate; + if (val & LC_REF_CLK_SEL) { + if (lcpll_hw.pms_mdiv =3D=3D 0x6b && + lcpll_hw.sdm_num_sign =3D=3D 0x01 && + lcpll_hw.sdm_num =3D=3D 0x02 && + lcpll_hw.sdm_deno =3D=3D 0x09 && + lcpll_hw.sdc_n =3D=3D FIELD_GET(LCPLL_SDC_N_MASK, 0x02)) + return FRL_8G4L_RATE; + } else { + const struct lcpll_config *cfg; + + for (i =3D 0; i < ARRAY_SIZE(rk_hdptx_frl_lcpll_cfg); i++) { + cfg =3D &rk_hdptx_frl_lcpll_cfg[i]; + + if (cfg->pms_mdiv =3D=3D lcpll_hw.pms_mdiv && + cfg->pms_sdiv =3D=3D lcpll_hw.pms_sdiv && + cfg->sdm_num_sign =3D=3D lcpll_hw.sdm_num_sign && + cfg->sdm_num =3D=3D lcpll_hw.sdm_num && + cfg->sdm_deno =3D=3D lcpll_hw.sdm_deno && + cfg->sdc_n =3D=3D lcpll_hw.sdc_n) + return cfg->rate; + } } =20 dev_dbg(hdptx->dev, "%s no FRL match found\n", __func__); --=20 2.55.0 From nobody Fri Jul 24 04:54:30 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 C1A0F39AD34 for ; Thu, 23 Jul 2026 19:42:00 +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=1784835727; cv=none; b=GPS52mqNLbYoesS6QwVdFWBJNX8sY3gFH5K2ImxrigvCzqNU0FdfxDoad5R9vAikoD2z/naRCk9z5wpzJsQsN3FQHwAO6kGPkutTxV5ZFiKhjaUIb45ozoGjfWZy37ZehBWmYXSlwuPeZoCtV9a+/UEG/jXO3YX2DmeUvdM6DC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784835727; c=relaxed/simple; bh=N/C1FUn4MDJ0V7Gnbk0YofpUdRfAiFbqXNfLZvV6094=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZByzrMn4WnbErcPifrKDtC3gBWoCcj4Ub0eG/tkQA+SbDrkNPaksruUEVZbmtOfvzdjzV6gd8JBCwXZim3epu78DvXckcLlFi+Jr6cVNY9etgTgDAWSvs9FA4biE7eARdFxMcr0XQ7ARAuH603yG6EbW76xm6WD9eIOUMTbGBiM= 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=egowjnYK; 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="egowjnYK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1784835710; bh=N/C1FUn4MDJ0V7Gnbk0YofpUdRfAiFbqXNfLZvV6094=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=egowjnYKGNOVWzyAivHvhXsRMzs6SlZWmSxzPdGYBD7WIl3TE86an3O75JfnXnw1G 8czzuuaFapB1gbeP2Du9fD4FInaidBwsTRJGVGQ3LrNDGN2DYeuFUHU+XYDbnaKSTZ bG76+qasuHHEO8vPHBqqv9E+c7Hg1r5NqmuhfCbeuEzuVOe4ztM2CPeYWfQXuTs9sf sRkJzMO9hEcO4C/Kkgg/ADJjNooEpBQj6hGqOVqaoDyjrf/JYbnIYYBAASSmKZ0dKF C5GoKEX71q4jCTTUv1hKkS2Yi5VKTq0kNrK98IFkqFs9a5vx+PfWmr/iWaiiYLzvav TUfKcIl8FDp3w== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 44DEC17E1064; Thu, 23 Jul 2026 21:41:50 +0200 (CEST) From: Cristian Ciocaltea Date: Thu, 23 Jul 2026 22:41:48 +0300 Subject: [PATCH v5 05/10] 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: <20260723-hdptx-clk-fixes-v5-5-8e786067865f@collabora.com> References: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@collabora.com> In-Reply-To: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@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, =?utf-8?q?Thomas_Niederpr=C3=BCm?= , Simon Wright , Diederik de Haas , Andy Yan X-Mailer: b4 0.15.2 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") Tested-by: Thomas Niederpr=C3=BCm Tested-by: Simon Wright Tested-by: Diederik de Haas # NanoPC-T6 LTS Reviewed-by: Andy Yan Signed-off-by: Cristian Ciocaltea --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 84 +++++++++++++------= ---- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index 3a1a43ec2552..792eb57755eb 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,22 @@ 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) { rk_hdptx_dp_reset(hdptx); } else { - ret =3D rk_hdptx_pll_cmn_config(hdptx); - if (ret) - goto dec_usage; + /* + * Ignore PLL config errors at this point as pll_config_dirty + * was not reset and, therefore, operation will be retried. + */ + 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,13 +1704,18 @@ 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)); + + 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); + } =20 if (ret) rk_hdptx_phy_consumer_put(hdptx, true); @@ -2081,7 +2090,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 @@ -2329,8 +2341,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. @@ -2362,17 +2385,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.55.0 From nobody Fri Jul 24 04:54:30 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 C24C03E6DFA for ; Thu, 23 Jul 2026 19:42:00 +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=1784835727; cv=none; b=LVjltyCg4pmuJV+jabNE4l+gyQgP/hsxwg5j0Rb9heY5t8M3/eaRDpLlkmAg6XuQIKLB57pQ3OXGfI/qqVp0w/xqJF+WpUDWd7aaNe0g4yWtn5s+2svwG2UCzYlbmq0pXxiv7eS6EVUdXQcyc6ijHhyU4aqHZe/VhhQ2VR3eYwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784835727; c=relaxed/simple; bh=FA6gjb7yFKww1Ld0T7YnzSA/v31jHcXY9TgmognE7xI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uQCF4muxy6X3R97hfb5d3q0A7kjop+LvA6qtMPSbEgKBvzLZ6z02xKHmStwx2e6rvv9Dg4r3PKFWqyBvPk8lH/HvvUtsaVGnjnn8FU5yzsb5byzvNbKHU8ZvN8EkU8uHqMfTiQBHsRDEqvn03a0/CQyrKFdorwa9j0a90nKWuqU= 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=LQSFi6NU; 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="LQSFi6NU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1784835711; bh=FA6gjb7yFKww1Ld0T7YnzSA/v31jHcXY9TgmognE7xI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LQSFi6NUPLkoLFJprgnNXsnuPUlUhF2CcJo4R1InI8d2146/7s0p4EszApB3rAUuM 6VJGB/yMKpX0Rt52z5DCrhtGj8bB+PLWK99B76YD756NSixPzW7iz6IzQXodGjbXUs AQCEcOplFzd81kKwE4a4HDjZZtXa42BV4PhOpKhYh4KHazUK5Rzi+7h8EmpTui7Ljo sJCC1qUdln/c6rOPBVmL7cDdwKVOVWAmnyc/yo+Tkza30dmEYO78hwi8n6ofs51Da5 cpvkMH4jmDggDX/yU7xXww5vnJH5nvOHKmBO9yeP0hJGQghbyBPthFllWNRISQnW3C +9SfkOLtjNDIw== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 0B08F17E124A; Thu, 23 Jul 2026 21:41:51 +0200 (CEST) From: Cristian Ciocaltea Date: Thu, 23 Jul 2026 22:41:49 +0300 Subject: [PATCH v5 06/10] 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: <20260723-hdptx-clk-fixes-v5-6-8e786067865f@collabora.com> References: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@collabora.com> In-Reply-To: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@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, =?utf-8?q?Thomas_Niederpr=C3=BCm?= , Simon Wright , Diederik de Haas , Andy Yan X-Mailer: b4 0.15.2 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(). Tested-by: Thomas Niederpr=C3=BCm Tested-by: Simon Wright Tested-by: Diederik de Haas # NanoPC-T6 LTS Reviewed-by: Andy Yan Signed-off-by: Cristian Ciocaltea --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index 792eb57755eb..31abff5ada9e 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -1660,22 +1660,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; @@ -1704,6 +1688,9 @@ static int rk_hdptx_phy_power_on(struct phy *phy) 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 --=20 2.55.0 From nobody Fri Jul 24 04:54:30 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 C2C9E3C819D for ; Thu, 23 Jul 2026 19:42:02 +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=1784835726; cv=none; b=QAFtwhfB6jCjQ1dKF6ol9LT+tvX9yhV54EJbyIiLrrWlI8QVxGjqnSucUCFdvC9ACwamJI5q1CSmFoF1jaDoigBq8nS57v3NA1w8j5S8sV7N2Hq8F+tyz2EhA0I11zGUynpAZF4fBedkhD8IRpfFgh6YgraW8ZeXmbhT30pe4So= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784835726; c=relaxed/simple; bh=Ii50quaNQ/xCX/bGr1AWgM8pL/yTxjNnuc4DhrYCdls=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sEHVnd8BLBenz7tXoUCMz7X+OnH8UP6f+9nfbqSelpZdFuCyqxrcvjPMwbE6dK6T3A1BnrQPY3xcDo0pZuF2x4L1u7RHQeFIVRUSC9px49vOqWf0YATmP4ymLCniUnCvEE16cDjVJNCJsY1YmrQiUqyB39e8vS/To+gRhmHMK2E= 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=QiWTkor/; 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="QiWTkor/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1784835711; bh=Ii50quaNQ/xCX/bGr1AWgM8pL/yTxjNnuc4DhrYCdls=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QiWTkor/umzCt9tZ4s0Wlfo+j4q18jPP+axwAqeJWDcmP1JrbJhv4TTIintvi1NgQ DlZzd4cox60t9Gs96s3bkhq4oh64xLDDpNEqFaH9iqH9j5M/U84M/RBXIra467htKY icgNHp2S/TgDW5OrC58XMQGVkh0WKXd3mKhZG7ddkqB+8V6ThvsLXhhYkJGVMoRICD 8WFtVwL8Hj2u/a3kTkbSaL60SBjR2zCSsiQrsy/TnlDxUcgZ1uJ+0bLB7TYpzBk4YQ 25uD65pJttDdvF9Eujcv1XpcMT0V8gVjlTFbJ/wAS128Zo0lOWiJZ6iwd9nxmryhPx U6G+iiCcUAgFA== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id C774817E1274; Thu, 23 Jul 2026 21:41:51 +0200 (CEST) From: Cristian Ciocaltea Date: Thu, 23 Jul 2026 22:41:50 +0300 Subject: [PATCH v5 07/10] phy: rockchip: samsung-hdptx: Consolidate consumer_put on error path 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: <20260723-hdptx-clk-fixes-v5-7-8e786067865f@collabora.com> References: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@collabora.com> In-Reply-To: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@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.15.2 rk_hdptx_phy_consumer_put() is invoked in both branches of the mode check conditional in rk_hdptx_phy_power_on() on the error path. Simplify the code by moving the single call to the end of the function. No functional change intended. Signed-off-by: Cristian Ciocaltea --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index 31abff5ada9e..eda8e5055588 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -1685,8 +1685,6 @@ 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); @@ -1703,11 +1701,11 @@ static int rk_hdptx_phy_power_on(struct phy *phy) else ret =3D rk_hdptx_tmds_ropll_mode_config(hdptx); } - - if (ret) - rk_hdptx_phy_consumer_put(hdptx, true); } =20 + if (ret) + rk_hdptx_phy_consumer_put(hdptx, true); + return ret; } =20 --=20 2.55.0 From nobody Fri Jul 24 04:54:30 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 CD4643D9551 for ; Thu, 23 Jul 2026 19:42:02 +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=1784835727; cv=none; b=m0lSF2RnOfMbNFqZ8A0wqMs8E/Gc6pW9UFziCL7GMOjdLOph+zixNQB8Jmhdql6vpmbOv5KHWYwyoXGfD1V6jrO4nTfZmTu5jYi5moBD93SvxkXxVPDnqP430g0xH6HxOwATYXPyYx4RZlOxJkNEAOvnpG4jnDVgkGRiEyqenPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784835727; c=relaxed/simple; bh=/Z9S3V5F+HkTvALb4lKHAoUP/Ofe0V9jBqF+2D9oDj4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=k+T2O04loiEJDcWxXzIf7bSYBvJlBLwoApFv1ZkXeQXKBEd4JAtPRYkTDyLvPnzQ5dYlE+GZLNBg1thTSFEJfqZdtdGfNgbUh2ZSjCmIn2h/Mgx3qhLfSKpEgq8QIALLvJhtvRtu3cWrbWWr6Bta4/eU3WB5/GyijpfudWEI2T8= 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=FLM5+Of/; 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="FLM5+Of/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1784835712; bh=/Z9S3V5F+HkTvALb4lKHAoUP/Ofe0V9jBqF+2D9oDj4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FLM5+Of/gosMr14EDkqZY9kBlFNRjQVAqDE5gAwhLJ/rVSWwQKKhBeiFwXcpYZptF X1ktj93HTBetqioZmN8OWZ72pb3mzWP1MCMXEye+1eUdq4eM6CCPLSoRtW6Jl/vevI QWgKVhEyRT1fnSM40WVkw37IVcpGRBHo53nvSEHpaEdJq1mrZb55ugWf8oR4t6N24G LcqgCaqlYYuMIA8JLVGYM2c7C0hUEPmvvaw2TrKqofY8Ur6EQTFvehtMi86ZVHb/Ol yN/k5rvRZAYg/8DlOO7jQA7jj0nGOHZx9MPj9fskOuSt2Q7ufzkjawCqmL3iDAPR4t ILgP6PuA6/yHg== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 8DDD217E151D; Thu, 23 Jul 2026 21:41:52 +0200 (CEST) From: Cristian Ciocaltea Date: Thu, 23 Jul 2026 22:41:51 +0300 Subject: [PATCH v5 08/10] 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: <20260723-hdptx-clk-fixes-v5-8-8e786067865f@collabora.com> References: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@collabora.com> In-Reply-To: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@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, =?utf-8?q?Thomas_Niederpr=C3=BCm?= , Simon Wright , Diederik de Haas , Dmitry Baryshkov X-Mailer: b4 0.15.2 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. Tested-by: Thomas Niederpr=C3=BCm Tested-by: Simon Wright Tested-by: Diederik de Haas # NanoPC-T6 LTS Reviewed-by: Dmitry Baryshkov Signed-off-by: Cristian Ciocaltea --- 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 eda8e5055588..da8f252fb719 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 @@ -2074,7 +2073,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__, @@ -2327,41 +2325,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.55.0 From nobody Fri Jul 24 04:54:30 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 C894B3E2767 for ; Thu, 23 Jul 2026 19:42:02 +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=1784835740; cv=none; b=b2Tk00ucuBuDqm3W5Cdp2UtTVnnP2iHm0AH9mB10vulzAA/Z0GLyN0543YoVq8sXJB4viScbLoaVb9Jh77IGZz7rt/z/KNiF/OAQpV2GxsRPD+k3WPXsu6iIHwWBpPG1vlABm2webAvSu4YdU5XoE0mpzEJkSxRq9tYi9/dQsO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784835740; c=relaxed/simple; bh=5OXrMaF+tNgPJkVuxdJnKbWlkMwckWO6ap72jrIjp4M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RUiQfxCvd2SxaI9PcSBmB2unUTnllea1rtpqEhkza5p83Nbm6Bf4qxG9ngXVViJadhxv7m9jvtdkzc2nl3yHN9XBr5IROdgTwPTiXCW/NNwk0/nMvVVqLH64A2xxdtzDb7yP+oxtt0LsinMdjFVz3URWmVy767prNQQGTZfSIIU= 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=M4BSjVNL; 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="M4BSjVNL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1784835713; bh=5OXrMaF+tNgPJkVuxdJnKbWlkMwckWO6ap72jrIjp4M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=M4BSjVNLijm6MdhxkB/ecCvIf2beXJohnwKxvix6woaRlU+djnzQwBh2elszJ1DRg 1gqm4C5UjKaxBskmr4h/OcQXpDjbYUtUxslNmQGnt1s68GPL9pLnw9i3/K1MrlzNyy VGDsXPUXrJ4UYhJt80hdJXHKJAcOZ9SqWqTZ7Q2qi5u9+SHMGep2LaKUMNzosRenHE kNZk4kTnxUEzLJuy1VFcRRfg1V4mVKWNCSuT/GdwsbKsOyKazqaaTX2GKH0xVUZ3OR kJ5DuGvZH2OtDVmKR+j3eGqeChU6zoZcYVAnf9ksX6Py5lDPHTdmeM1po5qxWIfqgY YL14GXokpGrJg== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 55F5D17E1550; Thu, 23 Jul 2026 21:41:53 +0200 (CEST) From: Cristian Ciocaltea Date: Thu, 23 Jul 2026 22:41:52 +0300 Subject: [PATCH v5 09/10] 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: <20260723-hdptx-clk-fixes-v5-9-8e786067865f@collabora.com> References: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@collabora.com> In-Reply-To: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@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, =?utf-8?q?Thomas_Niederpr=C3=BCm?= , Simon Wright , Diederik de Haas , Dmitry Baryshkov X-Mailer: b4 0.15.2 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. Tested-by: Thomas Niederpr=C3=BCm Tested-by: Simon Wright Tested-by: Diederik de Haas # NanoPC-T6 LTS Reviewed-by: Dmitry Baryshkov Signed-off-by: Cristian Ciocaltea --- 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 da8f252fb719..03977b830414 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) @@ -1616,9 +1617,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); @@ -1665,7 +1665,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, @@ -1693,7 +1693,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); @@ -1828,8 +1828,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: @@ -1885,8 +1884,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.55.0 From nobody Fri Jul 24 04:54:30 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 D7ECC379C5E for ; Thu, 23 Jul 2026 19:42:05 +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=1784835734; cv=none; b=borQqX+cBznxtRKpntq6t47WxETp1UPOP+rd3ZhMN237t75VALOCJFCj0F5lzX2qWOrbcdrHgk3+sXJufCxlXLO8PjX2kNqjWNivKXYQRUR+WmOY9Dzp4QEoM2XaxTN2PlGBwpajiral8TmpU5qAZQYp16EMby+vNx/eJAtHsG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784835734; c=relaxed/simple; bh=PRfBlmThak5T5U5tff8nKvBvXtDEt75yF8aVu8TNhxg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m9pGhHc8TRh2emOSCqvVD8LQkA/PJdaFyX1zv1diOB+NIFba7EpDprzcMZzGY8XL4hd9ddeR6JACZATdaffxcdncVrsSFxjTH2RI33+ig4Gjjjaxj1PVzf4tOGBL4/IeJAALU+BuiYcGxEBiKs1BY6I+D0BThLwWVaFXhcCD3vg= 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=fbJm7lYN; 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="fbJm7lYN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1784835714; bh=PRfBlmThak5T5U5tff8nKvBvXtDEt75yF8aVu8TNhxg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fbJm7lYNVdJ3myoilWECaTpq3MiW80JA/mf1jA18jNlW2ZSS9YxCC5XwA5rzz8qkN t77gp+bamATnKtYDMjO/hssvZKuvUMuf1xi4EPjSCIsVCuBvdg/Kfkn4VVx08Jhcoi 4ao6Fgy7Gv9c6v6OC3Zd/u10unRoCaLAeGNZsKttNNC+iW8118aWzmheRkqfcG3vso +kOT5cTwNS0HbIc/QgxJZn9twxiVNW185Il+cCRFfGAGsJs9mLBXYdV5wrkINCweJb 6ZvDsBF/FeY/flhrCLA0QMd2wUl5kkT1PnLOLCS9Heek24oNDeJALylm7TCMQ4fKr/ +Vc76+/WsHtFg== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 2271F17E371F; Thu, 23 Jul 2026 21:41:54 +0200 (CEST) From: Cristian Ciocaltea Date: Thu, 23 Jul 2026 22:41:53 +0300 Subject: [PATCH v5 10/10] 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: <20260723-hdptx-clk-fixes-v5-10-8e786067865f@collabora.com> References: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@collabora.com> In-Reply-To: <20260723-hdptx-clk-fixes-v5-0-8e786067865f@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, =?utf-8?q?Thomas_Niederpr=C3=BCm?= , Simon Wright , Diederik de Haas , Dmitry Baryshkov X-Mailer: b4 0.15.2 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. Tested-by: Thomas Niederpr=C3=BCm Tested-by: Simon Wright Tested-by: Diederik de Haas # NanoPC-T6 LTS Reviewed-by: Dmitry Baryshkov Signed-off-by: Cristian Ciocaltea --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 30 +++++++++++++++----= ---- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/ph= y/rockchip/phy-rockchip-samsung-hdptx.c index 03977b830414..aa0e36260381 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)); @@ -2177,7 +2187,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(0023), &val); if (ret) return 0; - lcpll_hw.pms_sdiv =3D val & 0xf; + lcpll_hw.pms_sdiv =3D FIELD_GET(LCPLL_PMS_SDIV_HBR_MASK, val); =20 ret =3D regmap_read(hdptx->regmap, CMN_REG(002B), &val); if (ret) @@ -2197,7 +2207,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 ret =3D regmap_read(hdptx->grf, GRF_HDPTX_CON0, &val); if (ret) @@ -2238,12 +2248,12 @@ static u64 rk_hdptx_phy_clk_calc_rate_from_pll_cfg(= struct rk_hdptx_phy *hdptx) ret =3D regmap_read(hdptx->regmap, CMN_REG(005E), &val); if (ret) return 0; - ropll_hw.sdm_en =3D val & ROPLL_SDM_EN_MASK; + ropll_hw.sdm_en =3D FIELD_GET(ROPLL_SDM_EN_MASK, val); =20 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; + ropll_hw.sdm_num_sign =3D FIELD_GET(ROPLL_SDM_NUM_SIGN_RBR_MASK, val); =20 ret =3D regmap_read(hdptx->regmap, CMN_REG(0065), &val); if (ret) @@ -2258,7 +2268,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(0069), &val); if (ret) return 0; - ropll_hw.sdc_n =3D (val & ROPLL_SDC_N_RBR_MASK) + 3; + ropll_hw.sdc_n =3D FIELD_GET(ROPLL_SDC_N_RBR_MASK, val) + 3; =20 ret =3D regmap_read(hdptx->regmap, CMN_REG(006c), &val); if (ret) @@ -2273,7 +2283,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.55.0