From patchwork Fri May 30 20:53:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 4274041 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B403C9F30B for ; Fri, 30 May 2014 20:56:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DC86203A0 for ; Fri, 30 May 2014 20:56:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B10DA201BC for ; Fri, 30 May 2014 20:56:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WqTob-0003bj-2h; Fri, 30 May 2014 20:54:13 +0000 Received: from mail-ig0-f172.google.com ([209.85.213.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WqTnz-0002y3-94 for linux-arm-kernel@lists.infradead.org; Fri, 30 May 2014 20:53:35 +0000 Received: by mail-ig0-f172.google.com with SMTP id uy17so1294319igb.5 for ; Fri, 30 May 2014 13:53:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q8/zwSZHL4yUaawYBEfStNqU07bajYuGmRrZHwzSf00=; b=SfKEo9u2p6EVx7PsXfHmWjoeH5xgNxnyCm9i/0XgxL+8yR05cTvnOuyI/VuFUxFc7B xpDRFkycVcE2bVhLeGHy+Vb3UK6UY38fFaHX4H2aKdPQ7CG4TPIu5b4E7EpL9u1uAx0/ 3Il8YrbBa2FxQlFkWvAfxG6w7Mc1vNyp30BCYpAWMGJRmlL71mtG9eNAIl5qTKi8Tmtx SrQUSlw3/DJVERnTfpgszPEAHuwWCZtrnAyDnLDF3g3TlxcgIwsBx/SHn6RWbJZHeU9l IxlFb7zDXSNLFYtsWnQdKFLL4b7jels1TLVpZ+qeyrCiwW3szyxlfaXdKGVbvrbdK58g eyiw== X-Gm-Message-State: ALoCoQlrNv6gpaZuXMZi/covBhNRSguBwteNcjMb88PIK5Ud/AOoicPCxLIdP8qjjwEJIvbB8phi X-Received: by 10.50.153.49 with SMTP id vd17mr33382igb.40.1401483193242; Fri, 30 May 2014 13:53:13 -0700 (PDT) Received: from localhost.localdomain (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id b8sm8057705igx.3.2014.05.30.13.53.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 May 2014 13:53:12 -0700 (PDT) From: Alex Elder To: mturquette@linaro.org, mporter@linaro.org, bcm@fixthebug.org Subject: [PATCH v4 2/7] clk: kona: move some code Date: Fri, 30 May 2014 15:53:03 -0500 Message-Id: <1401483188-5395-3-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1401483188-5395-1-git-send-email-elder@linaro.org> References: <1401483188-5395-1-git-send-email-elder@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140530_135335_368550_A82B7DCD X-CRM114-Status: GOOD ( 17.76 ) X-Spam-Score: -0.7 (/) Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move the definition of __peri_clk_init() up in "clk-kona.c", in preparation for the next patch (so it's defined before it's needed). Move kona_ccu_init() and __kona_clk_init() as well. Done as a separate patch so doing so doesn't obscure other changes. Signed-off-by: Alex Elder --- drivers/clk/bcm/clk-kona.c | 174 ++++++++++++++++++++++----------------------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c index ee8e988..0c64504 100644 --- a/drivers/clk/bcm/clk-kona.c +++ b/drivers/clk/bcm/clk-kona.c @@ -975,6 +975,93 @@ static int selector_write(struct ccu_data *ccu, struct bcm_clk_gate *gate, return ret; } +/* Put a peripheral clock into its initial state */ +static bool __peri_clk_init(struct kona_clk *bcm_clk) +{ + struct ccu_data *ccu = bcm_clk->ccu; + struct peri_clk_data *peri = bcm_clk->u.peri; + const char *name = bcm_clk->init_data.name; + struct bcm_clk_trig *trig; + + BUG_ON(bcm_clk->type != bcm_clk_peri); + + if (!policy_init(ccu, &peri->policy)) { + pr_err("%s: error initializing policy for %s\n", + __func__, name); + return false; + } + if (!gate_init(ccu, &peri->gate)) { + pr_err("%s: error initializing gate for %s\n", __func__, name); + return false; + } + if (!hyst_init(ccu, &peri->hyst)) { + pr_err("%s: error initializing hyst for %s\n", __func__, name); + return false; + } + if (!div_init(ccu, &peri->gate, &peri->div, &peri->trig)) { + pr_err("%s: error initializing divider for %s\n", __func__, + name); + return false; + } + + /* + * For the pre-divider and selector, the pre-trigger is used + * if it's present, otherwise we just use the regular trigger. + */ + trig = trigger_exists(&peri->pre_trig) ? &peri->pre_trig + : &peri->trig; + + if (!div_init(ccu, &peri->gate, &peri->pre_div, trig)) { + pr_err("%s: error initializing pre-divider for %s\n", __func__, + name); + return false; + } + + if (!sel_init(ccu, &peri->gate, &peri->sel, trig)) { + pr_err("%s: error initializing selector for %s\n", __func__, + name); + return false; + } + + return true; +} + +static bool __kona_clk_init(struct kona_clk *bcm_clk) +{ + switch (bcm_clk->type) { + case bcm_clk_peri: + return __peri_clk_init(bcm_clk); + default: + BUG(); + } + return -EINVAL; +} + +/* Set a CCU and all its clocks into their desired initial state */ +bool __init kona_ccu_init(struct ccu_data *ccu) +{ + unsigned long flags; + unsigned int which; + struct clk **clks = ccu->clk_data.clks; + bool success = true; + + flags = ccu_lock(ccu); + __ccu_write_enable(ccu); + + for (which = 0; which < ccu->clk_data.clk_num; which++) { + struct kona_clk *bcm_clk; + + if (!clks[which]) + continue; + bcm_clk = to_kona_clk(__clk_get_hw(clks[which])); + success &= __kona_clk_init(bcm_clk); + } + + __ccu_write_disable(ccu); + ccu_unlock(ccu, flags); + return success; +} + /* Clock operations */ static int kona_peri_clk_enable(struct clk_hw *hw) @@ -1186,90 +1273,3 @@ struct clk_ops kona_peri_clk_ops = { .get_parent = kona_peri_clk_get_parent, .set_rate = kona_peri_clk_set_rate, }; - -/* Put a peripheral clock into its initial state */ -static bool __peri_clk_init(struct kona_clk *bcm_clk) -{ - struct ccu_data *ccu = bcm_clk->ccu; - struct peri_clk_data *peri = bcm_clk->u.peri; - const char *name = bcm_clk->init_data.name; - struct bcm_clk_trig *trig; - - BUG_ON(bcm_clk->type != bcm_clk_peri); - - if (!policy_init(ccu, &peri->policy)) { - pr_err("%s: error initializing policy for %s\n", - __func__, name); - return false; - } - if (!gate_init(ccu, &peri->gate)) { - pr_err("%s: error initializing gate for %s\n", __func__, name); - return false; - } - if (!hyst_init(ccu, &peri->hyst)) { - pr_err("%s: error initializing hyst for %s\n", __func__, name); - return false; - } - if (!div_init(ccu, &peri->gate, &peri->div, &peri->trig)) { - pr_err("%s: error initializing divider for %s\n", __func__, - name); - return false; - } - - /* - * For the pre-divider and selector, the pre-trigger is used - * if it's present, otherwise we just use the regular trigger. - */ - trig = trigger_exists(&peri->pre_trig) ? &peri->pre_trig - : &peri->trig; - - if (!div_init(ccu, &peri->gate, &peri->pre_div, trig)) { - pr_err("%s: error initializing pre-divider for %s\n", __func__, - name); - return false; - } - - if (!sel_init(ccu, &peri->gate, &peri->sel, trig)) { - pr_err("%s: error initializing selector for %s\n", __func__, - name); - return false; - } - - return true; -} - -static bool __kona_clk_init(struct kona_clk *bcm_clk) -{ - switch (bcm_clk->type) { - case bcm_clk_peri: - return __peri_clk_init(bcm_clk); - default: - BUG(); - } - return -EINVAL; -} - -/* Set a CCU and all its clocks into their desired initial state */ -bool __init kona_ccu_init(struct ccu_data *ccu) -{ - unsigned long flags; - unsigned int which; - struct clk **clks = ccu->clk_data.clks; - bool success = true; - - flags = ccu_lock(ccu); - __ccu_write_enable(ccu); - - for (which = 0; which < ccu->clk_data.clk_num; which++) { - struct kona_clk *bcm_clk; - - if (!clks[which]) - continue; - bcm_clk = to_kona_clk(__clk_get_hw(clks[which])); - success &= __kona_clk_init(bcm_clk); - } - - __ccu_write_disable(ccu); - ccu_unlock(ccu, flags); - return success; -}