dm: clk: Extend clk_get_parent_rate() to support CLK_GET_RATE_NOCACHE flag
authorLukasz Majewski <lukma@denx.de>
Mon, 24 Jun 2019 13:50:46 +0000 (15:50 +0200)
committerStefano Babic <sbabic@denx.de>
Fri, 19 Jul 2019 12:50:30 +0000 (14:50 +0200)
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>
drivers/clk/clk-uclass.c

index 506ba6014c973cb6b517aba2ce2002322560e186..5acf186b01eb6f0e1e360f9633feadac63fcbf66 100644 (file)
@@ -410,8 +410,8 @@ long long 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;