Skip to contentSkip to conversation

clk: Propagate clk_set_rate() if CLK_SET_PARENT_RATE present

PATCH In review Sam Protsenko 5 participants 17 messages Mar 8, 2024 – Dec 13, 2024 Common clk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: Propagate clk_set_rate() if CLK_SET_PARENT_RATE present

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

---
 drivers/clk/clk-uclass.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/clk/clk-uclass.c +14 -2
index ed6e60bc4841..755f05f34669 100644
@@ -571,8 +571,20 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
 		return 0;
 	ops = clk_dev_ops(clk->dev);
 
-	if (!ops->set_rate)
-		return -ENOSYS;
+	/* Try to find parents which can set rate */
+	while (!ops->set_rate) {
+		struct clk *parent;
+
+		if (!(clk->flags & CLK_SET_RATE_PARENT))
+			return -ENOSYS;
+
+		parent = clk_get_parent(clk);
+		if (IS_ERR_OR_NULL(parent) || !clk_valid(parent))
+			return -ENODEV;
+
+		clk = parent;
+		ops = clk_dev_ops(clk->dev);
+	}
 
 	/* get private clock struct used for cache */
 	clk_get_priv(clk, &clkp);
Signature · 1 line
2.39.2
#1 lore raw
Quoted 10 lines · Sam Protsenko

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

Quoted 2 lines

---

Hi Lukasz, Sean, Tom,

If this patch looks good to you and there are no outstanding comments, can you please apply it? It's needed as a part of eMMC enablement for E850-96 board, as eMMC gate (leaf) clock is specified as ciu clock in dts, which requires further clock rate change propagation up to divider clock.

Thanks!

Quoted 33 lines
 drivers/clk/clk-uclass.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/clk/clk-uclass.c +14 -3
index ed6e60bc4841..755f05f34669 100644
@@ -571,8 +571,20 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
                return 0;
        ops = clk_dev_ops(clk->dev);
 
-       if (!ops->set_rate)
-               return -ENOSYS;
+       /* Try to find parents which can set rate */
+       while (!ops->set_rate) {
+               struct clk *parent;
+
+               if (!(clk->flags & CLK_SET_RATE_PARENT))
+                       return -ENOSYS;
+
+               parent = clk_get_parent(clk);
+               if (IS_ERR_OR_NULL(parent) || !clk_valid(parent))
+                       return -ENODEV;
+
+               clk = parent;
+               ops = clk_dev_ops(clk->dev);
+       }
 
        /* get private clock struct used for cache */
        clk_get_priv(clk, &clkp);
--

2.39.2

#2 lore raw
Quoted 14 lines · Sam Protsenko
Quoted 11 lines · Sam Protsenko

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

---

Hi Lukasz, Sean, Tom,

Quoted 7 lines

If this patch looks good to you and there are no outstanding comments, can you please apply it? It's needed as a part of eMMC enablement for E850-96 board, as eMMC gate (leaf) clock is specified as ciu clock in dts, which requires further clock rate change propagation up to divider clock.

Thanks!

Please be patient. The release cycle is quite long. My patch set for HiSilicon clk framework has been ignored for ~2months already.

Quoted 34 lines
Quoted 34 lines
  drivers/clk/clk-uclass.c | 16 ++++++++++++++--
  1 file changed, 14 insertions(+), 2 deletions(-)
drivers/clk/clk-uclass.c +14 -3
index ed6e60bc4841..755f05f34669 100644
@@ -571,8 +571,20 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
                 return 0;
         ops = clk_dev_ops(clk->dev);
 
-       if (!ops->set_rate)
-               return -ENOSYS;
+       /* Try to find parents which can set rate */
+       while (!ops->set_rate) {
+               struct clk *parent;
+
+               if (!(clk->flags & CLK_SET_RATE_PARENT))
+                       return -ENOSYS;
+
+               parent = clk_get_parent(clk);
+               if (IS_ERR_OR_NULL(parent) || !clk_valid(parent))
+                       return -ENODEV;
+
+               clk = parent;
+               ops = clk_dev_ops(clk->dev);
+       }
 
         /* get private clock struct used for cache */
         clk_get_priv(clk, &clkp);
