From patchwork Thu Jun 1 11:36:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrice CHOTARD X-Patchwork-Id: 769644 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3wdllY4zDFz9s78 for ; Thu, 1 Jun 2017 21:40:41 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 7B557C21D5C; Thu, 1 Jun 2017 11:39:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 47A24C21D35; Thu, 1 Jun 2017 11:36:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E9DBFC21D6E; Thu, 1 Jun 2017 11:36:50 +0000 (UTC) Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lists.denx.de (Postfix) with ESMTPS id E6196C21CA6 for ; Thu, 1 Jun 2017 11:36:47 +0000 (UTC) Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v51BYTRw020395; Thu, 1 Jun 2017 13:36:47 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 2apxk45431-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Jun 2017 13:36:47 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 86C9338; Thu, 1 Jun 2017 11:36:46 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag6node3.st.com [10.75.127.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 73CC5254B; Thu, 1 Jun 2017 11:36:46 +0000 (GMT) Received: from localhost (10.75.127.46) by SFHDAG6NODE3.st.com (10.75.127.18) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Thu, 1 Jun 2017 13:36:46 +0200 From: To: Marek Vasut , , Date: Thu, 1 Jun 2017 13:36:16 +0200 Message-ID: <1496316982-16572-6-git-send-email-patrice.chotard@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1496316982-16572-1-git-send-email-patrice.chotard@st.com> References: <1496316982-16572-1-git-send-email-patrice.chotard@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) To SFHDAG6NODE3.st.com (10.75.127.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-01_02:, , signatures=0 Cc: christophe.kerello@st.com Subject: [U-Boot] [PATCH v5 05/11] clk: add clk_disable_all() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Reviewed-by: Simon Glass --- v5: _ none 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 1215121..1c6d087 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -199,6 +199,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