[v2,20/35] clk: stm32: fix set_rate propagation for parent clocks

Message ID 20261107143241.2236511-21-dario.binacchi@amarulasolutions.com
State New
Headers
Series Add Engicam MicroGEA-STM32MP257D-RMM board support |

Commit Message

Dario Binacchi Nov. 7, 2026, 2:32 p.m. UTC
From: Gabriel Fernandez <gabriel.fernandez@foss.st.com>

Use the generic clk framework set_rate path in the STM32 RCC wrapper
so CLK_SET_RATE_PARENT can propagate rate changes to parent clocks
when the leaf clock does not implement set_rate directly.

This is the case of the STM32MP25 LTDC kernel clock, whose rate can't
be set otherwise:

  stm32_display display-controller@48010000: fail to set pixel clock 27000000 hz, ret=-38

Fixes: 901e0d95df3b ("clk: stm32: fix clock counter")
Signed-off-by: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>

---

Changes in v2:
- Take the original patch from the ST downstream tree, keeping
  Gabriel's authorship

 drivers/clk/stm32/clk-stm32-core.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.43.0
  

Comments

Patrice CHOTARD Nov. 16, 2026, 10:16 a.m. UTC | #1
On 11/7/26 15:32, Dario Binacchi wrote:
> From: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
> 
> Use the generic clk framework set_rate path in the STM32 RCC wrapper
> so CLK_SET_RATE_PARENT can propagate rate changes to parent clocks
> when the leaf clock does not implement set_rate directly.
> 
> This is the case of the STM32MP25 LTDC kernel clock, whose rate can't
> be set otherwise:
> 
>   stm32_display display-controller@48010000: fail to set pixel clock 27000000 hz, ret=-38
> 
> Fixes: 901e0d95df3b ("clk: stm32: fix clock counter")
> Signed-off-by: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> 
> ---
> 
> Changes in v2:
> - Take the original patch from the ST downstream tree, keeping
>   Gabriel's authorship
> 
>  drivers/clk/stm32/clk-stm32-core.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/clk/stm32/clk-stm32-core.c b/drivers/clk/stm32/clk-stm32-core.c
> index cd6bdee5412f..29d2f64e0c76 100644
> --- a/drivers/clk/stm32/clk-stm32-core.c
> +++ b/drivers/clk/stm32/clk-stm32-core.c
> @@ -168,17 +168,16 @@ static ulong stm32_clk_get_rate(struct clk *clk)
>  
>  static ulong stm32_clk_set_rate(struct clk *clk, unsigned long clk_rate)
>  {
> -	const struct clk_ops *ops;
>  	struct clk *c = NULL;
>  
>  	if (!clk->id || clk_get_by_id(clk->id, &c))
>  		return -ENOENT;
>  
> -	ops = clk_dev_ops(c->dev);
> -	if (!ops->set_rate)
> -		return -ENOSYS;
> -
> -	return ops->set_rate(c, clk_rate);
> +	/*
> +	 * Let the clk framework handle CLK_SET_RATE_PARENT propagation for
> +	 * gate clocks that do not implement set_rate directly.
> +	 */
> +	return clk_set_rate(c, clk_rate);
>  }
>  
>  const struct clk_ops stm32_clk_ops = {


Hi Dario

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
  
Patrice CHOTARD Nov. 26, 2026, 7:46 a.m. UTC | #2
On 11/16/26 11:16, Patrice CHOTARD wrote:
> 
> 
> On 11/7/26 15:32, Dario Binacchi wrote:
>> From: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
>>
>> Use the generic clk framework set_rate path in the STM32 RCC wrapper
>> so CLK_SET_RATE_PARENT can propagate rate changes to parent clocks
>> when the leaf clock does not implement set_rate directly.
>>
>> This is the case of the STM32MP25 LTDC kernel clock, whose rate can't
>> be set otherwise:
>>
>>   stm32_display display-controller@48010000: fail to set pixel clock 27000000 hz, ret=-38
>>
>> Fixes: 901e0d95df3b ("clk: stm32: fix clock counter")
>> Signed-off-by: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
>> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
>>
>> ---
>>
>> Changes in v2:
>> - Take the original patch from the ST downstream tree, keeping
>>   Gabriel's authorship
>>
>>  drivers/clk/stm32/clk-stm32-core.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/clk/stm32/clk-stm32-core.c b/drivers/clk/stm32/clk-stm32-core.c
>> index cd6bdee5412f..29d2f64e0c76 100644
>> --- a/drivers/clk/stm32/clk-stm32-core.c
>> +++ b/drivers/clk/stm32/clk-stm32-core.c
>> @@ -168,17 +168,16 @@ static ulong stm32_clk_get_rate(struct clk *clk)
>>  
>>  static ulong stm32_clk_set_rate(struct clk *clk, unsigned long clk_rate)
>>  {
>> -	const struct clk_ops *ops;
>>  	struct clk *c = NULL;
>>  
>>  	if (!clk->id || clk_get_by_id(clk->id, &c))
>>  		return -ENOENT;
>>  
>> -	ops = clk_dev_ops(c->dev);
>> -	if (!ops->set_rate)
>> -		return -ENOSYS;
>> -
>> -	return ops->set_rate(c, clk_rate);
>> +	/*
>> +	 * Let the clk framework handle CLK_SET_RATE_PARENT propagation for
>> +	 * gate clocks that do not implement set_rate directly.
>> +	 */
>> +	return clk_set_rate(c, clk_rate);
>>  }
>>  
>>  const struct clk_ops stm32_clk_ops = {
> 
> 
> Hi Dario
> 
> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
> 
> Thanks
> Patrice

Applied to u-boot-stm32/main

Thanks
Patrice

> 
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32@st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
  

Patch

diff --git a/drivers/clk/stm32/clk-stm32-core.c b/drivers/clk/stm32/clk-stm32-core.c
index cd6bdee5412f..29d2f64e0c76 100644
--- a/drivers/clk/stm32/clk-stm32-core.c
+++ b/drivers/clk/stm32/clk-stm32-core.c
@@ -168,17 +168,16 @@  static ulong stm32_clk_get_rate(struct clk *clk)
 
 static ulong stm32_clk_set_rate(struct clk *clk, unsigned long clk_rate)
 {
-	const struct clk_ops *ops;
 	struct clk *c = NULL;
 
 	if (!clk->id || clk_get_by_id(clk->id, &c))
 		return -ENOENT;
 
-	ops = clk_dev_ops(c->dev);
-	if (!ops->set_rate)
-		return -ENOSYS;
-
-	return ops->set_rate(c, clk_rate);
+	/*
+	 * Let the clk framework handle CLK_SET_RATE_PARENT propagation for
+	 * gate clocks that do not implement set_rate directly.
+	 */
+	return clk_set_rate(c, clk_rate);
 }
 
 const struct clk_ops stm32_clk_ops = {