--

2.39.2

Signature · 2 lines
Regards,
Yang Xiwen
#3 lore raw
Quoted 21 lines · Yang Xiwen
Quoted 20 lines · Sam Protsenko
Quoted 11 lines · Sam Protsenko

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

---

Hi Lukasz, Sean, Tom,

If this patch looks good to you and there are no outstanding comments, can you please apply it? It's needed as a part of eMMC enablement for E850-96 board, as eMMC gate (leaf) clock is specified as ciu clock in dts, which requires further clock rate change propagation up to divider clock.

Quoted 4 lines
Quoted 1 line

Thanks!

Please be patient. The release cycle is quite long. My patch set for HiSilicon clk framework has been ignored for ~2months already.

Sorry, I've been busy IRL recently.

I will try to review patches in the backlog, but it might be a few more weeks.

--Sean

#4 lore raw
In reply to Sam Protsenko
Quoted 31 lines · Sam Protsenko

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

---
  drivers/clk/clk-uclass.c | 16 ++++++++++++++--
  1 file changed, 14 insertions(+), 2 deletions(-)
drivers/clk/clk-uclass.c +7 -2
index ed6e60bc4841..755f05f34669 100644
@@ -571,8 +571,20 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
  		return 0;
  	ops = clk_dev_ops(clk->dev);
 
-	if (!ops->set_rate)
-		return -ENOSYS;
+	/* Try to find parents which can set rate */
+	while (!ops->set_rate) {
+		struct clk *parent;
+
+		if (!(clk->flags & CLK_SET_RATE_PARENT))
+			return -ENOSYS;
+

drivers/clk/clk-uclass.c ulong clk_set_rate(struct clk *clk, ulong rate) · line 590

Quoted 10 lines
drivers/clk/clk-uclass.c +7 -0
+		parent = clk_get_parent(clk);
+		if (IS_ERR_OR_NULL(parent) || !clk_valid(parent))
+			return -ENODEV;
+
+		clk = parent;
+		ops = clk_dev_ops(clk->dev);
+	}
 
  	/* get private clock struct used for cache */
  	clk_get_priv(clk, &clkp);

Can you give an example of where this is needed?

--Sean

#5 lore raw
Quoted 13 lines · Sean Anderson
Quoted 11 lines · Sam Protsenko

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

---

[snip]

Quoted 3 lines

Can you give an example of where this is needed?

Sure. In my case it's needed for eMMC enablement on E850-96 board. eMMC node in the device tree [1] is a gate clock (CLK_GOUT_MMC_EMBD_SDCLKIN), so the MMC driver won't be able to change its rate. But that clock actually has CLK_SET_RATE_PARENT flag set in the clock driver [2]. So the right thing to do in this case (and that's basically how it's done in Linux kernel too) is to traverse the clock tree upwards, and try to find the parent capable to do .set_rate (which is usually a divider clock), and use it to change the clock rate. I'm working on exynos_dw_mmc driver [3] right now, making it use CCF clocks, but I can't do that before this patch is applied.

Grepping the U-Boot tree I can see the CLK_SET_RATE_PARENT flag is also used in various IMX clock drivers and STM32MP13 clock driver. I guess without this change those flags will be basically ignored.

Thanks!

[1] https://source.denx.de/u-boot/u-boot/-/blob/master/arch/arm/dts/exynos850.dtsi#L408
[2] https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/clk/exynos/clk-exynos850.c#L353
[3] https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/mmc/exynos_dw_mmc.c#L117

Quoted 1 line

--Sean

#6 lore raw
Quoted 33 lines · Sam Protsenko
Quoted 13 lines · Sean Anderson
Quoted 11 lines · Sam Protsenko

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

---

[snip]

Quoted 3 lines

Can you give an example of where this is needed?

Sure. In my case it's needed for eMMC enablement on E850-96 board. eMMC node in the device tree [1] is a gate clock (CLK_GOUT_MMC_EMBD_SDCLKIN), so the MMC driver won't be able to change its rate. But that clock actually has CLK_SET_RATE_PARENT flag set in the clock driver [2]. So the right thing to do in this case (and that's basically how it's done in Linux kernel too) is to traverse the clock tree upwards, and try to find the parent capable to do .set_rate (which is usually a divider clock), and use it to change the clock rate. I'm working on exynos_dw_mmc driver [3] right now, making it use CCF clocks, but I can't do that before this patch is applied.

