[PATCH v2] clk: qcom: clk-rpmh: Make all VRMs optional

Alexander Koskovich posted 1 patch 2 months ago
There is a newer version of this series
drivers/clk/qcom/clk-rpmh.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
[PATCH v2] clk: qcom: clk-rpmh: Make all VRMs optional
Posted by Alexander Koskovich 2 months ago
Some VRMs aren't present on all boards, so mark them as optional. This
prevents probe failures on boards where not all VRMs are present.

This resolves an issue seen on the Nothing Phone (4a) (Eliza) where
probe fails due to RPMH_RF_CLK5 not being present on the board, this is
due to this device having a slightly different PMIC configuration from
the Eliza MTP.

This matches the downstream approach of marking all VRMs as optional
and makes the previous clka_optional handling redundant.

Signed-off-by: Alexander Koskovich <akoskovich@pm.me>
---
Changes in v2:
- Squashed clka_optional revert into patch (Dmitry)
- Simplified patch by just checking if CLK_RPMH_VRM_EN_OFFSET (Konrad)
- Squashed cover into patch commit message and expanded on background
- Link to v1: https://lore.kernel.org/r/20260412-clk-rpmh-vrm-opt-v1-0-37c890c420ff@pm.me
---
 drivers/clk/qcom/clk-rpmh.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
