diff options
author | Patrice Chotard <patrice.chotard@st.com> | 2017-07-18 11:57:07 +0200 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2017-07-28 23:34:08 +0200 |
commit | 82a8a669b4f7159f1f3c3251c2fcb36965896290 (patch) | |
tree | 6b52c69f258d57d59a86c76def7adeb2457bca51 /drivers/clk/clk-uclass.c | |
parent | 3b9d1bdd4e5fe0c44e5d4d0a0916dbccc558749d (diff) | |
download | u-boot-82a8a669b4f7159f1f3c3251c2fcb36965896290.zip u-boot-82a8a669b4f7159f1f3c3251c2fcb36965896290.tar.gz u-boot-82a8a669b4f7159f1f3c3251c2fcb36965896290.tar.bz2 |
clk: add clk_release_all()
Add clk_release_all() method which Disable/Free an
array of clocks that has been previously requested by
clk_request/get_by_*()
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/clk/clk-uclass.c')
-rw-r--r-- | drivers/clk/clk-uclass.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 83b6328..ffbe872 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -65,6 +65,8 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk) debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk); assert(clk); + clk->dev = NULL; + ret = dev_read_phandle_with_args(dev, "clocks", "#clock-cells", 0, index, &args); if (ret) { @@ -102,6 +104,7 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk) int index; debug("%s(dev=%p, name=%s, clk=%p)\n", __func__, dev, name, clk); + clk->dev = NULL; index = dev_read_stringlist_search(dev, "clock-names", name); if (index < 0) { @@ -187,6 +190,29 @@ int clk_disable(struct clk *clk) return ops->disable(clk); } +int clk_release_all(struct clk *clk, int count) +{ + int i, ret; + + for (i = 0; i < count; i++) { + debug("%s(clk[%d]=%p)\n", __func__, i, &clk[i]); + + /* check if clock has been previously requested */ + if (!clk[i].dev) + continue; + + ret = clk_disable(&clk[i]); + if (ret && ret != -ENOSYS) + return ret; + + ret = clk_free(&clk[i]); + if (ret && ret != -ENOSYS) + return ret; + } + + return 0; +} + UCLASS_DRIVER(clk) = { .id = UCLASS_CLK, .name = "clk", |