[20/33] clk: stm32: propagate rate changes to the parent clock

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

Commit Message

Dario Binacchi Nov. 4, 2026, 8:49 a.m. UTC
Since commit 901e0d95df3b ("clk: stm32: fix clock counter"), the
set_rate operation of the clock is called directly, so the
CLK_SET_RATE_PARENT flag is ignored and the rate of a clock relying on
its parent, like the STM32MP25 LTDC kernel clock, can't be set anymore:

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

Use clk_set_rate() again, which walks up the parents having
CLK_SET_RATE_PARENT set. Unlike clk_enable(), it doesn't update any
counter, so the issue fixed by that commit is not reintroduced.

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

 drivers/clk/stm32/clk-stm32-core.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

-- 
2.43.0
  

Comments

Patrice CHOTARD Nov. 6, 2026, 4:46 p.m. UTC | #1
On 11/4/26 09:49, Dario Binacchi wrote:
> Since commit 901e0d95df3b ("clk: stm32: fix clock counter"), the
> set_rate operation of the clock is called directly, so the
> CLK_SET_RATE_PARENT flag is ignored and the rate of a clock relying on
> its parent, like the STM32MP25 LTDC kernel clock, can't be set anymore:
> 
>   stm32_display display-controller@48010000: fail to set pixel clock 27000000 hz, ret=-38
> 
> Use clk_set_rate() again, which walks up the parents having
> CLK_SET_RATE_PARENT set. Unlike clk_enable(), it doesn't update any
> counter, so the issue fixed by that commit is not reintroduced.
> 
> Fixes: 901e0d95df3b ("clk: stm32: fix clock counter")
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> ---
> 
>  drivers/clk/stm32/clk-stm32-core.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/clk/stm32/clk-stm32-core.c b/drivers/clk/stm32/clk-stm32-core.c
> index cd6bdee5412f..f9a0ba2f5748 100644
> --- a/drivers/clk/stm32/clk-stm32-core.c
> +++ b/drivers/clk/stm32/clk-stm32-core.c
> @@ -168,17 +168,12 @@ 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);
> +	return clk_set_rate(c, clk_rate);
>  }
>  
>  const struct clk_ops stm32_clk_ops = {

Hi Dario

This patch is coming from ST downstream tree :
https://github.com/STMicroelectronics/u-boot/commit/804e2d5f7b376703a465e1a9a81b5d7db7adfd01

Please, keep original Signed-off-by: Gabriel Fernandez <gabriel.fernandez@foss.st.com>

Thanks
Patrice
  
Dario Binacchi Nov. 7, 2026, 2:24 p.m. UTC | #2
Hi Patrice,

On Fri, Nov 6, 2026 at 5:46 PM Patrice CHOTARD
<patrice.chotard@foss.st.com> wrote:
>
>
>
> On 11/4/26 09:49, Dario Binacchi wrote:
> > Since commit 901e0d95df3b ("clk: stm32: fix clock counter"), the
> > set_rate operation of the clock is called directly, so the
> > CLK_SET_RATE_PARENT flag is ignored and the rate of a clock relying on
> > its parent, like the STM32MP25 LTDC kernel clock, can't be set anymore:
> >
> >   stm32_display display-controller@48010000: fail to set pixel clock 27000000 hz, ret=-38
> >
> > Use clk_set_rate() again, which walks up the parents having
> > CLK_SET_RATE_PARENT set. Unlike clk_enable(), it doesn't update any
> > counter, so the issue fixed by that commit is not reintroduced.
> >
> > Fixes: 901e0d95df3b ("clk: stm32: fix clock counter")
> > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> > ---
> >
> >  drivers/clk/stm32/clk-stm32-core.c | 7 +------
> >  1 file changed, 1 insertion(+), 6 deletions(-)
> >
> > diff --git a/drivers/clk/stm32/clk-stm32-core.c b/drivers/clk/stm32/clk-stm32-core.c
> > index cd6bdee5412f..f9a0ba2f5748 100644
> > --- a/drivers/clk/stm32/clk-stm32-core.c
> > +++ b/drivers/clk/stm32/clk-stm32-core.c
> > @@ -168,17 +168,12 @@ 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);
> > +     return clk_set_rate(c, clk_rate);
> >  }
> >
> >  const struct clk_ops stm32_clk_ops = {
>
> Hi Dario
>
> This patch is coming from ST downstream tree :
> https://github.com/STMicroelectronics/u-boot/commit/804e2d5f7b376703a465e1a9a81b5d7db7adfd01
>
> Please, keep original Signed-off-by: Gabriel Fernandez <gabriel.fernandez@foss.st.com>

Thanks for pointing it out. In v2 I will send Gabriel's patch, keeping
him as the author with his
Signed-off-by, and adding the Fixes tag.

Thanks and regards,
Dario

>
> Thanks
> Patrice



-- 
Dario Binacchi
Senior Embedded Software Engineer
M. +39 328 0625246
dario.binacchi@amarulasolutions.com
―――――――――――――――
Amarula Solutions SRL
 Via Felice Cavallotti 25D, 41012 Carpi, MO, IT
info@amarulasolutions.com
www.amarulasolutions.com
  

Patch

diff --git a/drivers/clk/stm32/clk-stm32-core.c b/drivers/clk/stm32/clk-stm32-core.c
index cd6bdee5412f..f9a0ba2f5748 100644
--- a/drivers/clk/stm32/clk-stm32-core.c
+++ b/drivers/clk/stm32/clk-stm32-core.c
@@ -168,17 +168,12 @@  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);
+	return clk_set_rate(c, clk_rate);
 }
 
 const struct clk_ops stm32_clk_ops = {