Quoted 6 lines

Grepping the U-Boot tree I can see the CLK_SET_RATE_PARENT flag is also used in various IMX clock drivers and STM32MP13 clock driver. I guess without this change those flags will be basically ignored.

Thanks!

Hi Sean,

Just wanted to check if you think my explanation above is ok and the patch can be applied? I'm finishing my new patch series for enabling MMC on E850-96, but this patch has to be applied first.

Thanks!

Quoted 5 lines

[1] https://source.denx.de/u-boot/u-boot/-/blob/master/arch/arm/dts/exynos850.dtsi#L408
[2] https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/clk/exynos/clk-exynos850.c#L353
[3] https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/mmc/exynos_dw_mmc.c#L117

Quoted 1 line

--Sean

#7 lore raw
Quoted 42 lines · Sam Protsenko
Quoted 33 lines · Sam Protsenko
Quoted 13 lines · Sean Anderson
Quoted 11 lines · Sam Protsenko

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

---

[snip]

Quoted 3 lines

Can you give an example of where this is needed?

Sure. In my case it's needed for eMMC enablement on E850-96 board. eMMC node in the device tree [1] is a gate clock (CLK_GOUT_MMC_EMBD_SDCLKIN), so the MMC driver won't be able to change its rate. But that clock actually has CLK_SET_RATE_PARENT flag set in the clock driver [2]. So the right thing to do in this case (and that's basically how it's done in Linux kernel too) is to traverse the clock tree upwards, and try to find the parent capable to do .set_rate (which is usually a divider clock), and use it to change the clock rate. I'm working on exynos_dw_mmc driver [3] right now, making it use CCF clocks, but I can't do that before this patch is applied.

Quoted 6 lines

Grepping the U-Boot tree I can see the CLK_SET_RATE_PARENT flag is also used in various IMX clock drivers and STM32MP13 clock driver. I guess without this change those flags will be basically ignored.

Thanks!

Quoted 8 lines

Hi Sean,

Just wanted to check if you think my explanation above is ok and the patch can be applied? I'm finishing my new patch series for enabling MMC on E850-96, but this patch has to be applied first.

Thanks!

Hi Tom,

Would it be reasonable to ask you to take care of this patch? It's been ignored for 3 months now, but it's needed for eMMC enablement on E850-96 board.

Thanks!

Quoted 5 lines
Quoted 5 lines

[1] https://source.denx.de/u-boot/u-boot/-/blob/master/arch/arm/dts/exynos850.dtsi#L408
[2] https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/clk/exynos/clk-exynos850.c#L353
[3] https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/mmc/exynos_dw_mmc.c#L117

Quoted 1 line

--Sean

#8 lore raw
Quoted 50 lines · Sam Protsenko
Quoted 48 lines · Sam Protsenko
Quoted 33 lines · Sam Protsenko
Quoted 13 lines · Sean Anderson
Quoted 11 lines · Sam Protsenko

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

---

[snip]

Quoted 3 lines

Can you give an example of where this is needed?

Sure. In my case it's needed for eMMC enablement on E850-96 board. eMMC node in the device tree [1] is a gate clock (CLK_GOUT_MMC_EMBD_SDCLKIN), so the MMC driver won't be able to change its rate. But that clock actually has CLK_SET_RATE_PARENT flag set in the clock driver [2]. So the right thing to do in this case (and that's basically how it's done in Linux kernel too) is to traverse the clock tree upwards, and try to find the parent capable to do .set_rate (which is usually a divider clock), and use it to change the clock rate. I'm working on exynos_dw_mmc driver [3] right now, making it use CCF clocks, but I can't do that before this patch is applied.

Quoted 6 lines

Grepping the U-Boot tree I can see the CLK_SET_RATE_PARENT flag is also used in various IMX clock drivers and STM32MP13 clock driver. I guess without this change those flags will be basically ignored.

Thanks!

Hi Sean,

