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: 31229 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3C08320671 for ; Fri, 30 May 2014 20:55:02 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id z6sf11591749yhz.9 for ; Fri, 30 May 2014 13:55:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=kU9HRelD9G43+Ru4Edhv4ZE9xseKRGnaUalWZv7UbTw=; b=kCDqvm8qdZBFvjmwm3tmJyzDS9DGBNbzVxdTrE8hZRjhuT5X6jsaNnj5vanz35hO8J InXqO4pC+qwFuP04w/ZhDce/tEXNcp1JhJpjNC6IN4shELdS7XF3G6ZEfZl3Jgiws3b6 IjFRSWAJAeP22npuWqxup8fK4NReF4x5lRuyZHCtnmTpyqItbBJDT26MJnwTbtf0G+Bz saujd3zBnPL/VE4H1xce5C85w7CT4TztqXXKSH6zShPHW37BqGZRN9yUM3bSx9JXSG3S vLcWYetf8NyGBNSVdhedSJAH3oZEY3TwURRSYTftxOBTY040sfmMljFjrRK89J3oxR5F 8FfA== X-Gm-Message-State: ALoCoQmj462ZDo9I0OfnCm8cIZqfuC9zL98k5/+uUWLG1HZmMUA5v1+0OSiS9ESq0+EjlnzL+GLq X-Received: by 10.58.94.163 with SMTP id dd3mr7398636veb.29.1401483302655; Fri, 30 May 2014 13:55:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.145 with SMTP id g17ls1158498qge.76.gmail; Fri, 30 May 2014 13:55:02 -0700 (PDT) X-Received: by 10.220.166.211 with SMTP id n19mr3614263vcy.69.1401483302493; Fri, 30 May 2014 13:55:02 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id jl6si4080442vdb.50.2014.05.30.13.55.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 13:55:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.176 as permitted sender) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jz11so2746689veb.21 for ; Fri, 30 May 2014 13:55:02 -0700 (PDT) X-Received: by 10.58.161.101 with SMTP id xr5mr12080117veb.36.1401483302406; Fri, 30 May 2014 13:55:02 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp141016vcb; Fri, 30 May 2014 13:55:01 -0700 (PDT) X-Received: by 10.66.141.109 with SMTP id rn13mr22000938pab.117.1401483301648; Fri, 30 May 2014 13:55:01 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ks8si7060929pbc.119.2014.05.30.13.55.00; Fri, 30 May 2014 13:55:00 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934705AbaE3Uys (ORCPT + 28 others); Fri, 30 May 2014 16:54:48 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:38830 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933855AbaE3UxN (ORCPT ); Fri, 30 May 2014 16:53:13 -0400 Received: by mail-ie0-f174.google.com with SMTP id lx4so2210273iec.5 for ; Fri, 30 May 2014 13:53:13 -0700 (PDT) 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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; -}