index 547729b1a8ee..269a884645b4 100644
--- a/drivers/clk/qcom/clk-rpmh.c
+++ b/drivers/clk/qcom/clk-rpmh.c
@@ -66,8 +66,6 @@ struct clk_rpmh {
 struct clk_rpmh_desc {
 	struct clk_hw **clks;
 	size_t num_clks;
-	/* RPMh clock clkaN are optional for this platform */
-	bool clka_optional;
 };
 
 static DEFINE_MUTEX(rpmh_clk_lock);
@@ -691,7 +689,6 @@ static struct clk_hw *sm8550_rpmh_clocks[] = {
 static const struct clk_rpmh_desc clk_rpmh_sm8550 = {
 	.clks = sm8550_rpmh_clocks,
 	.num_clks = ARRAY_SIZE(sm8550_rpmh_clocks),
-	.clka_optional = true,
 };
 
 static struct clk_hw *sm8650_rpmh_clocks[] = {
@@ -723,7 +720,6 @@ static struct clk_hw *sm8650_rpmh_clocks[] = {
 static const struct clk_rpmh_desc clk_rpmh_sm8650 = {
 	.clks = sm8650_rpmh_clocks,
 	.num_clks = ARRAY_SIZE(sm8650_rpmh_clocks),
-	.clka_optional = true,
 };
 
 static struct clk_hw *sc7280_rpmh_clocks[] = {
@@ -893,7 +889,6 @@ static struct clk_hw *sm8750_rpmh_clocks[] = {
 static const struct clk_rpmh_desc clk_rpmh_sm8750 = {
 	.clks = sm8750_rpmh_clocks,
 	.num_clks = ARRAY_SIZE(sm8750_rpmh_clocks),
-	.clka_optional = true,
 };
 
 static struct clk_hw *glymur_rpmh_clocks[] = {
@@ -951,6 +946,9 @@ static struct clk_hw *of_clk_rpmh_hw_get(struct of_phandle_args *clkspec,
 		return ERR_PTR(-EINVAL);
 	}
 
+	if (!rpmh->clks[idx])
+		return ERR_PTR(-ENOENT);
+
 	return rpmh->clks[idx];
 }
 
@@ -983,8 +981,7 @@ static int clk_rpmh_probe(struct platform_device *pdev)
 		if (!res_addr) {
 			hw_clks[i] = NULL;
 
-			if (desc->clka_optional &&
-			    !strncmp(rpmh_clk->res_name, "clka", sizeof("clka") - 1))
+			if (rpmh_clk->res_addr == CLK_RPMH_VRM_EN_OFFSET)
 				continue;
 
 			dev_err(&pdev->dev, "missing RPMh resource address for %s\n",

---
base-commit: 591cd656a1bf5ea94a222af5ef2ee76df029c1d2
change-id: 20260412-clk-rpmh-vrm-opt-78b97cf451ba

Best regards,
-- 
Alexander Koskovich <akoskovich@pm.me>
Re: [PATCH v2] clk: qcom: clk-rpmh: Make all VRMs optional
Posted by Konrad Dybcio 2 months ago
On 4/14/26 1:34 PM, Alexander Koskovich wrote:
> Some VRMs aren't present on all boards, so mark them as optional. This
> prevents probe failures on boards where not all VRMs are present.
> 
> This resolves an issue seen on the Nothing Phone (4a) (Eliza) where
> probe fails due to RPMH_RF_CLK5 not being present on the board, this is
> due to this device having a slightly different PMIC configuration from
> the Eliza MTP.
> 
> This matches the downstream approach of marking all VRMs as optional
> and makes the previous clka_optional handling redundant.
> 
> Signed-off-by: Alexander Koskovich <akoskovich@pm.me>
> ---
> Changes in v2:
> - Squashed clka_optional revert into patch (Dmitry)
> - Simplified patch by just checking if CLK_RPMH_VRM_EN_OFFSET (Konrad)
> - Squashed cover into patch commit message and expanded on background
> - Link to v1: https://lore.kernel.org/r/20260412-clk-rpmh-vrm-opt-v1-0-37c890c420ff@pm.me
> ---

[...]

>  static struct clk_hw *glymur_rpmh_clocks[] = {
> @@ -951,6 +946,9 @@ static struct clk_hw *of_clk_rpmh_hw_get(struct of_phandle_args *clkspec,
>  		return ERR_PTR(-EINVAL);
>  	}
>  
> +	if (!rpmh->clks[idx])
> +		return ERR_PTR(-ENOENT);

Hm, this is going to surface in some places where a nullptr has been
happily accepted up until now..

Bjorn, Dmitry, WDYT?

Konrad
Re: [PATCH v2] clk: qcom: clk-rpmh: Make all VRMs optional
Posted by Dmitry Baryshkov 2 months ago
On Tue, Apr 14, 2026 at 01:53:01PM +0200, Konrad Dybcio wrote:
> On 4/14/26 1:34 PM, Alexander Koskovich wrote:
> > Some VRMs aren't present on all boards, so mark them as optional. This
> > prevents probe failures on boards where not all VRMs are present.
> > 
> > This resolves an issue seen on the Nothing Phone (4a) (Eliza) where
> > probe fails due to RPMH_RF_CLK5 not being present on the board, this is
> > due to this device having a slightly different PMIC configuration from
> > the Eliza MTP.
> > 
> > This matches the downstream approach of marking all VRMs as optional
> > and makes the previous clka_optional handling redundant.
> > 
> > Signed-off-by: Alexander Koskovich <akoskovich@pm.me>
> > ---
> > Changes in v2:
> > - Squashed clka_optional revert into patch (Dmitry)
> > - Simplified patch by just checking if CLK_RPMH_VRM_EN_OFFSET (Konrad)
> > - Squashed cover into patch commit message and expanded on background
> > - Link to v1: https://lore.kernel.org/r/20260412-clk-rpmh-vrm-opt-v1-0-37c890c420ff@pm.me
> > ---
> 
> [...]
> 
> >  static struct clk_hw *glymur_rpmh_clocks[] = {
> > @@ -951,6 +946,9 @@ static struct clk_hw *of_clk_rpmh_hw_get(struct of_phandle_args *clkspec,
> >  		return ERR_PTR(-EINVAL);
> >  	}
> >  
> > +	if (!rpmh->clks[idx])
> > +		return ERR_PTR(-ENOENT);
> 
> Hm, this is going to surface in some places where a nullptr has been
> happily accepted up until now..
> 
> Bjorn, Dmitry, WDYT?

Yep. I'd rather drop that part.

-- 
With best wishes
Dmitry