diff options
author | Chunfeng Yun <chunfeng.yun@mediatek.com> | 2020-01-09 06:35:07 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-01-16 17:39:45 +0300 |
commit | d646420e29da43ad2e23105ec72fb18ee911d0fd (patch) | |
tree | 7daf33521eddd16f2283c90ba8eefdd5fd57590e /drivers | |
parent | bd7c798605a33107ccce6d5023af8adf9febc4f1 (diff) | |
download | u-boot-d646420e29da43ad2e23105ec72fb18ee911d0fd.tar.xz |
clk: add APIs to get (optional) clock by name without a device
Sometimes we may need get (optional) clock without a device,
that means use ofnode.
e.g. when the phy node has subnode, and there is no device created
for subnode, in this case, we need these new APIs to get subnode's
clock.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/clk/clk-uclass.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index b7e18668cb..93cb490eb5 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -344,6 +344,34 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk) return clk_get_by_index(dev, index, clk); } +int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk) +{ + int index; + + debug("%s(node=%p, name=%s, clk=%p)\n", __func__, + ofnode_get_name(node), name, clk); + clk->dev = NULL; + + index = ofnode_stringlist_search(node, "clock-names", name); + if (index < 0) { + debug("fdt_stringlist_search() failed: %d\n", index); + return index; + } + + return clk_get_by_index_nodev(node, index, clk); +} + +int clk_get_optional_nodev(ofnode node, const char *name, struct clk *clk) +{ + int ret; + + ret = clk_get_by_name_nodev(node, name, clk); + if (ret == -ENODATA) + return 0; + + return ret; +} + int clk_release_all(struct clk *clk, int count) { int i, ret; |