From mboxrd@z Thu Jan 1 00:00:00 1970 From: patrice.chotard at st.com Date: Wed, 24 May 2017 15:01:51 +0200 Subject: [U-Boot] [PATCH v4 05/11] clk: add clk_disable_all() In-Reply-To: <1495630917-25272-1-git-send-email-patrice.chotard@st.com> References: <1495630917-25272-1-git-send-email-patrice.chotard@st.com> Message-ID: <1495630917-25272-6-git-send-email-patrice.chotard@st.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Patrice Chotard Add clk_disable_all() method which Request/Disable/Free an array of clocks that has been previously requested by clk_request/get_by_*() Signed-off-by: Patrice Chotard --- v4: _ add clk_disable_all() method as suggested by Marek Vasut and Simon Glass drivers/clk/clk-uclass.c | 22 ++++++++++++++++++++++ include/clk.h | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 5c4dd19..44bac0d 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -201,6 +201,28 @@ int clk_disable(struct clk *clk) return ops->disable(clk); } +int clk_disable_all(struct clk *clk, int count) +{ + int i, ret; + + debug("%s(clk=%p count=%d)\n", __func__, clk, count); + + for (i = 0; i < count; i++) { + ret = clk_request(clk->dev, &clk[i]); + if (ret && ret != -ENOSYS) + return ret; + + 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", diff --git a/include/clk.h b/include/clk.h index 801920c..25a3f32 100644 --- a/include/clk.h +++ b/include/clk.h @@ -186,6 +186,16 @@ int clk_enable(struct clk *clk); */ int clk_disable(struct clk *clk); +/** + * clk_disable_all() - Request/Disable (turn off)/Free clocks. + * + * @clk: A clock struct array that was previously successfully + * requested by clk_request/get_by_*(). + * @count Number of clock contained in the array + * @return zero on success, or -ve error code. + */ +int clk_disable_all(struct clk *clk, int count); + int soc_clk_dump(void); #endif -- 1.9.1