diff mbox series

[U-Boot,v4,13/13] dm: clk: Extend clk_get_parent_rate() tosupport CLK_GET_RATE_NOCACHE flag

Message ID 20190516221042.3583-14-lukma@denx.de
State Awaiting Upstream
Delegated to: Stefano Babic
Headers show
Series clk: Port Linux common clock framework[CCF] to U-boot (tag: 5.0-rc3) | expand

Commit Message

Lukasz Majewski May 16, 2019, 10:10 p.m. UTC
If the CLK_GET_RATE_NOCACHE flag is set - the clk_get_parent_rate()
provides recalculated clock value without considering the cache setting.

This may be necessary for some clocks tightly coupled with power domains
(i.e. imx8), and prevents from reading invalid cached values.

Signed-off-by: Lukasz Majewski <lukma@denx.de>

---

Changes in v4:
- New patch

Changes in v3: None

 drivers/clk/clk-uclass.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Peng Fan May 17, 2019, 6:03 a.m. UTC | #1
> Subject: [PATCH v4 13/13] dm: clk: Extend clk_get_parent_rate() to support
> CLK_GET_RATE_NOCACHE flag
> 
> If the CLK_GET_RATE_NOCACHE flag is set - the clk_get_parent_rate()
> provides recalculated clock value without considering the cache setting.
> 
> This may be necessary for some clocks tightly coupled with power domains
> (i.e. imx8), and prevents from reading invalid cached values.
> 
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> 
> ---
> 
> Changes in v4:
> - New patch
> 
> Changes in v3: None
> 
>  drivers/clk/clk-uclass.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index
> 6f054396e3..3dcfae85c4 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c
> @@ -13,6 +13,7 @@
>  #include <dm/read.h>
>  #include <dt-structs.h>
>  #include <errno.h>
> +#include <linux/clk-provider.h>
> 
>  static inline const struct clk_ops *clk_dev_ops(struct udevice *dev)  { @@
> -409,8 +410,8 @@ ulong clk_get_parent_rate(struct clk *clk)
>  	if (!ops->get_rate)
>  		return -ENOSYS;
> 
> -	/* Read the 'rate' if not already set */
> -	if (!pclk->rate)
> +	/* Read the 'rate' if not already set or if proper flag set*/
> +	if (!pclk->rate || pclk->flags & CLK_GET_RATE_NOCACHE)
>  		pclk->rate = clk_get_rate(pclk);

Reviewed-by: Peng Fan <peng.fan@nxp.com>

> 
>  	return pclk->rate;
> --
> 2.11.0
Stefano Babic June 10, 2019, 9:39 a.m. UTC | #2
> If the CLK_GET_RATE_NOCACHE flag is set - the clk_get_parent_rate()
> provides recalculated clock value without considering the cache setting.
> This may be necessary for some clocks tightly coupled with power domains
> (i.e. imx8), and prevents from reading invalid cached values.
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 6f054396e3..3dcfae85c4 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -13,6 +13,7 @@ 
 #include <dm/read.h>
 #include <dt-structs.h>
 #include <errno.h>
+#include <linux/clk-provider.h>
 
 static inline const struct clk_ops *clk_dev_ops(struct udevice *dev)
 {
@@ -409,8 +410,8 @@  ulong clk_get_parent_rate(struct clk *clk)
 	if (!ops->get_rate)
 		return -ENOSYS;
 
-	/* Read the 'rate' if not already set */
-	if (!pclk->rate)
+	/* Read the 'rate' if not already set or if proper flag set*/
+	if (!pclk->rate || pclk->flags & CLK_GET_RATE_NOCACHE)
 		pclk->rate = clk_get_rate(pclk);
 
 	return pclk->rate;