summaryrefslogtreecommitdiff
path: root/drivers/clk
diff options
context:
space:
mode:
authorLukasz Majewski <lukma@denx.de>2019-06-24 16:50:43 +0300
committerStefano Babic <sbabic@denx.de>2019-07-19 15:50:30 +0300
commit4aa78300a025b7e09aa8e902b2178b1870ef1ec5 (patch)
treee687f90f042d8b4f44ab86f65525a393ca3c3d17 /drivers/clk
parent0c660c2b3263ba1d6e3c0dd43d813ef17b051207 (diff)
downloadu-boot-4aa78300a025b7e09aa8e902b2178b1870ef1ec5.tar.xz
dm: clk: Define clk_get_parent_rate() for clk operations
This commit adds the clk_get_parent_rate() function, which is responsible for getting the rate of parent clock. Unfortunately, u-boot's DM support for getting parent is different (the parent relationship is in udevice) than the one in Common Clock Framework [CCF] in Linux. To alleviate this problem - the clk_get_parent_rate() function has been introduced to clk-uclass.c. Signed-off-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Peng Fan <peng.fan@nxp.com>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/clk-uclass.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 4346c61eea..899b2dda6f 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -395,6 +395,28 @@ struct clk *clk_get_parent(struct clk *clk)
return pclk;
}
+long long clk_get_parent_rate(struct clk *clk)
+{
+ const struct clk_ops *ops;
+ struct clk *pclk;
+
+ debug("%s(clk=%p)\n", __func__, clk);
+
+ pclk = clk_get_parent(clk);
+ if (IS_ERR(pclk))
+ return -ENODEV;
+
+ ops = clk_dev_ops(pclk->dev);
+ if (!ops->get_rate)
+ return -ENOSYS;
+
+ /* Read the 'rate' if not already set */
+ if (!pclk->rate)
+ pclk->rate = clk_get_rate(pclk);
+
+ return pclk->rate;
+}
+
ulong clk_set_rate(struct clk *clk, ulong rate)
{
const struct clk_ops *ops = clk_dev_ops(clk->dev);