Just wanted to check if you think my explanation above is ok and the patch can be applied? I'm finishing my new patch series for enabling MMC on E850-96, but this patch has to be applied first.

Quoted 8 lines
Quoted 2 lines

Thanks!

Hi Tom,

Would it be reasonable to ask you to take care of this patch? It's been ignored for 3 months now, but it's needed for eMMC enablement on E850-96 board.

Any comments at this point Sean?

Signature · 1 line
Tom
#9 lore raw

Hi all

Working on the clock now. I have done a different implementation

clk-mux, clk-gate I have added a clk_generic_set_rate that is a stub that propagate to the parent, I think that should work the same but wihout this while and even on preparation on more
changes I need. Can be work on your case too?

Michael

Quoted 65 lines · Tom Rini
Quoted 50 lines · Sam Protsenko
Quoted 48 lines · Sam Protsenko
Quoted 33 lines · Sam Protsenko
Quoted 13 lines · Sean Anderson
Quoted 11 lines · Sam Protsenko

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

---

[snip]

Quoted 3 lines

Can you give an example of where this is needed?

Sure. In my case it's needed for eMMC enablement on E850-96 board. eMMC node in the device tree [1] is a gate clock (CLK_GOUT_MMC_EMBD_SDCLKIN), so the MMC driver won't be able to change its rate. But that clock actually has CLK_SET_RATE_PARENT flag set in the clock driver [2]. So the right thing to do in this case (and that's basically how it's done in Linux kernel too) is to traverse the clock tree upwards, and try to find the parent capable to do .set_rate (which is usually a divider clock), and use it to change the clock rate. I'm working on exynos_dw_mmc driver [3] right now, making it use CCF clocks, but I can't do that before this patch is applied.

Quoted 6 lines

Grepping the U-Boot tree I can see the CLK_SET_RATE_PARENT flag is also used in various IMX clock drivers and STM32MP13 clock driver. I guess without this change those flags will be basically ignored.

Thanks!

Hi Sean,

Just wanted to check if you think my explanation above is ok and the patch can be applied? I'm finishing my new patch series for enabling MMC on E850-96, but this patch has to be applied first.

Quoted 8 lines
Quoted 2 lines

Thanks!

Hi Tom,

Would it be reasonable to ask you to take care of this patch? It's been ignored for 3 months now, but it's needed for eMMC enablement on E850-96 board.

Any comments at this point Sean?

--
Tom

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#10 lore raw
Quoted 10 lines · Michael Nazzareno Trimarchi

Hi all

Working on the clock now. I have done a different implementation

clk-mux, clk-gate I have added a clk_generic_set_rate that is a stub that propagate to the parent, I think that should work the same but wihout this while and even on preparation on more
changes I need. Can be work on your case too?

Hi Michael,

I've provided some thoughts on your gate/mux implementation here: [1]. As you've submitted your (different) implementation of the same feature, but 4 months later, I guess my patch doesn't cover your cases, or perhaps it has some design flaws? Please let me know.

If anything, that shows there is a rising need in this propagation feature. I'd like to encourage the maintainers to take a look at both implementations, and maybe at least comment on why there is hesitance to accept this patch. It's been almost 5 months that I'm trying to push that through, and my MMC work (DDR mode on E850-96 board to be precise) still very much depends on this.

Thanks!

[1] https://lists.denx.de/pipermail/u-boot/2024-July/559753.html

Quoted 83 lines

Michael

Quoted 57 lines · Tom Rini
Quoted 55 lines · Sam Protsenko
Quoted 42 lines · Sam Protsenko
Quoted 33 lines · Sam Protsenko
Quoted 13 lines · Sean Anderson
Quoted 11 lines · Sam Protsenko

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

---

[snip]

Quoted 3 lines

Can you give an example of where this is needed?

Sure. In my case it's needed for eMMC enablement on E850-96 board. eMMC node in the device tree [1] is a gate clock (CLK_GOUT_MMC_EMBD_SDCLKIN), so the MMC driver won't be able to change its rate. But that clock actually has CLK_SET_RATE_PARENT flag set in the clock driver [2]. So the right thing to do in this case (and that's basically how it's done in Linux kernel too) is to traverse the clock tree upwards, and try to find the parent capable to do .set_rate (which is usually a divider clock), and use it to change the clock rate. I'm working on exynos_dw_mmc driver [3] right now, making it use CCF clocks, but I can't do that before this patch is applied.

