From patchwork Mon Jun 16 13:40:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 31968 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 588F8206A0 for ; Mon, 16 Jun 2014 13:41:44 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id r10sf9557826pdi.10 for ; Mon, 16 Jun 2014 06:41:43 -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=dIt6Yu8mvkgGqwMyfbvXw0XCME44c17OM4ZyhMM2Koo=; b=JRk9qcd3BxsUlyowFHkLJVo+W+vJTfBJEkY4ZcROhHwMcNoXofGgjBd8EEqS78YxXO ifU6Q70180U/XqVnmONDXgsvV8a/hmdOPBQjJ9LRsn4R+fe0pauydd1dTm7oZIkIs9rE WRtigK7c6Xu56xYfKLAr/1rUcS7HLQ6MHo9ujdcBJMzSjftzh2PeUBQfwTUrl/ZsGZyD ydsivuOp5HWWljS94KvLJ8Dzh1V+czxZcf1Yw9iQIw0hxWVgOn//VIvXFPfHAGdjiqWu T8PeQM0JUYQi7FAK6Y7pl3T/ZrI26B+qJ/BmG4Ja76WDj1aQoN5Fgx96U8wTU3SFQ62Y pHew== X-Gm-Message-State: ALoCoQkcbutiv3kBlPdX/9atRLXwsVXpyvbV0EzX9v4uNCV/6o2ZLtU6gZZqGK8Mo9hclWUWEgF0 X-Received: by 10.68.216.230 with SMTP id ot6mr703206pbc.3.1402926103556; Mon, 16 Jun 2014 06:41:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.225 with SMTP id 88ls292431qgt.85.gmail; Mon, 16 Jun 2014 06:41:43 -0700 (PDT) X-Received: by 10.221.36.73 with SMTP id sz9mr18749vcb.62.1402926103431; Mon, 16 Jun 2014 06:41:43 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id tv5si4115786vcb.38.2014.06.16.06.41.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Jun 2014 06:41:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ij19so5017876vcb.9 for ; Mon, 16 Jun 2014 06:41:43 -0700 (PDT) X-Received: by 10.220.15.8 with SMTP id i8mr609877vca.45.1402926103323; Mon, 16 Jun 2014 06:41:43 -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.221.54.6 with SMTP id vs6csp135942vcb; Mon, 16 Jun 2014 06:41:42 -0700 (PDT) X-Received: by 10.66.119.136 with SMTP id ku8mr24437238pab.121.1402926102394; Mon, 16 Jun 2014 06:41:42 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gu11si5131779pbd.223.2014.06.16.06.41.41; Mon, 16 Jun 2014 06:41:41 -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 S1754356AbaFPNlk (ORCPT + 7 others); Mon, 16 Jun 2014 09:41:40 -0400 Received: from mail-ig0-f170.google.com ([209.85.213.170]:51673 "EHLO mail-ig0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752317AbaFPNjv (ORCPT ); Mon, 16 Jun 2014 09:39:51 -0400 Received: by mail-ig0-f170.google.com with SMTP id h3so3867228igd.3 for ; Mon, 16 Jun 2014 06:39:50 -0700 (PDT) X-Received: by 10.50.80.50 with SMTP id o18mr25971454igx.40.1402925990457; Mon, 16 Jun 2014 06:39:50 -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 k20sm20775727igf.5.2014.06.16.06.39.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Jun 2014 06:39:49 -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 v6 1/7] clk: kona: move some code Date: Mon, 16 Jun 2014 08:40:01 -0500 Message-Id: <1402926007-4436-2-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1402926007-4436-1-git-send-email-elder@linaro.org> References: <1402926007-4436-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.220.178 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 95af2e6..b643d35 100644 --- a/drivers/clk/bcm/clk-kona.c +++ b/drivers/clk/bcm/clk-kona.c @@ -981,6 +981,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) @@ -1192,90 +1279,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; -}