Quoted 6 lines

Grepping the U-Boot tree I can see the CLK_SET_RATE_PARENT flag is also used in various IMX clock drivers and STM32MP13 clock driver. I guess without this change those flags will be basically ignored.

Thanks!

Quoted 8 lines

Hi Sean,

Just wanted to check if you think my explanation above is ok and the patch can be applied? I'm finishing my new patch series for enabling MMC on E850-96, but this patch has to be applied first.

Thanks!

Hi Tom,

Quoted 8 lines
Quoted 3 lines

Would it be reasonable to ask you to take care of this patch? It's been ignored for 3 months now, but it's needed for eMMC enablement on E850-96 board.

Any comments at this point Sean?

--
Tom

--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com

#11 lore raw

Hi Sam

Il mar 23 lug 2024, 22:53 Sam Protsenko <[email protected]> ha scritto:

Quoted 20 lines
Quoted 10 lines · Michael Nazzareno Trimarchi

Hi all

Working on the clock now. I have done a different implementation

clk-mux, clk-gate I have added a clk_generic_set_rate that is a stub that propagate to the parent, I think that should work the same but wihout this while and even on preparation on more
changes I need. Can be work on your case too?

Hi Michael,

I've provided some thoughts on your gate/mux implementation here: [1]. As you've submitted your (different) implementation of the same feature, but 4 months later, I guess my patch doesn't cover your cases, or perhaps it has some design flaws? Please let me know.

Quoted 7 lines

If anything, that shows there is a rising need in this propagation feature. I'd like to encourage the maintainers to take a look at both implementations, and maybe at least comment on why there is hesitance to accept this patch. It's been almost 5 months that I'm trying to push that through, and my MMC work (DDR mode on E850-96 board to be precise) still very much depends on this.

My series is still not ready and I have no problem to go with your while for now

Michael

Quoted 112 lines

Thanks!

[1] https://lists.denx.de/pipermail/u-boot/2024-July/559753.html

Quoted 9 lines

Michael

Quoted 6 lines · Tom Rini
Quoted 4 lines · Sam Protsenko
Quoted 2 lines · Sam Protsenko

On Wed, May 1, 2024 at 4:12 PM Sam Protsenko <

Quoted 2 lines · [email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Wed, Apr 10, 2024 at 9:53 PM Sean Anderson <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Sam Protsenko
Quoted 1 line

Sometimes clocks provided to a consumer might not have

.set_rate

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

operation (like gate or mux clocks), but have

CLK_SET_PARENT_RATE flag

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

set. In that case it's usually possible to find a parent up

the tree

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

which is capable of setting the rate (div, pll, etc).

Implement a simple

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

lookup procedure for such cases, to traverse the clock tree

until

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

.set_rate capable parent is found, and use that parent to

actually

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

change the rate. The search will stop once the first

.set_rate capable

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

clock is found, which is usually enough to handle most cases.

---

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

[snip]

Quoted 3 lines

Can you give an example of where this is needed?

Sure. In my case it's needed for eMMC enablement on E850-96

board.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

eMMC node in the device tree [1] is a gate clock (CLK_GOUT_MMC_EMBD_SDCLKIN), so the MMC driver won't be able to

change

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

its rate. But that clock actually has CLK_SET_RATE_PARENT flag

set in

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

the clock driver [2]. So the right thing to do in this case (and that's basically how it's done in Linux kernel too) is to

traverse the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

clock tree upwards, and try to find the parent capable to do

.set_rate

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(which is usually a divider clock), and use it to change the

clock

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

rate. I'm working on exynos_dw_mmc driver [3] right now, making

it use

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

CCF clocks, but I can't do that before this patch is applied.

Grepping the U-Boot tree I can see the CLK_SET_RATE_PARENT flag

is

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

also used in various IMX clock drivers and STM32MP13 clock

driver. I

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

guess without this change those flags will be basically ignored.

Thanks!

Hi Sean,

Just wanted to check if you think my explanation above is ok and

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

patch can be applied? I'm finishing my new patch series for

enabling

Quoted 30 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

MMC on E850-96, but this patch has to be applied first.

Thanks!

Hi Tom,

Quoted 8 lines
Quoted 3 lines

Would it be reasonable to ask you to take care of this patch? It's been ignored for 3 months now, but it's needed for eMMC enablement on E850-96 board.

Any comments at this point Sean?

--
Tom

--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com

#12 lore raw

[snip]

Quoted 10 lines
Quoted 7 lines

If anything, that shows there is a rising need in this propagation feature. I'd like to encourage the maintainers to take a look at both implementations, and maybe at least comment on why there is hesitance to accept this patch. It's been almost 5 months that I'm trying to push that through, and my MMC work (DDR mode on E850-96 board to be precise) still very much depends on this.

My series is still not ready and I have no problem to go with your while for now

Hi Sean,

Can you please apply this patch, if it's ok with you?

Thanks!

[snip]

#13 lore raw
Quoted 11 lines · Sam Protsenko

[snip]

Quoted 8 lines
Quoted 7 lines

If anything, that shows there is a rising need in this propagation feature. I'd like to encourage the maintainers to take a look at both implementations, and maybe at least comment on why there is hesitance to accept this patch. It's been almost 5 months that I'm trying to push that through, and my MMC work (DDR mode on E850-96 board to be precise) still very much depends on this.

Quoted 7 lines
Quoted 2 lines

My series is still not ready and I have no problem to go with your while for now

Hi Sean,

Can you please apply this patch, if it's ok with you?

Gentle reminder.

Quoted 3 lines

Thanks!

[snip]

#14 lore raw

Hi Sean,

This series has been pending for 5 months now. If there are no objections, can you please apply it?

Thanks!

Quoted 27 lines · Sam Protsenko
Quoted 11 lines · Sam Protsenko

[snip]

Quoted 8 lines
Quoted 7 lines

If anything, that shows there is a rising need in this propagation feature. I'd like to encourage the maintainers to take a look at both implementations, and maybe at least comment on why there is hesitance to accept this patch. It's been almost 5 months that I'm trying to push that through, and my MMC work (DDR mode on E850-96 board to be precise) still very much depends on this.

Quoted 7 lines
Quoted 2 lines

My series is still not ready and I have no problem to go with your while for now

Hi Sean,

Can you please apply this patch, if it's ok with you?

Gentle reminder.

Quoted 3 lines

Thanks!

[snip]

#15 lore raw

Hi Tom, Sean,

Can we please apply this patch? I don't really understand why it's been consistently ignored for so long, with no explanation even. eMMC on E850-96 still doesn't work properly, this patch is really needed.

Thanks!

Quoted 37 lines · Sam Protsenko

Hi Sean,

This series has been pending for 5 months now. If there are no objections, can you please apply it?

Thanks!

Quoted 27 lines · Sam Protsenko
Quoted 11 lines · Sam Protsenko

[snip]

Quoted 8 lines
Quoted 7 lines

If anything, that shows there is a rising need in this propagation feature. I'd like to encourage the maintainers to take a look at both implementations, and maybe at least comment on why there is hesitance to accept this patch. It's been almost 5 months that I'm trying to push that through, and my MMC work (DDR mode on E850-96 board to be precise) still very much depends on this.

Quoted 7 lines
Quoted 2 lines

My series is still not ready and I have no problem to go with your while for now

Hi Sean,

Can you please apply this patch, if it's ok with you?

Gentle reminder.

Quoted 3 lines

Thanks!

[snip]

#16 lore raw
In reply to Sam Protsenko
Quoted 10 lines · Sam Protsenko

Sometimes clocks provided to a consumer might not have .set_rate operation (like gate or mux clocks), but have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Implement a simple lookup procedure for such cases, to traverse the clock tree until .set_rate capable parent is found, and use that parent to actually change the rate. The search will stop once the first .set_rate capable clock is found, which is usually enough to handle most cases.

[...]

Applied to u-boot/next, thanks!

Signature · 1 line
Tom